Merge pull request #507 from Blizzard/rule-cpp-output

Allow rules to generate code that subsequently gets compiled.
This commit is contained in:
Jason Perkins 2016-06-10 13:58:38 -04:00 committed by GitHub
commit a4a8ee19f8
2 changed files with 23 additions and 4 deletions

View File

@ -61,6 +61,7 @@
m.elements.computeInputsGroup = function(r)
return {
m.computeCompileInputsTargets,
m.computeLinkInputsTargets,
m.computeLibInputsTargets,
}
@ -254,6 +255,15 @@
function m.computeCompileInputsTargets(r)
p.push('<ComputeCompileInputsTargets>')
p.w('$(ComputeCompileInputsTargets);')
p.w('Compute%sOutput;', r.name)
p.pop('</ComputeCompileInputsTargets>')
end
function m.dependsOnTargets(r)
p.w('DependsOnTargets="$(%sDependsOn);Compute%sOutput"', r.name, r.name)
end
@ -267,11 +277,14 @@
function m.linkLib(r)
local linkable
local linkable, compileable
for i = 1, #r.buildoutputs do
if (path.islinkable(r.buildoutputs[i])) then
linkable = true
end
if (path.iscppfile(r.buildoutputs[i])) then
compileable = true
end
end
if linkable then
for i, el in pairs { 'Link', 'Lib', 'ImpLib' } do
@ -281,6 +294,12 @@
p.pop()
end
end
if compileable then
p.push('<ClCompile', el)
p.w('Include="%%(%sOutputs.Identity)"', r.name)
p.w('Condition="\'%%(Extension)\'==\'.cc\' or \'%%(Extension)\'==\'.cpp\' or \'%%(Extension)\'==\'.cxx\' or \'%%(Extension)\'==\'.c\'" />')
p.pop()
end
end
@ -302,7 +321,7 @@
function m.outputs(r)
p.w('<%sOutputs', r.name)
p.w(' Condition="\'@(%s)\' != \'\' and \'%%(%s.ExcludedFromBuild)\' != \'true\'"', r.name, r.name)
p.w(' Include="%%(%s.Outputs)" />', r.name)
p.w(' Include="%%(%s.Outputs)" />', r.name)
end

View File

@ -29,8 +29,8 @@ int do_isabsolute(const char* path)
if (path[0] == '"')
return do_isabsolute(path + 1);
// $(foo)
if (path[0] == '$' && path[1] == '(')
// $(foo) and %(foo)
if ((path[0] == '%' || path[0] == '$') && path[1] == '(')
{
path += 2;
closing = strchr(path, ')');