Custom Rule fixes.

This commit is contained in:
Tom van Dijck 2016-08-02 10:19:56 -07:00
parent 7b712d7ce3
commit 8b7b4c1139
3 changed files with 56 additions and 37 deletions

View File

@ -31,6 +31,7 @@
["file.basename"] = { absolute = false, token = "%(Filename)" },
["file.abspath"] = { absolute = true, token = "%(FullPath)" },
["file.relpath"] = { absolute = false, token = "%(Identity)" },
["file.path"] = { absolute = true, token = "%(RelativeDir)" },
}

View File

@ -84,7 +84,6 @@
return {
m.propertyDefaults,
m.commandLineTemplates,
m.outputs,
m.executionDescription,
m.additionalDependencies,
}
@ -144,18 +143,18 @@
function m.commandLineTemplates(r)
if #r.buildcommands then
-- create shadow context.
local env = p.rule.createEnvironment(r, "[%s]")
local ctx = p.context.extent(r, env)
-- create shadow context.
local env = p.rule.createEnvironment(r, "[%s]")
local ctx = p.context.extent(r, env)
-- now use the shadow context to detoken.
local buildcommands = ctx.buildcommands
-- now use the shadow context to detoken.
local cmds = os.translateCommands(ctx.buildcommands, p.WINDOWS)
-- write out the result.
-- write out the result.
if buildcommands and #buildcommands > 0 then
local cmds = os.translateCommands(buildcommands, p.WINDOWS)
cmds = table.concat(cmds, p.eol())
p.x('<CommandLineTemplate>%s</CommandLineTemplate>', cmds)
p.x('<CommandLineTemplate>@echo off\n%s</CommandLineTemplate>', cmds)
end
end
@ -170,28 +169,16 @@
function m.executionDescription(r)
if r.buildmessage then
-- create shadow context.
local env = p.rule.createEnvironment(r, "[%s]")
local ctx = p.context.extent(r, env)
-- create shadow context.
local env = p.rule.createEnvironment(r, "%%(%s)")
local ctx = p.context.extent(r, env)
-- write out the result.
p.x('<ExecutionDescription>%s</ExecutionDescription>', ctx.buildmessage)
-- now use the shadow context to detoken.
local buildmessage = ctx.buildmessage
-- write out the result.
if buildmessage and #buildmessage > 0 then
p.x('<ExecutionDescription>%s</ExecutionDescription>', buildmessage)
end
end
function m.outputs(r)
if #r.buildoutputs then
-- create shadow context.
local pathVars = p.rule.createPathVars(r, "%%(%s)")
local ctx = p.context.extent(r, { pathVars = pathVars })
-- now use the shadow context to detoken.
local outputs = table.concat(ctx.buildoutputs, ";")
-- write out the result.
p.x('<Outputs>%s</Outputs>', path.translate(outputs))
end
end

View File

@ -20,6 +20,7 @@
return {
p.vstudio.projectElement,
m.availableItemGroup,
m.computedProperties,
m.computeInputsGroup,
m.usingTask,
m.ruleTarget,
@ -54,6 +55,29 @@
end
---
-- Generate the computed outputs property.
---
function m.computedProperties(r)
-- create shadow context.
local pathVars = p.rule.createPathVars(r, "%%(%s)")
local ctx = p.context.extent(r, { pathVars = pathVars })
-- now use the shadow context to detoken.
local buildoutputs = ctx.buildoutputs
-- write the output.
if buildoutputs and #buildoutputs > 0 then
local outputs = table.concat(buildoutputs, ";")
p.push('<ItemDefinitionGroup>')
p.push('<%s>', r.name)
p.x('<Outputs>%s</Outputs>', path.translate(outputs))
p.pop('</%s>', r.name)
p.pop('</ItemDefinitionGroup>')
end
end
---
-- Generate the computed input targets group.
@ -277,12 +301,19 @@
function m.linkLib(r)
-- create shadow context.
local pathVars = p.rule.createPathVars(r, "%%(%s)")
local ctx = p.context.extent(r, { pathVars = pathVars })
-- now use the shadow context to detoken.
local buildoutputs = ctx.buildoutputs
local linkable, compileable
for i = 1, #r.buildoutputs do
if (path.islinkable(r.buildoutputs[i])) then
for i = 1, #buildoutputs do
if (path.islinkable(buildoutputs[i])) then
linkable = true
end
if (path.iscppfile(r.buildoutputs[i])) then
if (path.iscppfile(buildoutputs[i])) then
compileable = true
end
end
@ -314,7 +345,7 @@
p.w('<Message')
p.w(' Importance="High"')
p.w(' Text="%%(%s.ExecutionDescription)" />', r.name)
end
end
@ -326,13 +357,13 @@
function m.properties(r)
function m.properties(r)
local defs = r.propertydefinition
for i = 1, #defs do
local name = defs[i].name
p.w('%s="%%(%s.%s)"', name, r.name, name)
end
end
end