From b2bb4ce3b28634135c6acc6f692df67e1869d847 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 30 Jul 2016 00:39:22 +0200 Subject: [PATCH] Builds libend (the simplest library). Becoming obvious I need to rework the way ackbuilder deals with lists. --- Makefile | 2 +- build.lua | 3 +++ first/ackbuilder.lua | 14 +++++++++--- first/build.lua | 12 +++++------ lang/cem/cpp.ansi/build.lua | 10 ++++----- mach/i86/libend/build.lua | 8 +++++++ mach/proto/as/build.lua | 8 +++---- plat/build.lua | 43 +++++++++++++++++++++++++++++++++++-- plat/pc86/build.lua | 7 ++++++ util/ack/build.lua | 1 - util/data/build.lua | 8 +++---- util/ncgg/build.lua | 18 ++++++++-------- 12 files changed, 98 insertions(+), 36 deletions(-) create mode 100644 mach/i86/libend/build.lua diff --git a/Makefile b/Makefile index a8381b487..78d3f9c2b 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ $(BUILDDIR)/build.ninja: Makefile else $(MAKECMDGOALS): $(BUILDDIR)/rules.mk - @make -r -f $(BUILDDIR)/rules.mk $@ \ + +@make -r -f $(BUILDDIR)/rules.mk $@ \ $(MAKEFLAGS) \ OBJDIR=$(OBJDIR) \ BINDIR=$(BINDIR) \ diff --git a/build.lua b/build.lua index 9db83f5cd..200744a4c 100644 --- a/build.lua +++ b/build.lua @@ -4,6 +4,9 @@ vars.cflags = { vars.ackcflags = { "-O" } +vars.plats = { + "pc86" +} installable { name = "ack", diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 49937d168..1330f53cd 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -30,9 +30,13 @@ end local function concat(...) local r = {} - for k, t in ipairs({...}) do - for _, v in ipairs(t) do - r[#r+1] = v + for _, t in ipairs({...}) do + if (type(t) == "table") and not t.is then + for _, v in ipairs(t) do + r[#r+1] = v + end + else + r[#r+1] = t end end return r @@ -413,6 +417,10 @@ local typeconverters = { end return i end, + + object = function(propname, i) + return i + end, } local function definerule(rulename, types, cb) diff --git a/first/build.lua b/first/build.lua index 6a8bc4c93..192f512e1 100644 --- a/first/build.lua +++ b/first/build.lua @@ -146,6 +146,7 @@ definerule("clibrary", srcs = { type="targets", default={} }, hdrs = { type="targets", default={} }, deps = { type="targets", default={} }, + _cfile = { type="object", default=cfile }, commands = { type="strings", default={ @@ -155,16 +156,13 @@ definerule("clibrary", } }, function (e) - local csrcs = filenamesof(e.srcs, "%.c$") - local hsrcs = filenamesof(e.srcs, "%.h$") - local ins = {} - for _, csrc in fpairs(csrcs) do - local n = basename(csrc):gsub("%.%w*$", "") - ins[#ins+1] = cfile { + for _, src in fpairs(e.srcs) do + local n = basename(src):gsub("%.%w*$", "") + ins[#ins+1] = e._cfile { name = e.name.."/"..n, cwd = e.cwd, - srcs = {csrc, unpack(hsrcs)}, + srcs = {src}, deps = e.deps, vars = { ["+cflags"] = { "-I"..e.cwd, }, diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index ee3275a51..85d92b925 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -65,7 +65,7 @@ normalrule { } } -llgen { +local llgen = llgen { name = "llgen", srcs = { "+tokenfile_g", @@ -80,13 +80,13 @@ tabgen { cprogram { name = "cpp", - srcs = { + srcs = concat( "./*.c", - "+llgen", + filenamesof(llgen, "%.c$"), "+next_c", "+symbol2str_c", - "+tabgen_c", - }, + "+tabgen_c" + ), deps = { "+llgen", "+macro_h", diff --git a/mach/i86/libend/build.lua b/mach/i86/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua index 39e491813..89731351c 100644 --- a/mach/proto/as/build.lua +++ b/mach/proto/as/build.lua @@ -30,15 +30,15 @@ definerule("build_as", return cprogram { name = e.name, - srcs = { + srcs = concat( "mach/proto/as/*.c", - yaccfiles, -- for .c file - }, + filenamesof(yaccfiles, "%.c$") + ), deps = { "h+emheaders", "modules/src/object+lib", archlib, - yaccfiles, -- for .h file + yaccfiles } } end diff --git a/plat/build.lua b/plat/build.lua index b8b457c0d..7febb9ada 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -25,11 +25,33 @@ definerule("ackfile", 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", { - arch = { type = "string" }, - plat = { type = "string" }, + arch = { type="string" }, + plat = { type="string" }, }, function(e) local descr = "plat/"..e.plat.."/descr" @@ -54,3 +76,20 @@ definerule("build_plat_tools", } 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 +) + + diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua index baef77e7e..c293a4ea6 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build.lua @@ -12,10 +12,17 @@ ackfile { vars = { plat = "pc86" } } +build_plat_libs { + name = "libs", + arch = "i86", + plat = "pc86", +} + installable { name = "pkg", map = { "+tools", + "+libs", ["$(PLATIND)/pc86/boot.o"] = "+boot" } } diff --git a/util/ack/build.lua b/util/ack/build.lua index dc46d44a8..4394484b4 100644 --- a/util/ack/build.lua +++ b/util/ack/build.lua @@ -19,7 +19,6 @@ cprogram { name = "ack", srcs = { "./*.c", - "./*.h", "+tables", }, deps = { diff --git a/util/data/build.lua b/util/data/build.lua index 784e1d6ac..5c9f0b3f8 100644 --- a/util/data/build.lua +++ b/util/data/build.lua @@ -1,4 +1,4 @@ -normalrule { +local generated = normalrule { name = "generated", ins = { "./new_table", @@ -22,10 +22,10 @@ normalrule { clibrary { name = "em_data", - srcs = { + srcs = concat( "./em_ptyp.c", - "+generated", -- so we build the C files - }, + filenamesof(generated, "%.c$") + ), hdrs = { "+generated" -- so we export the H files }, diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index e583963a2..57d9e4753 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -5,18 +5,18 @@ local cggparser = yacc { srcs = { "./cgg.y" } } -flex { +local cgglexer = flex { name = "cgglexer", srcs = { "./scan.l" } } normalrule { name = "keywords", - ins = { + ins = concat( "./cvtkeywords", "./keywords", - unpack(filenamesof({cggparser}, "%.h$")) - }, + filenamesof({cggparser}, "%.h$") + ), outleaves = { "enterkeyw.c" }, commands = { "%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" @@ -25,12 +25,12 @@ normalrule { cprogram { name = "ncgg", - srcs = { + srcs = concat( "./*.c", - "+cggparser", -- for .c file - "+cgglexer", -- for .c file - "+keywords", - }, + filenamesof({cggparser}, "%.c$"), + filenamesof({cgglexer}, "%.c$"), + "+keywords" + ), deps = { "+cggparser", -- for .h file "+cgglexer", -- for .h file