Fix per-file custom build commands in C++ gmake action

This commit is contained in:
Aleksi Juvani 2014-09-27 15:30:42 +00:00
parent ee305d4ff1
commit 7640661f4b

View File

@ -172,10 +172,10 @@
function make.cppObjects(prj)
-- create lists for intermediate files, at the project level and
-- for each configuration
local root = { objects={}, resources={} }
local root = { objects={}, resources={}, customfiles={} }
local configs = {}
for cfg in project.eachconfig(prj) do
configs[cfg] = { objects={}, resources={} }
configs[cfg] = { objects={}, resources={}, customfiles={} }
end
-- now walk the list of files in the project
@ -235,6 +235,8 @@
local output = project.getrelative(prj, filecfg.buildoutputs[1])
if path.isobjectfile(output) then
table.insert(configs[cfg].objects, output)
else
table.insert(configs[cfg].customfiles, output)
end
end
end
@ -254,11 +256,12 @@
listobjects('OBJECTS :=', root.objects, 'o')
listobjects('RESOURCES :=', root.resources, 'res')
listobjects('CUSTOMFILES :=', root.customfiles)
-- ...then individual configurations, as needed
for cfg in project.eachconfig(prj) do
local files = configs[cfg]
if #files.objects > 0 or #files.resources > 0 then
if #files.objects > 0 or #files.resources > 0 or #files.customfiles > 0 then
_x('ifeq ($(config),%s)', cfg.shortname)
if #files.objects > 0 then
listobjects(' OBJECTS +=', files.objects)
@ -266,6 +269,9 @@
if #files.resources > 0 then
listobjects(' RESOURCES +=', files.resources)
end
if #files.customfiles > 0 then
listobjects(' CUSTOMFILES +=', files.customfiles)
end
_p('endif')
_p('')
end
@ -332,7 +338,7 @@
function make.cppTargetRules(prj)
_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)')
_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES) ${CUSTOMFILES}')
_p('\t@echo Linking %s', prj.name)
_p('\t$(SILENT) $(LINKCMD)')
_p('\t$(POSTBUILDCMDS)')