Builds libend (the simplest library). Becoming obvious I need to rework the way

ackbuilder deals with lists.
This commit is contained in:
David Given 2016-07-30 00:39:22 +02:00
parent 363d13cc2f
commit b2bb4ce3b2
12 changed files with 98 additions and 36 deletions

View file

@ -74,7 +74,7 @@ $(BUILDDIR)/build.ninja: Makefile
else else
$(MAKECMDGOALS): $(BUILDDIR)/rules.mk $(MAKECMDGOALS): $(BUILDDIR)/rules.mk
@make -r -f $(BUILDDIR)/rules.mk $@ \ +@make -r -f $(BUILDDIR)/rules.mk $@ \
$(MAKEFLAGS) \ $(MAKEFLAGS) \
OBJDIR=$(OBJDIR) \ OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \ BINDIR=$(BINDIR) \

View file

@ -4,6 +4,9 @@ vars.cflags = {
vars.ackcflags = { vars.ackcflags = {
"-O" "-O"
} }
vars.plats = {
"pc86"
}
installable { installable {
name = "ack", name = "ack",

View file

@ -30,9 +30,13 @@ end
local function concat(...) local function concat(...)
local r = {} local r = {}
for k, t in ipairs({...}) do for _, t in ipairs({...}) do
for _, v in ipairs(t) do if (type(t) == "table") and not t.is then
r[#r+1] = v for _, v in ipairs(t) do
r[#r+1] = v
end
else
r[#r+1] = t
end end
end end
return r return r
@ -413,6 +417,10 @@ local typeconverters = {
end end
return i return i
end, end,
object = function(propname, i)
return i
end,
} }
local function definerule(rulename, types, cb) local function definerule(rulename, types, cb)

View file

@ -146,6 +146,7 @@ definerule("clibrary",
srcs = { type="targets", default={} }, srcs = { type="targets", default={} },
hdrs = { type="targets", default={} }, hdrs = { type="targets", default={} },
deps = { type="targets", default={} }, deps = { type="targets", default={} },
_cfile = { type="object", default=cfile },
commands = { commands = {
type="strings", type="strings",
default={ default={
@ -155,16 +156,13 @@ definerule("clibrary",
} }
}, },
function (e) function (e)
local csrcs = filenamesof(e.srcs, "%.c$")
local hsrcs = filenamesof(e.srcs, "%.h$")
local ins = {} local ins = {}
for _, csrc in fpairs(csrcs) do for _, src in fpairs(e.srcs) do
local n = basename(csrc):gsub("%.%w*$", "") local n = basename(src):gsub("%.%w*$", "")
ins[#ins+1] = cfile { ins[#ins+1] = e._cfile {
name = e.name.."/"..n, name = e.name.."/"..n,
cwd = e.cwd, cwd = e.cwd,
srcs = {csrc, unpack(hsrcs)}, srcs = {src},
deps = e.deps, deps = e.deps,
vars = { vars = {
["+cflags"] = { "-I"..e.cwd, }, ["+cflags"] = { "-I"..e.cwd, },

View file

@ -65,7 +65,7 @@ normalrule {
} }
} }
llgen { local llgen = llgen {
name = "llgen", name = "llgen",
srcs = { srcs = {
"+tokenfile_g", "+tokenfile_g",
@ -80,13 +80,13 @@ tabgen {
cprogram { cprogram {
name = "cpp", name = "cpp",
srcs = { srcs = concat(
"./*.c", "./*.c",
"+llgen", filenamesof(llgen, "%.c$"),
"+next_c", "+next_c",
"+symbol2str_c", "+symbol2str_c",
"+tabgen_c", "+tabgen_c"
}, ),
deps = { deps = {
"+llgen", "+llgen",
"+macro_h", "+macro_h",

View file

@ -0,0 +1,8 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = { "./*.s" },
vars = { plat = plat },
}
end

View file

@ -30,15 +30,15 @@ definerule("build_as",
return cprogram { return cprogram {
name = e.name, name = e.name,
srcs = { srcs = concat(
"mach/proto/as/*.c", "mach/proto/as/*.c",
yaccfiles, -- for .c file filenamesof(yaccfiles, "%.c$")
}, ),
deps = { deps = {
"h+emheaders", "h+emheaders",
"modules/src/object+lib", "modules/src/object+lib",
archlib, archlib,
yaccfiles, -- for .h file yaccfiles
} }
} }
end end

View file

@ -25,11 +25,33 @@ definerule("ackfile",
end end
) )
definerule("acklibrary",
{
srcs = { type="targets", default={} },
hdrs = { type="targets", default={} },
deps = { type="targets", default={} },
},
function (e)
return clibrary {
name = e.name,
srcs = e.srcs,
hdrs = e.hdrs,
deps = {
"util/arch+pkg",
unpack(e.deps)
},
_cfile = ackfile,
commands = {
"ACKDIR=$(INSDIR) $(INSDIR)/bin/aal q %{outs[1]} %{ins}"
}
}
end
)
definerule("build_plat_tools", definerule("build_plat_tools",
{ {
arch = { type = "string" }, arch = { type="string" },
plat = { type = "string" }, plat = { type="string" },
}, },
function(e) function(e)
local descr = "plat/"..e.plat.."/descr" local descr = "plat/"..e.plat.."/descr"
@ -54,3 +76,20 @@ definerule("build_plat_tools",
} }
end end
) )
definerule("build_plat_libs",
{
arch = { type="string" },
plat = { type="string" },
},
function(e)
return installable {
name = e.name,
map = {
["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat
}
}
end
)

View file

@ -12,10 +12,17 @@ ackfile {
vars = { plat = "pc86" } vars = { plat = "pc86" }
} }
build_plat_libs {
name = "libs",
arch = "i86",
plat = "pc86",
}
installable { installable {
name = "pkg", name = "pkg",
map = { map = {
"+tools", "+tools",
"+libs",
["$(PLATIND)/pc86/boot.o"] = "+boot" ["$(PLATIND)/pc86/boot.o"] = "+boot"
} }
} }

View file

@ -19,7 +19,6 @@ cprogram {
name = "ack", name = "ack",
srcs = { srcs = {
"./*.c", "./*.c",
"./*.h",
"+tables", "+tables",
}, },
deps = { deps = {

View file

@ -1,4 +1,4 @@
normalrule { local generated = normalrule {
name = "generated", name = "generated",
ins = { ins = {
"./new_table", "./new_table",
@ -22,10 +22,10 @@ normalrule {
clibrary { clibrary {
name = "em_data", name = "em_data",
srcs = { srcs = concat(
"./em_ptyp.c", "./em_ptyp.c",
"+generated", -- so we build the C files filenamesof(generated, "%.c$")
}, ),
hdrs = { hdrs = {
"+generated" -- so we export the H files "+generated" -- so we export the H files
}, },

View file

@ -5,18 +5,18 @@ local cggparser = yacc {
srcs = { "./cgg.y" } srcs = { "./cgg.y" }
} }
flex { local cgglexer = flex {
name = "cgglexer", name = "cgglexer",
srcs = { "./scan.l" } srcs = { "./scan.l" }
} }
normalrule { normalrule {
name = "keywords", name = "keywords",
ins = { ins = concat(
"./cvtkeywords", "./cvtkeywords",
"./keywords", "./keywords",
unpack(filenamesof({cggparser}, "%.h$")) filenamesof({cggparser}, "%.h$")
}, ),
outleaves = { "enterkeyw.c" }, outleaves = { "enterkeyw.c" },
commands = { commands = {
"%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" "%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}"
@ -25,12 +25,12 @@ normalrule {
cprogram { cprogram {
name = "ncgg", name = "ncgg",
srcs = { srcs = concat(
"./*.c", "./*.c",
"+cggparser", -- for .c file filenamesof({cggparser}, "%.c$"),
"+cgglexer", -- for .c file filenamesof({cgglexer}, "%.c$"),
"+keywords", "+keywords"
}, ),
deps = { deps = {
"+cggparser", -- for .h file "+cggparser", -- for .h file
"+cgglexer", -- for .h file "+cgglexer", -- for .h file