From 1a7b4f872916c8271c76aa40630ced8902d2ca85 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:05:24 +0200 Subject: [PATCH] Build the examples when doing a normal build; this exercises the compiler as a whole and is one step further towards a proper test suite. --- build.lua | 12 +++++++----- examples/build.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ first/build.lua | 3 ++- plat/build.lua | 24 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 examples/build.lua diff --git a/build.lua b/build.lua index 24dcb39b4..3c5e34c8d 100644 --- a/build.lua +++ b/build.lua @@ -12,6 +12,11 @@ vars.plats = { "rpi", } +local plat_packages = {} +for _, p in ipairs(vars.plats) do + plat_packages[#plat_packages+1] = "plat/"..p.."+pkg" +end + installable { name = "ack", map = { @@ -19,17 +24,14 @@ installable { "lang/cem/cemcom.ansi+pkg", "lang/m2/comp+pkg", "lang/pc/comp+pkg", - "plat/cpm+pkg", - "plat/linux386+pkg", - "plat/linux68k+pkg", - "plat/rpi+pkg", - "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", "util/arch+pkg", "util/led+pkg", "util/misc+pkg", "util/opt+pkg", + "examples+pkg", + plat_packages } } diff --git a/examples/build.lua b/examples/build.lua new file mode 100644 index 000000000..631752976 --- /dev/null +++ b/examples/build.lua @@ -0,0 +1,44 @@ +include("plat/build.lua") + +local conly = { + rpi = true +} + +local sourcefiles = filenamesof( + "./hilo.b", + "./hilo.c", + "./hilo.mod", + "./hilo.p", + "./mandelbrot.c", + "./paranoia.c", + "./startrek.c" +) + +local installmap = {} +for _, file in ipairs(sourcefiles) do + local b = basename(file) + local be = replace(b, "%.", "_") + local _, _, e = b:find("%.(%w*)$") + + for _, plat in ipairs(vars.plats) do + if (e == "c") or not conly[plat] then + local exe = ackprogram { + name = be.."_"..plat, + srcs = { file }, + vars = { + plat = plat, + lang = e, + } + } + + installmap["$(PLATIND)/examples/"..be.."."..plat] = exe + end + end + installmap["$(PLATIND)/examples/"..b] = file +end + +installable { + name = "pkg", + map = installmap +} + diff --git a/first/build.lua b/first/build.lua index 0efdadb12..3240f9f1a 100644 --- a/first/build.lua +++ b/first/build.lua @@ -216,6 +216,7 @@ definerule("cprogram", { srcs = { type="targets", default={} }, deps = { type="targets", default={} }, + _clibrary = { type="object", default=clibrary }, commands = { type="strings", default={ @@ -229,7 +230,7 @@ definerule("cprogram", for _, f in pairs( matching( filenamesof( - clibrary { + e._clibrary { name = e.name .. "/main", cwd = e.cwd, srcs = e.srcs, diff --git a/plat/build.lua b/plat/build.lua index f46db0bbe..d24e5d3f2 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -54,6 +54,30 @@ definerule("acklibrary", end ) +definerule("ackprogram", + { + srcs = { type="targets", default={} }, + deps = { type="targets", default={} }, + }, + function (e) + return cprogram { + name = e.name, + srcs = e.srcs, + deps = { + "plat/"..e.vars.plat.."+pkg", + "util/ack+pkg", + "util/led+pkg", + "util/amisc+pkg", + e.deps + }, + _clibrary = acklibrary, + commands = { + "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -.%{lang} -o %{outs} %{ins}" + } + } + end +) + definerule("build_plat_libs", { arch = { type="string" }, -- 2.34.1