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.
This commit is contained in:
David Given 2016-08-20 14:05:24 +02:00
parent 53c9731036
commit 1a7b4f8729
4 changed files with 77 additions and 6 deletions

View file

@ -12,6 +12,11 @@ vars.plats = {
"rpi", "rpi",
} }
local plat_packages = {}
for _, p in ipairs(vars.plats) do
plat_packages[#plat_packages+1] = "plat/"..p.."+pkg"
end
installable { installable {
name = "ack", name = "ack",
map = { map = {
@ -19,17 +24,14 @@ installable {
"lang/cem/cemcom.ansi+pkg", "lang/cem/cemcom.ansi+pkg",
"lang/m2/comp+pkg", "lang/m2/comp+pkg",
"lang/pc/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/ack+pkg",
"util/amisc+pkg", "util/amisc+pkg",
"util/arch+pkg", "util/arch+pkg",
"util/led+pkg", "util/led+pkg",
"util/misc+pkg", "util/misc+pkg",
"util/opt+pkg", "util/opt+pkg",
"examples+pkg",
plat_packages
} }
} }

44
examples/build.lua Normal file
View file

@ -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
}

View file

@ -216,6 +216,7 @@ definerule("cprogram",
{ {
srcs = { type="targets", default={} }, srcs = { type="targets", default={} },
deps = { type="targets", default={} }, deps = { type="targets", default={} },
_clibrary = { type="object", default=clibrary },
commands = { commands = {
type="strings", type="strings",
default={ default={
@ -229,7 +230,7 @@ definerule("cprogram",
for _, f in pairs( for _, f in pairs(
matching( matching(
filenamesof( filenamesof(
clibrary { e._clibrary {
name = e.name .. "/main", name = e.name .. "/main",
cwd = e.cwd, cwd = e.cwd,
srcs = e.srcs, srcs = e.srcs,

View file

@ -54,6 +54,30 @@ definerule("acklibrary",
end 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", definerule("build_plat_libs",
{ {
arch = { type="string" }, arch = { type="string" },