From 22d46ce57c765e352182984b2f55a460fd5a3034 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Thu, 7 Aug 2014 18:07:32 -0400 Subject: [PATCH] More modernizing of VC 201x for extensibility --- src/actions/vstudio/vs2010_vcxproj.lua | 111 +++++++++++------- src/actions/vstudio/vs2010_vcxproj_user.lua | 58 ++++++--- .../vstudio/vc2010/test_debug_settings.lua | 16 +-- .../vstudio/vc2010/test_excluded_configs.lua | 2 +- tests/actions/vstudio/vc2010/test_link.lua | 2 +- 5 files changed, 119 insertions(+), 70 deletions(-) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index d9c5181f..7c4f1876 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -247,7 +247,7 @@ return { m.clCompile, m.resourceCompile, - m.link, + m.linker, m.manifest, m.buildEvents, m.imageXex, @@ -347,66 +347,87 @@ -- Write out the linker tool block. -- - m.elements.link = function(cfg, explicit) + m.elements.linker = function(cfg, explicit) return { - m.subSystem, - m.generateDebugInformation, - m.optimizeReferences, - m.linkDynamic, + m.link, + m.lib, + m.linkLibraryDependencies, } end - m.elements.linkDynamic = function(cfg, explicit) - return { - m.additionalDependencies, - m.additionalLibraryDirectories, - m.importLibrary, - m.entryPointSymbol, - m.generateMapFile, - m.moduleDefinitionFile, - m.treatLinkerWarningAsErrors, - m.additionalLinkOptions, - } - end - - m.elements.linkStatic = function(cfg, explicit) - return { - m.treatLinkerWarningAsErrors, - m.additionalLinkOptions, - } - end - - function m.link(cfg) - _p(2,'') + function m.linker(cfg) local explicit = vstudio.needsExplicitLink(cfg) - p.callArray(m.elements.link, cfg, explicit) - _p(2,'') - - if cfg.kind == premake.STATICLIB then - m.linkStatic(cfg, explicit) - end - - m.linkLibraryDependencies(cfg, explicit) + p.callArray(m.elements.linker, cfg, explicit) end - function m.linkDynamic(cfg, explicit) - if cfg.kind ~= premake.STATICLIB then - p.callArray(m.elements.linkDynamic, cfg, explicit) + + + m.elements.link = function(cfg, explicit) + if cfg.kind == p.STATICLIB then + return { + m.subSystem, + m.generateDebugInformation, + m.optimizeReferences, + } + else + return { + m.subSystem, + m.generateDebugInformation, + m.optimizeReferences, + m.additionalDependencies, + m.additionalLibraryDirectories, + m.importLibrary, + m.entryPointSymbol, + m.generateMapFile, + m.moduleDefinitionFile, + m.treatLinkerWarningAsErrors, + m.additionalLinkOptions, + } end end - function m.linkStatic(cfg, explicit) + function m.link(cfg, explicit) local contents = p.capture(function () - p.callArray(m.elements.linkStatic, cfg, explicit) + p.push() + p.callArray(m.elements.link, cfg, explicit) + p.pop() end) if #contents > 0 then - _p(2,'') - _p("%s", contents) - _p(2,'') + p.push('') + p.outln(contents) + p.pop('') end end + + m.elements.lib = function(cfg, explicit) + if cfg.kind == p.STATICLIB then + return { + m.treatLinkerWarningAsErrors, + m.additionalLinkOptions, + } + else + return { + } + end + end + + function m.lib(cfg, explicit) + local contents = p.capture(function () + p.push() + p.callArray(m.elements.lib, cfg, explicit) + p.pop() + end) + if #contents > 0 then + p.push('') + p.outln(contents) + p.pop('') + end + end + + + -- -- Write the manifest section. -- @@ -832,7 +853,7 @@ if #links > 0 then links = path.translate(table.concat(links, ";")) - _x(3,'%s;%%(AdditionalDependencies)', links) + p.x('%s;%%(AdditionalDependencies)', links) end end diff --git a/src/actions/vstudio/vs2010_vcxproj_user.lua b/src/actions/vstudio/vs2010_vcxproj_user.lua index da33e530..8bebef61 100755 --- a/src/actions/vstudio/vs2010_vcxproj_user.lua +++ b/src/actions/vstudio/vs2010_vcxproj_user.lua @@ -18,56 +18,84 @@ vc2010.xmlDeclaration() vc2010.project() for cfg in project.eachconfig(prj) do - _p(1,'', vc2010.condition(cfg)) - vc2010.debugsettings(cfg) - _p(1,'') + p.push('', vc2010.condition(cfg)) + vc2010.debugSettings(cfg) + p.pop('') end _p('') end - function vc2010.debugsettings(cfg) - vc2010.localDebuggerCommand(cfg) - vc2010.localDebuggerWorkingDirectory(cfg) - vc2010.debuggerFlavor(cfg) - vc2010.localDebuggerCommandArguments(cfg) - vc2010.localDebuggerEnvironment(cfg) + + + vc2010.elements.debugSettings = function(cfg) + return { + vc2010.localDebuggerCommand, + vc2010.localDebuggerWorkingDirectory, + vc2010.debuggerFlavor, + vc2010.localDebuggerCommandArguments, + vc2010.localDebuggerEnvironment, + vc2010.localDebuggerMergeEnvironment, + } end + function vc2010.debugSettings(cfg) + p.callArray(vc2010.elements.debugSettings, cfg) + end + + + function vc2010.debuggerFlavor(cfg) if cfg.debugdir or cfg.debugcommand then - _p(2,'WindowsLocalDebugger') + p.w('WindowsLocalDebugger') end end + + function vc2010.localDebuggerCommand(cfg) if cfg.debugcommand then local dir = project.getrelative(cfg.project, cfg.debugcommand) - _p(2,'%s', path.translate(dir)) + p.w('%s', path.translate(dir)) end end + + function vc2010.localDebuggerCommandArguments(cfg) if #cfg.debugargs > 0 then - _x(2,'%s', table.concat(cfg.debugargs, " ")) + p.x('%s', table.concat(cfg.debugargs, " ")) end end + + function vc2010.localDebuggerWorkingDirectory(cfg) if cfg.debugdir then local dir = project.getrelative(cfg.project, cfg.debugdir) - _x(2,'%s', path.translate(dir)) + p.x('%s', path.translate(dir)) end end + + function vc2010.localDebuggerEnvironment(cfg) if #cfg.debugenvs > 0 then local envs = table.concat(cfg.debugenvs, "\n") if cfg.flags.DebugEnvsInherit then envs = envs .. "\n$(LocalDebuggerEnvironment)" end - _p(2,'%s', envs) + p.w('%s', envs) + if cfg.flags.DebugEnvsDontMerge then - _p(2,'false') + p.w(2,'false') end end end + + + + function vc2010.localDebuggerMergeEnvironment(cfg) + if #cfg.debugenvs > 0 and cfg.flags.DebugEnvsDontMerge then + p.w(2,'false') + end + end diff --git a/tests/actions/vstudio/vc2010/test_debug_settings.lua b/tests/actions/vstudio/vc2010/test_debug_settings.lua index 1ac40dc5..d54dfece 100755 --- a/tests/actions/vstudio/vc2010/test_debug_settings.lua +++ b/tests/actions/vstudio/vc2010/test_debug_settings.lua @@ -21,7 +21,7 @@ local function prepare() local cfg = test.getconfig(prj, "Debug") - vc2010.debugsettings(cfg) + vc2010.debugSettings(cfg) end @@ -42,8 +42,8 @@ debugcommand "bin/emulator.exe" prepare() test.capture [[ - bin\emulator.exe - WindowsLocalDebugger +bin\emulator.exe +WindowsLocalDebugger ]] end @@ -56,8 +56,8 @@ debugdir "bin/debug" prepare() test.capture [[ - bin\debug - WindowsLocalDebugger +bin\debug +WindowsLocalDebugger ]] end @@ -69,7 +69,7 @@ debugargs { "arg1", "arg2" } prepare() test.capture [[ - arg1 arg2 +arg1 arg2 ]] end @@ -81,7 +81,7 @@ debugenvs { "key=value" } prepare() test.capture [[ - key=value +key=value ]] end @@ -93,7 +93,7 @@ debugenvs { "key=value", "foo=bar" } prepare() test.capture [[ - key=value +key=value foo=bar ]] end diff --git a/tests/actions/vstudio/vc2010/test_excluded_configs.lua b/tests/actions/vstudio/vc2010/test_excluded_configs.lua index 556c5a0c..dcbd88b1 100644 --- a/tests/actions/vstudio/vc2010/test_excluded_configs.lua +++ b/tests/actions/vstudio/vc2010/test_excluded_configs.lua @@ -36,7 +36,7 @@ local function prepare(platform) local cfg = test.getconfig(prj, "Debug", platform) - vc2010.link(cfg) + vc2010.linker(cfg) end diff --git a/tests/actions/vstudio/vc2010/test_link.lua b/tests/actions/vstudio/vc2010/test_link.lua index 049b93a1..cbb2a0e1 100644 --- a/tests/actions/vstudio/vc2010/test_link.lua +++ b/tests/actions/vstudio/vc2010/test_link.lua @@ -23,7 +23,7 @@ local function prepare(platform) local cfg = test.getconfig(prj, "Debug", platform) - vc2010.link(cfg) + vc2010.linker(cfg) end