diff options
| author | Michael Forney <mforney@mforney.org> | 2020-06-14 11:31:16 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2020-06-15 23:35:02 -0700 |
| commit | 8494d08ca91d3ed20978836e5817f6c2a69925ed (patch) | |
| tree | d38b361c3b91522b7fc4b8d3c60252d55a561a28 | |
| parent | 83d28a0cd387362c9f31f11783556c0ac547b3cd (diff) | |
Add fspec output
| -rw-r--r-- | ninja.lua | 25 | ||||
| -rwxr-xr-x | setup.lua | 31 |
2 files changed, 50 insertions, 6 deletions
@@ -434,14 +434,20 @@ function file(path, mode, src) if pkg.gendir:hasprefix('pkg/') and not fs(pkg.name, path) then return end + mode = ('%04o'):format(tonumber(mode, 8)) + pkg.fspec[path] = { + type='reg', + mode=mode, + source=src:gsub('^%$(%w+)', pkg, 1), + } + table.insert(pkg.inputs.fspec.implicit, src) local out = '$builddir/root.hash/'..path - mode = tonumber(mode, 8) - local perm = string.format('10%04o %s', mode, path) + local perm = ('10%s %s'):format(mode, path) build('githash', out, {src, '|', '$basedir/scripts/hash.sh', '||', '$builddir/root.stamp'}, { args=perm, }) table.insert(pkg.inputs.index, out) - if mode ~= 420 and mode ~= 493 then -- 0644 and 0755 + if mode ~= '0644' and mode ~= '0755' then table.insert(pkg.perms, perm) end end @@ -450,14 +456,23 @@ function dir(path, mode) if pkg.gendir:hasprefix('pkg/') and not fs(pkg.name, path) then return end - mode = tonumber(mode, 8) - table.insert(pkg.perms, string.format('04%04o %s', mode, path)) + mode = ('%04o'):format(tonumber(mode, 8)) + pkg.fspec[path] = { + type='dir', + mode=mode, + } + table.insert(pkg.perms, ('04%s %s'):format(mode, path)) end function sym(path, target) if pkg.gendir:hasprefix('pkg/') and not fs(pkg.name, path) then return end + pkg.fspec[path] = { + type='sym', + mode='0777', + target=target, + } local out = '$builddir/root.hash/'..path build('githash', out, {'|', '$basedir/scripts/hash.sh', '||', '$builddir/root.stamp'}, { args=string.format('120000 %s %s', path, target), @@ -29,6 +29,7 @@ function subgen(dir) 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() @@ -42,12 +43,18 @@ function subgen(dir) end function gen(gendir) + local dir = basedir..'/'..gendir + local outdir = config.builddir..'/'..gendir pkg={ name=gendir:match('[^/]*$'), + dir=dir, gendir=gendir, + srcdir=dir..'/src', + outdir=outdir, inputs={ perms={}, index={}, + fspec={implicit={}}, gen={ '$basedir/ninja.lua', '$basedir/sets.lua', @@ -58,9 +65,9 @@ function gen(gendir) fetch={}, }, perms={}, + fspec={}, } assert(os.execute('mkdir -p '..gendir)) - local outdir = config.builddir..'/'..gendir assert(os.execute('mkdir -p '..outdir)) io.output(gendir..'/local.ninja.tmp') set('gendir', gendir) @@ -99,6 +106,18 @@ function gen(gendir) table.insert(pkg.inputs.perms, '$outdir/local.perms') f:close() end + if next(pkg.fspec) then + local f = assert(io.open(outdir..'/local.fspec', 'w')) + for _, path in ipairs(table.keys(pkg.fspec)) do + f:write(('/%s\n'):format(path)) + for k, v in pairs(pkg.fspec[path]) do + f:write(('%s=%s\n'):format(k, v)) + end + f:write('\n') + end + f:close() + table.insert(pkg.inputs.fspec, '$outdir/local.fspec') + end if next(pkg.inputs.perms) then build('mergeperms', '$outdir/root.perms', pkg.inputs.perms) else @@ -111,6 +130,16 @@ function gen(gendir) else build('empty', '$outdir/root.index') end + if next(pkg.inputs.fspec) then + if next(pkg.inputs.fspec.implicit) then + table.insert(pkg.inputs.fspec, {'|', pkg.inputs.fspec.implicit}) + end + build('cat', '$outdir/root.fspec', pkg.inputs.fspec, { + description = ' FSPEC $outdir/root.fspec', + }) + else + build('empty', '$outdir/root.fspec') + end build('phony', '$dir/root', pkg.inputs.root) io.close() os.rename(gendir..'/local.ninja.tmp', gendir..'/local.ninja') |
