From 6fbc7ca3d79d161f6e410e55902456a3f5e1801e Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 23 Sep 2014 15:19:57 -0400 Subject: [PATCH] Support linker inputs in generated rule files --- src/actions/vstudio/vs2010_rules_targets.lua | 58 ++++++++++++++------ src/base/path.lua | 10 ++++ 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/actions/vstudio/vs2010_rules_targets.lua b/src/actions/vstudio/vs2010_rules_targets.lua index 5501a34d..916ad2b0 100644 --- a/src/actions/vstudio/vs2010_rules_targets.lua +++ b/src/actions/vstudio/vs2010_rules_targets.lua @@ -24,7 +24,7 @@ m.computeInputsGroup, m.usingTask, m.ruleTarget, - m.computeOutput, + m.computeOutputTarget, } end @@ -174,18 +174,27 @@ -- Generate the rule's computed output element. --- - m.elements.computeOutput = function(r) + m.elements.computeOutputItems = function(r) + return { + m.outputs, + m.linkLib, + } + end + + m.elements.computeOutputTarget = function(r) return { - m.dirsToMake, m.makeDir, } end - function m.computeOutput(r) + function m.computeOutputTarget(r) p.push('', r.name) - p.callArray(m.elements.computeOutput, r) + p.push('') + p.callArray(m.elements.computeOutputItems, r) + p.pop('') + p.callArray(m.elements.computeOutputTarget, r) p.pop('') end @@ -251,24 +260,33 @@ - function m.dirsToMake(r) - p.push('') - p.w('<%sDirsToMake', r.name) - p.w(' Condition="\'@(%s)\' != \'\' and \'%%(%s.ExcludedFromBuild)\' != \'true\'"', r.name, r.name) - p.w(' Include="%%(%s.Outputs)" />', r.name) - p.pop('') - end - - - function m.inputs(r) p.w('Inputs="%%(%s.Identity)"', r.name) end + function m.linkLib(r) + local linkable + for i = 1, #r.buildoutputs do + if (path.islinkable(r.buildoutputs[i])) then + linkable = true + end + end + if linkable then + for i, el in pairs { 'Link', 'Lib', 'ImpLib' } do + p.push('<%s', el) + p.w('Include="%%(%sOutputs.Identity)"', r.name) + p.w('Condition="\'%%(Extension)\'==\'.obj\' or \'%%(Extension)\'==\'.res\' or \'%%(Extension)\'==\'.rsc\' or \'%%(Extension)\'==\'.lib\'" />') + p.pop() + end + end + end + + + function m.makeDir(r) - p.w('', r.name) + p.w('', r.name) end @@ -281,6 +299,14 @@ + 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) + end + + + function m.properties(r) local defs = r.propertyDefinition for i = 1, #defs do diff --git a/src/base/path.lua b/src/base/path.lua index 3200fbcc..5b1f0a53 100644 --- a/src/base/path.lua +++ b/src/base/path.lua @@ -169,6 +169,16 @@ end +--- +-- Is this a type of file that can be linked? +--- + + function path.islinkable(fname) + return path.hasextension(fname, { ".o", ".obj", ".a", ".lib", ".so" }) + end + + + -- -- Returns true if the filename represents an object file. --