A bit of clean-up work over the recently modified call array code
This commit is contained in:
parent
1b28b48a6b
commit
b320248d7b
@ -43,10 +43,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Write the opening <VisualStudioProject> element of the project file.
|
-- Write the opening <VisualStudioProject> element of the project file.
|
||||||
-- In this case, the call list is for XML attributes rather than elements.
|
-- In this case, the call list is for XML attributes rather than elements.
|
||||||
--
|
---
|
||||||
|
|
||||||
m.elements.visualStudioProject = function(prj)
|
m.elements.visualStudioProject = function(prj)
|
||||||
return {
|
return {
|
||||||
@ -68,10 +68,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Write out the <Configurations> element group, enumerating each of the
|
-- Write out the <Configurations> element group, enumerating each of the
|
||||||
-- configuration-architecture pairings.
|
-- configuration-architecture pairings.
|
||||||
--
|
---
|
||||||
|
|
||||||
function m.configurations(prj)
|
function m.configurations(prj)
|
||||||
-- Visual Studio requires each configuration to be paired up with each
|
-- Visual Studio requires each configuration to be paired up with each
|
||||||
@ -126,10 +126,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Write out the <Configuration> element, describing a specific Premake
|
-- Write out the <Configuration> element, describing a specific Premake
|
||||||
-- build configuration/platform pairing.
|
-- build configuration/platform pairing.
|
||||||
--
|
---
|
||||||
|
|
||||||
m.elements.configuration = function(cfg)
|
m.elements.configuration = function(cfg)
|
||||||
return {
|
return {
|
||||||
@ -151,29 +151,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- Write an empty, placehold configuration for those build configuration
|
|
||||||
-- and architecture pairs that aren't valid build targets in the solution.
|
|
||||||
--
|
|
||||||
|
|
||||||
function m.emptyConfiguration(cfg, arch)
|
|
||||||
p.push('<Configuration')
|
|
||||||
p.w('Name="%s|%s"', vstudio.projectPlatform(cfg), arch)
|
|
||||||
p.w('IntermediateDirectory="$(PlatformName)\\$(ConfigurationName)"')
|
|
||||||
p.w('ConfigurationType="1"')
|
|
||||||
p.w('>')
|
|
||||||
|
|
||||||
local tools = m.toolsForConfig(cfg, true)
|
|
||||||
for i, tool in ipairs(tools) do
|
|
||||||
m.tool(tool)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Write out the <References> element group.
|
-- Write out the <References> element group.
|
||||||
--
|
---
|
||||||
|
|
||||||
m.elements.references = function(prj)
|
m.elements.references = function(prj)
|
||||||
return {
|
return {
|
||||||
@ -190,10 +170,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
---
|
||||||
-- I don't do anything with globals yet, but here it is if you want to
|
-- I don't do anything with globals yet, but here it is if you want to
|
||||||
-- extend it.
|
-- extend it.
|
||||||
--
|
---
|
||||||
|
|
||||||
m.elements.globals = function(prj)
|
m.elements.globals = function(prj)
|
||||||
return {}
|
return {}
|
||||||
@ -258,6 +238,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m.elements.VCBscMakeTool = function(cfg)
|
m.elements.VCBscMakeTool = function(cfg)
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
@ -268,6 +249,60 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
m.elements.VCCLCompilerTool = function(cfg, toolset)
|
||||||
|
if not toolset then
|
||||||
|
-- no, use the standard set of attributes
|
||||||
|
return {
|
||||||
|
m.compilerToolName,
|
||||||
|
m.VCCLCompilerTool_additionalOptions,
|
||||||
|
m.optimization,
|
||||||
|
m.additionalIncludeDirectories,
|
||||||
|
m.wholeProgramOptimization,
|
||||||
|
m.preprocessorDefinitions,
|
||||||
|
m.minimalRebuild,
|
||||||
|
m.basicRuntimeChecks,
|
||||||
|
m.bufferSecurityCheck,
|
||||||
|
m.stringPooling,
|
||||||
|
m.exceptionHandling,
|
||||||
|
m.runtimeLibrary,
|
||||||
|
m.enableFunctionLevelLinking,
|
||||||
|
m.enableEnhancedInstructionSet,
|
||||||
|
m.floatingPointModel,
|
||||||
|
m.runtimeTypeInfo,
|
||||||
|
m.treatWChar_tAsBuiltInType,
|
||||||
|
m.usePrecompiledHeader,
|
||||||
|
m.programDatabaseFileName,
|
||||||
|
m.warnings,
|
||||||
|
m.debugInformationFormat,
|
||||||
|
m.compileAs,
|
||||||
|
m.forcedIncludeFiles,
|
||||||
|
m.omitDefaultLib,
|
||||||
|
}
|
||||||
|
else
|
||||||
|
-- yes, use the custom tool attributes
|
||||||
|
return {
|
||||||
|
m.compilerToolName,
|
||||||
|
m.VCCLExternalCompilerTool_additionalOptions,
|
||||||
|
m.additionalIncludeDirectories,
|
||||||
|
m.preprocessorDefinitions,
|
||||||
|
m.usePrecompiledHeader,
|
||||||
|
m.programDatabaseFileName,
|
||||||
|
m.debugInformationFormat,
|
||||||
|
m.compileAs,
|
||||||
|
m.forcedIncludeFiles,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function m.VCCLCompilerTool(cfg)
|
||||||
|
p.push('<Tool')
|
||||||
|
p.callArray(m.elements.VCCLCompilerTool, cfg, m.toolset(cfg))
|
||||||
|
p.pop('/>')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m.elements.VCCustomBuildTool = function(cfg)
|
m.elements.VCCustomBuildTool = function(cfg)
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
@ -464,59 +499,6 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
m.elements.VCCLCompilerTool = function(cfg, toolset)
|
|
||||||
if not toolset then
|
|
||||||
-- no, use the standard set of attributes
|
|
||||||
return {
|
|
||||||
m.compilerToolName,
|
|
||||||
m.VCCLCompilerTool_additionalOptions,
|
|
||||||
m.optimization,
|
|
||||||
m.additionalIncludeDirectories,
|
|
||||||
m.wholeProgramOptimization,
|
|
||||||
m.preprocessorDefinitions,
|
|
||||||
m.minimalRebuild,
|
|
||||||
m.basicRuntimeChecks,
|
|
||||||
m.bufferSecurityCheck,
|
|
||||||
m.stringPooling,
|
|
||||||
m.exceptionHandling,
|
|
||||||
m.runtimeLibrary,
|
|
||||||
m.enableFunctionLevelLinking,
|
|
||||||
m.enableEnhancedInstructionSet,
|
|
||||||
m.floatingPointModel,
|
|
||||||
m.runtimeTypeInfo,
|
|
||||||
m.treatWChar_tAsBuiltInType,
|
|
||||||
m.usePrecompiledHeader,
|
|
||||||
m.programDatabaseFileName,
|
|
||||||
m.warnings,
|
|
||||||
m.debugInformationFormat,
|
|
||||||
m.compileAs,
|
|
||||||
m.forcedIncludeFiles,
|
|
||||||
m.omitDefaultLib,
|
|
||||||
}
|
|
||||||
else
|
|
||||||
-- yes, use the custom tool attributes
|
|
||||||
return {
|
|
||||||
m.compilerToolName,
|
|
||||||
m.VCCLExternalCompilerTool_additionalOptions,
|
|
||||||
m.additionalIncludeDirectories,
|
|
||||||
m.preprocessorDefinitions,
|
|
||||||
m.usePrecompiledHeader,
|
|
||||||
m.programDatabaseFileName,
|
|
||||||
m.debugInformationFormat,
|
|
||||||
m.compileAs,
|
|
||||||
m.forcedIncludeFiles,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function m.VCCLCompilerTool(cfg)
|
|
||||||
p.push('<Tool')
|
|
||||||
p.callArray(m.elements.VCCLCompilerTool, cfg, m.toolset(cfg))
|
|
||||||
p.pop('/>')
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function m.DebuggerTool(cfg)
|
function m.DebuggerTool(cfg)
|
||||||
p.w('<DebuggerTool')
|
p.w('<DebuggerTool')
|
||||||
p.w('/>')
|
p.w('/>')
|
||||||
@ -1109,19 +1091,12 @@
|
|||||||
|
|
||||||
|
|
||||||
function m.compileAs(cfg, toolset)
|
function m.compileAs(cfg, toolset)
|
||||||
local prjcfg, filecfg
|
local prj, file = config.normalize(cfg)
|
||||||
if cfg.config then
|
local c = project.isc(prj)
|
||||||
prjcfg = cfg.config
|
if file then
|
||||||
filecfg = cfg
|
if path.iscfile(file.name) ~= c then
|
||||||
else
|
if path.iscppfile(file.name) then
|
||||||
prjcfg = cfg
|
local value = iif(c, 2, 1)
|
||||||
filecfg = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if filecfg then
|
|
||||||
if path.iscfile(filecfg.name) ~= project.isc(filecfg.project) then
|
|
||||||
if path.iscppfile(filecfg.name) then
|
|
||||||
local value = iif(filecfg.project.language == p.CPP, 1, 2)
|
|
||||||
p.w('CompileAs="%s"', value)
|
p.w('CompileAs="%s"', value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1129,7 +1104,7 @@
|
|||||||
local compileAs
|
local compileAs
|
||||||
if toolset then
|
if toolset then
|
||||||
compileAs = "0"
|
compileAs = "0"
|
||||||
elseif prjcfg.project.language == "C" then
|
elseif c then
|
||||||
compileAs = "1"
|
compileAs = "1"
|
||||||
end
|
end
|
||||||
if compileAs then
|
if compileAs then
|
||||||
@ -1139,26 +1114,20 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function m.compilerToolName(cfg)
|
|
||||||
local prjcfg, filecfg
|
|
||||||
if cfg.config then
|
|
||||||
prjcfg = cfg.config
|
|
||||||
filecfg = cfg
|
|
||||||
else
|
|
||||||
prjcfg = cfg
|
|
||||||
filecfg = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
function m.compilerToolName(cfg)
|
||||||
local name
|
local name
|
||||||
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
|
local prj, file = config.normalize(cfg)
|
||||||
|
if file and fileconfig.hasCustomBuildRule(file) then
|
||||||
name = "VCCustomBuildTool"
|
name = "VCCustomBuildTool"
|
||||||
else
|
else
|
||||||
name = iif(prjcfg.system == p.XBOX360, "VCCLX360CompilerTool", "VCCLCompilerTool")
|
name = iif(prj.system == p.XBOX360, "VCCLX360CompilerTool", "VCCLCompilerTool")
|
||||||
end
|
end
|
||||||
p.w('Name="%s"', name)
|
p.w('Name="%s"', name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.configurationType(cfg)
|
function m.configurationType(cfg)
|
||||||
local cfgtypes = {
|
local cfgtypes = {
|
||||||
Makefile = 0,
|
Makefile = 0,
|
||||||
@ -1511,38 +1480,23 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function m.usePrecompiledHeader(cfg)
|
function m.usePrecompiledHeader(cfg)
|
||||||
-- TODO: make a generic way to get both the project and, if
|
local prj, file = config.normalize(cfg)
|
||||||
-- applicable, the file configuration from an object that might
|
if file then
|
||||||
-- be either. Then I can write more generic code.
|
if prj.pchsource == file.abspath and
|
||||||
|
not prj.flags.NoPCH and
|
||||||
local prjcfg, filecfg
|
prj.system ~= p.PS3
|
||||||
if cfg.config then
|
|
||||||
prjcfg = cfg.config
|
|
||||||
filecfg = cfg
|
|
||||||
else
|
|
||||||
prjcfg = cfg
|
|
||||||
filecfg = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- AND THEN simplify this block; I can merge some of this logic.
|
|
||||||
|
|
||||||
if not filecfg then
|
|
||||||
-- project configuration
|
|
||||||
if not prjcfg.flags.NoPCH and prjcfg.pchheader then
|
|
||||||
p.w('UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
|
|
||||||
p.x('PrecompiledHeaderThrough="%s"', prjcfg.pchheader)
|
|
||||||
else
|
|
||||||
p.w('UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or prjcfg.flags.NoPCH, 0, 2))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- file configuration
|
|
||||||
if prjcfg.pchsource == filecfg.abspath and
|
|
||||||
not prjcfg.flags.NoPCH and
|
|
||||||
prjcfg.system ~= p.PS3
|
|
||||||
then
|
then
|
||||||
p.w('UsePrecompiledHeader="1"')
|
p.w('UsePrecompiledHeader="1"')
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if not prj.flags.NoPCH and prj.pchheader then
|
||||||
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
|
||||||
|
p.x('PrecompiledHeaderThrough="%s"', prj.pchheader)
|
||||||
|
else
|
||||||
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or prj.flags.NoPCH, 0, 2))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -540,3 +540,26 @@
|
|||||||
|
|
||||||
return flags
|
return flags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns both a project configuration and a file configuration from a
|
||||||
|
-- configuration argument that could be either.
|
||||||
|
--
|
||||||
|
-- @param cfg
|
||||||
|
-- A project or file configuration object.
|
||||||
|
-- @return
|
||||||
|
-- Both a project configuration and a file configuration. If the input
|
||||||
|
-- argument is a project configuration, the file configuration value is
|
||||||
|
-- returned as nil.
|
||||||
|
---
|
||||||
|
|
||||||
|
function config.normalize(cfg)
|
||||||
|
if cfg.config ~= nil then
|
||||||
|
return cfg.config, cfg
|
||||||
|
else
|
||||||
|
return cfg, nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user