Filename variables now get passed into ackbuilder on the command line.

This commit is contained in:
David Given 2016-08-15 00:47:08 +02:00
parent 420c47c386
commit 46bd70380c
2 changed files with 48 additions and 28 deletions

View file

@ -55,27 +55,21 @@ NINJA := $(shell which ninja)
ifneq ($(findstring +, $(MAKECMDGOALS)),)
ifneq ($(NINJA),)
$(MAKECMDGOALS): $(BUILDDIR)/build.ninja $(BUILDDIR)/rules.ninja
$(MAKECMDGOALS): $(BUILDDIR)/build.ninja
@ninja -f $(BUILDDIR)/build.ninja $(MAKECMDGOALS)
$(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" >> $@
else
$(MAKECMDGOALS): $(BUILDDIR)/rules.mk
+@make -r -f $(BUILDDIR)/rules.mk $@ \
$(MAKEFLAGS) \
$(MAKEFLAGS)
endif
endif
$(BUILDDIR)/build.ninja: first/ackbuilder.lua Makefile $(BUILD_FILES)
@mkdir -p $(BUILDDIR)
@lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \
@ -84,18 +78,22 @@ $(MAKECMDGOALS): $(BUILDDIR)/rules.mk
PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \
AR=$(AR) \
CC=$(CC)
CC=$(CC) \
> $(BUILDDIR)/build.ninja
endif
endif
$(BUILDDIR)/rules.ninja: first/ackbuilder.lua $(BUILD_FILES)
$(BUILDDIR)/rules.mk: first/ackbuilder.lua Makefile $(BUILD_FILES)
@mkdir -p $(BUILDDIR)
@lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja
$(BUILDDIR)/rules.mk: first/ackbuilder.lua $(BUILD_FILES)
@mkdir -p $(BUILDDIR)
@lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk
@lua5.1 first/ackbuilder.lua first/build.lua build.lua --make \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \
INCDIR=$(INCDIR) \
INSDIR=$(INSDIR) \
PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \
AR=$(AR) \
CC=$(CC) \
> $(BUILDDIR)/rules.mk
clean:
@rm -rf $(BUILDDIR)

View file

@ -602,6 +602,12 @@ end
local function install_make_emitter()
emit("hide = @\n")
function emitter:var(name, value)
-- Don't let emit insert spaces.
emit(name.."="..value.."\n")
end
function emitter:rule(name, ins, outs)
emit(".INTERMEDIATE:", name, "\n")
for i = 1, #ins do
@ -656,6 +662,11 @@ local function install_ninja_emitter()
)
end
function emitter:var(name, value)
-- Don't let emit insert spaces.
emit(name.."="..unmake(value).."\n")
end
function emitter:rule(name, ins, outs)
if (#outs == 0) then
emit("build", name, ": phony", unmake(ins), "\n")
@ -853,24 +864,35 @@ do
{
["make"] = function()
emitter_type = install_make_emitter
return 1
return 0
end,
["ninja"] = function()
emitter_type = install_ninja_emitter
return 1
return 0
end,
[" unrecognised"] = function(arg)
error(string.format("unrecognised argument '%s'", arg))
end,
[" files"] = function(files)
emitter_type()
for _, f in ipairs(files) do
local _, _, name, value = f:find("^([%w_]+)=(.*)$")
if name then
emitter:var(name, value)
end
end
for _, f in ipairs(files) do
if not f:find("=") then
loadbuildfile(f)
end
end
end
},
{...}
)