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