ack/util/ncgg/build.lua

77 lines
1.2 KiB
Lua
Raw Normal View History

2016-07-26 21:35:30 +00:00
include("first/yacc.lua")
local cggparser = yacc {
name = "cggparser",
srcs = { "./cgg.y" }
}
local cgglexer = flex {
2016-07-26 21:35:30 +00:00
name = "cgglexer",
srcs = { "./scan.l" }
}
normalrule {
name = "keywords",
ins = concat(
2016-07-26 21:35:30 +00:00
"./cvtkeywords",
"./keywords",
filenamesof({cggparser}, "%.h$")
),
2016-07-26 21:35:30 +00:00
outleaves = { "enterkeyw.c" },
commands = {
"%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}"
}
}
cprogram {
name = "ncgg",
srcs = concat(
2016-07-26 21:35:30 +00:00
"./*.c",
filenamesof({cggparser}, "%.c$"),
filenamesof({cgglexer}, "%.c$"),
"+keywords"
),
2016-07-26 21:35:30 +00:00
deps = {
"+cggparser", -- for .h file
"+cgglexer", -- for .h file
"h+emheaders",
"util/data+em_data",
}
}
definerule("ncgg",
{
srcs = { type="targets" }
},
function(e)
-- Remember this is executed from the caller's directory; local
-- target names will resolve there
if (#e.srcs ~= 1) then
error("you must supply exactly one input file")
end
local cpptable = cppfile {
name = e.name.."/cpptable",
outleaf = "cpptable",
srcs = e.srcs
}
return normalrule {
name = e.name,
cwd = e.cwd,
outleaves = {
"tables.c",
"tables.h",
},
ins = {
"util/ncgg+ncgg",
cpptable
},
commands = {
"cd %{dir} && %{ins}",
"mv %{dir}/tables.H %{dir}/tables.h"
}
}
end
)