Better cwd handling.
This commit is contained in:
parent
c8711628ab
commit
90764320bb
|
@ -358,6 +358,7 @@ local function definerule(rulename, types, cb)
|
|||
end
|
||||
|
||||
types.name = { type="string" }
|
||||
types.cwd = { type="string", optional=true }
|
||||
|
||||
for propname, typespec in pairs(types) do
|
||||
if not typeconverters[typespec.type] then
|
||||
|
@ -366,6 +367,7 @@ local function definerule(rulename, types, cb)
|
|||
end
|
||||
end
|
||||
|
||||
local rulecwd = cwd
|
||||
local rule = function(e)
|
||||
local args = {}
|
||||
for propname, typespec in pairs(types) do
|
||||
|
@ -388,8 +390,16 @@ local function definerule(rulename, types, cb)
|
|||
|
||||
args.environment = environment
|
||||
args.fullname = cwd.."+"..args.name
|
||||
args.rulecwd = rulecwd
|
||||
if not args.cwd then
|
||||
args.cwd = cwd
|
||||
end
|
||||
|
||||
local oldcwd = cwd
|
||||
cwd = rulecwd
|
||||
local result = cb(args) or {}
|
||||
cwd = oldcwd
|
||||
|
||||
result.is = result.is or {}
|
||||
result.is[rulename] = true
|
||||
result.fullname = args.fullname
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local function objdir(e)
|
||||
return concatpath("$(OBJDIR)", cwd(), e.name)
|
||||
return concatpath("$(OBJDIR)", e.cwd, e.name)
|
||||
end
|
||||
|
||||
definerule("normalrule",
|
||||
|
@ -69,6 +69,7 @@ definerule("cfile",
|
|||
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
cwd = e.cwd,
|
||||
ins = {csrcs[1], unpack(hsrcs)},
|
||||
outleaves = {outleaf},
|
||||
label = e.label,
|
||||
|
@ -102,6 +103,7 @@ definerule("bundle",
|
|||
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
cwd = e.cwd,
|
||||
ins = e.srcs,
|
||||
outleaves = outleaves,
|
||||
label = e.label,
|
||||
|
@ -137,10 +139,11 @@ definerule("clibrary",
|
|||
local n = basename(csrc):gsub("%.%w*$", "")
|
||||
ins[#ins+1] = cfile {
|
||||
name = e.name.."/"..n,
|
||||
cwd = e.cwd,
|
||||
srcs = {csrc, unpack(hsrcs)},
|
||||
deps = e.deps,
|
||||
cflags = {
|
||||
"-I"..cwd(),
|
||||
"-I"..e.cwd,
|
||||
unpack(e.cflags)
|
||||
},
|
||||
}
|
||||
|
@ -158,6 +161,7 @@ definerule("clibrary",
|
|||
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
cwd = e.cwd,
|
||||
ins = ins,
|
||||
outleaves = { e.name..".a", unpack(basename(hdrs)) },
|
||||
label = e.label,
|
||||
|
@ -188,6 +192,7 @@ definerule("cprogram",
|
|||
{
|
||||
clibrary {
|
||||
name = e.name .. "/main",
|
||||
cwd = e.cwd,
|
||||
srcs = e.srcs,
|
||||
deps = e.deps,
|
||||
cflags = e.cflags,
|
||||
|
@ -201,6 +206,7 @@ definerule("cprogram",
|
|||
|
||||
return normalrule {
|
||||
name = e.name,
|
||||
cwd = e.cwd,
|
||||
ins = libs,
|
||||
outleaves = { e.name },
|
||||
commands = e.commands,
|
||||
|
|
Loading…
Reference in a new issue