From 309a76cb8a25a79ea194472ed262bd4d5aecc54d Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Sun, 12 Feb 2012 16:08:27 -0500 Subject: [PATCH] Improved extensibility of VC2010 generator --- src/actions/vstudio/_vstudio.lua | 16 ++--- src/actions/vstudio/vs2010_vcxproj.lua | 59 ++++++++++++------- .../vstudio/vc2010/test_compile_settings.lua | 2 +- tests/actions/vstudio/vc2010/test_link.lua | 2 +- 4 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index c6d4f8e4..59e4beda 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -92,14 +92,16 @@ -- Studio compatible identifier. -- + vstudio.architectures = + { + x64 = "x64", + xbox360 = "Xbox 360", + } + function vstudio.architecture(cfg) - if cfg.system == premake.XBOX360 then - return "Xbox 360" - end - if cfg.architecture == "x32" then - return "Win32" - end - return cfg.architecture or "Win32" + return vstudio.architectures[cfg.architecture] or + vstudio.architectures[cfg.system] or + "Win32" end diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 5ff6979b..2d1dccd0 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -45,9 +45,9 @@ for cfg in project.eachconfig(prj) do _p(1,'', vc2010.condition(cfg)) - vc2010.clcompile_ng(cfg) + vc2010.clCompile(cfg) vc2010.resourceCompile(cfg) - vc2010.link_ng(cfg) + vc2010.link(cfg) vc2010.buildEvents(cfg) _p(1,'') end @@ -191,7 +191,7 @@ -- Write the the compiler settings block. -- - function vc2010.clcompile_ng(cfg) + function vc2010.clCompile(cfg) _p(2,'') if not cfg.flags.NoPCH and cfg.pchheader then @@ -303,7 +303,7 @@ -- Write out the linker tool block. -- - function vc2010.link_ng(cfg) + function vc2010.link(cfg) _p(2,'') local subsystem = iif(cfg.kind == premake.CONSOLEAPP, "Console", "Windows") @@ -328,17 +328,8 @@ end function vc2010.link_dynamic(cfg) - local links = config.getlinks(cfg, "system", "fullpath") - if #links > 0 then - links = path.translate(table.concat(links, ";")) - _x(3,'%s;%%(AdditionalDependencies)', links) - end - - if #cfg.libdirs > 0 then - local dirs = project.getrelative(cfg.project, cfg.libdirs) - dirs = path.translate(table.concat(dirs, ";")) - _x(3,'%s;%%(AdditionalLibraryDirectories)', dirs) - end + vc2010.additionalDependencies(cfg) + vc2010.additionalLibraryDirectories(cfg) if vc2010.config_type(cfg) == "Application" and not cfg.flags.WinMain and not cfg.flags.Managed then _p(3,'mainCRTStartup') @@ -463,6 +454,19 @@ end +-- +-- Write out the linker's additionalDependencies element. +-- + + function vc2010.additionalDependencies(cfg) + local links = config.getlinks(cfg, "system", "fullpath") + if #links > 0 then + links = path.translate(table.concat(links, ";")) + _x(3,'%s;%%(AdditionalDependencies)', links) + end + end + + -- -- Write out the element, which is used by -- both the compiler and resource compiler blocks. @@ -477,6 +481,19 @@ end +-- +-- Write out the linker's element. +-- + + function vc2010.additionalLibraryDirectories(cfg) + if #cfg.libdirs > 0 then + local dirs = project.getrelative(cfg.project, cfg.libdirs) + dirs = path.translate(table.concat(dirs, ";")) + _x(3,'%s;%%(AdditionalLibraryDirectories)', dirs) + end + end + + -- -- Write out the element for the linker blocks. -- @@ -806,7 +823,7 @@ end end - function vc2010.clcompile(cfg) + function vc2010.clcompile_old(cfg) _p(2,'') if #cfg.buildoptions > 0 then @@ -935,7 +952,7 @@ -- Generate the element and its children. -- - function vc2010.link(cfg) + function vc2010.link_old(cfg) _p(2,'') _p(3,'%s', iif(cfg.kind == "ConsoleApp", "Console", "Windows")) _p(3,'%s', tostring(cfg.flags.Symbols ~= nil)) @@ -946,7 +963,7 @@ end if cfg.kind ~= 'StaticLib' then - vc2010.additionalDependencies(cfg) + vc2010.additionalDependencies_old(cfg) _p(3,'$(OutDir)%s', cfg.buildtarget.name) if #cfg.libdirs > 0 then @@ -973,7 +990,7 @@ -- by an ). -- - function vc2010.additionalDependencies(cfg) + function vc2010.additionalDependencies_old(cfg) local links = premake.getlinks(cfg, "system", "fullpath") if #links > 0 then _p(3,'%s;%%(AdditionalDependencies)', @@ -987,10 +1004,10 @@ local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) _p(1,'' ,premake.esc(cfginfo.name)) - vc2010.clcompile(cfg) + vc2010.clcompile_old(cfg) resource_compile(cfg) item_def_lib(cfg) - vc2010.link(cfg) + vc2010.link_old(cfg) event_hooks(cfg) _p(1,'') diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/tests/actions/vstudio/vc2010/test_compile_settings.lua index fbaa8700..a6e45ba8 100644 --- a/tests/actions/vstudio/vc2010/test_compile_settings.lua +++ b/tests/actions/vstudio/vc2010/test_compile_settings.lua @@ -22,7 +22,7 @@ local function prepare(platform) cfg = project.getconfig(prj, "Debug", platform) - vc2010.clcompile_ng(cfg) + vc2010.clCompile(cfg) end diff --git a/tests/actions/vstudio/vc2010/test_link.lua b/tests/actions/vstudio/vc2010/test_link.lua index 4ad4add7..a0e83e6e 100644 --- a/tests/actions/vstudio/vc2010/test_link.lua +++ b/tests/actions/vstudio/vc2010/test_link.lua @@ -24,7 +24,7 @@ local function prepare(platform) cfg = project.getconfig(prj, "Debug", platform) - vc2010.link_ng(cfg) + vc2010.link(cfg) end