opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: 48898ef12c66143b4426235497dc10f8581a3800
Parent: 4b038191fb185d9ca79bbfd2d2b5bd830c7bb095
Author: Michael Forney
Date:   Sat,  7 Mar 2026 14:59:16 -0800

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.

Diffstat:
Mgen.lua | 10+++++++++-
Mrules.ninja | 2+-
Msetup.lua | 32++++++++++----------------------
3 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/gen.lua b/gen.lua @@ -36,6 +36,14 @@ build('fspec-tar', '$outdir/root.tar.zst', {'$outdir/root.fspec', '|', '$builddi --rule('gensquashfs', 'gensquashfs -F $in -D . -f -c gzip $out') --build('gensquashfs', '$outdir/root.squashfs', {'$outdir/root.sqfslist'}) -build('phony', 'build.ninja', 'ninja', {generator='1'}) +build('phony', 'build.ninja', 'local.ninja', {generator='1'}) +build('gen', 'local.ninja', { + '|', + '$basedir/ninja.lua', + '$basedir/sets.lua', + '$basedir/setup.lua', + 'config.lua', + '$gendir/gen', +}) io.write('default $builddir/root.tree\n') diff --git a/rules.ninja b/rules.ninja @@ -1,5 +1,5 @@ rule gen - command = lua $basedir/setup.lua $gendir + command = lua $basedir/setup.lua generator = 1 # toolchain diff --git a/setup.lua b/setup.lua @@ -21,8 +21,6 @@ if not config.prefix then config.prefix = '' end -local recurse = not arg[1] - local function gen(gendir) local dir = basedir..'/'..gendir local outdir = config.builddir..'/'..gendir @@ -35,13 +33,7 @@ local function gen(gendir) inputs={ index={}, fspec={}, - gen={ - '$basedir/ninja.lua', - '$basedir/sets.lua', - '$basedir/setup.lua', - 'config.lua', - }, - ninja={'$gendir/local.ninja'}, + gen={}, fetch={}, }, fspec={}, @@ -56,8 +48,7 @@ local function gen(gendir) end load('gen.lua') - build('gen', '$gendir/local.ninja', {'|', pkg.inputs.gen}) - phony('ninja', pkg.inputs.ninja) + build('phony', '$gendir/gen', pkg.inputs.gen) if pkg.hdrs then phony('headers', pkg.hdrs) @@ -127,19 +118,16 @@ end function subgen(dir) local file = '$gendir/'..dir..'/local.ninja' subninja(file) - table.insert(pkg.inputs.ninja, '$gendir/'..dir..'/ninja') + table.insert(pkg.inputs.gen, '$gendir/'..dir..'/gen') table.insert(pkg.inputs.index, '$outdir/'..dir..'/root.index') table.insert(pkg.inputs.fspec, '$outdir/'..dir..'/tree.fspec') - local cmd = ('exec test -f %s/%s/local.ninja'):format(pkg.gendir, dir) - if recurse or not os.execute(cmd) then - local oldpkg, oldout = pkg, io.output() - if pkg.gendir ~= '.' then - dir = pkg.gendir..'/'..dir - end - gen(dir) - pkg = oldpkg - io.output(oldout) + local oldpkg, oldout = pkg, io.output() + if pkg.gendir ~= '.' then + dir = pkg.gendir..'/'..dir end + gen(dir) + pkg = oldpkg + io.output(oldout) end -gen(arg[1] or '.') +gen('.')