-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.lua
132 lines (106 loc) · 3.94 KB
/
build.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
section [[
This file is part of lsvg.
lsvg is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
lsvg is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with lsvg. If not, see <https://www.gnu.org/licenses/>.
For further information about lsvg you can visit
https://codeberg.org/cdsoft/lsvg
]]
local F = require "F"
version "2.6.8"
help.name "lsvg"
help.description [[
$name: Lua scriptable SVG generator
]]
var "builddir" ".build"
clean "$builddir"
---------------------------------------------------------------------
section "Compilation"
---------------------------------------------------------------------
local sources = {
ls "src/*.lua",
build "$builddir/version" {
description = "GIT version",
command = "echo $version > $out",
},
}
build.luax.add_global "flags" "-q"
-- used by LuaX only
local binaries = {
build.luax.native "$builddir/lsvg" { sources },
build.luax.lua "$builddir/lsvg.lua" { sources },
}
local lsvg_luax = build.luax.luax "$builddir/lsvg.luax" { sources }
install "bin" { binaries }
phony "release" {
build.tar "$builddir/release/${version}/lsvg-${version}-lua.tar.gz" {
base = "$builddir/release/.build",
name = "lsvg-${version}-lua",
build.luax.lua("$builddir/release/.build/lsvg-${version}-lua/bin/lsvg.lua") { sources },
},
require "targets" : map(function(target)
return build.tar("$builddir/release/${version}/lsvg-${version}-"..target.name..".tar.gz") {
base = "$builddir/release/.build",
name = "lsvg-${version}-"..target.name,
build.luax[target.name]("$builddir/release/.build/lsvg-${version}-"..target.name/"bin/lsvg") { sources },
}
end),
}
---------------------------------------------------------------------
section "Test"
---------------------------------------------------------------------
rule "lsvg" {
description = "LSVG $in",
command = {
"LUA_PATH=tests/?.lua",
"$lsvg $in -o $out --MF $depfile -- lsvg demo",
},
depfile = "$out.d",
}
rule "diff" {
description = "DIFF $in",
command = "diff -b --color $in && touch $out",
}
local test_envs = F{
{ "$builddir/lsvg", "$builddir/test/luax" },
{ "$builddir/lsvg.lua", "$builddir/test/lua" },
}
local tests = ls "tests/*.lua"
: map(function(input)
return test_envs : map(function(test_env)
local lsvg, test_dir = F.unpack(test_env)
local test_type = test_dir:basename()
local output_svg = test_dir / input:basename():splitext()..".svg"
local ref = input:splitext()..".svg"
local output_ok = output_svg:splitext()..".ok"
local output_svg_d = output_svg..".d"
local ref_d = ref.."."..test_type..".d"
local output_deps_ok = output_svg:splitext()..".d.ok"
return build(output_svg) { "lsvg", input,
lsvg = lsvg,
implicit_in = lsvg,
implicit_out = output_svg_d,
validations = {
build(output_ok) { "diff", ref, output_svg },
build(output_deps_ok) { "diff", ref_d, output_svg_d },
},
}
end)
end)
---------------------------------------------------------------------
section "Shortcuts"
---------------------------------------------------------------------
help "compile" "Compile $name"
phony "compile" { binaries, lsvg_luax }
help "test" "Test $name"
phony "test" (tests)
help "all" "Compile and test $name"
phony "all" { "compile", "test" }
default "all"