diff options
| author | Michael Forney <mforney@mforney.org> | 2022-10-30 15:30:25 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2022-10-30 15:30:25 -0700 |
| commit | 9efcfba5d4c95dead994ee57cfa249e553c304e2 (patch) | |
| tree | 5a1b34444cc6c5376df13f7d829b803ee46eacd9 /ninja.lua | |
| parent | 75ce80bd7e003775855d1343989d6f1ffd1b4bcd (diff) | |
Handle absolute paths in build scripts
This is useful to link with system libraries for testing.
Diffstat (limited to 'ninja.lua')
| -rw-r--r-- | ninja.lua | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -179,7 +179,7 @@ function set(var, val, indent) end function subninja(file) - if not file:hasprefix('$') then + if not file:match('^[$/]') then file = '$gendir/'..file end io.write(string.format('subninja %s\n', file)) @@ -265,7 +265,7 @@ end function compile(rule, src, deps, args) local obj = src..'.o' - if not src:hasprefix('$') then + if not src:match('^[$/]') then src = '$srcdir/'..src obj = '$outdir/'..obj end @@ -314,7 +314,7 @@ function link(out, files, args) local objs = {} local deps = {} for _, file in ipairs(files) do - if not file:hasprefix('$') then + if not file:match('^[$/]') then file = '$outdir/'..file end if file:hassuffix('.d') then @@ -343,7 +343,7 @@ function ar(out, files) local objs, nobjs = {}, 0 local deps, ndeps = {out}, 1 for _, file in ipairs(files) do - if not file:hasprefix('$') then + if not file:match('^[$/]') then file = '$outdir/'..file end if file:find('%.[ad]$') then @@ -367,7 +367,7 @@ function exe(out, srcs, deps, args) end function yacc(name, gram) - if not gram:hasprefix('$') then + if not gram:match('^[$/]') then gram = '$srcdir/'..gram end build('yacc', expand{'$outdir/', name, {'.tab.c', '.tab.h'}}, gram, { @@ -486,7 +486,7 @@ end function man(srcs, section) for _, src in ipairs(srcs) do - if not src:hasprefix('$') then + if not src:match('^[$/]') then src = '$srcdir/'..src end local i = src:find('/', 1, true) |
