diff options
| author | Michael Forney <mforney@mforney.org> | 2020-06-14 11:33:31 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2020-06-15 23:35:02 -0700 |
| commit | 214296ab724829d700e09dc5863e38a8bd2e0565 (patch) | |
| tree | 36048bf2ef71da1a4cac9dd7ee61e17e3ed34687 | |
| parent | 8494d08ca91d3ed20978836e5817f6c2a69925ed (diff) | |
Make gen a local function
| -rwxr-xr-x | setup.lua | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -23,26 +23,7 @@ end local recurse = not arg[1] -function subgen(dir) - local file = '$gendir/'..dir..'/local.ninja' - subninja(file) - table.insert(pkg.inputs.ninja, '$gendir/'..dir..'/ninja') - table.insert(pkg.inputs.index, '$outdir/'..dir..'/root.index') - table.insert(pkg.inputs.perms, '$outdir/'..dir..'/root.perms') - table.insert(pkg.inputs.fspec, '$outdir/'..dir..'/root.fspec') - local cmd = string.format('test -f %s/%s/local.ninja', 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) - end -end - -function gen(gendir) +local function gen(gendir) local dir = basedir..'/'..gendir local outdir = config.builddir..'/'..gendir pkg={ @@ -148,4 +129,23 @@ function gen(gendir) end end +function subgen(dir) + local file = '$gendir/'..dir..'/local.ninja' + subninja(file) + table.insert(pkg.inputs.ninja, '$gendir/'..dir..'/ninja') + table.insert(pkg.inputs.index, '$outdir/'..dir..'/root.index') + table.insert(pkg.inputs.perms, '$outdir/'..dir..'/root.perms') + table.insert(pkg.inputs.fspec, '$outdir/'..dir..'/root.fspec') + local cmd = string.format('test -f %s/%s/local.ninja', 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) + end +end + gen(arg[1] or '.') |
