commit 8af7719
Michael Forney
·
2026-03-07 22:59:16 +0000 UTC
parent cdc695d
Remove recursive setup.lua operation This was inherited from when the gen scripts were written in rc and it was too slow to run the whole thing when any individual package changed. This is not an issue in Lua, and switching to a single invocation will allow for future improvements such as relying more on the Lua package system.
3 files changed,
+20,
-24
M
gen.lua
+9,
-1
1@@ -36,6 +36,14 @@ build('fspec-tar', '$outdir/root.tar.zst', {'$outdir/root.fspec', '|', '$builddi
2 --rule('gensquashfs', 'gensquashfs -F $in -D . -f -c gzip $out')
3 --build('gensquashfs', '$outdir/root.squashfs', {'$outdir/root.sqfslist'})
4
5-build('phony', 'build.ninja', 'ninja', {generator='1'})
6+build('phony', 'build.ninja', 'local.ninja', {generator='1'})
7+build('gen', 'local.ninja', {
8+ '|',
9+ '$basedir/ninja.lua',
10+ '$basedir/sets.lua',
11+ '$basedir/setup.lua',
12+ 'config.lua',
13+ '$gendir/gen',
14+})
15
16 io.write('default $builddir/root.tree\n')
+1,
-1
1@@ -1,5 +1,5 @@
2 rule gen
3- command = lua $basedir/setup.lua $gendir
4+ command = lua $basedir/setup.lua
5 generator = 1
6
7 # toolchain
+10,
-22
1@@ -21,8 +21,6 @@ if not config.prefix then
2 config.prefix = ''
3 end
4
5-local recurse = not arg[1]
6-
7 local function gen(gendir)
8 local dir = basedir..'/'..gendir
9 local outdir = config.builddir..'/'..gendir
10@@ -35,13 +33,7 @@ local function gen(gendir)
11 inputs={
12 index={},
13 fspec={},
14- gen={
15- '$basedir/ninja.lua',
16- '$basedir/sets.lua',
17- '$basedir/setup.lua',
18- 'config.lua',
19- },
20- ninja={'$gendir/local.ninja'},
21+ gen={},
22 fetch={},
23 },
24 fspec={},
25@@ -56,8 +48,7 @@ local function gen(gendir)
26 end
27 load('gen.lua')
28
29- build('gen', '$gendir/local.ninja', {'|', pkg.inputs.gen})
30- phony('ninja', pkg.inputs.ninja)
31+ build('phony', '$gendir/gen', pkg.inputs.gen)
32
33 if pkg.hdrs then
34 phony('headers', pkg.hdrs)
35@@ -127,19 +118,16 @@ end
36 function subgen(dir)
37 local file = '$gendir/'..dir..'/local.ninja'
38 subninja(file)
39- table.insert(pkg.inputs.ninja, '$gendir/'..dir..'/ninja')
40+ table.insert(pkg.inputs.gen, '$gendir/'..dir..'/gen')
41 table.insert(pkg.inputs.index, '$outdir/'..dir..'/root.index')
42 table.insert(pkg.inputs.fspec, '$outdir/'..dir..'/tree.fspec')
43- local cmd = ('exec test -f %s/%s/local.ninja'):format(pkg.gendir, dir)
44- if recurse or not os.execute(cmd) then
45- local oldpkg, oldout = pkg, io.output()
46- if pkg.gendir ~= '.' then
47- dir = pkg.gendir..'/'..dir
48- end
49- gen(dir)
50- pkg = oldpkg
51- io.output(oldout)
52+ local oldpkg, oldout = pkg, io.output()
53+ if pkg.gendir ~= '.' then
54+ dir = pkg.gendir..'/'..dir
55 end
56+ gen(dir)
57+ pkg = oldpkg
58+ io.output(oldout)
59 end
60
61-gen(arg[1] or '.')
62+gen('.')