logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: 2df90914df3e9e1197b267791024cb97b5638d7f
parent d94a0753e7ada0fd8ff204b75a6b385188ad80f0
Author: Michael Forney <mforney@mforney.org>
Date:   Mon, 22 Jun 2020 22:41:35 -0700

Add blake3 hashes to fspec files

Diffstat:

Mninja.lua1-
Apkg/b3sum/.gitignore1+
Mpkg/b3sum/gen.lua7+++++++
Apkg/fspec-sync/.gitignore1+
Mpkg/fspec-sync/gen.lua9+++++++++
Mrules.ninja3+++
Msetup.lua13++++++++-----
7 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/ninja.lua b/ninja.lua @@ -455,7 +455,6 @@ function file(path, mode, src) mode=mode, source=src:gsub('^%$(%w+)', pkg, 1), } - table.insert(pkg.inputs.fspec.implicit, src) gitfile(path, mode, src) end diff --git a/pkg/b3sum/.gitignore b/pkg/b3sum/.gitignore @@ -0,0 +1 @@ +/host.ninja diff --git a/pkg/b3sum/gen.lua b/pkg/b3sum/gen.lua @@ -8,6 +8,13 @@ pkg.hdrs = { install=true, } +sub('host.ninja', function() + set('outdir', '$outdir/host') + toolchain(config.host) + + lib('libblake3.a', {'blake3.c', 'blake3_dispatch.c', 'blake3_portable.c'}) +end) + lib('libblake3.a', [[ blake3.c blake3_dispatch.c diff --git a/pkg/fspec-sync/.gitignore b/pkg/fspec-sync/.gitignore @@ -0,0 +1 @@ +/host.ninja diff --git a/pkg/fspec-sync/gen.lua b/pkg/fspec-sync/gen.lua @@ -3,6 +3,15 @@ cflags{ '-isystem $builddir/pkg/b3sum/include', } +sub('host.ninja', function() + set('outdir', '$outdir/host') + toolchain(config.host) + cflags{'-isystem $builddir/pkg/b3sum/include'} + + lib('libcommon.a', {'fatal.c', 'parse.c', 'reallocarray.c'}) + exe('fspec-hash', {'fspec-hash.c', 'libcommon.a', '$builddir/pkg/b3sum/host/libblake3.a'}, {'pkg/b3sum/headers'}) +end) + lib('libcommon.a', {'fatal.c', 'parse.c', 'reallocarray.c'}) exe('fspec-hash', {'fspec-hash.c', 'libcommon.a', '$builddir/pkg/b3sum/libblake3.a'}, {'pkg/b3sum/headers'}) diff --git a/rules.ninja b/rules.ninja @@ -118,6 +118,9 @@ rule git-archive rule git-init command = git init $repo_flags $repo && touch $out +rule fspec-hash + command = $builddir/pkg/fspec-sync/host/fspec-hash <$in >$out + rule fetch command = cd $basedir && sh $$OLDPWD/$script $gendir && touch $$OLDPWD/$out description = FETCH $gendir diff --git a/setup.lua b/setup.lua @@ -34,7 +34,7 @@ local function gen(gendir) outdir=outdir, inputs={ index={}, - fspec={implicit={}}, + fspec={}, gen={ '$basedir/ninja.lua', '$basedir/sets.lua', @@ -78,6 +78,7 @@ local function gen(gendir) local out = outdir..'/local.fspec' local tmp = out..'.tmp' local f = assert(io.open(tmp, 'w')) + local srcs = {} for _, path, fspec in sortedpairs(pkg.fspec) do f:write(('/%s\n'):format(path)) for _, k in ipairs{'type', 'mode', 'source', 'target'} do @@ -87,6 +88,10 @@ local function gen(gendir) end end f:write('\n') + local src = fspec.source + if src then + srcs[#srcs + 1] = src + end end f:close() if os.execute(('exec cmp -s %s %s'):format(tmp, out)) then @@ -94,7 +99,8 @@ local function gen(gendir) else os.rename(tmp, out) end - table.insert(pkg.inputs.fspec, '$outdir/local.fspec') + build('fspec-hash', '$outdir/local-hashed.fspec', {'$outdir/local.fspec', '|', '$builddir/pkg/fspec-sync/host/fspec-hash', srcs}) + table.insert(pkg.inputs.fspec, '$outdir/local-hashed.fspec') end if next(pkg.inputs.index) then build('cat', '$outdir/root.index', pkg.inputs.index, { @@ -104,9 +110,6 @@ local function gen(gendir) 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', })