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

View file

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