We can build our first C file.

This commit is contained in:
David Given 2016-08-07 21:56:53 +02:00
parent b50dc4214a
commit 0d77cb8279
16 changed files with 258 additions and 38 deletions

View file

@ -12,11 +12,12 @@ installable {
name = "ack", name = "ack",
map = { map = {
"lang/cem/cemcom.ansi+pkg", "lang/cem/cemcom.ansi+pkg",
"plat/pc86+pkg",
"util/ack+pkg", "util/ack+pkg",
"util/amisc+pkg", "util/amisc+pkg",
"util/arch+pkg", "util/arch+pkg",
"util/misc+pkg", "util/misc+pkg",
"plat/pc86+pkg", "util/opt+pkg",
} }
} }

View file

@ -415,7 +415,7 @@ loadtarget = function(targetname)
target = targets[targetname] target = targets[targetname]
if not target then if not target then
error(string.format("build file '%s' contains no rule '%s'", error(string.format("build file '%s' contains no target '%s'",
filename, targetpart)) filename, targetpart))
end end
end end

0
lang/build.lua Normal file
View file

View file

@ -1,4 +1,5 @@
include("util/LLgen/build.lua") include("util/LLgen/build.lua")
include("util/cmisc/build.lua")
normalrule { normalrule {
name = "parameters", name = "parameters",
@ -50,12 +51,24 @@ clibrary {
} }
normalrule { normalrule {
name = "tokenname-g", name = "tokenfile-g",
ins = { ins = {
"./make.tokfile", "./make.tokfile",
"./tokenname.c", "./tokenname.c",
}, },
outleaves = { "tokenname.g" }, outleaves = { "tokenfile.g" },
commands = {
"sh %{ins[1]} < %{ins[2]} > %{outs}",
}
}
normalrule {
name = "symbol2str-c",
ins = {
"./make.tokcase",
"./tokenname.c",
},
outleaves = { "symbol2str.c" },
commands = { commands = {
"sh %{ins[1]} < %{ins[2]} > %{outs}", "sh %{ins[1]} < %{ins[2]} > %{outs}",
} }
@ -64,14 +77,23 @@ normalrule {
llgen { llgen {
name = "llgen", name = "llgen",
srcs = { srcs = {
"+tokenname-g", -- must be first "+tokenfile-g", -- must be first
"./*.g", "./*.g",
}, },
} }
tabgen {
name = "tabgen",
srcs = { "./char.tab" }
}
cprogram { cprogram {
name = "cemcom", name = "cemcom",
srcs = { srcs = {
"./LLlex.c",
"./LLmessage.c",
"./arith.c",
"./blocks.c",
"./ch3.c", "./ch3.c",
"./ch3bin.c", "./ch3bin.c",
"./ch3mon.c", "./ch3mon.c",
@ -111,17 +133,24 @@ cprogram {
"./tokenname.c", "./tokenname.c",
"./type.c", "./type.c",
"./util.c", "./util.c",
"+symbol2str-c",
"+tabgen",
matching(filenamesof("+llgen"), "%.c$"),
}, },
deps = { deps = {
"./*.h",
"+parameters", "+parameters",
"+nextlib", "+nextlib",
"+llgen", "+llgen",
"h+emheaders", "h+emheaders",
"modules/src/alloc+lib", "modules/src/alloc+lib",
"modules/src/em_code+lib_k", "modules/src/em_code+lib_k",
"modules/src/em_mes+lib",
"modules/src/flt_arith+lib", "modules/src/flt_arith+lib",
"modules/src/idf+lib", "modules/src/idf+lib",
"modules/src/input+lib", "modules/src/input+lib",
"modules/src/print+lib",
"modules/src/string+lib",
"modules/src/system+lib", "modules/src/system+lib",
"modules+headers", "modules+headers",
"util/data+em_data", "util/data+em_data",

View file

@ -1,6 +1,4 @@
% %
hdrs = { "./src/system/system.h" },
hdrs = { "./src/system/system.h" },
% CHARACTER CLASSES % CHARACTER CLASSES
% %
% some general settings: % some general settings:

View file

@ -0,0 +1,29 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = {
"./assert/*.c",
},
hdrs = {
},
vars = { plat = plat }
}
ackfile {
name = "crt_"..plat,
srcs = { "./head_ac.e" },
vars = { plat = plat },
deps = {
"h+emheaders"
}
}
installable {
name = "pkg_"..plat,
map = {
["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat,
--["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat,
}
}
end

8
mach/i86/libem/build.lua Normal file
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

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

View file

@ -0,0 +1,7 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
hdrs = { "./assert.h" },
}

View file

@ -0,0 +1,11 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
deps = {
"h+emheaders",
"modules+headers",
"modules/src/em_code+em_code_ek_h",
"util/data+em_data",
}
}

View file

@ -1,6 +1,22 @@
clibrary { clibrary {
name = "lib", name = "lib",
srcs = { "./*.c" }, srcs = {
"./flt_ar2flt.c",
"./flt_div.c",
"./flt_flt2ar.c",
"./flt_modf.c",
"./flt_str2fl.c",
"./flt_cmp.c",
"./flt_add.c",
"./b64_add.c",
"./flt_mul.c",
"./flt_nrm.c",
"./b64_sft.c",
"./flt_umin.c",
"./flt_chk.c",
"./split.c",
"./ucmp.c",
},
hdrs = { "./flt_arith.h" }, hdrs = { "./flt_arith.h" },
deps = { deps = {
"modules+headers" "modules+headers"

View file

@ -25,14 +25,16 @@ normalrule {
} }
} }
clibrary { local function variant(name, cflags)
name = "lib_ev", clibrary {
name = name,
vars = { vars = {
["+cflags"] = { ["+cflags"] = {
"-DPRIVATE=static", "-DPRIVATE=static",
"-DEXPORT=", "-DEXPORT=",
"-DNDEBUG", "-DNDEBUG",
"-DCHECKING" "-DCHECKING",
unpack(cflags)
}, },
}, },
srcs = { srcs = {
@ -53,6 +55,9 @@ clibrary {
"modules/src/system+lib", "modules/src/system+lib",
"util/data+em_data", "util/data+em_data",
} }
} }
end
variant("lib_ev", {})
variant("lib_kv", { "-DCOMPACT" })

View file

@ -13,9 +13,10 @@ definerule("ackfile",
name = e.name, name = e.name,
srcs = e.srcs, srcs = e.srcs,
deps = { deps = {
"lang/cem/cpp.ansi+pkg",
"plat/"..plat.."+tools", "plat/"..plat.."+tools",
"util/ack+pkg", "util/ack+pkg",
"lang/cem/cpp.ansi+pkg", "util/misc+pkg",
e.deps e.deps
}, },
commands = { commands = {
@ -43,7 +44,7 @@ definerule("acklibrary",
_cfile = ackfile, _cfile = ackfile,
commands = { commands = {
"rm -f %{outs[1]}", "rm -f %{outs[1]}",
"ACKDIR=$(INSDIR) $(INSDIR)/bin/aal q %{outs[1]} %{ins}" "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal qc %{outs[1]} %{ins}"
} }
} }
end end
@ -73,6 +74,7 @@ definerule("build_plat_tools",
["$(PLATDEP)/"..e.plat.."/as"] = as, ["$(PLATDEP)/"..e.plat.."/as"] = as,
["$(PLATDEP)/"..e.plat.."/ncg"] = ncg, ["$(PLATDEP)/"..e.plat.."/ncg"] = ncg,
["$(PLATIND)/descr/"..e.plat] = descr, ["$(PLATIND)/descr/"..e.plat] = descr,
"util/opt+pkg",
} }
} }
end end
@ -87,7 +89,10 @@ definerule("build_plat_libs",
return installable { return installable {
name = e.name, name = e.name,
map = { map = {
["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat,
["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat,
["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat,
"lang/cem/libcc.ansi+pkg_"..e.plat,
} }
} }
end end

View file

@ -1,4 +1,5 @@
include("plat/build.lua") include("plat/build.lua")
include("lang/build.lua")
build_plat_tools { build_plat_tools {
name = "tools", name = "tools",

View file

@ -19,10 +19,27 @@ cprogram {
} }
} }
cprogram {
name = "decode",
srcs = { "./convert.c" },
deps = {
"h+emheaders",
"modules+headers",
"modules/src/alloc+lib",
"modules/src/em_code+lib_k",
"modules/src/print+lib",
"modules/src/read_em+lib_kv",
"modules/src/string+lib",
"modules/src/system+lib",
"util/data+em_data",
}
}
installable { installable {
name = "pkg", name = "pkg",
map = { map = {
["$(PLATDEP)/em_encode"] = "+encode", ["$(PLATDEP)/em_encode"] = "+encode",
["$(PLATDEP)/em_decode"] = "+decode",
["$(INSDIR)/bin/esize"] = "+esize", ["$(INSDIR)/bin/esize"] = "+esize",
["$(PLATIND)/man/man1/esize.1"] = "./esize.1", ["$(PLATIND)/man/man1/esize.1"] = "./esize.1",
["$(PLATIND)/man/man6/em_decode.6"] = "./em_decode.6" ["$(PLATIND)/man/man6/em_decode.6"] = "./em_decode.6"

85
util/opt/build.lua Normal file
View file

@ -0,0 +1,85 @@
include("first/yacc.lua")
yacc {
name = "yacc",
srcs = { "./mktab.y" }
}
flex {
name = "flex",
srcs = { "./scan.l" }
}
cprogram {
name = "mktab",
srcs = {
matching(filenamesof("+yacc"), "%.c$"),
matching(filenamesof("+flex"), "%.c$"),
},
deps = {
"+flex",
"+yacc",
"util/data+em_data",
}
}
normalrule {
name = "pattern_c",
ins = {
"+mktab",
"./patterns",
"lang/cem/cpp.ansi+cpp"
},
outleaves = { "pattern.c" },
commands = {
"%{ins[3]} < %{ins[2]} | %{ins[1]} > %{outs}"
}
}
normalrule {
name = "pop_push_c",
ins = {
"./pop_push.awk",
"h/em_table"
},
outleaves = { "pop_push.c" },
commands = {
"awk -f %{ins[1]} < %{ins[2]} > %{outs}"
}
}
local function variant(name, cflags)
cprogram {
name = name,
srcs = {
"+pattern_c",
"+pop_push_c",
"./*.c",
},
deps = {
"./*.h",
"h+emheaders",
"modules/src/alloc+lib",
"modules/src/print+lib",
"modules/src/string+lib",
"modules/src/system+lib",
"util/data+em_data",
},
vars = {
["+cflags"] = cflags
}
}
end
variant("em_opt", {})
variant("em_opt2", {"-DGLOBAL_OPT"})
installable {
name = "pkg",
map = {
["$(PLATDEP)/em_opt"] = "+em_opt",
["$(PLATDEP)/em_opt2"] = "+em_opt2",
["$(INSDIR)/share/man/man6/em_opt.6"] = "./em_opt.6",
}
}