From 91272ebd3781835b586f8f21447408b360065c15 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Mon, 11 Feb 2013 13:25:33 -0500 Subject: [PATCH] Make more VC'10 project elements available for override by add-ons; clean up naming conventions of modified functions --- src/actions/vstudio/_vstudio.lua | 62 +- src/actions/vstudio/vs2010_vcxproj.lua | 634 +++++++++++------- .../vstudio/vs2010_vcxproj_filters.lua | 22 +- src/actions/vstudio/vs2010_vcxproj_user.lua | 32 +- .../vstudio/vc2010/test_compile_settings.lua | 2 +- .../vstudio/vc2010/test_config_props.lua | 6 +- .../vstudio/vc2010/test_excluded_configs.lua | 10 +- tests/actions/vstudio/vc2010/test_files.lua | 2 +- tests/actions/vstudio/vc2010/test_header.lua | 4 +- tests/actions/vstudio/vc2010/test_link.lua | 4 +- .../vstudio/vc2010/test_project_configs.lua | 6 +- .../vstudio/vc2010/test_project_refs.lua | 6 +- .../vstudio/vc2010/test_prop_sheet.lua | 8 +- 13 files changed, 460 insertions(+), 338 deletions(-) diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index e92c1e57..9a4cc745 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -25,9 +25,9 @@ isnextgen = true, valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, - + valid_languages = { "C", "C++", "C#" }, - + valid_tools = { cc = { "msc" }, dotnet = { "msnet" }, @@ -36,7 +36,7 @@ onsolution = function(sln) premake.generate(sln, ".sln", vstudio.sln2005.generate_ng) end, - + onproject = function(prj) if premake.isdotnetproject(prj) then premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) @@ -46,7 +46,7 @@ premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user_ng) end end, - + oncleansolution = vstudio.cleansolution, oncleanproject = vstudio.cleanproject, oncleantarget = vstudio.cleantarget @@ -61,7 +61,7 @@ -- temporary, until I can phase out the legacy implementations isnextgen = true, - + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_languages = { "C", "C++", "C#" }, @@ -118,9 +118,9 @@ premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) else - premake.generate(prj, ".vcxproj", vstudio.vc2010.generate_ng) - premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generate_user_ng) - premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generate_filters_ng) + premake.generate(prj, ".vcxproj", vstudio.vc2010.generate) + premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generateUser) + premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generateFilters) end end, @@ -157,9 +157,9 @@ premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) else - premake.generate(prj, ".vcxproj", vstudio.vc2010.generate_ng) - premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generate_user_ng) - premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generate_filters_ng) + premake.generate(prj, ".vcxproj", vstudio.vc2010.generate) + premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generateUser) + premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generateFilters) end end, @@ -175,14 +175,14 @@ -- add-ons. -- - vstudio.vs200x_architectures = + vstudio.vs200x_architectures = { x32 = "x86", x64 = "x64", xbox360 = "Xbox 360", } - - vstudio.vs2010_architectures = + + vstudio.vs2010_architectures = { } @@ -213,7 +213,7 @@ function vstudio.archFromConfig(cfg, win32) local iscpp = premake.iscppproject(cfg.project) - local arch = architecture(cfg.system, cfg.architecture) + local arch = architecture(cfg.system, cfg.architecture) if not arch then arch = iif(iscpp, "x86", "Any CPU") end @@ -221,7 +221,7 @@ if win32 and iscpp and arch == "x86" then arch = "Win32" end - + return arch end @@ -235,7 +235,7 @@ -- @return -- A Visual Studio architecture identifier, or nil if no mapping -- could be made. --- +-- function vstudio.archFromPlatform(platform) local system = premake.api.checkvalue(platform, premake.fields.system) @@ -263,7 +263,7 @@ local cfgdeps = config.getlinks(cfg, "dependencies", "object") ex = #prjdeps ~= #cfgdeps end - return ex + return ex end @@ -276,7 +276,7 @@ -- @param arch -- An optional architecture identifier, to override the configuration. -- @return --- A project configuration identifier of the form +-- A project configuration identifier of the form -- |. -- @@ -334,7 +334,7 @@ -- --- Determine the appropriate Visual Studio platform identifier for a +-- Determine the appropriate Visual Studio platform identifier for a -- solution-level configuration. -- -- @param cfg @@ -351,7 +351,7 @@ local platarch if platform then platform = vstudio.archFromPlatform(platform) or platform - + -- Value for 32-bit arch is different depending on whether this solution -- contains C++ or C# projects or both if platform ~= "x86" then @@ -373,7 +373,7 @@ -- get a VS architecture identifier for this project local prjcfg = project.getconfig(prj, cfg.buildcfg, cfg.platform) if prjcfg then - local prjarch = vstudio.archFromConfig(prjcfg) + local prjarch = vstudio.archFromConfig(prjcfg) if not slnarch then slnarch = prjarch elseif slnarch ~= prjarch then @@ -410,20 +410,20 @@ function vstudio.solutionarch(cfg) local hascpp = false local hasdotnet = false - + -- if the configuration has a platform identifier, use that as default local arch = cfg.platform - + -- if the platform identifier matches a known system or architecture, -- - + for prj in solution.eachproject_ng(cfg.solution) do - if premake.iscppproject(prj) then + if premake.iscppproject(prj) then hascpp = true elseif premake.isdotnetproject(prj) then hasdotnet = true end - + if hascpp and hasdotnet then return "Mixed Platforms" end @@ -437,7 +437,7 @@ end end end - + -- use a default if no other architecture was specified arch = arch or iif(hascpp, "Win32", "Any CPU") return arch @@ -458,14 +458,14 @@ function vstudio.solutionconfig(cfg) local platform = cfg.platform - + -- if no platform name was specified, use the architecture instead; - -- since architectures are defined in the projects and not at the + -- since architectures are defined in the projects and not at the -- solution level, need to poke around to figure this out if not platform then platform = vstudio.solutionarch(cfg) end - + return string.format("%s|%s", cfg.buildcfg, platform) end diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 3e56176c..19d21064 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -1,7 +1,7 @@ -- -- vs2010_vcxproj.lua -- Generate a Visual Studio 201x C/C++ project. --- Copyright (c) 2009-2012 Jason Perkins and the Premake project +-- Copyright (c) 2009-2013 Jason Perkins and the Premake project -- premake.vstudio.vc2010 = {} @@ -16,12 +16,12 @@ -- Generate a Visual Studio 201x C++ project, with support for the new platforms API. -- - function vc2010.generate_ng(prj) + function vc2010.generate(prj) io.eol = "\r\n" io.indent = " " io.utf8() - vc2010.header_ng("Build") + vc2010.project("Build") vc2010.projectConfigurations(prj) vc2010.globals(prj) @@ -36,7 +36,7 @@ _p(1,'') for cfg in project.eachconfig(prj) do - vc2010.propertySheet(cfg) + vc2010.propertySheets(cfg) end _p(1,'') @@ -47,17 +47,17 @@ for cfg in project.eachconfig(prj) do _p(1,'', vc2010.condition(cfg)) - vc2010.ClCompile(cfg) + vc2010.clCompile(cfg) vc2010.resourceCompile(cfg) - vc2010.Link(cfg) + vc2010.link(cfg) vc2010.buildEvents(cfg) _p(1,'') end - vc2010.files_ng(prj) - vc2010.projectReferences_ng(prj) + vc2010.files(prj) + vc2010.projectReferences(prj) - vc2010.Import(prj) + vc2010.import(prj) _p('') end @@ -68,7 +68,7 @@ -- Output the XML declaration and opening tag. -- - function vc2010.header_ng(target) + function vc2010.project(target) _p('') local defaultTargets = "" @@ -118,8 +118,8 @@ -- function vc2010.globals(prj) - _p(1,'') - _p(2,'{%s}', prj.uuid) + vc2010.propertyGroup(nil, "Globals") + vc2010.projectGuid(prj) -- try to determine what kind of targets we're building here local isWin, isManaged @@ -152,23 +152,13 @@ -- function vc2010.configurationProperties(cfg) - _p(1,'', vc2010.condition(cfg)) - _p(2,'%s', vc2010.config_type(cfg)) - _p(2,'%s', tostring(premake.config.isdebugbuild(cfg))) - - if _ACTION == "vs2012" then - _p(2,'v110') - end - - if cfg.flags.MFC then - _p(2,'%s', iif(cfg.flags.StaticRuntime, "Static", "Dynamic")) - end - - if cfg.flags.Managed then - _p(2,'true') - end - - _p(2,'%s', iif(cfg.flags.Unicode, "Unicode", "MultiByte")) + vc2010.propertyGroup(cfg, "Configuration") + vc2010.configurationType(cfg) + vc2010.useDebugLibraries(cfg) + vc2010.platformToolset(cfg) + vc2010.useOfMfc(cfg) + vc2010.clrSupport(cfg) + vc2010.characterSet(cfg) _p(1,'') end @@ -177,7 +167,7 @@ -- Write out the default property sheets for a configuration. -- - function vc2010.propertySheet(cfg) + function vc2010.propertySheets(cfg) _p(1,'', vc2010.condition(cfg)) _p(2,'') _p(1,'') @@ -190,35 +180,15 @@ -- function vc2010.outputProperties(cfg) - local target = cfg.buildtarget - - _p(1,'', vc2010.condition(cfg)) - - if cfg.kind ~= premake.STATICLIB then - _p(2,'%s', tostring(premake.config.canincrementallink(cfg))) - end - - if cfg.kind == premake.SHAREDLIB and cfg.flags.NoImportLib then - _p(2,'true'); - end - - local outdir = project.getrelative(cfg.project, target.directory) - _x(2,'%s\\', path.translate(outdir)) - - if cfg.system == premake.XBOX360 then - _x(2,'$(OutDir)%s', target.name) - end - - local objdir = project.getrelative(cfg.project, cfg.objdir) - _x(2,'%s\\', path.translate(objdir)) - - _x(2,'%s%s', target.prefix, target.basename) - _x(2,'%s', target.extension) - - if cfg.flags.NoManifest then - _p(2,'false') - end - + vc2010.propertyGroup(cfg) + vc2010.linkIncremental(cfg) + vc2010.ignoreImportLibrary(cfg) + vc2010.outDir(cfg) + vc2010.outputFile(cfg) + vc2010.intDir(cfg) + vc2010.targetName(cfg) + vc2010.targetExt(cfg) + vc2010.generateManifest(cfg) _p(1,'') end @@ -227,95 +197,32 @@ -- Write the the compiler settings block. -- - function vc2010.ClCompile(cfg) + function vc2010.clCompile(cfg) _p(2,'') - - if not cfg.flags.NoPCH and cfg.pchheader then - _p(3,'Use') - _x(3,'%s', path.getname(cfg.pchheader)) - else - _p(3,'NotUsing') - end - - vc2010.WarningLevel(cfg) - vc2010.TreatWarningAsError(cfg) - vc2010.BasicRuntimeChecks(cfg) - + vc2010.precompiledHeader(cfg) + vc2010.warningLevel(cfg) + vc2010.treatWarningAsError(cfg) + vc2010.basicRuntimeChecks(cfg) vc2010.preprocessorDefinitions(cfg.defines) vc2010.additionalIncludeDirectories(cfg, cfg.includedirs) - - if #cfg.forceincludes > 0 then - local includes = project.getrelative(cfg.project, cfg.forceincludes) - _x(3,'%s', table.concat(includes, ';')) - end - - vc2010.debuginfo(cfg) - - if cfg.flags.Symbols and cfg.debugformat ~= "c7" then - local filename = cfg.buildtarget.basename - _p(3,'$(OutDir)%s.pdb', filename) - end - - _p(3,'%s', vc2010.optimization(cfg)) - - if premake.config.isoptimizedbuild(cfg) then - _p(3,'true') - _p(3,'true') - end - - vc2010.MinimalRebuild(cfg) - - if cfg.flags.NoFramePointer then - _p(3,'true') - end - - if premake.config.isoptimizedbuild(cfg) then - _p(3,'true') - end - - if cfg.flags.StaticRuntime then - _p(3,'%s', iif(premake.config.isdebugbuild(cfg), "MultiThreadedDebug", "MultiThreaded")) - end - - if cfg.flags.NoExceptions then - _p(3,'false') - elseif cfg.flags.SEH then - _p(3,'Async') - end - - if cfg.flags.NoRTTI and not cfg.flags.Managed then - _p(3,'false') - end - - if cfg.flags.NativeWChar then - _p(3,'true') - elseif cfg.flags.NoNativeWChar then - _p(3,'false') - end - - if cfg.flags.FloatFast then - _p(3,'Fast') - elseif cfg.flags.FloatStrict and not cfg.flags.Managed then - _p(3,'Strict') - end - - if cfg.flags.EnableSSE2 then - _p(3,'StreamingSIMDExtensions2') - elseif cfg.flags.EnableSSE then - _p(3,'StreamingSIMDExtensions') - end - - vc2010.MultiProcessorCompilation(cfg) - - if #cfg.buildoptions > 0 then - local options = table.concat(cfg.buildoptions, " ") - _x(3,'%s %%(AdditionalOptions)', options) - end - - if cfg.project.language == "C" then - _p(3,'CompileAsC') - end - + vc2010.forceIncludes(cfg) + vc2010.debugInformationFormat(cfg) + vc2010.programDataBaseFileName(cfg) + vc2010.optimization(cfg) + vc2010.functionLevelLinking(cfg) + vc2010.intrinsicFunctions(cfg) + vc2010.minimalRebuild(cfg) + vc2010.omitFramePointers(cfg) + vc2010.stringPooling(cfg) + vc2010.runtimeLibrary(cfg) + vc2010.exceptionHandling(cfg) + vc2010.runtimeTypeInfo(cfg) + vc2010.treatWChar_tAsBuiltInType(cfg) + vc2010.floatingPointModel(cfg) + vc2010.enableEnhancedInstructionSet(cfg) + vc2010.multiProcessorCompilation(cfg) + vc2010.clCompile_AdditionalOptions(cfg) + vc2010.compileAs(cfg) _p(2,'') end @@ -336,57 +243,37 @@ -- Write out the linker tool block. -- - function vc2010.Link(cfg) + function vc2010.link(cfg) local explicit = vstudio.needsExplicitLink(cfg) _p(2,'') - local subsystem = iif(cfg.kind == premake.CONSOLEAPP, "Console", "Windows") - _p(3,'%s', subsystem) - - _p(3,'%s', tostring(cfg.flags.Symbols ~= nil)) - - if premake.config.isoptimizedbuild(cfg) then - _p(3,'true') - _p(3,'true') - end + vc2010.subSystem(cfg) + vc2010.generateDebugInformation(cfg) + vc2010.optimizeReferences(cfg) if cfg.kind ~= premake.STATICLIB then - vc2010.LinkDynamic(cfg, explicit) + vc2010.linkDynamic(cfg, explicit) end _p(2,'') if cfg.kind == premake.STATICLIB then - vc2010.LinkStatic(cfg) + vc2010.linkStatic(cfg) end - -- Left to its own devices, VS will happily link against a project dependency - -- that has been excluded from the build. As a workaround, disable dependency - -- linking and list all siblings explicitly - if explicit then - _p(2,'') - _p(3,'false') - _p(2,'') - end + vc2010.linkLibraryDependencies(cfg, explicit) end - function vc2010.LinkDynamic(cfg, explicit) + function vc2010.linkDynamic(cfg, explicit) vc2010.additionalDependencies(cfg, explicit) vc2010.additionalLibraryDirectories(cfg) - - if cfg.kind == premake.SHAREDLIB then - _x(3,'%s', path.translate(cfg.linktarget.relpath)) - end - - if vc2010.config_type(cfg) == "Application" and not cfg.flags.WinMain and not cfg.flags.Managed then - _p(3,'mainCRTStartup') - end - + vc2010.importLibrary(cfg) + vc2010.entryPointSymbol(cfg) vc2010.additionalLinkOptions(cfg) end - function vc2010.LinkStatic(cfg) + function vc2010.linkStatic(cfg) _p(2,'') vc2010.additionalLinkOptions(cfg) _p(2,'') @@ -415,16 +302,16 @@ -- Write out the list of source code files, and any associated configuration. -- - function vc2010.files_ng(prj) - vc2010.simplefilesgroup_ng(prj, "ClInclude") - vc2010.compilerfilesgroup_ng(prj) - vc2010.simplefilesgroup_ng(prj, "None") - vc2010.simplefilesgroup_ng(prj, "ResourceCompile") + function vc2010.files(prj) + vc2010.simplefilesgroup(prj, "ClInclude") + vc2010.compilerfilesgroup(prj) + vc2010.simplefilesgroup(prj, "None") + vc2010.simplefilesgroup(prj, "ResourceCompile") vc2010.customBuildFilesGroup(prj) end - function vc2010.simplefilesgroup_ng(prj, group) - local files = vc2010.getfilegroup_ng(prj, group) + function vc2010.simplefilesgroup(prj, group) + local files = vc2010.getfilegroup(prj, group) if #files > 0 then _p(1,'') for _, file in ipairs(files) do @@ -434,8 +321,8 @@ end end - function vc2010.compilerfilesgroup_ng(prj) - local files = vc2010.getfilegroup_ng(prj, "ClCompile") + function vc2010.compilerfilesgroup(prj) + local files = vc2010.getfilegroup(prj, "ClCompile") if #files > 0 then _p(1,'') for _, file in ipairs(files) do @@ -464,7 +351,7 @@ end function vc2010.customBuildFilesGroup(prj) - local files = vc2010.getfilegroup_ng(prj, "CustomBuild") + local files = vc2010.getfilegroup(prj, "CustomBuild") if #files > 0 then _p(1,'') for _, file in ipairs(files) do @@ -489,7 +376,7 @@ end end - function vc2010.getfilegroup_ng(prj, group) + function vc2010.getfilegroup(prj, group) -- check for a cached copy before creating local groups = prj.vc2010_file_groups if not groups then @@ -539,7 +426,7 @@ -- Generate the list of project dependencies. -- - function vc2010.projectReferences_ng(prj) + function vc2010.projectReferences(prj) local deps = project.getdependencies(prj) if #deps > 0 then local prjpath = project.getlocation(prj) @@ -557,18 +444,31 @@ -- --- Generate the list of target imports. +-- Format and return a Visual Studio Condition attribute. -- - function vc2010.Import(prj) - _p(1,'') - _p(1,'') - _p(1,'') + function vc2010.condition(cfg) + return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', premake.esc(vstudio.projectConfig(cfg))) end -- --- Write out the linker's additionalDependencies element. +-- Map Premake's project kinds to Visual Studio configuration types. +-- + + function vc2010.configType(cfg) + local map = { + SharedLib = "DynamicLibrary", + StaticLib = "StaticLibrary", + ConsoleApp = "Application", + WindowedApp = "Application" + } + return map[cfg.kind] + end + + +-- +-- Handlers for individual project elements. -- function vc2010.additionalDependencies(cfg, explicit) @@ -594,11 +494,6 @@ end --- --- Write out the element, which is used by --- both the compiler and resource compiler blocks. --- - function vc2010.additionalIncludeDirectories(cfg, includedirs) if #includedirs > 0 then local dirs = project.getrelative(cfg.project, includedirs) @@ -608,10 +503,6 @@ end --- --- Write out the linker's element. --- - function vc2010.additionalLibraryDirectories(cfg) if #cfg.libdirs > 0 then local dirs = project.getrelative(cfg.project, cfg.libdirs) @@ -621,10 +512,6 @@ end --- --- Write out the element for the linker blocks. --- - function vc2010.additionalLinkOptions(cfg) if #cfg.linkoptions > 0 then local opts = table.concat(cfg.linkoptions, " ") @@ -633,35 +520,46 @@ end --- --- Format and return a Visual Studio Condition attribute. --- - - function vc2010.condition(cfg) - return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', premake.esc(vstudio.projectConfig(cfg))) + function vc2010.basicRuntimeChecks(cfg) + if cfg.flags.NoRuntimeChecks then + _p(3,'Default') + end end --- --- Map Premake's project kinds to Visual Studio configuration types. --- - - function vc2010.config_type(cfg) - local map = { - SharedLib = "DynamicLibrary", - StaticLib = "StaticLibrary", - ConsoleApp = "Application", - WindowedApp = "Application" - } - return map[cfg.kind] + function vc2010.characterSet(cfg) + _p(2,'%s', iif(cfg.flags.Unicode, "Unicode", "MultiByte")) end --- --- Translate Premake's debugging settings to the Visual Studio equivalent. --- + function vc2010.clCompile_AdditionalOptions(cfg) + if #cfg.buildoptions > 0 then + local options = table.concat(cfg.buildoptions, " ") + _x(3,'%s %%(AdditionalOptions)', options) + end + end - function vc2010.debuginfo(cfg) + + function vc2010.clrSupport(cfg) + if cfg.flags.Managed then + _p(2,'true') + end + end + + + function vc2010.compileAs(cfg) + if cfg.project.language == "C" then + _p(3,'CompileAsC') + end + end + + + function vc2010.configurationType(cfg) + _p(2,'%s', vc2010.configType(cfg)) + end + + + function vc2010.debugInformationFormat(cfg) local value if cfg.flags.Symbols then if cfg.debugformat == "c7" then @@ -682,9 +580,152 @@ end --- --- Translate Premake's optimization flags to the Visual Studio equivalents. --- + function vc2010.enableEnhancedInstructionSet(cfg) + if cfg.flags.EnableSSE2 then + _p(3,'StreamingSIMDExtensions2') + elseif cfg.flags.EnableSSE then + _p(3,'StreamingSIMDExtensions') + end + end + + + function vc2010.entryPointSymbol(cfg) + if vc2010.configType(cfg) == "Application" and not cfg.flags.WinMain and not cfg.flags.Managed then + _p(3,'mainCRTStartup') + end + end + + + function vc2010.exceptionHandling(cfg) + if cfg.flags.NoExceptions then + _p(3,'false') + elseif cfg.flags.SEH then + _p(3,'Async') + end + end + + + function vc2010.floatingPointModel(cfg) + if cfg.flags.FloatFast then + _p(3,'Fast') + elseif cfg.flags.FloatStrict and not cfg.flags.Managed then + _p(3,'Strict') + end + end + + + function vc2010.forceIncludes(cfg) + if #cfg.forceincludes > 0 then + local includes = project.getrelative(cfg.project, cfg.forceincludes) + _x(3,'%s', table.concat(includes, ';')) + end + end + + + function vc2010.functionLevelLinking(cfg) + if premake.config.isoptimizedbuild(cfg) then + _p(3,'true') + end + end + + + function vc2010.generateDebugInformation(cfg) + _p(3,'%s', tostring(cfg.flags.Symbols ~= nil)) + end + + + function vc2010.generateManifest(cfg) + if cfg.flags.NoManifest then + _p(2,'false') + end + end + + + function vc2010.ignoreImportLibrary(cfg) + if cfg.kind == premake.SHAREDLIB and cfg.flags.NoImportLib then + _p(2,'true'); + end + end + + + function vc2010.import(prj) + _p(1,'') + _p(1,'') + _p(1,'') + end + + + function vc2010.importLibrary(cfg) + if cfg.kind == premake.SHAREDLIB then + _x(3,'%s', path.translate(cfg.linktarget.relpath)) + end + end + + + function vc2010.intDir(cfg) + local objdir = project.getrelative(cfg.project, cfg.objdir) + _x(2,'%s\\', path.translate(objdir)) + end + + + function vc2010.intrinsicFunctions(cfg) + if premake.config.isoptimizedbuild(cfg) then + _p(3,'true') + end + end + + + function vc2010.linkIncremental(cfg) + if cfg.kind ~= premake.STATICLIB then + _p(2,'%s', tostring(premake.config.canincrementallink(cfg))) + end + end + + + function vc2010.linkLibraryDependencies(cfg, explicit) + -- Left to its own devices, VS will happily link against a project dependency + -- that has been excluded from the build. As a workaround, disable dependency + -- linking and list all siblings explicitly + if explicit then + _p(2,'') + _p(3,'false') + _p(2,'') + end + end + + + function vc2010.minimalRebuild(cfg) + if premake.config.isoptimizedbuild(cfg) or + cfg.flags.NoMinimalRebuild or + cfg.flags.MultiProcessorCompile or + cfg.debugformat == premake.C7 + then + _p(3,'false') + end + end + + + function vc2010.multiProcessorCompilation(cfg) + if cfg.flags.MultiProcessorCompile then + _p(3,'true') + end + end + + + function vc2010.omitFramePointers(cfg) + if cfg.flags.NoFramePointer then + _p(3,'true') + end + end + + + function vc2010.optimizeReferences(cfg) + if premake.config.isoptimizedbuild(cfg) then + _p(3,'true') + _p(3,'true') + end + end + function vc2010.optimization(cfg) local result = "Disabled" @@ -697,14 +738,39 @@ result = "MaxSpeed" end end - return result + _p(3,'%s', result) end --- --- Write out a element, used by both the compiler --- and resource compiler blocks. --- + function vc2010.outDir(cfg) + local outdir = project.getrelative(cfg.project, cfg.buildtarget.directory) + _x(2,'%s\\', path.translate(outdir)) + end + + + function vc2010.outputFile(cfg) + if cfg.system == premake.XBOX360 then + _x(2,'$(OutDir)%s', cfg.buildtarget.name) + end + end + + + function vc2010.platformToolset(cfg) + if _ACTION == "vs2012" then + _p(2,'v110') + end + end + + + function vc2010.precompiledHeader(cfg) + if not cfg.flags.NoPCH and cfg.pchheader then + _p(3,'Use') + _x(3,'%s', path.getname(cfg.pchheader)) + else + _p(3,'NotUsing') + end + end + function vc2010.preprocessorDefinitions(defines) if #defines > 0 then @@ -714,43 +780,99 @@ end --- --- Handlers for individual project elements. --- - - function vc2010.BasicRuntimeChecks(cfg) - if cfg.flags.NoRuntimeChecks then - _p(3,'Default') + function vc2010.programDataBaseFileName(cfg) + if cfg.flags.Symbols and cfg.debugformat ~= "c7" then + local filename = cfg.buildtarget.basename + _p(3,'$(OutDir)%s.pdb', filename) end end - function vc2010.MinimalRebuild(cfg) - if premake.config.isoptimizedbuild(cfg) or - cfg.flags.NoMinimalRebuild or - cfg.flags.MultiProcessorCompile or - cfg.debugformat == premake.C7 - then - _p(3,'false') + function vc2010.projectGuid(prj) + _p(2,'{%s}', prj.uuid) + end + + + function vc2010.propertyGroup(cfg, label) + local cond + if cfg then + cond = string.format(' %s', vc2010.condition(cfg)) + end + + if label then + label = string.format(' Label="%s"', label) + end + + _p(1,'', cond or "", label or "") + end + + + function vc2010.runtimeLibrary(cfg) + if cfg.flags.StaticRuntime then + _p(3,'%s', iif(premake.config.isdebugbuild(cfg), "MultiThreadedDebug", "MultiThreaded")) end end - function vc2010.MultiProcessorCompilation(cfg) - if cfg.flags.MultiProcessorCompile then - _p(3,'true') + function vc2010.runtimeTypeInfo(cfg) + if cfg.flags.NoRTTI and not cfg.flags.Managed then + _p(3,'false') end end - function vc2010.TreatWarningAsError(cfg) + function vc2010.stringPooling(cfg) + if premake.config.isoptimizedbuild(cfg) then + _p(3,'true') + end + end + + + function vc2010.subSystem(cfg) + local subsystem = iif(cfg.kind == premake.CONSOLEAPP, "Console", "Windows") + _p(3,'%s', subsystem) + end + + + function vc2010.targetExt(cfg) + _x(2,'%s', cfg.buildtarget.extension) + end + + + function vc2010.targetName(cfg) + _x(2,'%s%s', cfg.buildtarget.prefix, cfg.buildtarget.basename) + end + + + function vc2010.treatWChar_tAsBuiltInType(cfg) + if cfg.flags.NativeWChar then + _p(3,'true') + elseif cfg.flags.NoNativeWChar then + _p(3,'false') + end + end + + + function vc2010.treatWarningAsError(cfg) if cfg.flags.FatalWarnings and not cfg.flags.NoWarnings then _p(3,'true') end end - function vc2010.WarningLevel(cfg) + function vc2010.useDebugLibraries(cfg) + _p(2,'%s', tostring(premake.config.isdebugbuild(cfg))) + end + + + function vc2010.useOfMfc(cfg) + if cfg.flags.MFC then + _p(2,'%s', iif(cfg.flags.StaticRuntime, "Static", "Dynamic")) + end + end + + + function vc2010.warningLevel(cfg) local w = 3 if cfg.flags.NoWarnings then w = 0 diff --git a/src/actions/vstudio/vs2010_vcxproj_filters.lua b/src/actions/vstudio/vs2010_vcxproj_filters.lua index e828fcc9..b677d961 100644 --- a/src/actions/vstudio/vs2010_vcxproj_filters.lua +++ b/src/actions/vstudio/vs2010_vcxproj_filters.lua @@ -7,25 +7,25 @@ local vc2010 = premake.vstudio.vc2010 local project = premake5.project local tree = premake.tree - + -- -- Generate a Visual Studio 201x C++ project, with support for the new platforms API. -- - function vc2010.generate_filters_ng(prj) + function vc2010.generateFilters(prj) io.eol = "\r\n" io.indent = " " - - vc2010.header_ng() - + + vc2010.project() + vc2010.filters_uniqueidentifiers(prj) vc2010.filters_filegroup(prj, "None") vc2010.filters_filegroup(prj, "ClInclude") vc2010.filters_filegroup(prj, "ClCompile") vc2010.filters_filegroup(prj, "ResourceCompile") vc2010.filters_filegroup(prj, "CustomBuild") - + _p('') end @@ -38,7 +38,7 @@ function vc2010.filters_uniqueidentifiers(prj) local opened = false - + local tr = project.getsourcetree(prj) tree.traverse(tr, { onbranch = function(node, depth) @@ -55,18 +55,18 @@ if opened then _p(1,'') - end + end end -- -- The second portion of the filters file assigns filters to each source --- code file, as needed. Group is one of "ClCompile", "ClInclude", +-- code file, as needed. Group is one of "ClCompile", "ClInclude", -- "ResourceCompile", or "None". -- function vc2010.filters_filegroup(prj, group) - local files = vc2010.getfilegroup_ng(prj, group) + local files = vc2010.getfilegroup(prj, group) if #files > 0 then _p(1,'') for _, file in ipairs(files) do @@ -76,7 +76,7 @@ _p(2,'', group) else _p(2,'<%s Include=\"%s\" />', group, path.translate(file.relpath)) - end + end end _p(1,'') end diff --git a/src/actions/vstudio/vs2010_vcxproj_user.lua b/src/actions/vstudio/vs2010_vcxproj_user.lua index d99f8949..530ffda2 100755 --- a/src/actions/vstudio/vs2010_vcxproj_user.lua +++ b/src/actions/vstudio/vs2010_vcxproj_user.lua @@ -1,7 +1,7 @@ -- --- vs2019_vcxproj_user.lua +-- vs2010_vcxproj_user.lua -- Generate a Visual Studio 201x C/C++ project .user file --- Copyright (c) 2011-2012 Jason Perkins and the Premake project +-- Copyright (c) 2011-2013 Jason Perkins and the Premake project -- local vstudio = premake.vstudio @@ -13,11 +13,11 @@ -- Generate a Visual Studio 201x C++ user file, with support for the new platforms API. -- - function vc2010.generate_user_ng(prj) + function vc2010.generateUser(prj) io.eol = "\r\n" io.indent = " " - - vc2010.header_ng() + + vc2010.project() for cfg in project.eachconfig(prj) do _p(1,'', vc2010.condition(cfg)) vc2010.debugsettings(cfg) @@ -27,40 +27,40 @@ end function vc2010.debugsettings(cfg) - vc2010.LocalDebuggerCommand(cfg) - vc2010.LocalDebuggerWorkingDirectory(cfg) - vc2010.DebuggerFlavor(cfg) - vc2010.LocalDebuggerCommandArguments(cfg) - vc2010.LocalDebuggerEnvironment(cfg) + vc2010.localDebuggerCommand(cfg) + vc2010.localDebuggerWorkingDirectory(cfg) + vc2010.debuggerFlavor(cfg) + vc2010.localDebuggerCommandArguments(cfg) + vc2010.localDebuggerEnvironment(cfg) end - function vc2010.DebuggerFlavor(cfg) + function vc2010.debuggerFlavor(cfg) if cfg.debugdir or cfg.debugcommand then - _p(2,'WindowsLocalDebugger') + _p(2,'WindowsLocalDebugger') end end - function vc2010.LocalDebuggerCommand(cfg) + function vc2010.localDebuggerCommand(cfg) if cfg.debugcommand then local dir = project.getrelative(cfg.project, cfg.debugcommand) _p(2,'%s', path.translate(dir)) end end - function vc2010.LocalDebuggerCommandArguments(cfg) + function vc2010.localDebuggerCommandArguments(cfg) if #cfg.debugargs > 0 then _x(2,'%s', table.concat(cfg.debugargs, " ")) end end - function vc2010.LocalDebuggerWorkingDirectory(cfg) + function vc2010.localDebuggerWorkingDirectory(cfg) if cfg.debugdir then local dir = project.getrelative(cfg.project, cfg.debugdir) _x(2,'%s', path.translate(dir)) end end - function vc2010.LocalDebuggerEnvironment(cfg) + function vc2010.localDebuggerEnvironment(cfg) if #cfg.debugenvs > 0 then local envs = table.concat(cfg.debugenvs, "\n") if cfg.flags.DebugEnvsInherit then diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/tests/actions/vstudio/vc2010/test_compile_settings.lua index ff7f80c9..1cdb1524 100644 --- a/tests/actions/vstudio/vc2010/test_compile_settings.lua +++ b/tests/actions/vstudio/vc2010/test_compile_settings.lua @@ -21,7 +21,7 @@ local function prepare(platform) cfg = project.getconfig(prj, "Debug", platform) - vc2010.ClCompile(cfg) + vc2010.clCompile(cfg) end diff --git a/tests/actions/vstudio/vc2010/test_config_props.lua b/tests/actions/vstudio/vc2010/test_config_props.lua index a20d1835..c8165191 100755 --- a/tests/actions/vstudio/vc2010/test_config_props.lua +++ b/tests/actions/vstudio/vc2010/test_config_props.lua @@ -11,15 +11,15 @@ -- --- Setup +-- Setup -- local sln, prj, cfg - + function suite.setup() sln, prj = test.createsolution() end - + local function prepare() cfg = project.getconfig(prj, "Debug") vc2010.configurationProperties(cfg) diff --git a/tests/actions/vstudio/vc2010/test_excluded_configs.lua b/tests/actions/vstudio/vc2010/test_excluded_configs.lua index 08bee4d2..94c08d03 100644 --- a/tests/actions/vstudio/vc2010/test_excluded_configs.lua +++ b/tests/actions/vstudio/vc2010/test_excluded_configs.lua @@ -17,19 +17,19 @@ function suite.setup() _ACTION = "vs2010" - + sln = solution("MySolution") configurations { "Debug", "Release" } platforms { "Zeus", "Ares" } language "C++" - + prj = project("MyProject") kind "ConsoleApp" links { "MyProject2", "MyProject3" } - + project("MyProject2") kind "StaticLib" - + project("MyProject3") kind "StaticLib" removeplatforms { "Ares" } @@ -37,7 +37,7 @@ local function prepare(platform) local cfg = premake5.project.getconfig(prj, "Debug", platform) - vc2010.Link(cfg) + vc2010.link(cfg) end diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua index b963e32d..9bff6469 100755 --- a/tests/actions/vstudio/vc2010/test_files.lua +++ b/tests/actions/vstudio/vc2010/test_files.lua @@ -20,7 +20,7 @@ local function prepare() prj = premake.solution.getproject_ng(sln, 1) - vc2010.files_ng(prj) + vc2010.files(prj) end diff --git a/tests/actions/vstudio/vc2010/test_header.lua b/tests/actions/vstudio/vc2010/test_header.lua index ffd2ec55..1a646871 100644 --- a/tests/actions/vstudio/vc2010/test_header.lua +++ b/tests/actions/vstudio/vc2010/test_header.lua @@ -15,7 +15,7 @@ -- function suite.project_onDefaultTarget() - vc2010.header_ng("Build") + vc2010.project("Build") test.capture [[ @@ -27,7 +27,7 @@ -- function suite.project_onNoDefaultTarget() - vc2010.header_ng() + vc2010.project() test.capture [[ diff --git a/tests/actions/vstudio/vc2010/test_link.lua b/tests/actions/vstudio/vc2010/test_link.lua index 18feb042..f8ce346a 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(cfg) + vc2010.link(cfg) end @@ -293,7 +293,7 @@ ]] end - + -- -- Enable reference optimizing if Optimize flag is specified. -- diff --git a/tests/actions/vstudio/vc2010/test_project_configs.lua b/tests/actions/vstudio/vc2010/test_project_configs.lua index 8449412a..39154bf0 100755 --- a/tests/actions/vstudio/vc2010/test_project_configs.lua +++ b/tests/actions/vstudio/vc2010/test_project_configs.lua @@ -10,16 +10,16 @@ -- --- Setup +-- Setup -- local sln, prj - + function suite.setup() _ACTION = "vs2010" sln = test.createsolution() end - + local function prepare() prj = premake.solution.getproject_ng(sln, 1) vc2010.projectConfigurations(prj) diff --git a/tests/actions/vstudio/vc2010/test_project_refs.lua b/tests/actions/vstudio/vc2010/test_project_refs.lua index 391641dc..8f04f4e6 100644 --- a/tests/actions/vstudio/vc2010/test_project_refs.lua +++ b/tests/actions/vstudio/vc2010/test_project_refs.lua @@ -24,7 +24,7 @@ local function prepare(platform) prj = premake.solution.getproject_ng(sln, 2) - vc2010.projectReferences_ng(prj) + vc2010.projectReferences(prj) end @@ -56,7 +56,7 @@ end -- --- Project references should always be specified relative to the +-- Project references should always be specified relative to the -- project doing the referencing. -- @@ -74,4 +74,4 @@ ]] end - + diff --git a/tests/actions/vstudio/vc2010/test_prop_sheet.lua b/tests/actions/vstudio/vc2010/test_prop_sheet.lua index b5f5d26a..5655dce0 100755 --- a/tests/actions/vstudio/vc2010/test_prop_sheet.lua +++ b/tests/actions/vstudio/vc2010/test_prop_sheet.lua @@ -11,18 +11,18 @@ -- --- Setup +-- Setup -- local sln, prj, cfg - + function suite.setup() sln, prj = test.createsolution() end - + local function prepare() cfg = project.getconfig(prj, "Debug") - vc2010.propertySheet(cfg) + vc2010.propertySheets(cfg) end