-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild-lsvg.lua
More file actions
132 lines (108 loc) · 4.24 KB
/
build-lsvg.lua
File metadata and controls
132 lines (108 loc) · 4.24 KB
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
--[[
This file is part of luax.
luax 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.
luax 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 luax. If not, see <https://www.gnu.org/licenses/>.
For further information about luax you can visit
https://codeberg.org/cdsoft/luax
--]]
-------------------------------------------------------------------------------
section "lsvg"
-------------------------------------------------------------------------------
local F = require "F"
local targets = require "luax-targets"
-------------------------------------------------------------------------------
-- Sources
-------------------------------------------------------------------------------
local lsvg_sources = ls "lsvg/*.lua"
-------------------------------------------------------------------------------
-- Compilation
-------------------------------------------------------------------------------
acc(compile) {
luax.lua "$builddir/bin/lsvg.lua" { lsvg_sources },
luax.native "$builddir/bin/lsvg" { lsvg_sources },
-- Add prebuilt scripts to the repository
build.cp "bin/lsvg.lua" "$builddir/bin/lsvg.lua",
}
-------------------------------------------------------------------------------
-- Generate the release archives
-------------------------------------------------------------------------------
local function build_release(target)
local archive = archive(target)
return {
cp_to(archive/"bin") {
"$builddir/bin/lsvg.lua",
},
target ~= "lua" and {
luax[target.name](archive/"bin/lsvg") {
lsvg_sources,
},
} or {},
}
end
acc(release) {
targets : map(build_release),
build_release "lua",
}
-------------------------------------------------------------------------------
-- Tests
-------------------------------------------------------------------------------
rule "lsvg" {
description = "LSVG $in",
command = {
"LUA_PATH=lsvg/tests/?.lua",
"PATH=$cache:$$PATH $lsvg $in -o $out --MF $depfile -- lsvg demo",
},
depfile = "$out.d",
implicit_in = "$lsvg",
}
local test_envs = F{
{ "$builddir/bin/lsvg", "$builddir/tests/lsvg/luax" },
{ "$builddir/bin/lsvg.lua", "$builddir/tests/lsvg/lua" },
}
acc(test) {
ls "lsvg/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)
}
-------------------------------------------------------------------------------
-- Documentation
-------------------------------------------------------------------------------
acc(doc) {
build.lsvg.svg "lsvg/doc/lsvg-banner.svg" {"luax/doc/luax-logo.lua", args={1024, 192, "--name lsvg"}},
ls "lsvg/doc/*.md.in" : map(function(src)
return gfm((src:splitext())) { src }
end),
}
-------------------------------------------------------------------------------
-- Install lsvg
-------------------------------------------------------------------------------
install "bin" {
"$builddir/bin/lsvg.lua",
"$builddir/bin/lsvg",
}