clibrary can now export headers.

This commit is contained in:
David Given 2016-06-29 13:28:45 +02:00
parent 7f7005bac5
commit c8711628ab

View file

@ -113,13 +113,14 @@ definerule("bundle",
definerule("clibrary", definerule("clibrary",
{ {
srcs = { type="targets" }, srcs = { type="targets" },
hdrs = { type="targets", default={} },
deps = { type="targets", default={} }, deps = { type="targets", default={} },
cflags = { type="strings", default={} }, cflags = { type="strings", default={} },
commands = { commands = {
type="strings", type="strings",
default={ default={
"rm -f %{outs}", "rm -f %{outs[1]}",
"$(AR) cqs %{outs} %{ins}" "$(AR) cqs %{outs[1]} %{ins}",
}, },
} }
}, },
@ -145,12 +146,25 @@ definerule("clibrary",
} }
end end
local hdrs = filenamesof(e.hdrs, "%.h$")
local commands = {}
for _, s in ipairs(e.commands) do
commands[#commands+1] = s
end
if (#hdrs > 0) then
commands[#commands+1] = "cp %{hdrs} %{dir}"
end
return normalrule { return normalrule {
name = e.name, name = e.name,
ins = ins, ins = ins,
outleaves = { e.name..".a" }, outleaves = { e.name..".a", unpack(basename(hdrs)) },
label = e.label, label = e.label,
commands = e.commands commands = commands,
vars = {
hdrs = hdrs
}
} }
end end
) )
@ -159,6 +173,7 @@ definerule("cprogram",
{ {
srcs = { type="targets", default={} }, srcs = { type="targets", default={} },
deps = { type="targets", default={} }, deps = { type="targets", default={} },
cflags = { type="strings", default={} },
commands = { commands = {
type="strings", type="strings",
default={ default={
@ -174,7 +189,8 @@ definerule("cprogram",
clibrary { clibrary {
name = e.name .. "/main", name = e.name .. "/main",
srcs = e.srcs, srcs = e.srcs,
deps = e.deps deps = e.deps,
cflags = e.cflags,
} }
}, },
"%.a$" "%.a$"