Merged project and file compiler configuration blocks
This commit is contained in:
parent
17f03ab901
commit
12b2949c37
@ -314,23 +314,6 @@
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
m.elements.fileConfigurationCompiler = function(filecfg)
|
|
||||||
if filecfg then
|
|
||||||
return {
|
|
||||||
m.customBuildTool,
|
|
||||||
m.objectFile,
|
|
||||||
m.optimization,
|
|
||||||
m.preprocessorDefinitions,
|
|
||||||
m.usePrecompiledHeader,
|
|
||||||
m.VCCLCompilerTool_fileConfig_additionalOptions,
|
|
||||||
m.forcedIncludeFiles,
|
|
||||||
m.compileAs,
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function m.fileConfiguration(cfg, node)
|
function m.fileConfiguration(cfg, node)
|
||||||
local filecfg = fileconfig.getconfig(node, cfg)
|
local filecfg = fileconfig.getconfig(node, cfg)
|
||||||
|
|
||||||
@ -345,26 +328,20 @@
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local compilerAttribs = p.capture(function ()
|
local compilerAttribs = p.capture(function ()
|
||||||
p.push(2)
|
p.push()
|
||||||
p.callArray(m.elements.fileConfigurationCompiler, filecfg)
|
m.VCCLCompilerTool(filecfg)
|
||||||
p.pop(2)
|
p.pop()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if #configAttribs > 0 or #compilerAttribs > 0 then
|
-- lines() > 3 skips empty <Tool Name="VCCLCompiler" /> elements
|
||||||
|
if #configAttribs > 0 or compilerAttribs:lines() > 3 then
|
||||||
p.push('<FileConfiguration')
|
p.push('<FileConfiguration')
|
||||||
p.w('Name="%s"', vstudio.projectConfig(cfg))
|
p.w('Name="%s"', vstudio.projectConfig(cfg))
|
||||||
if #configAttribs > 0 then
|
if #configAttribs > 0 then
|
||||||
p.outln(configAttribs)
|
p.outln(configAttribs)
|
||||||
end
|
end
|
||||||
p.w('>')
|
p.w('>')
|
||||||
|
p.outln(compilerAttribs)
|
||||||
p.push('<Tool')
|
|
||||||
p.w('Name="%s"', m.VCCLCompilerToolName(filecfg or cfg))
|
|
||||||
if #compilerAttribs > 0 then
|
|
||||||
p.outln(compilerAttribs)
|
|
||||||
end
|
|
||||||
p.pop('/>')
|
|
||||||
|
|
||||||
p.pop('</FileConfiguration>')
|
p.pop('</FileConfiguration>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -420,7 +397,7 @@
|
|||||||
end
|
end
|
||||||
p.w('Name="%s"', name)
|
p.w('Name="%s"', name)
|
||||||
|
|
||||||
if not cfg.fake then
|
if cfg and not cfg.fake then
|
||||||
p.callArray(callFunc, cfg, ...)
|
p.callArray(callFunc, cfg, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -476,7 +453,9 @@
|
|||||||
if not toolset then
|
if not toolset then
|
||||||
-- not a custom tool, use the standard set of attributes
|
-- not a custom tool, use the standard set of attributes
|
||||||
return {
|
return {
|
||||||
m.VCCLCompilerTool_additionalOptions,
|
m.customBuildTool,
|
||||||
|
m.objectFile,
|
||||||
|
m.additionalCompilerOptions,
|
||||||
m.optimization,
|
m.optimization,
|
||||||
m.additionalIncludeDirectories,
|
m.additionalIncludeDirectories,
|
||||||
m.wholeProgramOptimization,
|
m.wholeProgramOptimization,
|
||||||
@ -503,7 +482,7 @@
|
|||||||
else
|
else
|
||||||
-- custom tool, use subset of attributes
|
-- custom tool, use subset of attributes
|
||||||
return {
|
return {
|
||||||
m.VCCLExternalCompilerTool_additionalOptions,
|
m.additionalExternalCompilerOptions,
|
||||||
m.additionalIncludeDirectories,
|
m.additionalIncludeDirectories,
|
||||||
m.preprocessorDefinitions,
|
m.preprocessorDefinitions,
|
||||||
m.usePrecompiledHeader,
|
m.usePrecompiledHeader,
|
||||||
@ -516,10 +495,10 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
function m.VCCLCompilerToolName(cfg)
|
function m.VCCLCompilerToolName(cfg)
|
||||||
local prj, file = config.normalize(cfg)
|
local prjcfg, filecfg = config.normalize(cfg)
|
||||||
if file and fileconfig.hasCustomBuildRule(file) then
|
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
|
||||||
return "VCCustomBuildTool"
|
return "VCCustomBuildTool"
|
||||||
elseif prj.system == p.XBOX360 then
|
elseif prjcfg and prjcfg.system == p.XBOX360 then
|
||||||
return "VCCLX360CompilerTool"
|
return "VCCLX360CompilerTool"
|
||||||
else
|
else
|
||||||
return "VCCLCompilerTool"
|
return "VCCLCompilerTool"
|
||||||
@ -819,6 +798,18 @@
|
|||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
function m.additionalCompilerOptions(cfg)
|
||||||
|
local opts = cfg.buildoptions
|
||||||
|
if cfg.flags.MultiProcessorCompile then
|
||||||
|
table.insert(opts, "/MP")
|
||||||
|
end
|
||||||
|
if #opts > 0 then
|
||||||
|
p.x('AdditionalOptions="%s"', table.concat(opts, " "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.additionalDependencies(cfg, toolset)
|
function m.additionalDependencies(cfg, toolset)
|
||||||
if #cfg.links == 0 then return end
|
if #cfg.links == 0 then return end
|
||||||
|
|
||||||
@ -853,6 +844,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function m.additionalExternalCompilerOptions(cfg, toolset)
|
||||||
|
local buildoptions = table.join(toolset.getcflags(cfg), toolset.getcxxflags(cfg), cfg.buildoptions)
|
||||||
|
if not cfg.flags.NoPCH and cfg.pchheader then
|
||||||
|
table.insert(buildoptions, '--use_pch="$(IntDir)/$(TargetName).pch"')
|
||||||
|
end
|
||||||
|
if #buildoptions > 0 then
|
||||||
|
p.x('AdditionalOptions="%s"', table.concat(buildoptions, " "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.additionalImageOptions(cfg)
|
function m.additionalImageOptions(cfg)
|
||||||
if #cfg.imageoptions > 0 then
|
if #cfg.imageoptions > 0 then
|
||||||
p.x('AdditionalOptions="%s"', table.concat(cfg.imageoptions, " "))
|
p.x('AdditionalOptions="%s"', table.concat(cfg.imageoptions, " "))
|
||||||
@ -878,9 +881,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.additionalResourceOptions(cfg)
|
function m.additionalLinkerOptions(cfg, toolset)
|
||||||
if #cfg.resoptions > 0 then
|
local flags = cfg.linkoptions
|
||||||
p.x('AdditionalOptions="%s"', table.concat(cfg.resoptions, " "))
|
if toolset then
|
||||||
|
flags = table.join(toolset.getldflags(cfg), flags)
|
||||||
|
end
|
||||||
|
if #flags > 0 then
|
||||||
|
p.x('AdditionalOptions="%s"', table.concat(flags, " "))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -900,57 +907,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.assemblySearchPath(cfg)
|
|
||||||
p.w('AssemblySearchPath=""')
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.VCCLCompilerTool_additionalOptions(cfg)
|
|
||||||
local opts = cfg.buildoptions
|
|
||||||
if cfg.flags.MultiProcessorCompile then
|
|
||||||
table.insert(opts, "/MP")
|
|
||||||
end
|
|
||||||
if #opts > 0 then
|
|
||||||
p.x('AdditionalOptions="%s"', table.concat(opts, " "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.VCCLCompilerTool_fileConfig_additionalOptions(filecfg)
|
|
||||||
local opts = filecfg.buildoptions
|
|
||||||
if #opts > 0 then
|
|
||||||
p.x('AdditionalOptions="%s"', table.concat(opts, " "))
|
|
||||||
end
|
|
||||||
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
|
|
||||||
table.insert(buildoptions, '--use_pch="$(IntDir)/$(TargetName).pch"')
|
|
||||||
end
|
|
||||||
if #buildoptions > 0 then
|
|
||||||
p.x('AdditionalOptions="%s"', table.concat(buildoptions, " "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.additionalLinkerOptions(cfg, toolset)
|
|
||||||
local flags = cfg.linkoptions
|
|
||||||
if toolset then
|
|
||||||
flags = table.join(toolset.getldflags(cfg), flags)
|
|
||||||
end
|
|
||||||
if #flags > 0 then
|
|
||||||
p.x('AdditionalOptions="%s"', table.concat(flags, " "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.additionalResourceIncludeDirectories(cfg)
|
function m.additionalResourceIncludeDirectories(cfg)
|
||||||
local dirs = table.join(cfg.includedirs, cfg.resincludedirs)
|
local dirs = table.join(cfg.includedirs, cfg.resincludedirs)
|
||||||
if #dirs > 0 then
|
if #dirs > 0 then
|
||||||
@ -961,6 +917,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function m.additionalResourceOptions(cfg)
|
||||||
|
if #cfg.resoptions > 0 then
|
||||||
|
p.x('AdditionalOptions="%s"', table.concat(cfg.resoptions, " "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.assemblyReferences(prj)
|
function m.assemblyReferences(prj)
|
||||||
-- Visual Studio doesn't support per-config references
|
-- Visual Studio doesn't support per-config references
|
||||||
local cfg = project.getfirstconfig(prj)
|
local cfg = project.getfirstconfig(prj)
|
||||||
@ -974,8 +938,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function m.assemblySearchPath(cfg)
|
||||||
|
p.w('AssemblySearchPath=""')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.basicRuntimeChecks(cfg)
|
function m.basicRuntimeChecks(cfg)
|
||||||
if not config.isOptimizedBuild(cfg)
|
local cfg, filecfg = config.normalize(cfg)
|
||||||
|
if not filecfg
|
||||||
|
and not config.isOptimizedBuild(cfg)
|
||||||
and not cfg.flags.Managed
|
and not cfg.flags.Managed
|
||||||
and not cfg.flags.NoRuntimeChecks
|
and not cfg.flags.NoRuntimeChecks
|
||||||
then
|
then
|
||||||
@ -1030,11 +1002,11 @@
|
|||||||
|
|
||||||
|
|
||||||
function m.compileAs(cfg, toolset)
|
function m.compileAs(cfg, toolset)
|
||||||
local prj, file = config.normalize(cfg)
|
local cfg, filecfg = config.normalize(cfg)
|
||||||
local c = project.isc(prj)
|
local c = project.isc(cfg)
|
||||||
if file then
|
if filecfg then
|
||||||
if path.iscfile(file.name) ~= c then
|
if path.iscfile(filecfg.name) ~= c then
|
||||||
if path.iscppfile(file.name) then
|
if path.iscppfile(filecfg.name) then
|
||||||
local value = iif(c, 2, 1)
|
local value = iif(c, 2, 1)
|
||||||
p.w('CompileAs="%s"', value)
|
p.w('CompileAs="%s"', value)
|
||||||
end
|
end
|
||||||
@ -1081,8 +1053,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.customBuildTool(filecfg)
|
function m.customBuildTool(cfg)
|
||||||
if fileconfig.hasCustomBuildRule(filecfg) then
|
local cfg, filecfg = config.normalize(cfg)
|
||||||
|
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
|
||||||
p.x('CommandLine="%s"', table.concat(filecfg.buildcommands,'\r\n'))
|
p.x('CommandLine="%s"', table.concat(filecfg.buildcommands,'\r\n'))
|
||||||
|
|
||||||
local outputs = project.getrelative(filecfg.project, filecfg.buildoutputs)
|
local outputs = project.getrelative(filecfg.project, filecfg.buildoutputs)
|
||||||
@ -1093,8 +1066,11 @@
|
|||||||
|
|
||||||
|
|
||||||
function m.debugInformationFormat(cfg, toolset)
|
function m.debugInformationFormat(cfg, toolset)
|
||||||
local fmt = iif(toolset, "0", m.symbols(cfg))
|
local prjcfg, filecfg = config.normalize(cfg)
|
||||||
p.w('DebugInformationFormat="%s"', fmt)
|
if not filecfg then
|
||||||
|
local fmt = iif(toolset, "0", m.symbols(cfg))
|
||||||
|
p.w('DebugInformationFormat="%s"', fmt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1124,7 +1100,10 @@
|
|||||||
|
|
||||||
|
|
||||||
function m.enableFunctionLevelLinking(cfg)
|
function m.enableFunctionLevelLinking(cfg)
|
||||||
p.w('EnableFunctionLevelLinking="true"')
|
local cfg, filecfg = config.normalize(cfg)
|
||||||
|
if not filecfg then
|
||||||
|
p.w('EnableFunctionLevelLinking="true"')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1325,8 +1304,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.objectFile(filecfg)
|
function m.objectFile(cfg)
|
||||||
if path.iscppfile(filecfg.name) then
|
local cfg, filecfg = config.normalize(cfg)
|
||||||
|
if filecfg and path.iscppfile(filecfg.name) then
|
||||||
if filecfg.objname ~= path.getbasename(filecfg.abspath) then
|
if filecfg.objname ~= path.getbasename(filecfg.abspath) then
|
||||||
p.x('ObjectFile="$(IntDir)\\%s.obj"', filecfg.objname)
|
p.x('ObjectFile="$(IntDir)\\%s.obj"', filecfg.objname)
|
||||||
end
|
end
|
||||||
@ -1510,16 +1490,20 @@
|
|||||||
|
|
||||||
|
|
||||||
function m.runtimeLibrary(cfg)
|
function m.runtimeLibrary(cfg)
|
||||||
local runtimes = {
|
local cfg, filecfg = config.normalize(cfg)
|
||||||
StaticRelease = 0,
|
if not filecfg then
|
||||||
StaticDebug = 1,
|
local runtimes = {
|
||||||
SharedRelease = 2,
|
StaticRelease = 0,
|
||||||
SharedDebug = 3,
|
StaticDebug = 1,
|
||||||
}
|
SharedRelease = 2,
|
||||||
p.w('RuntimeLibrary="%s"', runtimes[config.getruntime(cfg)])
|
SharedDebug = 3,
|
||||||
|
}
|
||||||
|
p.w('RuntimeLibrary="%s"', runtimes[config.getruntime(cfg)])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.runtimeTypeInfo(cfg)
|
function m.runtimeTypeInfo(cfg)
|
||||||
if cfg.flags.NoRTTI and not cfg.flags.Managed then
|
if cfg.flags.NoRTTI and not cfg.flags.Managed then
|
||||||
p.w('RuntimeTypeInfo="false"')
|
p.w('RuntimeTypeInfo="false"')
|
||||||
@ -1627,16 +1611,27 @@
|
|||||||
|
|
||||||
|
|
||||||
function m.warnings(cfg)
|
function m.warnings(cfg)
|
||||||
|
local prjcfg, filecfg = config.normalize(cfg)
|
||||||
|
|
||||||
|
local level
|
||||||
if cfg.warnings == "Off" then
|
if cfg.warnings == "Off" then
|
||||||
p.w('WarningLevel="0"')
|
level = "0"
|
||||||
else
|
elseif cfg.warnings == "Extra" then
|
||||||
p.w('WarningLevel="%d"', iif(cfg.warnings == "Extra", 4, 3))
|
level = "4"
|
||||||
if cfg.flags.FatalCompileWarnings then
|
elseif not filecfg then
|
||||||
p.w('WarnAsError="true"')
|
level = "3"
|
||||||
end
|
end
|
||||||
if _ACTION < "vs2008" and not cfg.flags.Managed then
|
|
||||||
p.w('Detect64BitPortabilityProblems="%s"', tostring(not cfg.flags.No64BitChecks))
|
if level then
|
||||||
end
|
p.w('WarningLevel="%s"', level)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= "Off" then
|
||||||
|
p.w('WarnAsError="true"')
|
||||||
|
end
|
||||||
|
|
||||||
|
if _ACTION < "vs2008" and not cfg.flags.Managed and cfg.warnings ~= "Off" and not filecfg then
|
||||||
|
p.w('Detect64BitPortabilityProblems="%s"', tostring(not cfg.flags.No64BitChecks))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
function config.normalize(cfg)
|
function config.normalize(cfg)
|
||||||
if cfg.config ~= nil then
|
if cfg and cfg.config ~= nil then
|
||||||
return cfg.config, cfg
|
return cfg.config, cfg
|
||||||
else
|
else
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user