From 13c072594d3ccda9a31f1a42d134274c560ff860 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 11 Mar 2014 12:10:33 -0400 Subject: [PATCH] Migrated more of the .vcproj support code to new conventions --- src/actions/vstudio/vs200x_vcproj.lua | 266 ++++++++++++------ .../vstudio/vc200x/test_external_linker.lua | 3 +- 2 files changed, 178 insertions(+), 91 deletions(-) diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index 0c460206..39fb7e2b 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -436,14 +436,13 @@ m.moduleDefinitionFile, m.generateManifest, m.generateDebugInformation, + m.programDatabaseFile, m.subSystem, m.optimizeReferences, m.enableCOMDATFolding, m.entryPointSymbol, m.importLibrary, m.targetMachine, - m.randomizedBaseAddress, - m.dataExecutionPrevention, } else return { @@ -481,6 +480,53 @@ ------------ + m.elements.VCManifestTool = function(cfg) + return { + m.additionalManifestFiles, + } + end + + function m.VCManifestTool(cfg) + if cfg.kind ~= p.STATICLIB then + m.VCTool("VCManifestTool", cfg) + end + end + + ------------ + + m.elements.VCMIDLTool = function(cfg) + return { + m.targetEnvironment(cfg) + } + end + + function m.VCMIDLTool(cfg) + m.VCTool("VCMIDLTool", cfg) + end + + ------------ + + m.elements.VCNMakeTool = function(cfg) + return { + m.buildCommandLine, + m.reBuildCommandLine, + m.cleanCommandLine, + m.output, + m.preprocessorDefinitions, + m.includeSearchPath, + m.forcedIncludes, + m.assemblySearchPath, + m.forcedUsingAssemblies, + m.compileAsManaged, + } + end + + function m.VCNMakeTool(cfg) + m.VCTool("VCNMakeTool", cfg) + end + + ------------ + m.elements.VCWebServiceProxyGeneratorTool = function(cfg) return {} end @@ -518,72 +564,6 @@ -- --------------------------------------------------------------------------- - function m.VCManifestTool(cfg) - if cfg.kind == p.STATICLIB then - return - end - - p.push('') - return - end - - local manifests = {} - for i, fname in ipairs(cfg.files) do - if path.getextension(fname) == ".manifest" then - table.insert(manifests, project.getrelative(cfg.project, fname)) - end - end - - if #manifests > 0 then - p.x('AdditionalManifestFiles="%s"', table.concat(manifests, ";")) - end - p.pop('/>') - end - - - function m.VCMIDLTool(cfg) - p.push('') - return - end - - if cfg.architecture == "x64" then - p.w('TargetEnvironment="3"') - end - - p.pop('/>') - end - - - function m.VCNMakeTool(cfg) - p.push('') - return - end - - m.nmakeCommandLine(cfg, cfg.buildcommands, "Build") - m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild") - m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean") - m.nmakeOutput(cfg) - p.w('PreprocessorDefinitions=""') - p.w('IncludeSearchPath=""') - p.w('ForcedIncludes=""') - p.w('AssemblySearchPath=""') - p.w('ForcedUsingAssemblies=""') - p.w('CompileAsManaged=""') - p.pop('/>') - end - function m.VCResourceCompilerTool(cfg) p.push(' 0 then + p.x('AdditionalManifestFiles="%s"', table.concat(manifests, ";")) + end + end + + + + function m.assemblySearchPath(cfg) + p.w('AssemblySearchPath=""') + end + + + function m.VCCLCompilerTool_additionalOptions(cfg) local opts = cfg.buildoptions if cfg.flags.MultiProcessorCompile then @@ -959,6 +960,7 @@ end + function m.VCCLCompilerTool_fileConfig_additionalOptions(filecfg) local opts = filecfg.buildoptions if #opts > 0 then @@ -967,6 +969,7 @@ end + function m.VCCLExternalCompilerTool_additionalOptions(cfg, toolset) local buildoptions = table.join(toolset.getcflags(cfg), toolset.getcxxflags(cfg), cfg.buildoptions) if not cfg.flags.NoPCH and cfg.pchheader then @@ -978,6 +981,7 @@ end + function m.additionalLinkerOptions(cfg, toolset) local flags = cfg.linkoptions if toolset then @@ -989,6 +993,7 @@ end + function m.assemblyReferences(prj) -- Visual Studio doesn't support per-config references local cfg = project.getfirstconfig(prj) @@ -1001,6 +1006,7 @@ end + function m.basicRuntimeChecks(cfg) if not config.isOptimizedBuild(cfg) and not cfg.flags.Managed @@ -1010,12 +1016,23 @@ end end + + function m.bufferSecurityCheck(cfg) if cfg.flags.NoBufferSecurityCheck then p.w('BufferSecurityCheck="false"') end end + + + function m.buildCommandLine(cfg) + commands = table.concat(cfg.buildcommands, "\r\n") + p.x('BuildCommandLine="%s"', commands) + end + + + function m.characterSet(cfg) if not vstudio.isMakefile(cfg) then p.w('CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2)) @@ -1023,6 +1040,14 @@ end + + function m.cleanCommandLine(cfg) + commands = table.concat(cfg.cleancommands, "\r\n") + p.x('CleanCommandLine="%s"', commands) + end + + + function m.compileAs(cfg, toolset) local prj, file = config.normalize(cfg) local c = project.isc(prj) @@ -1048,6 +1073,12 @@ + function m.compileAsManaged(cfg) + p.w('CompileAsManaged=""') + end + + + function m.configurationType(cfg) local cfgtypes = { Makefile = 0, @@ -1079,12 +1110,6 @@ end - function m.dataExecutionPrevention(cfg, toolset) - if toolset then - p.w('DataExecutionPrevention="0"') - end - end - function m.debugInformationFormat(cfg, toolset) local fmt = iif(toolset, "0", m.symbols(cfg)) @@ -1092,6 +1117,7 @@ end + function m.enableCOMDATFolding(cfg, toolset) if config.isOptimizedBuild(cfg) and not toolset then p.w('EnableCOMDATFolding="2"') @@ -1099,6 +1125,7 @@ end + function m.enableEnhancedInstructionSet(cfg) local map = { SSE = "1", SSE2 = "2" } local value = map[cfg.vectorextensions] @@ -1108,11 +1135,13 @@ end + function m.enableFunctionLevelLinking(cfg) p.w('EnableFunctionLevelLinking="%s"', m.bool(true)) end + function m.entryPointSymbol(cfg, toolset) if (cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp") and not cfg.flags.WinMain and @@ -1123,6 +1152,7 @@ end + function m.exceptionHandling(cfg) if cfg.flags.NoExceptions then p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0)) @@ -1132,6 +1162,7 @@ end + function m.excludedFromBuild(filecfg) if not filecfg or filecfg.flags.ExcludeFromBuild then p.w('ExcludedFromBuild="true"') @@ -1139,6 +1170,7 @@ end + function m.floatingPointModel(cfg) local map = { Strict = "1", Fast = "2" } local value = map[cfg.floatingpoint] @@ -1148,6 +1180,7 @@ end + function m.forcedIncludeFiles(cfg) if #cfg.forceincludes > 0 then local includes = path.translate(project.getrelative(cfg.project, cfg.forceincludes)) @@ -1160,6 +1193,19 @@ end + + function m.forcedIncludes(cfg) + p.w('ForcedIncludes=""') + end + + + + function m.forcedUsingAssemblies(cfg) + p.w('ForcedUsingAssemblies=""') + end + + + function m.keyword(prj) local windows, managed, makefile for cfg in project.eachconfig(prj) do @@ -1181,6 +1227,7 @@ end + function m.generateDebugInformation(cfg, toolset) if not toolset then p.w('GenerateDebugInformation="%s"', m.bool(m.symbols(cfg) ~= 0)) @@ -1188,6 +1235,7 @@ end + function m.generateManifest(cfg, toolset) if cfg.flags.NoManifest or toolset then p.w('GenerateManifest="%s"', m.bool(false)) @@ -1195,6 +1243,7 @@ end + function m.ignoreImportLibrary(cfg, toolset) if cfg.flags.NoImportLib and not toolset then p.w('IgnoreImportLibrary="%s"', m.bool(true)) @@ -1202,6 +1251,7 @@ end + function m.importLibrary(cfg, toolset) if cfg.kind == p.SHAREDLIB and not toolset then local implibdir = cfg.linktarget.abspath @@ -1217,6 +1267,13 @@ end + + function m.includeSearchPath(cfg) + p.w('IncludeSearchPath=""') + end + + + function m.intermediateDirectory(cfg) local objdir if not cfg.fake then @@ -1228,6 +1285,7 @@ end + function m.linkIncremental(cfg, toolset) local value if not toolset then @@ -1239,6 +1297,7 @@ end + function m.linkLibraryDependencies(cfg, toolset) if vstudio.needsExplicitLink(cfg) and not toolset then p.w('LinkLibraryDependencies="false"') @@ -1246,6 +1305,7 @@ end + function m.managedExtensions(cfg) if cfg.flags.Managed then p.w('ManagedExtensions="1"') @@ -1253,6 +1313,7 @@ end + function m.minimalRebuild(cfg) if config.isDebugBuild(cfg) and cfg.debugformat ~= "c7" and @@ -1265,6 +1326,7 @@ end + function m.moduleDefinitionFile(cfg, toolset) if not toolset then local deffile = config.findfile(cfg, ".def") @@ -1275,16 +1337,6 @@ end - function m.nmakeCommandLine(cfg, commands, phase) - commands = table.concat(commands, "\r\n") - p.w('%sCommandLine="%s"', phase, p.esc(commands)) - end - - - function m.nmakeOutput(cfg) - p.w('Output="$(OutDir)%s"', cfg.buildtarget.name) - end - function m.objectFile(filecfg) if path.iscppfile(filecfg.name) then @@ -1295,6 +1347,7 @@ end + function m.omitDefaultLib(cfg) if cfg.flags.OmitDefaultLibrary then p.w('OmitDefaultLibName="true"') @@ -1302,6 +1355,7 @@ end + function m.omitFramePointers(cfg) if cfg.flags.NoFramePointer then p.w('OmitFramePointers="%s"', m.bool(true)) @@ -1309,6 +1363,7 @@ end + function m.optimization(cfg) local map = { Off=0, On=3, Debug=0, Full=3, Size=1, Speed=2 } local value = map[cfg.optimize] @@ -1318,6 +1373,7 @@ end + function m.optimizeReferences(cfg, toolset) if config.isOptimizedBuild(cfg) and not toolset then p.w('OptimizeReferences="2"') @@ -1325,17 +1381,26 @@ end + + function m.output(cfg) + p.w('Output="$(OutDir)%s"', cfg.buildtarget.name) + end + + + function m.outputDirectory(cfg) local outdir = project.getrelative(cfg.project, cfg.buildtarget.directory) p.x('OutputDirectory="%s"', path.translate(outdir)) end + function m.outputFile(cfg) p.x('OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name) end + function m.platforms(prj) p.push('') table.foreachi(m.architectures(prj), function(arch) @@ -1347,13 +1412,22 @@ end + function m.preprocessorDefinitions(cfg) - if #cfg.defines > 0 then + if #cfg.defines > 0 or vstudio.isMakefile(cfg) then p.x('PreprocessorDefinitions="%s"', table.concat(cfg.defines, ";")) end end + + function m.programDatabaseFile(cfg, toolset) + if toolset then + p.w('ProgramDatabaseFile=""') + end + end + + function m.programDataBaseFileName(cfg, toolset) if toolset then p.w('ProgramDataBaseFileName=""') @@ -1361,16 +1435,19 @@ end + function m.projectGUID(prj) p.w('ProjectGUID="{%s}"', prj.uuid) end + function m.projectName(prj) p.x('Name="%s"', prj.name) end + function m.projectReferences(prj) local deps = project.getdependencies(prj) if #deps > 0 then @@ -1398,15 +1475,16 @@ end + function m.projectType(prj) p.w('ProjectType="Visual C++"') end - function m.randomizedBaseAddress(cfg, toolset) - if toolset then - p.w('RandomizedBaseAddress="1"') - end + + function m.reBuildCommandLine(cfg) + commands = table.concat(cfg.rebuildcommands, "\r\n") + p.x('ReBuildCommandLine="%s"', commands) end @@ -1420,6 +1498,7 @@ end + function m.resourcePreprocessorDefinitions(cfg) local defs = table.join(cfg.defines, cfg.resdefines) if #defs > 0 then @@ -1428,6 +1507,7 @@ end + function m.rootNamespace(prj) local hasWindows = project.hasConfig(prj, function(cfg) return cfg.system == p.WINDOWS @@ -1443,6 +1523,7 @@ end + function m.runtimeLibrary(cfg) local runtimes = { StaticRelease = 0, @@ -1475,6 +1556,13 @@ end + function m.targetEnvironment(cfg) + if cfg.architecture == "x64" then + p.w('TargetEnvironment="3"') + end + end + + function m.targetFrameworkVersion(prj) local windows, makefile for cfg in project.eachconfig(prj) do diff --git a/tests/actions/vstudio/vc200x/test_external_linker.lua b/tests/actions/vstudio/vc200x/test_external_linker.lua index f4f50c73..ec5e55cd 100644 --- a/tests/actions/vstudio/vc200x/test_external_linker.lua +++ b/tests/actions/vstudio/vc200x/test_external_linker.lua @@ -43,8 +43,7 @@ OutputFile="$(OutDir)\MyProject.elf" LinkIncremental="0" GenerateManifest="false" - RandomizedBaseAddress="1" - DataExecutionPrevention="0" + ProgramDatabaseFile="" /> ]] end