2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
-- vs200x_vcproj.lua
|
|
|
|
-- Generate a Visual Studio 2002-2008 C/C++ project.
|
2013-02-07 15:58:31 +00:00
|
|
|
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
premake.vstudio.vc200x = {}
|
2014-01-28 15:42:49 +00:00
|
|
|
local m = premake.vstudio.vc200x
|
2013-07-12 15:07:26 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
local p = premake
|
|
|
|
local vstudio = p.vstudio
|
|
|
|
local context = p.context
|
|
|
|
local project = p.project
|
|
|
|
local config = p.config
|
|
|
|
local fileconfig = p.fileconfig
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements = {}
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-09-27 18:25:10 +00:00
|
|
|
|
|
|
|
|
2013-05-22 15:15:48 +00:00
|
|
|
---
|
|
|
|
-- Generate a Visual Studio 200x C++ or Makefile project.
|
|
|
|
---
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.project = function(prj)
|
2014-01-16 19:22:38 +00:00
|
|
|
return {
|
2014-01-28 15:42:49 +00:00
|
|
|
m.xmlElement,
|
|
|
|
m.visualStudioProject,
|
|
|
|
m.platforms,
|
|
|
|
m.toolFiles,
|
|
|
|
m.configurations,
|
|
|
|
m.references,
|
|
|
|
m.files,
|
|
|
|
m.globals
|
2014-01-16 19:22:38 +00:00
|
|
|
}
|
|
|
|
end
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.generate(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.callArray(m.elements.project, prj)
|
|
|
|
p.pop('</VisualStudioProject>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
2014-01-16 19:22:38 +00:00
|
|
|
-- Write the opening <VisualStudioProject> element of the project file.
|
|
|
|
-- In this case, the call list is for XML attributes rather than elements.
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.visualStudioProject = function(prj)
|
2014-01-16 19:22:38 +00:00
|
|
|
return {
|
2014-01-28 15:42:49 +00:00
|
|
|
m.projectType,
|
|
|
|
m.version,
|
|
|
|
m.projectName,
|
|
|
|
m.projectGUID,
|
|
|
|
m.rootNamespace,
|
|
|
|
m.keyword,
|
|
|
|
m.targetFrameworkVersion
|
2014-01-16 19:22:38 +00:00
|
|
|
}
|
|
|
|
end
|
2013-10-23 14:51:11 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.visualStudioProject(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<VisualStudioProject')
|
|
|
|
p.callArray(m.elements.visualStudioProject, prj)
|
|
|
|
p.w('>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
2013-10-18 14:38:00 +00:00
|
|
|
-- Write out the <Configurations> element group, enumerating each of the
|
|
|
|
-- configuration-architecture pairings.
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.configurations(prj)
|
2013-10-18 14:38:00 +00:00
|
|
|
-- Visual Studio requires each configuration to be paired up with each
|
|
|
|
-- architecture, even if the pairing doesn't make any sense (i.e. Win32
|
|
|
|
-- DLL DCRT|PS3). Start by finding the names of all of the configurations
|
|
|
|
-- that actually are in the project; I'll use this to help identify the
|
|
|
|
-- configurations that *aren't* in the project below.
|
|
|
|
|
2013-10-28 15:01:41 +00:00
|
|
|
local isRealConfig = {}
|
2012-11-30 19:05:19 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2013-10-28 15:01:41 +00:00
|
|
|
local name = vstudio.projectConfig(cfg)
|
|
|
|
isRealConfig[name] = true
|
2013-10-18 14:38:00 +00:00
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
local architectures = m.architectures(prj)
|
2013-10-18 14:38:00 +00:00
|
|
|
|
|
|
|
-- Now enumerate all of the configurations in the project and write
|
|
|
|
-- out their <Configuration> blocks.
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Configurations>')
|
2013-10-18 14:38:00 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2013-10-28 15:01:41 +00:00
|
|
|
local thisName = vstudio.projectConfig(cfg)
|
2014-01-18 19:54:46 +00:00
|
|
|
for i, arch in ipairs(architectures) do
|
2013-10-28 15:01:41 +00:00
|
|
|
local testName = vstudio.projectConfig(cfg, arch)
|
2013-10-18 14:38:00 +00:00
|
|
|
|
|
|
|
-- Does this architecture match the one in the project config
|
|
|
|
-- that I'm trying to write? If so, go ahead and output the
|
|
|
|
-- full <Configuration> block.
|
|
|
|
|
2013-10-28 15:01:41 +00:00
|
|
|
if thisName == testName then
|
2014-01-28 15:42:49 +00:00
|
|
|
m.configuration(cfg)
|
|
|
|
m.tools(cfg)
|
2014-01-31 19:29:58 +00:00
|
|
|
p.pop('</Configuration>')
|
2013-10-18 14:38:00 +00:00
|
|
|
|
|
|
|
-- Otherwise, check the list of valid configurations I built
|
|
|
|
-- earlier. If this configuration is in the list, then I will
|
|
|
|
-- get to it on another pass of this loop. If it is not in
|
|
|
|
-- the list, then it isn't really part of the project, and I
|
|
|
|
-- need to output a dummy configuration in its place.
|
|
|
|
|
2013-10-30 18:22:53 +00:00
|
|
|
elseif not isRealConfig[testName] then
|
2013-10-18 14:38:00 +00:00
|
|
|
-- this is a fake config to make VS happy
|
2014-01-28 15:42:49 +00:00
|
|
|
m.emptyConfiguration(cfg, arch)
|
2014-01-31 19:29:58 +00:00
|
|
|
p.pop('</Configuration>')
|
2013-10-18 14:38:00 +00:00
|
|
|
end
|
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('</Configurations>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
-- Write out the <Configuration> element, describing a specific Premake
|
|
|
|
-- build configuration/platform pairing.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.configuration = function(cfg)
|
2014-01-16 19:22:38 +00:00
|
|
|
return {
|
2014-01-28 15:42:49 +00:00
|
|
|
m.outputDirectory,
|
|
|
|
m.intermediateDirectory,
|
|
|
|
m.configurationType,
|
|
|
|
m.useOfMFC,
|
|
|
|
m.characterSet,
|
|
|
|
m.managedExtensions
|
2014-01-16 19:22:38 +00:00
|
|
|
}
|
|
|
|
end
|
2013-10-28 15:01:41 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.configuration(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Configuration')
|
|
|
|
p.w('Name="%s"', vstudio.projectConfig(cfg))
|
|
|
|
p.callArray(m.elements.configuration, cfg)
|
|
|
|
p.w('>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Write an empty, placehold configuration for those build configuration
|
|
|
|
-- and architecture pairs that aren't valid build targets in the solution.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.emptyConfiguration(cfg, arch)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Configuration')
|
|
|
|
p.w('Name="%s|%s"', vstudio.projectPlatform(cfg), arch)
|
|
|
|
p.w('IntermediateDirectory="$(PlatformName)\\$(ConfigurationName)"')
|
|
|
|
p.w('ConfigurationType="1"')
|
|
|
|
p.w('>')
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
local tools = m.toolsForConfig(cfg, true)
|
2014-01-18 19:54:46 +00:00
|
|
|
for i, tool in ipairs(tools) do
|
2014-01-28 15:42:49 +00:00
|
|
|
m.tool(tool)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2013-10-18 14:38:00 +00:00
|
|
|
--
|
|
|
|
-- Write out the <References> element group.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.references = function(prj)
|
2014-01-16 19:22:38 +00:00
|
|
|
return {
|
2014-01-28 15:42:49 +00:00
|
|
|
m.assemblyReferences,
|
|
|
|
m.projectReferences,
|
2014-01-16 19:22:38 +00:00
|
|
|
}
|
|
|
|
end
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.references(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<References>')
|
|
|
|
p.callArray(m.elements.references, prj)
|
|
|
|
p.pop('</References>')
|
2013-10-18 14:38:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2013-10-18 14:38:00 +00:00
|
|
|
--
|
|
|
|
-- I don't do anything with globals yet, but here it is if you want to
|
|
|
|
-- extend it.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.globals = function(prj)
|
2014-01-16 19:22:38 +00:00
|
|
|
return {}
|
|
|
|
end
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.globals(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Globals>')
|
|
|
|
p.callArray(m.elements.globals, prj)
|
|
|
|
p.pop('</Globals>')
|
2013-10-18 14:38:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
---------------------------------------------------------------------------
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
2014-01-24 18:06:52 +00:00
|
|
|
-- Handlers for the individual tool sections of the project.
|
|
|
|
--
|
|
|
|
-- There is a lot of repetition here; most of these tools are just
|
|
|
|
-- placeholders for modules to override as needed.
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
---------------------------------------------------------------------------
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-24 18:06:52 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
-- The implementation of a "normal" tool. Writes the opening tool element
|
|
|
|
-- and name attribute, calls the corresponding function list, and then
|
|
|
|
-- closes the element.
|
|
|
|
--
|
|
|
|
-- @param name
|
|
|
|
-- The name of the tool, e.g. "VCCustomBuildTool".
|
|
|
|
-- @param ...
|
|
|
|
-- Any additional arguments required by the call list.
|
|
|
|
---
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCTool(name, ...)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="%s"', name)
|
|
|
|
p.callArray(m.elements[name], ...)
|
|
|
|
p.pop('/>')
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCALinkTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCALinkTool(cfg)
|
|
|
|
m.VCTool("VCALinkTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCAppVerifierTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCAppVerifierTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind ~= p.STATICLIB then
|
2014-01-28 15:42:49 +00:00
|
|
|
m.VCTool("VCAppVerifierTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCBscMakeTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCBscMakeTool(cfg)
|
|
|
|
m.VCTool("VCBscMakeTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCCustomBuildTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCCustomBuildTool(cfg)
|
|
|
|
m.VCTool("VCCustomBuildTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCFxCopTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCFxCopTool(cfg)
|
|
|
|
m.VCTool("VCFxCopTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCManagedResourceCompilerTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCManagedResourceCompilerTool(cfg)
|
|
|
|
m.VCTool("VCManagedResourceCompilerTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCWebServiceProxyGeneratorTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCWebServiceProxyGeneratorTool(cfg)
|
|
|
|
m.VCTool("VCWebServiceProxyGeneratorTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCXDCMakeTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCXDCMakeTool(cfg)
|
|
|
|
m.VCTool("VCXDCMakeTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.VCXMLDataGeneratorTool = function(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCXMLDataGeneratorTool(cfg)
|
|
|
|
m.VCTool("VCXMLDataGeneratorTool", cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
-- EVERYTHING BELOW THIS NEEDS REWORK, which I'm in the process of
|
|
|
|
-- doing right now. Hold on tight.
|
|
|
|
--
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-21 15:55:00 +00:00
|
|
|
---
|
2013-03-07 15:45:33 +00:00
|
|
|
-- Return the list of tools required to build a specific configuration.
|
|
|
|
-- Each tool gets represented by an XML element in the project file.
|
2013-05-21 15:55:00 +00:00
|
|
|
--
|
|
|
|
-- @param cfg
|
|
|
|
-- The configuration being written.
|
|
|
|
-- @param isEmptyCfg
|
|
|
|
-- If true, the list is for the generation of an empty or dummy
|
|
|
|
-- configuration block; in this case different rules apply.
|
2013-03-07 15:45:33 +00:00
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.toolsForConfig(cfg, isEmptyCfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if vstudio.isMakefile(cfg) and not isEmptyCfg then
|
2013-04-03 18:09:39 +00:00
|
|
|
return {
|
|
|
|
"VCNMakeTool"
|
|
|
|
}
|
|
|
|
end
|
2013-03-07 15:45:33 +00:00
|
|
|
if _ACTION == "vs2002" then
|
|
|
|
return {
|
|
|
|
"VCCLCompilerTool",
|
|
|
|
"VCCustomBuildTool",
|
|
|
|
"VCLinkerTool",
|
|
|
|
"VCMIDLTool",
|
|
|
|
"VCPostBuildEventTool",
|
|
|
|
"VCPreBuildEventTool",
|
|
|
|
"VCPreLinkEventTool",
|
|
|
|
"VCResourceCompilerTool",
|
|
|
|
"VCWebServiceProxyGeneratorTool",
|
|
|
|
"VCWebDeploymentTool"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if _ACTION == "vs2003" then
|
|
|
|
return {
|
|
|
|
"VCCLCompilerTool",
|
|
|
|
"VCCustomBuildTool",
|
|
|
|
"VCLinkerTool",
|
|
|
|
"VCMIDLTool",
|
|
|
|
"VCPostBuildEventTool",
|
|
|
|
"VCPreBuildEventTool",
|
|
|
|
"VCPreLinkEventTool",
|
|
|
|
"VCResourceCompilerTool",
|
|
|
|
"VCWebServiceProxyGeneratorTool",
|
|
|
|
"VCXMLDataGeneratorTool",
|
|
|
|
"VCWebDeploymentTool",
|
|
|
|
"VCManagedWrapperGeneratorTool",
|
|
|
|
"VCAuxiliaryManagedWrapperGeneratorTool"
|
|
|
|
}
|
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.system == p.XBOX360 then
|
2013-03-07 15:45:33 +00:00
|
|
|
return {
|
|
|
|
"VCPreBuildEventTool",
|
|
|
|
"VCCustomBuildTool",
|
|
|
|
"VCXMLDataGeneratorTool",
|
|
|
|
"VCWebServiceProxyGeneratorTool",
|
|
|
|
"VCMIDLTool",
|
|
|
|
"VCCLCompilerTool",
|
|
|
|
"VCManagedResourceCompilerTool",
|
|
|
|
"VCResourceCompilerTool",
|
|
|
|
"VCPreLinkEventTool",
|
|
|
|
"VCLinkerTool",
|
|
|
|
"VCALinkTool",
|
|
|
|
"VCX360ImageTool",
|
|
|
|
"VCBscMakeTool",
|
|
|
|
"VCX360DeploymentTool",
|
|
|
|
"VCPostBuildEventTool",
|
|
|
|
"DebuggerTool",
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
"VCPreBuildEventTool",
|
|
|
|
"VCCustomBuildTool",
|
|
|
|
"VCXMLDataGeneratorTool",
|
|
|
|
"VCWebServiceProxyGeneratorTool",
|
|
|
|
"VCMIDLTool",
|
|
|
|
"VCCLCompilerTool",
|
|
|
|
"VCManagedResourceCompilerTool",
|
|
|
|
"VCResourceCompilerTool",
|
|
|
|
"VCPreLinkEventTool",
|
|
|
|
"VCLinkerTool",
|
|
|
|
"VCALinkTool",
|
|
|
|
"VCManifestTool",
|
|
|
|
"VCXDCMakeTool",
|
|
|
|
"VCBscMakeTool",
|
|
|
|
"VCFxCopTool",
|
|
|
|
"VCAppVerifierTool",
|
|
|
|
"VCPostBuildEventTool"
|
|
|
|
}
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
-- Map target systems to their default toolset. If no mapping is
|
|
|
|
-- listed, the built-in Visual Studio tools will be used
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.toolsets = {
|
2014-01-31 16:40:09 +00:00
|
|
|
ps3 = p.tools.snc
|
2013-03-07 15:45:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Identify the toolset to use for a given configuration. Returns nil to
|
|
|
|
-- use the built-in Visual Studio compiler, or a toolset interface to
|
|
|
|
-- use the alternate external compiler setup.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.toolset(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
return p.tools[cfg.toolset] or m.toolsets[cfg.system]
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
-- Write out all of the tool elements for a specific configuration
|
|
|
|
-- of the project.
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.tools(cfg)
|
|
|
|
local calls = m.toolsForConfig(cfg)
|
2014-01-24 18:06:52 +00:00
|
|
|
for i, tool in ipairs(calls) do
|
2014-01-28 15:42:49 +00:00
|
|
|
if m[tool] then
|
|
|
|
m[tool](cfg)
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCCLCompilerTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
2014-01-28 15:42:49 +00:00
|
|
|
m.compilerToolName(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
|
|
|
-- Decide between the built-in compiler or an external toolset;
|
|
|
|
-- PS3 uses the external toolset
|
2014-01-28 15:42:49 +00:00
|
|
|
local toolset = m.toolset(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
if toolset then
|
2014-01-28 15:42:49 +00:00
|
|
|
m.VCCLExternalCompilerTool(cfg, toolset)
|
2012-11-30 19:05:19 +00:00
|
|
|
else
|
2014-01-28 15:42:49 +00:00
|
|
|
m.VCCLBuiltInCompilerTool(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.builtInCompilerTool = function(cfg)
|
2014-01-16 19:22:38 +00:00
|
|
|
return {
|
2014-01-28 15:42:49 +00:00
|
|
|
m.enableEnhancedInstructionSet,
|
|
|
|
m.floatingPointModel,
|
|
|
|
m.runtimeTypeInfo,
|
|
|
|
m.treatWChar_tAsBuiltInType,
|
2014-01-16 19:22:38 +00:00
|
|
|
}
|
|
|
|
end
|
2013-09-27 18:25:10 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCCLBuiltInCompilerTool(cfg)
|
|
|
|
m.VCCLCompilerTool_additionalOptions(cfg)
|
|
|
|
m.optimization(cfg, 4)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if cfg.flags.NoFramePointer then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('OmitFramePointers="%s"', m.bool(true))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.additionalIncludeDirectories(cfg, cfg.includedirs)
|
|
|
|
m.wholeProgramOptimization(cfg)
|
|
|
|
m.preprocessorDefinitions(cfg, cfg.defines)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.minimalRebuild(cfg)
|
|
|
|
m.basicRuntimeChecks(cfg)
|
|
|
|
m.bufferSecurityCheck(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-10-16 17:47:09 +00:00
|
|
|
if config.isOptimizedBuild(cfg) then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('StringPooling="%s"', m.bool(true))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if cfg.flags.NoExceptions then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0))
|
2012-11-30 19:05:19 +00:00
|
|
|
elseif cfg.flags.SEH and _ACTION > "vs2003" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ExceptionHandling="2"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.runtimeLibrary(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('EnableFunctionLevelLinking="%s"', m.bool(true))
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.callArray(m.elements.builtInCompilerTool, cfg)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if not cfg.flags.NoPCH and cfg.pchheader then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
|
|
|
|
p.x('PrecompiledHeaderThrough="%s"', cfg.pchheader)
|
2012-11-30 19:05:19 +00:00
|
|
|
else
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.programDatabaseFileName(cfg)
|
|
|
|
m.warnings(cfg)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('DebugInformationFormat="%s"', m.symbols(cfg))
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if cfg.project.language == "C" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('CompileAs="1"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.forcedIncludeFiles(cfg)
|
|
|
|
m.omitDefaultLib(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCCLExternalCompilerTool(cfg, toolset)
|
|
|
|
m.VCCLExternalCompilerTool_additionalOptions(cfg, toolset)
|
|
|
|
m.additionalIncludeDirectories(cfg, cfg.includedirs)
|
|
|
|
m.preprocessorDefinitions(cfg, cfg.defines)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
|
|
|
if not cfg.flags.NoPCH and cfg.pchheader then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
|
|
|
|
p.x('PrecompiledHeaderThrough="%s"', cfg.pchheader)
|
2012-11-30 19:05:19 +00:00
|
|
|
else
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.programDatabaseFileName(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('DebugInformationFormat="0"')
|
|
|
|
p.w('CompileAs="0"')
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.forcedIncludeFiles(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.DebuggerTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('<DebuggerTool')
|
|
|
|
p.w('/>')
|
2013-02-08 15:35:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCLinkerTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="%s"', m.linkerTool(cfg))
|
2012-11-30 19:05:19 +00:00
|
|
|
|
|
|
|
-- Decide between the built-in linker or an external toolset;
|
|
|
|
-- PS3 uses the external toolset
|
2014-01-28 15:42:49 +00:00
|
|
|
local toolset = m.toolset(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
if toolset then
|
2014-01-28 15:42:49 +00:00
|
|
|
m.VCExternalLinkerTool(cfg, toolset)
|
2012-11-30 19:05:19 +00:00
|
|
|
else
|
2014-01-28 15:42:49 +00:00
|
|
|
m.VCBuiltInLinkerTool(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCBuiltInLinkerTool(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
local explicitLink = vstudio.needsExplicitLink(cfg)
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind ~= p.STATICLIB then
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if explicitLink then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('LinkLibraryDependencies="false"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if cfg.flags.NoImportLib then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('IgnoreImportLibrary="%s"', m.bool(true))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if #cfg.linkoptions > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.linkoptions, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if #cfg.links > 0 then
|
2014-01-28 15:42:49 +00:00
|
|
|
local links = m.links(cfg, explicitLink)
|
2012-11-30 19:05:19 +00:00
|
|
|
if links ~= "" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalDependencies="%s"', links)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind ~= p.STATICLIB then
|
|
|
|
p.w('LinkIncremental="%s"', iif(config.canLinkIncremental(cfg) , 2, 1))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.additionalLibraryDirectories(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind ~= p.STATICLIB then
|
2012-11-30 19:05:19 +00:00
|
|
|
local deffile = config.findfile(cfg, ".def")
|
|
|
|
if deffile then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ModuleDefinitionFile="%s"', deffile)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if cfg.flags.NoManifest then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('GenerateManifest="%s"', m.bool(false))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('GenerateDebugInformation="%s"', m.bool(m.symbols(cfg) ~= 0))
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
if m.symbols(cfg) >= 3 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('ProgramDataBaseFileName="$(OutDir)\\%s.pdb"', cfg.buildtarget.basename)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('SubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2))
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-10-16 17:47:09 +00:00
|
|
|
if config.isOptimizedBuild(cfg) then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('OptimizeReferences="2"')
|
|
|
|
p.w('EnableCOMDATFolding="2"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if (cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp") and not cfg.flags.WinMain then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('EntryPointSymbol="mainCRTStartup"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if cfg.kind == "SharedLib" then
|
|
|
|
local implibdir = cfg.linktarget.abspath
|
|
|
|
-- I can't actually stop the import lib, but I can hide it in the objects directory
|
|
|
|
if cfg.flags.NoImportLib then
|
|
|
|
implibdir = path.join(cfg.objdir, path.getname(implibdir))
|
|
|
|
end
|
|
|
|
implibdir = project.getrelative(cfg.project, implibdir)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('ImportLibrary="%s"', path.translate(implibdir))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('TargetMachine="%d"', iif(cfg.architecture == "x64", 17, 1))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCExternalLinkerTool(cfg, toolset)
|
2012-11-30 19:05:19 +00:00
|
|
|
local explicitLink = vstudio.needsExplicitLink(cfg)
|
|
|
|
|
|
|
|
local buildoptions = table.join(toolset.getldflags(cfg), cfg.linkoptions)
|
|
|
|
if #buildoptions > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(buildoptions, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
if #cfg.links > 0 then
|
|
|
|
local links = toolset.getlinks(cfg, not explicitLink)
|
|
|
|
if #links > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalDependencies="%s"', table.concat(links, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind ~= p.STATICLIB then
|
|
|
|
p.w('LinkIncremental="0"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.additionalLibraryDirectories(cfg)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind ~= p.STATICLIB then
|
|
|
|
p.w('GenerateManifest="%s"', m.bool(false))
|
|
|
|
p.w('ProgramDatabaseFile=""')
|
|
|
|
p.w('RandomizedBaseAddress="1"')
|
|
|
|
p.w('DataExecutionPrevention="0"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCManifestTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind == p.STATICLIB then
|
2013-05-21 15:55:00 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
local manifests = {}
|
2014-01-18 19:54:46 +00:00
|
|
|
for i, fname in ipairs(cfg.files) do
|
2012-11-30 19:05:19 +00:00
|
|
|
if path.getextension(fname) == ".manifest" then
|
|
|
|
table.insert(manifests, project.getrelative(cfg.project, fname))
|
|
|
|
end
|
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="VCManifestTool"')
|
2012-11-30 19:05:19 +00:00
|
|
|
if #manifests > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalManifestFiles="%s"', table.concat(manifests, ";"))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCMIDLTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="VCMIDLTool"')
|
2012-11-30 19:05:19 +00:00
|
|
|
if cfg.architecture == "x64" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('TargetEnvironment="3"')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCNMakeTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="VCNMakeTool"')
|
2014-01-28 15:42:49 +00:00
|
|
|
m.nmakeCommandLine(cfg, cfg.buildcommands, "Build")
|
|
|
|
m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild")
|
|
|
|
m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean")
|
|
|
|
m.nmakeOutput(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('PreprocessorDefinitions=""')
|
|
|
|
p.w('IncludeSearchPath=""')
|
|
|
|
p.w('ForcedIncludes=""')
|
|
|
|
p.w('AssemblySearchPath=""')
|
|
|
|
p.w('ForcedUsingAssemblies=""')
|
|
|
|
p.w('CompileAsManaged=""')
|
|
|
|
p.pop('/>')
|
2013-04-03 18:09:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCResourceCompilerTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="VCResourceCompilerTool"')
|
2012-11-30 19:05:19 +00:00
|
|
|
|
|
|
|
if #cfg.resoptions > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.resoptions, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.preprocessorDefinitions(cfg, table.join(cfg.defines, cfg.resdefines))
|
|
|
|
m.additionalIncludeDirectories(cfg, table.join(cfg.includedirs, cfg.resincludedirs))
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCBuildEventTool(cfg, event)
|
2014-01-15 21:12:29 +00:00
|
|
|
local name = "VC" .. event .. "EventTool"
|
|
|
|
local field = event:lower()
|
|
|
|
local steps = cfg[field .. "commands"]
|
|
|
|
local msg = cfg[field .. "message"]
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="%s"', name)
|
2012-11-30 19:05:19 +00:00
|
|
|
if #steps > 0 then
|
2014-01-15 21:12:29 +00:00
|
|
|
if msg then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('Description="%s"', msg)
|
2014-01-15 21:12:29 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('CommandLine="%s"', table.implode(steps, "", "", "\r\n"))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCPreBuildEventTool(cfg)
|
|
|
|
m.VCBuildEventTool(cfg, "PreBuild")
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCPreLinkEventTool(cfg)
|
|
|
|
m.VCBuildEventTool(cfg, "PreLink")
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCPostBuildEventTool(cfg)
|
|
|
|
m.VCBuildEventTool(cfg, "PostBuild")
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCX360DeploymentTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="VCX360DeploymentTool"')
|
|
|
|
p.w('DeploymentType="0"')
|
2012-11-30 19:05:19 +00:00
|
|
|
if #cfg.deploymentoptions > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.deploymentoptions, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCX360ImageTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="VCX360ImageTool"')
|
2012-11-30 19:05:19 +00:00
|
|
|
if #cfg.imageoptions > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.imageoptions, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
if cfg.imagepath ~= nil then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('OutputFileName="%s"', path.translate(cfg.imagepath))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
---------------------------------------------------------------------------
|
2013-03-04 16:45:27 +00:00
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
-- Handlers for the source file tree
|
2013-03-04 16:45:27 +00:00
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
---------------------------------------------------------------------------
|
2013-03-04 16:45:27 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.files(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Files>')
|
2013-06-13 18:10:02 +00:00
|
|
|
|
|
|
|
-- Fetch the source tree, sorted how Visual Studio likes it: alpha
|
|
|
|
-- sorted, with any leading ../ sequences ignored. At the top level
|
|
|
|
-- of the tree, files go after folders, otherwise before.
|
|
|
|
|
2013-05-21 15:55:00 +00:00
|
|
|
local tr = project.getsourcetree(prj, function(a,b)
|
2013-06-13 18:10:02 +00:00
|
|
|
local istop = (a.parent.parent == nil)
|
|
|
|
|
2013-05-21 15:55:00 +00:00
|
|
|
local aSortName = a.name
|
|
|
|
local bSortName = b.name
|
|
|
|
|
|
|
|
-- Only file nodes have a relpath field; folder nodes do not
|
2013-06-13 18:10:02 +00:00
|
|
|
if a.relpath then
|
|
|
|
if not b.relpath then
|
|
|
|
return not istop
|
|
|
|
end
|
|
|
|
aSortName = a.relpath:gsub("%.%.%/", "")
|
|
|
|
end
|
|
|
|
|
|
|
|
if b.relpath then
|
|
|
|
if not a.relpath then
|
|
|
|
return istop
|
|
|
|
end
|
|
|
|
bSortName = b.relpath:gsub("%.%.%/", "")
|
|
|
|
end
|
2013-05-21 15:55:00 +00:00
|
|
|
|
|
|
|
return aSortName < bSortName
|
|
|
|
end)
|
2013-03-04 16:45:27 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.tree.traverse(tr, {
|
2013-03-04 16:45:27 +00:00
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
-- folders, virtual or otherwise, are handled at the internal nodes
|
2014-01-31 16:40:09 +00:00
|
|
|
onbranchenter = function(node)
|
|
|
|
p.push('<Filter')
|
|
|
|
p.w('Name="%s"', node.name)
|
|
|
|
p.w('>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end,
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
onbranchexit = function(node)
|
|
|
|
p.pop('</Filter>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end,
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
-- source files are handled at the leaves
|
2014-01-31 16:40:09 +00:00
|
|
|
onleaf = function(node)
|
|
|
|
p.push('<File')
|
|
|
|
p.w('RelativePath="%s"', path.translate(node.relpath))
|
|
|
|
p.w('>')
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2014-01-31 16:40:09 +00:00
|
|
|
m.fileConfiguration(cfg, node)
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('</File>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
}, false, 2)
|
2013-06-13 18:10:02 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('</Files>')
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.fileConfiguration(cfg, node)
|
2013-07-12 15:07:26 +00:00
|
|
|
local filecfg = fileconfig.getconfig(node, cfg)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
-- Generate the individual sections of the file configuration
|
|
|
|
-- element and capture the results to a buffer. I will only
|
|
|
|
-- write the file configuration if the buffers are not empty.
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
local configAttribs = io.capture(function ()
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push()
|
|
|
|
m.fileConfiguration_extraAttributes(cfg, filecfg)
|
|
|
|
p.pop()
|
2013-03-12 22:26:19 +00:00
|
|
|
end)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
local compilerAttribs = io.capture(function ()
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push(2)
|
|
|
|
m.fileConfiguration_compilerAttributes(cfg, filecfg)
|
|
|
|
p.pop(2)
|
2013-03-12 22:26:19 +00:00
|
|
|
end)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
if #configAttribs > 0 or compilerAttribs:lines() > 1 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<FileConfiguration')
|
|
|
|
p.w('Name="%s"', vstudio.projectConfig(cfg))
|
2013-03-12 22:26:19 +00:00
|
|
|
if #configAttribs > 0 then
|
|
|
|
_p("%s", configAttribs)
|
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('>')
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
2013-03-12 22:26:19 +00:00
|
|
|
if #compilerAttribs > 0 then
|
|
|
|
_p("%s", compilerAttribs)
|
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
|
|
|
p.pop('</FileConfiguration>')
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
--
|
|
|
|
-- Collect extra attributes for the opening element of a particular file
|
|
|
|
-- configuration block.
|
|
|
|
--
|
|
|
|
-- @param cfg
|
|
|
|
-- The project configuration under consideration.
|
|
|
|
-- @param filecfg
|
|
|
|
-- The file configuration under consideration.
|
|
|
|
--
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.fileConfiguration_extraAttributes(cfg, filecfg)
|
|
|
|
m.excludedFromBuild(filecfg)
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
--
|
|
|
|
-- Collect attributes for the compiler tool element of a particular
|
|
|
|
-- file configuration block.
|
|
|
|
--
|
|
|
|
-- @param cfg
|
|
|
|
-- The project configuration under consideration.
|
|
|
|
-- @param filecfg
|
|
|
|
-- The file configuration under consideration.
|
|
|
|
--
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.fileConfiguration_compilerAttributes(cfg, filecfg)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
-- Must always have a name attribute
|
2014-01-31 16:40:09 +00:00
|
|
|
m.compilerToolName(cfg, filecfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-03-12 22:26:19 +00:00
|
|
|
if filecfg then
|
2014-01-31 16:40:09 +00:00
|
|
|
m.customBuildTool(filecfg)
|
|
|
|
m.objectFile(filecfg)
|
|
|
|
m.optimization(filecfg)
|
|
|
|
m.usePrecompiledHeader(filecfg)
|
|
|
|
m.VCCLCompilerTool_fileConfig_additionalOptions(filecfg)
|
|
|
|
m.forcedIncludeFiles(filecfg)
|
|
|
|
m.compileAs(filecfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-03-12 22:26:19 +00:00
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2013-10-18 14:38:00 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
-- Support functions
|
|
|
|
--
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Build a list architectures which are used by a project.
|
|
|
|
--
|
|
|
|
-- @param prj
|
|
|
|
-- The project under consideration.
|
|
|
|
-- @return
|
|
|
|
-- An array of Visual Studio architectures.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.architectures(prj)
|
2013-10-18 14:38:00 +00:00
|
|
|
architectures = {}
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
local arch = vstudio.archFromConfig(cfg, true)
|
|
|
|
if not table.contains(architectures, arch) then
|
|
|
|
table.insert(architectures, arch)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return architectures
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Return a properly cased boolean for the current Visual Studio version.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.bool(value)
|
2013-10-18 14:38:00 +00:00
|
|
|
if (_ACTION < "vs2005") then
|
|
|
|
return iif(value, "TRUE", "FALSE")
|
|
|
|
else
|
|
|
|
return iif(value, "true", "false")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Returns the list of libraries required to link a specific configuration,
|
|
|
|
-- formatted for Visual Studio's XML.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.links(cfg, explicit)
|
2013-10-18 14:38:00 +00:00
|
|
|
local scope = iif(explicit, "all", "system")
|
|
|
|
local links = config.getlinks(cfg, scope, "fullpath")
|
|
|
|
for i, link in ipairs(links) do
|
|
|
|
if link:find(" ", 1, true) then
|
|
|
|
link = '"' .. link .. '"'
|
|
|
|
end
|
|
|
|
links[i] = path.translate(link)
|
|
|
|
end
|
|
|
|
return table.concat(links, " ")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Returns the correct name for the linker tool element, based on
|
|
|
|
-- the configuration target system.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.linkerTool(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.kind == p.STATICLIB then
|
2013-10-18 14:38:00 +00:00
|
|
|
return "VCLibrarianTool"
|
2014-01-31 16:40:09 +00:00
|
|
|
elseif cfg.system == p.XBOX360 then
|
2013-10-18 14:38:00 +00:00
|
|
|
return "VCX360LinkerTool"
|
|
|
|
else
|
|
|
|
return "VCLinkerTool"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Return the debugging symbol level for a configuration.
|
|
|
|
--
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.symbols(cfg)
|
2013-10-18 14:38:00 +00:00
|
|
|
if not cfg.flags.Symbols then
|
|
|
|
return 0
|
|
|
|
elseif cfg.debugformat == "c7" then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
-- Edit-and-continue doesn't work for some configurations
|
|
|
|
if cfg.flags.NoEditAndContinue or
|
|
|
|
config.isOptimizedBuild(cfg) or
|
|
|
|
cfg.flags.Managed or
|
|
|
|
cfg.system == "x64" or
|
|
|
|
cfg.platform == "x64" -- TODO: remove this when the _ng stuff goes live
|
|
|
|
then
|
|
|
|
return 3
|
|
|
|
else
|
|
|
|
return 4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
---------------------------------------------------------------------------
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
-- Handlers for individual project elements
|
2012-11-30 19:05:19 +00:00
|
|
|
--
|
2013-03-07 15:45:33 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.additionalIncludeDirectories(cfg, includedirs)
|
2012-11-30 19:05:19 +00:00
|
|
|
if #includedirs > 0 then
|
|
|
|
local dirs = project.getrelative(cfg.project, includedirs)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalIncludeDirectories="%s"', path.translate(table.concat(dirs, ";")))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.additionalLibraryDirectories(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
if #cfg.libdirs > 0 then
|
|
|
|
local dirs = table.concat(project.getrelative(cfg.project, cfg.libdirs), ";")
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalLibraryDirectories="%s"', path.translate(dirs))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCCLCompilerTool_additionalOptions(cfg)
|
2013-03-07 15:45:33 +00:00
|
|
|
local opts = cfg.buildoptions
|
|
|
|
if cfg.flags.MultiProcessorCompile then
|
|
|
|
table.insert(opts, "/MP")
|
|
|
|
end
|
|
|
|
if #opts > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(opts, " "))
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.VCCLCompilerTool_fileConfig_additionalOptions(filecfg)
|
2013-03-12 22:26:19 +00:00
|
|
|
local opts = filecfg.buildoptions
|
|
|
|
if #opts > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(opts, " "))
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.VCCLExternalCompilerTool_additionalOptions(cfg, toolset)
|
2013-03-07 15:45:33 +00:00
|
|
|
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
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('AdditionalOptions="%s"', table.concat(buildoptions, " "))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.assemblyReferences(prj)
|
2013-03-07 15:45:33 +00:00
|
|
|
-- Visual Studio doesn't support per-config references
|
|
|
|
local cfg = project.getfirstconfig(prj)
|
|
|
|
local refs = config.getlinks(cfg, "system", "fullpath", "managed")
|
|
|
|
table.foreachi(refs, function(value)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<AssemblyReference')
|
|
|
|
p.x('RelativePath="%s"', path.translate(value))
|
|
|
|
p.pop('/>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.basicRuntimeChecks(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if not config.isOptimizedBuild(cfg)
|
2013-03-07 15:45:33 +00:00
|
|
|
and not cfg.flags.Managed
|
|
|
|
and not cfg.flags.NoRuntimeChecks
|
|
|
|
then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('BasicRuntimeChecks="3"')
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.bufferSecurityCheck(cfg)
|
2013-08-15 22:22:23 +00:00
|
|
|
if cfg.flags.NoBufferSecurityCheck then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('BufferSecurityCheck="false"')
|
2013-08-15 22:22:23 +00:00
|
|
|
end
|
|
|
|
end
|
2013-03-07 15:45:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.characterSet(cfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if not vstudio.isMakefile(cfg) then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2))
|
2013-04-03 18:09:39 +00:00
|
|
|
end
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.compileAs(filecfg)
|
2013-03-28 14:33:28 +00:00
|
|
|
if path.iscfile(filecfg.name) ~= project.isc(filecfg.project) then
|
2013-03-12 22:26:19 +00:00
|
|
|
if path.iscppfile(filecfg.name) then
|
2014-01-31 16:40:09 +00:00
|
|
|
local value = iif(filecfg.project.language == p.CPP, 1, 2)
|
|
|
|
p.w('CompileAs="%s"', value)
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.compilerToolName(cfg, filecfg)
|
2013-03-12 22:26:19 +00:00
|
|
|
local name
|
2013-07-12 15:07:26 +00:00
|
|
|
if fileconfig.hasCustomBuildRule(filecfg) then
|
2013-03-12 22:26:19 +00:00
|
|
|
name = "VCCustomBuildTool"
|
|
|
|
else
|
2014-01-31 16:40:09 +00:00
|
|
|
name = iif(cfg.system == p.XBOX360, "VCCLX360CompilerTool", "VCCLCompilerTool")
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Name="%s"', name)
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.configurationType(cfg)
|
2013-04-03 18:09:39 +00:00
|
|
|
local cfgtypes = {
|
|
|
|
Makefile = 0,
|
2013-06-26 11:28:57 +00:00
|
|
|
None = 0,
|
2013-04-03 18:09:39 +00:00
|
|
|
SharedLib = 2,
|
|
|
|
StaticLib = 4,
|
|
|
|
}
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ConfigurationType="%s"', cfgtypes[cfg.kind] or 1)
|
2013-04-03 18:09:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.customBuildTool(filecfg)
|
2013-07-12 15:07:26 +00:00
|
|
|
if fileconfig.hasCustomBuildRule(filecfg) then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('CommandLine="%s"', table.concat(filecfg.buildcommands,'\r\n'))
|
2013-04-09 19:12:04 +00:00
|
|
|
|
|
|
|
local outputs = project.getrelative(filecfg.project, filecfg.buildoutputs)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('Outputs="%s"', table.concat(outputs, ' '))
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.enableEnhancedInstructionSet(cfg)
|
2013-09-27 18:49:21 +00:00
|
|
|
local map = { SSE = "1", SSE2 = "2" }
|
|
|
|
local value = map[cfg.vectorextensions]
|
|
|
|
if value and cfg.system ~= "Xbox360" and cfg.architecture ~= "x64" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('EnableEnhancedInstructionSet="%d"', value)
|
2013-09-27 18:49:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.excludedFromBuild(filecfg)
|
2013-03-12 22:26:19 +00:00
|
|
|
if not filecfg or filecfg.flags.ExcludeFromBuild then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ExcludedFromBuild="true"')
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.floatingPointModel(cfg)
|
2013-09-27 18:49:21 +00:00
|
|
|
local map = { Strict = "1", Fast = "2" }
|
|
|
|
local value = map[cfg.floatingpoint]
|
|
|
|
if value then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('FloatingPointModel="%d"', value)
|
2013-09-27 18:49:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.forcedIncludeFiles(cfg)
|
2012-11-30 19:05:19 +00:00
|
|
|
if #cfg.forceincludes > 0 then
|
2013-03-12 22:26:19 +00:00
|
|
|
local includes = path.translate(project.getrelative(cfg.project, cfg.forceincludes))
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ForcedIncludeFiles="%s"', table.concat(includes, ';'))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
2013-02-20 14:57:37 +00:00
|
|
|
if #cfg.forceusings > 0 then
|
2013-03-12 22:26:19 +00:00
|
|
|
local usings = path.translate(project.getrelative(cfg.project, cfg.forceusings))
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ForcedUsingFiles="%s"', table.concat(usings, ';'))
|
2013-02-20 14:57:37 +00:00
|
|
|
end
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.omitDefaultLib(cfg)
|
2013-10-30 04:03:24 +00:00
|
|
|
if cfg.flags.OmitDefaultLibrary then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('OmitDefaultLibName="true"')
|
2013-10-30 04:03:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.keyword(prj)
|
2013-10-23 14:51:11 +00:00
|
|
|
local windows, managed, makefile
|
|
|
|
for cfg in project.eachconfig(prj) do
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.system == p.WINDOWS then windows = true end
|
2013-10-23 14:51:11 +00:00
|
|
|
if cfg.flags.Managed then managed = true end
|
|
|
|
if vstudio.isMakefile(cfg) then makefile = true end
|
|
|
|
end
|
|
|
|
|
|
|
|
if windows then
|
|
|
|
local keyword = "Win32Proj"
|
|
|
|
if managed then
|
|
|
|
keyword = "ManagedCProj"
|
|
|
|
end
|
|
|
|
if makefile then
|
|
|
|
keyword = "MakeFileProj"
|
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Keyword="%s"', keyword)
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.intermediateDirectory(cfg)
|
2013-10-28 15:01:41 +00:00
|
|
|
local objdir = project.getrelative(cfg.project, cfg.objdir)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('IntermediateDirectory="%s"', path.translate(objdir))
|
2013-10-28 15:01:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.managedExtensions(cfg)
|
2013-10-28 15:01:41 +00:00
|
|
|
if cfg.flags.Managed then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ManagedExtensions="1"')
|
2013-10-28 15:01:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.minimalRebuild(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if config.isDebugBuild(cfg) and
|
2013-03-07 15:45:33 +00:00
|
|
|
cfg.debugformat ~= "c7" and
|
|
|
|
not cfg.flags.NoMinimalRebuild and
|
|
|
|
not cfg.flags.Managed and
|
|
|
|
not cfg.flags.MultiProcessorCompile
|
|
|
|
then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('MinimalRebuild="%s"', m.bool(true))
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.nmakeCommandLine(cfg, commands, phase)
|
2013-04-07 18:30:58 +00:00
|
|
|
commands = table.concat(commands, "\r\n")
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('%sCommandLine="%s"', phase, p.esc(commands))
|
2013-04-07 18:30:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.nmakeOutput(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Output="$(OutDir)%s"', cfg.buildtarget.name)
|
2013-04-03 18:09:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.objectFile(filecfg)
|
2013-03-12 22:26:19 +00:00
|
|
|
if path.iscppfile(filecfg.name) then
|
2013-06-21 21:32:33 +00:00
|
|
|
if filecfg.objname ~= path.getbasename(filecfg.abspath) then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('ObjectFile="$(IntDir)\\%s.obj"', filecfg.objname)
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.optimization(cfg)
|
2013-10-16 18:29:49 +00:00
|
|
|
local map = { Off=0, On=3, Debug=0, Full=3, Size=1, Speed=2 }
|
|
|
|
local value = map[cfg.optimize]
|
|
|
|
if value or not cfg.abspath then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Optimization="%s"', value or 0)
|
2013-10-16 18:29:49 +00:00
|
|
|
end
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.outputDirectory(cfg)
|
2013-10-28 15:01:41 +00:00
|
|
|
local outdir = project.getrelative(cfg.project, cfg.buildtarget.directory)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('OutputDirectory="%s"', path.translate(outdir))
|
2013-10-28 15:01:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.platforms(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Platforms>')
|
2014-01-28 15:42:49 +00:00
|
|
|
table.foreachi(m.architectures(prj), function(arch)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Platform')
|
|
|
|
p.w('Name="%s"', arch)
|
|
|
|
p.pop('/>')
|
2013-10-18 14:38:00 +00:00
|
|
|
end)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('</Platforms>')
|
2013-10-18 14:38:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.preprocessorDefinitions(cfg, defines)
|
2013-03-07 15:45:33 +00:00
|
|
|
if #defines > 0 then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('PreprocessorDefinitions="%s"', table.concat(defines, ";"))
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.programDatabaseFileName(cfg)
|
2013-03-07 15:45:33 +00:00
|
|
|
local target = cfg.buildtarget
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('ProgramDataBaseFileName="$(OutDir)\\%s%s.pdb"', target.prefix, target.basename)
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.projectGUID(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ProjectGUID="{%s}"', prj.uuid)
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.projectName(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('Name="%s"', prj.name)
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.projectReferences(prj)
|
2013-03-07 15:45:33 +00:00
|
|
|
local deps = project.getdependencies(prj)
|
|
|
|
if #deps > 0 then
|
2013-05-23 15:46:50 +00:00
|
|
|
|
|
|
|
-- This is a little odd: Visual Studio wants the "relative path to project"
|
2013-07-12 15:07:26 +00:00
|
|
|
-- to be relative to the *solution*, rather than the project doing the
|
2013-05-23 15:46:50 +00:00
|
|
|
-- referencing. Which, in theory, would break if the project is included
|
|
|
|
-- in more than one solution. But that's how they do it.
|
|
|
|
|
2014-01-18 19:54:46 +00:00
|
|
|
for i, dep in ipairs(deps) do
|
2013-05-23 15:46:50 +00:00
|
|
|
|
2013-09-30 14:16:56 +00:00
|
|
|
local relpath = path.getrelative(prj.solution.location, vstudio.projectfile(dep))
|
2013-05-23 15:46:50 +00:00
|
|
|
|
|
|
|
-- Visual Studio wants the path to start with ./ or ../
|
|
|
|
if not relpath:startswith(".") then
|
|
|
|
relpath = "./" .. relpath
|
|
|
|
end
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<ProjectReference')
|
|
|
|
p.w('ReferencedProjectIdentifier="{%s}"', dep.uuid)
|
|
|
|
p.w('RelativePathToProject="%s"', path.translate(relpath))
|
|
|
|
p.pop('/>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.projectType(prj)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ProjectType="Visual C++"')
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.rootNamespace(prj)
|
2013-10-23 14:51:11 +00:00
|
|
|
local hasWindows = project.hasConfig(prj, function(cfg)
|
2014-01-31 16:40:09 +00:00
|
|
|
return cfg.system == p.WINDOWS
|
2013-10-23 14:51:11 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
-- Technically, this should be skipped for pure makefile projects that
|
|
|
|
-- do not contain any empty configurations. But I need to figure out a
|
|
|
|
-- a good way to check the empty configuration bit first.
|
|
|
|
|
|
|
|
if hasWindows and _ACTION > "vs2003" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('RootNamespace="%s"', prj.name)
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.runtimeLibrary(cfg)
|
2013-03-27 15:12:37 +00:00
|
|
|
local runtimes = {
|
|
|
|
StaticRelease = 0,
|
|
|
|
StaticDebug = 1,
|
|
|
|
SharedRelease = 2,
|
|
|
|
SharedDebug = 3,
|
|
|
|
}
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('RuntimeLibrary="%s"', runtimes[config.getruntime(cfg)])
|
2013-03-27 15:12:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.runtimeTypeInfo(cfg)
|
2013-09-27 19:12:50 +00:00
|
|
|
if cfg.flags.NoRTTI and not cfg.flags.Managed then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('RuntimeTypeInfo="false"')
|
2013-09-27 19:12:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.targetFrameworkVersion(prj)
|
2013-10-23 14:51:11 +00:00
|
|
|
local windows, makefile
|
|
|
|
for cfg in project.eachconfig(prj) do
|
2014-01-31 16:40:09 +00:00
|
|
|
if cfg.system == p.WINDOWS then windows = true end
|
2013-10-23 14:51:11 +00:00
|
|
|
if vstudio.isMakefile(cfg) then makefile = true end
|
|
|
|
end
|
|
|
|
|
|
|
|
local version = 0
|
|
|
|
if makefile or not windows then
|
|
|
|
version = 196613
|
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('TargetFrameworkVersion="%d"', version)
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.tool(name)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
|
|
|
p.w('Name="%s"', name)
|
|
|
|
p.pop('/>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.toolFiles(prj)
|
2013-05-21 15:55:00 +00:00
|
|
|
if _ACTION > "vs2003" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('<ToolFiles>')
|
|
|
|
p.w('</ToolFiles>')
|
2013-05-21 15:55:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.treatWChar_tAsBuiltInType(cfg)
|
2013-09-27 19:12:50 +00:00
|
|
|
local map = { On = "true", Off = "false" }
|
|
|
|
local value = map[cfg.nativewchar]
|
|
|
|
if value then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('TreatWChar_tAsBuiltInType="%s"', value)
|
2013-09-27 19:12:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.useOfMFC(cfg)
|
2013-10-28 15:01:41 +00:00
|
|
|
if (cfg.flags.MFC) then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('UseOfMFC="%d"', iif(cfg.flags.StaticRuntime, 1, 2))
|
2013-10-28 15:01:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
function m.usePrecompiledHeader(filecfg)
|
2013-03-12 22:26:19 +00:00
|
|
|
local cfg = filecfg.config
|
|
|
|
if cfg.pchsource == filecfg.abspath and
|
|
|
|
not cfg.flags.NoPCH and
|
2014-01-31 16:40:09 +00:00
|
|
|
cfg.system ~= p.PS3
|
2013-03-12 22:26:19 +00:00
|
|
|
then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('UsePrecompiledHeader="1"')
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.version(prj)
|
2013-10-23 14:51:11 +00:00
|
|
|
local map = {
|
|
|
|
vs2002 = '7.0',
|
|
|
|
vs2003 = '7.1',
|
|
|
|
vs2005 = '8.0',
|
|
|
|
vs2008 = '9.0'
|
|
|
|
}
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Version="%s0"', map[_ACTION])
|
2013-10-23 14:51:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.warnings(cfg)
|
2013-09-29 16:39:07 +00:00
|
|
|
if cfg.warnings == "Off" then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('WarningLevel="0"')
|
2013-09-29 16:39:07 +00:00
|
|
|
else
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('WarningLevel="%d"', iif(cfg.warnings == "Extra", 4, 3))
|
2013-09-29 16:39:07 +00:00
|
|
|
if cfg.flags.FatalWarnings then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('WarnAsError="%s"', m.bool(true))
|
2013-09-29 16:39:07 +00:00
|
|
|
end
|
|
|
|
if _ACTION < "vs2008" and not cfg.flags.Managed then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Detect64BitPortabilityProblems="%s"', m.bool(not cfg.flags.No64BitChecks))
|
2013-09-29 16:39:07 +00:00
|
|
|
end
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.wholeProgramOptimization(cfg)
|
2013-09-27 18:49:21 +00:00
|
|
|
if cfg.flags.LinkTimeOptimization then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.x('WholeProgramOptimization="true"')
|
2013-09-27 18:49:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.xmlElement()
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('<?xml version="1.0" encoding="Windows-1252"?>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|