From 1fdc69fb97e53a92204771742ec63d67b5b35d33 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 19 Jul 2016 23:43:14 +0200 Subject: [PATCH] cemcom.ansi now builds. --- Makefile | 22 +++---- h/build.lua | 20 +++---- lang/cem/cemcom.ansi/build.lua | 3 + modules/build.lua | 104 ++++++++++++++++++++++++++++++++- util/LLgen/build.lua | 59 ------------------- util/data/build.lua | 36 ++++++++++++ 6 files changed, 161 insertions(+), 83 deletions(-) create mode 100644 util/data/build.lua diff --git a/Makefile b/Makefile index 7cc12c271..a8381b487 100644 --- a/Makefile +++ b/Makefile @@ -60,21 +60,21 @@ $(MAKECMDGOALS): $(BUILDDIR)/build.ninja $(BUILDDIR)/rules.ninja $(BUILDDIR)/build.ninja: Makefile @mkdir -p $(BUILDDIR) - echo "OBJDIR = $(OBJDIR)" > $@ - echo "BINDIR = $(BINDIR)" >> $@ - echo "LIBDIR = $(LIBDIR)" >> $@ - echo "INCDIR = $(INCDIR)" >> $@ - echo "INSDIR = $(INSDIR)" >> $@ - echo "PLATIND = $(PLATIND)" >> $@ - echo "PLATDEP = $(PLATDEP)" >> $@ - echo "AR = $(AR)" >> $@ - echo "CC = $(CC)" >> $@ - echo "subninja $(BUILDDIR)/rules.ninja" >> $@ + @echo "OBJDIR = $(OBJDIR)" > $@ + @echo "BINDIR = $(BINDIR)" >> $@ + @echo "LIBDIR = $(LIBDIR)" >> $@ + @echo "INCDIR = $(INCDIR)" >> $@ + @echo "INSDIR = $(INSDIR)" >> $@ + @echo "PLATIND = $(PLATIND)" >> $@ + @echo "PLATDEP = $(PLATDEP)" >> $@ + @echo "AR = $(AR)" >> $@ + @echo "CC = $(CC)" >> $@ + @echo "subninja $(BUILDDIR)/rules.ninja" >> $@ 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/h/build.lua b/h/build.lua index d1900ac5f..7fd9d6728 100644 --- a/h/build.lua +++ b/h/build.lua @@ -9,17 +9,6 @@ normalrule { } } -bundle { - name = "emheaders", - srcs = { - "./em_*.h", - "./arch.h", - "./out.h", - "./ranlib.h", - "+em_path", - } -} - normalrule { name = "local", ins = {}, @@ -32,3 +21,12 @@ normalrule { } } +clibrary { + name = "emheaders", + hdrs = { + "./*.h", + "+em_path", + "+local", + } +} + diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index 5f8476ad3..e330eded9 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -119,10 +119,13 @@ cprogram { "+llgen", "h+emheaders", "modules+alloc", + "modules+em_code_k", "modules+flt_arith", "modules+idf", + "modules+input", "modules+headers", "modules+system", + "util/data+libem", }, } diff --git a/modules/build.lua b/modules/build.lua index 18a380f20..cbf72d0ba 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -1,6 +1,8 @@ -bundle { +clibrary { name = "headers", - srcs = { "./h/*.h" } + hdrs = { + "./h/*.h" + } } clibrary { @@ -35,6 +37,14 @@ clibrary { hdrs = { "./src/idf/idf_pkg.*" }, } +clibrary { + name = "input", + srcs = { + "./src/input/*.c" + }, + hdrs = { "./src/input/inp_pkg.*" } +} + clibrary { name = "string", srcs = { "./src/string/*.c" }, @@ -51,3 +61,93 @@ clibrary { }, } +normalrule { + name = "em_code_ek_h", + ins = { + "./src/em_code/make.em.gen", + "./src/em_code/em.nogen", + "h/em_table" + }, + outleaves = { "em_codeEK.h" }, + commands = { + "%{ins[1]} %{ins[3]} > %{outs}", + "cat %{ins[2]} >> %{outs}" + } +} + +for _, variant in ipairs { + { "e", "-DREADABLE_EM" }, + { "k", "" } +} do + local code = variant[1] + local cflags = variant[2] + + clibrary { + name = "em_code_"..code, + srcs = { + "./src/em_code/C_out.c", + "./src/em_code/bhcst.c", + "./src/em_code/bhdlb.c", + "./src/em_code/bhdnam.c", + "./src/em_code/bhfcon.c", + "./src/em_code/bhicon.c", + "./src/em_code/bhilb.c", + "./src/em_code/bhpnam.c", + "./src/em_code/bhucon.c", + "./src/em_code/crcst.c", + "./src/em_code/crdlb.c", + "./src/em_code/crdnam.c", + "./src/em_code/crilb.c", + "./src/em_code/crpnam.c", + "./src/em_code/crscon.c", + "./src/em_code/crxcon.c", + "./src/em_code/cst.c", + "./src/em_code/dfdlb.c", + "./src/em_code/dfdnam.c", + "./src/em_code/dfilb.c", + "./src/em_code/dlb.c", + "./src/em_code/dnam.c", + "./src/em_code/em.c", + "./src/em_code/end.c", + "./src/em_code/endarg.c", + "./src/em_code/exc.c", + "./src/em_code/failed.c", + "./src/em_code/fcon.c", + "./src/em_code/getid.c", + "./src/em_code/icon.c", + "./src/em_code/ilb.c", + "./src/em_code/insert.c", + "./src/em_code/internerr.c", + "./src/em_code/msend.c", + "./src/em_code/msstart.c", + "./src/em_code/op.c", + "./src/em_code/opcst.c", + "./src/em_code/opdlb.c", + "./src/em_code/opdnam.c", + "./src/em_code/opilb.c", + "./src/em_code/opnarg.c", + "./src/em_code/oppnam.c", + "./src/em_code/pnam.c", + "./src/em_code/pro.c", + "./src/em_code/pronarg.c", + "./src/em_code/psdlb.c", + "./src/em_code/psdnam.c", + "./src/em_code/pspnam.c", + "./src/em_code/scon.c", + "./src/em_code/ucon.c", + }, + hdrs = { + "+em_code_ek_h" + }, + deps = { + "+alloc", + "+em_code_ek_h", + "+headers", + "+system", + "h+emheaders", + "h+local", + "util/data+libem", + }, + cflags = { cflags } + } +end diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua index ff0b7f638..fd60daa59 100644 --- a/util/LLgen/build.lua +++ b/util/LLgen/build.lua @@ -36,62 +36,3 @@ definerule("llgen", } end ) - ---[[ -D := util/LLgen - -# Rule to build LLgen. - -define build-llgen-impl - $(call reset) - $(eval cflags += -DNON_CORRECTING -DLIBDIR=\"$(abspath $D/lib)\") - $(call cfile, $D/src/main.c) - $(call cfile, $D/src/gencode.c) - $(call cfile, $D/src/compute.c) - $(call cfile, $D/src/check.c) - $(call cfile, $D/src/reach.c) - $(call cfile, $D/src/global.c) - $(call cfile, $D/src/name.c) - $(call cfile, $D/src/sets.c) - $(call cfile, $D/src/alloc.c) - $(call cfile, $D/src/machdep.c) - $(call cfile, $D/src/cclass.c) - $(call cfile, $D/src/savegram.c) - - # These use pre-LLgen'd version of the files. If LLgen.g gets updated, - # they need rebuilding. Use the bootstrap script to do this. - - $(call cfile, $D/src/LLgen.c) - $(call cfile, $D/src/Lpars.c) - $(call cfile, $D/src/tokens.c) - - $(call cprogram, $(BINDIR)/LLgen) - LLGEN := $o -endef - -$(eval $(build-llgen-impl)) - -# Rule to invoke to *use* LLgen. -# -# $1: directory to put output files -# $2: input files -# -# Output files are compiled via cfile and queued. - -define llgen-impl -$(eval o := $1/Lpars.c $(patsubst %.g, $(strip $1)/%.c, $(notdir $2))) -$(eval CLEANABLES += $o $1/Lpars.h) - -$o: $1/Lpars.h -$1/Lpars.h: $2 $(LLGEN) - @echo LLGEN $1/Lpars.c - @mkdir -p $1 - $(hide) $(RM) $o $1/Lpars.h - $(hide) cd $1 && $(LLGEN) $(abspath $2) - -$(foreach f,$o,$(call cfile,$f)) - -endef - -llgen = $(eval $(call llgen-impl,$1,$2)) ---]] diff --git a/util/data/build.lua b/util/data/build.lua new file mode 100644 index 000000000..7ed75e280 --- /dev/null +++ b/util/data/build.lua @@ -0,0 +1,36 @@ +normalrule { + name = "generated", + ins = { + "./new_table", + "h/em_table", -- relative to root, which is a bit evil + }, + outleaves = { + "em_flag.c", + "em_pseu.c", + "em_mnem.c", + "em_spec.h", + "em_pseu.h", + "em_mnem.h", + }, + deps = { + "h+emheaders" + }, + commands = { + "%{ins[1]} %{ins[2]} %{dir} %{dir}" + } +} + +clibrary { + name = "libem", + srcs = { + "./em_ptyp.c", + "+generated", -- so we build the C files + }, + hdrs = { + "+generated" -- so we export the H files + }, + deps = { + "+generated", -- so we can see the H files + "h+emheaders" + } +}