From 2e91c9c4ce10384a845098d0236dee8a946fc86b Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 22 Jun 2020 11:46:27 -0700 Subject: Add gitfile helper function --- ninja.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'ninja.lua') diff --git a/ninja.lua b/ninja.lua index 19e0b167..210a45f2 100644 --- a/ninja.lua +++ b/ninja.lua @@ -428,6 +428,18 @@ local function fs(name, path) return (config.fs.include or config.fs.exclude) and specmatch(config.fs, path) end +function gitfile(path, mode, src) + local out = '$builddir/root.hash/'..path + local perm = ('10%04o %s'):format(tonumber(mode, 8), path) + build('githash', out, {src, '|', '$basedir/scripts/hash.sh', '||', '$builddir/root.stamp'}, { + args=perm, + }) + table.insert(pkg.inputs.index, out) + if mode ~= '0644' and mode ~= '0755' then + table.insert(pkg.perms, perm) + end +end + function file(path, mode, src) if pkg.gendir:hasprefix('pkg/') and not fs(pkg.name, path) then return @@ -439,15 +451,7 @@ function file(path, mode, src) source=src:gsub('^%$(%w+)', pkg, 1), } table.insert(pkg.inputs.fspec.implicit, src) - local out = '$builddir/root.hash/'..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 ~= '0644' and mode ~= '0755' then - table.insert(pkg.perms, perm) - end + gitfile(path, mode, src) end function dir(path, mode) -- cgit v1.2.3