2012-11-30 19:05:19 +00:00
|
|
|
--
|
|
|
|
-- vs200x_vcproj.lua
|
|
|
|
-- Generate a Visual Studio 2002-2008 C/C++ project.
|
2014-02-27 14:54:55 +00:00
|
|
|
-- Copyright (c) 2009-2014 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-02-08 15:44:57 +00:00
|
|
|
p.indent("\t")
|
2014-01-31 16:40:09 +00:00
|
|
|
p.callArray(m.elements.project, prj)
|
|
|
|
p.pop('</VisualStudioProject>')
|
2015-08-24 20:06:57 +00:00
|
|
|
p.w()
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-16 19:22:38 +00:00
|
|
|
|
2014-02-11 16:11:46 +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.
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
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
|
|
|
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
2013-10-18 14:38:00 +00:00
|
|
|
-- Write out the <Configurations> element group, enumerating each of the
|
|
|
|
-- configuration-architecture pairings.
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.configurations(prj)
|
2014-02-18 15:59:56 +00:00
|
|
|
p.push('<Configurations>')
|
|
|
|
|
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
|
2014-02-18 15:59:56 +00:00
|
|
|
-- DLL DCRT|PS3). Start by building a map between configurations and
|
|
|
|
-- their Visual Studio names. I will use this to determine which
|
|
|
|
-- pairings are "real", and which need to be synthesized.
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
local mapping = {}
|
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)
|
2014-02-18 15:59:56 +00:00
|
|
|
mapping[cfg] = name
|
|
|
|
mapping[name] = cfg
|
2013-10-18 14:38:00 +00:00
|
|
|
end
|
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
-- Now enumerate each configuration and architecture pairing
|
2013-10-18 14:38:00 +00:00
|
|
|
|
|
|
|
for cfg in project.eachconfig(prj) do
|
2014-01-18 19:54:46 +00:00
|
|
|
for i, arch in ipairs(architectures) do
|
2014-02-18 15:59:56 +00:00
|
|
|
local target
|
|
|
|
|
|
|
|
-- Generate a Visual Studio name from this pairing and see if
|
|
|
|
-- it matches. If so, I can go ahead and output the markup for
|
|
|
|
-- this configuration.
|
|
|
|
|
2013-10-28 15:01:41 +00:00
|
|
|
local testName = vstudio.projectConfig(cfg, arch)
|
2014-02-18 15:59:56 +00:00
|
|
|
if testName == mapping[cfg] then
|
|
|
|
target = cfg
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
-- Okay, this pairing doesn't match this configuration. Check
|
|
|
|
-- the mapping to see if it matches some *other* configuration.
|
|
|
|
-- If it does, I can ignore it as it will getting written on
|
|
|
|
-- another pass through the loop. If it does not, then this is
|
|
|
|
-- one of those fake configurations that I have to synthesize.
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
elseif not mapping[testName] then
|
|
|
|
target = { fake = true }
|
|
|
|
end
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
-- If I'm not ignoring this pairing, output the result now
|
2013-10-18 14:38:00 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
if target then
|
|
|
|
m.configuration(target, testName)
|
|
|
|
m.tools(target)
|
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
|
|
|
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
2012-11-30 19:05:19 +00:00
|
|
|
-- Write out the <Configuration> element, describing a specific Premake
|
|
|
|
-- build configuration/platform pairing.
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
m.elements.configuration = function(cfg)
|
2014-02-18 15:59:56 +00:00
|
|
|
if cfg.fake then
|
|
|
|
return {
|
|
|
|
m.intermediateDirectory,
|
|
|
|
m.configurationType
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.outputDirectory,
|
|
|
|
m.intermediateDirectory,
|
|
|
|
m.configurationType,
|
|
|
|
m.useOfMFC,
|
|
|
|
m.characterSet,
|
2014-02-27 12:47:51 +00:00
|
|
|
m.managedExtensions,
|
2014-02-18 15:59:56 +00:00
|
|
|
}
|
|
|
|
end
|
2014-01-16 19:22:38 +00:00
|
|
|
end
|
2013-10-28 15:01:41 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
function m.configuration(cfg, name)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Configuration')
|
2014-02-18 15:59:56 +00:00
|
|
|
p.w('Name="%s"', name)
|
2014-01-31 16:40:09 +00:00
|
|
|
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
|
|
|
|
2014-02-21 14:04:52 +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, all
|
|
|
|
-- of which are implemented farther down in this file.
|
|
|
|
--
|
|
|
|
-- @param cfg
|
|
|
|
-- The configuration being written.
|
2014-02-27 14:54:55 +00:00
|
|
|
---
|
2014-02-21 14:04:52 +00:00
|
|
|
|
|
|
|
m.elements.tools = function(cfg)
|
|
|
|
if vstudio.isMakefile(cfg) and not cfg.fake then
|
|
|
|
return {
|
|
|
|
m.VCNMakeTool
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if cfg.system == p.XBOX360 then
|
|
|
|
return {
|
|
|
|
m.VCPreBuildEventTool,
|
|
|
|
m.VCCustomBuildTool,
|
|
|
|
m.VCXMLDataGeneratorTool,
|
|
|
|
m.VCWebServiceProxyGeneratorTool,
|
|
|
|
m.VCMIDLTool,
|
|
|
|
m.VCCLCompilerTool,
|
|
|
|
m.VCManagedResourceCompilerTool,
|
|
|
|
m.VCResourceCompilerTool,
|
|
|
|
m.VCPreLinkEventTool,
|
|
|
|
m.VCLinkerTool,
|
|
|
|
m.VCALinkTool,
|
|
|
|
m.VCX360ImageTool,
|
|
|
|
m.VCBscMakeTool,
|
|
|
|
m.VCX360DeploymentTool,
|
|
|
|
m.VCPostBuildEventTool,
|
|
|
|
m.DebuggerTool,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.VCPreBuildEventTool,
|
|
|
|
m.VCCustomBuildTool,
|
|
|
|
m.VCXMLDataGeneratorTool,
|
|
|
|
m.VCWebServiceProxyGeneratorTool,
|
|
|
|
m.VCMIDLTool,
|
|
|
|
m.VCCLCompilerTool,
|
|
|
|
m.VCManagedResourceCompilerTool,
|
|
|
|
m.VCResourceCompilerTool,
|
|
|
|
m.VCPreLinkEventTool,
|
|
|
|
m.VCLinkerTool,
|
|
|
|
m.VCALinkTool,
|
|
|
|
m.VCManifestTool,
|
|
|
|
m.VCXDCMakeTool,
|
|
|
|
m.VCBscMakeTool,
|
|
|
|
m.VCFxCopTool,
|
|
|
|
m.VCAppVerifierTool,
|
|
|
|
m.VCPostBuildEventTool,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.tools(cfg)
|
2014-02-27 14:54:55 +00:00
|
|
|
premake.callArray(m.elements.tools, cfg, config.toolset(cfg))
|
2014-02-21 14:04:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
2013-10-18 14:38:00 +00:00
|
|
|
-- Write out the <References> element group.
|
2014-02-11 16:11:46 +00:00
|
|
|
---
|
2013-10-18 14:38:00 +00:00
|
|
|
|
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
|
|
|
|
2014-03-20 15:21:02 +00:00
|
|
|
---
|
|
|
|
-- Write out the <Files> element group.
|
|
|
|
---
|
|
|
|
|
|
|
|
function m.files(prj)
|
|
|
|
local tr = m.filesSorted(prj)
|
|
|
|
p.push('<Files>')
|
|
|
|
p.tree.traverse(tr, {
|
|
|
|
onbranchenter = m.filesFilterStart,
|
|
|
|
onbranchexit = m.filesFilterEnd,
|
|
|
|
onleaf = m.filesFile,
|
|
|
|
}, false)
|
|
|
|
p.pop('</Files>')
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.filesSorted(prj)
|
|
|
|
-- 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.
|
|
|
|
return project.getsourcetree(prj, function(a,b)
|
|
|
|
local istop = (a.parent.parent == nil)
|
|
|
|
|
|
|
|
local aSortName = a.name
|
|
|
|
local bSortName = b.name
|
|
|
|
|
|
|
|
-- Only file nodes have a relpath field; folder nodes do not
|
|
|
|
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
|
|
|
|
|
|
|
|
return aSortName < bSortName
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.filesFilterStart(node)
|
|
|
|
p.push('<Filter')
|
|
|
|
p.w('Name="%s"', node.name)
|
|
|
|
p.w('>')
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.filesFilterEnd(node)
|
|
|
|
p.pop('</Filter>')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.filesFile(node)
|
|
|
|
p.push('<File')
|
|
|
|
p.w('RelativePath="%s"', path.translate(node.relpath))
|
|
|
|
p.w('>')
|
|
|
|
local prj = node.project
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
m.fileConfiguration(cfg, node)
|
|
|
|
end
|
|
|
|
p.pop('</File>')
|
|
|
|
end
|
|
|
|
|
|
|
|
m.elements.fileConfigurationAttributes = function(filecfg)
|
|
|
|
return {
|
|
|
|
m.excludedFromBuild,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.fileConfiguration(cfg, node)
|
|
|
|
local filecfg = fileconfig.getconfig(node, cfg)
|
|
|
|
|
|
|
|
-- 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.
|
|
|
|
|
|
|
|
local configAttribs = p.capture(function ()
|
|
|
|
p.push()
|
|
|
|
p.callArray(m.elements.fileConfigurationAttributes, filecfg)
|
|
|
|
p.pop()
|
|
|
|
end)
|
|
|
|
|
|
|
|
local compilerAttribs = p.capture(function ()
|
2014-04-03 15:00:47 +00:00
|
|
|
p.push()
|
|
|
|
m.VCCLCompilerTool(filecfg)
|
|
|
|
p.pop()
|
2014-03-20 15:21:02 +00:00
|
|
|
end)
|
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
-- lines() > 3 skips empty <Tool Name="VCCLCompiler" /> elements
|
|
|
|
if #configAttribs > 0 or compilerAttribs:lines() > 3 then
|
2014-03-20 15:21:02 +00:00
|
|
|
p.push('<FileConfiguration')
|
|
|
|
p.w('Name="%s"', vstudio.projectConfig(cfg))
|
|
|
|
if #configAttribs > 0 then
|
|
|
|
p.outln(configAttribs)
|
|
|
|
end
|
|
|
|
p.w('>')
|
2014-04-03 15:00:47 +00:00
|
|
|
p.outln(compilerAttribs)
|
2014-03-20 15:21:02 +00:00
|
|
|
p.pop('</FileConfiguration>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-11 16:11:46 +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-02-11 16:11:46 +00:00
|
|
|
---
|
2013-10-18 14:38:00 +00:00
|
|
|
|
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
|
2014-03-06 15:11:08 +00:00
|
|
|
-- The name of the tool, e.g. "VCCustomBuildTool".
|
2014-01-24 18:06:52 +00:00
|
|
|
-- @param ...
|
|
|
|
-- Any additional arguments required by the call list.
|
|
|
|
---
|
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
function m.VCTool(name, cfg, ...)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Tool')
|
2014-02-18 15:59:56 +00:00
|
|
|
|
|
|
|
local nameFunc = m[name .. "Name"]
|
|
|
|
local callFunc = m.elements[name]
|
|
|
|
|
|
|
|
if nameFunc then
|
|
|
|
name = nameFunc(cfg, ...)
|
|
|
|
end
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('Name="%s"', name)
|
2014-02-18 15:59:56 +00:00
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
if cfg and not cfg.fake then
|
2014-02-18 15:59:56 +00:00
|
|
|
p.callArray(callFunc, cfg, ...)
|
|
|
|
end
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2014-01-24 18:06:52 +00:00
|
|
|
end
|
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
m.elements.DebuggerTool = function(cfg)
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.DebuggerTool(cfg)
|
2014-02-21 14:04:52 +00:00
|
|
|
p.push('<DebuggerTool')
|
|
|
|
p.pop('/>')
|
2014-02-18 15:59:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-02-11 16:11:46 +00:00
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
2014-02-11 16:11:46 +00:00
|
|
|
m.elements.VCCLCompilerTool = function(cfg, toolset)
|
|
|
|
if not toolset then
|
2014-02-21 14:04:52 +00:00
|
|
|
-- not a custom tool, use the standard set of attributes
|
2014-02-11 16:11:46 +00:00
|
|
|
return {
|
2014-04-03 15:00:47 +00:00
|
|
|
m.customBuildTool,
|
|
|
|
m.objectFile,
|
|
|
|
m.additionalCompilerOptions,
|
2014-02-11 16:11:46 +00:00
|
|
|
m.optimization,
|
|
|
|
m.additionalIncludeDirectories,
|
|
|
|
m.wholeProgramOptimization,
|
|
|
|
m.preprocessorDefinitions,
|
2015-03-09 22:49:19 +00:00
|
|
|
m.undefinePreprocessorDefinitions,
|
2014-02-11 16:11:46 +00:00
|
|
|
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,
|
2014-03-06 15:11:08 +00:00
|
|
|
m.programDataBaseFileName,
|
2014-04-08 18:33:01 +00:00
|
|
|
m.warningLevel,
|
|
|
|
m.warnAsError,
|
|
|
|
m.detect64BitPortabilityProblems,
|
2014-02-11 16:11:46 +00:00
|
|
|
m.debugInformationFormat,
|
|
|
|
m.compileAs,
|
2015-03-09 23:53:46 +00:00
|
|
|
m.disableSpecificWarnings,
|
2014-02-11 16:11:46 +00:00
|
|
|
m.forcedIncludeFiles,
|
|
|
|
m.omitDefaultLib,
|
|
|
|
}
|
|
|
|
else
|
2014-02-21 14:04:52 +00:00
|
|
|
-- custom tool, use subset of attributes
|
2014-02-11 16:11:46 +00:00
|
|
|
return {
|
2014-04-03 15:00:47 +00:00
|
|
|
m.additionalExternalCompilerOptions,
|
2014-02-11 16:11:46 +00:00
|
|
|
m.additionalIncludeDirectories,
|
|
|
|
m.preprocessorDefinitions,
|
2015-03-09 22:49:19 +00:00
|
|
|
m.undefinePreprocessorDefinitions,
|
2014-02-11 16:11:46 +00:00
|
|
|
m.usePrecompiledHeader,
|
2014-03-06 15:11:08 +00:00
|
|
|
m.programDataBaseFileName,
|
2014-02-11 16:11:46 +00:00
|
|
|
m.debugInformationFormat,
|
|
|
|
m.compileAs,
|
|
|
|
m.forcedIncludeFiles,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
function m.VCCLCompilerToolName(cfg)
|
2014-04-03 15:00:47 +00:00
|
|
|
local prjcfg, filecfg = config.normalize(cfg)
|
|
|
|
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
|
2014-02-18 15:59:56 +00:00
|
|
|
return "VCCustomBuildTool"
|
2014-04-03 15:00:47 +00:00
|
|
|
elseif prjcfg and prjcfg.system == p.XBOX360 then
|
2014-02-18 15:59:56 +00:00
|
|
|
return "VCCLX360CompilerTool"
|
|
|
|
else
|
|
|
|
return "VCCLCompilerTool"
|
|
|
|
end
|
2014-02-11 16:11:46 +00:00
|
|
|
end
|
|
|
|
|
2014-02-27 14:54:55 +00:00
|
|
|
function m.VCCLCompilerTool(cfg, toolset)
|
|
|
|
m.VCTool("VCCLCompilerTool", cfg, toolset)
|
2014-02-18 15:59:56 +00:00
|
|
|
end
|
2014-02-11 16:11:46 +00:00
|
|
|
|
2014-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-02-11 16:11:46 +00:00
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
m.elements.VCLinkerTool = function(cfg, toolset)
|
|
|
|
if cfg.kind ~= p.STATICLIB then
|
|
|
|
return {
|
|
|
|
m.linkLibraryDependencies,
|
|
|
|
m.ignoreImportLibrary,
|
|
|
|
m.additionalLinkerOptions,
|
|
|
|
m.additionalDependencies,
|
|
|
|
m.outputFile,
|
|
|
|
m.linkIncremental,
|
|
|
|
m.additionalLibraryDirectories,
|
|
|
|
m.moduleDefinitionFile,
|
|
|
|
m.generateManifest,
|
|
|
|
m.generateDebugInformation,
|
2014-03-11 16:10:33 +00:00
|
|
|
m.programDatabaseFile,
|
2014-03-06 15:11:08 +00:00
|
|
|
m.subSystem,
|
|
|
|
m.optimizeReferences,
|
|
|
|
m.enableCOMDATFolding,
|
|
|
|
m.entryPointSymbol,
|
|
|
|
m.importLibrary,
|
|
|
|
m.targetMachine,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.additionalLinkerOptions,
|
|
|
|
m.additionalDependencies,
|
|
|
|
m.outputFile,
|
|
|
|
m.additionalLibraryDirectories,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCLinkerToolName(cfg)
|
|
|
|
if cfg.kind == p.STATICLIB then
|
|
|
|
return "VCLibrarianTool"
|
|
|
|
elseif cfg.system == p.XBOX360 then
|
|
|
|
return "VCX360LinkerTool"
|
|
|
|
else
|
|
|
|
return "VCLinkerTool"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCLinkerTool(cfg, toolset)
|
|
|
|
m.VCTool("VCLinkerTool", cfg, toolset)
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
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 {
|
2014-03-14 14:24:48 +00:00
|
|
|
m.targetEnvironment
|
2014-03-11 16:10:33 +00:00
|
|
|
}
|
|
|
|
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,
|
2015-03-09 22:49:19 +00:00
|
|
|
m.undefinePreprocessorDefinitions,
|
2014-03-11 16:10:33 +00:00
|
|
|
m.includeSearchPath,
|
|
|
|
m.forcedIncludes,
|
|
|
|
m.assemblySearchPath,
|
|
|
|
m.forcedUsingAssemblies,
|
|
|
|
m.compileAsManaged,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCNMakeTool(cfg)
|
|
|
|
m.VCTool("VCNMakeTool", cfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
------------
|
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
m.elements.VCBuildTool = function(cfg, stage)
|
|
|
|
return {
|
|
|
|
m.commandLine,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCBuildToolName(cfg, stage)
|
|
|
|
return "VC" .. stage .. "EventTool"
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCPreBuildEventTool(cfg)
|
|
|
|
m.VCTool("VCBuildTool", cfg, "PreBuild")
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCPreLinkEventTool(cfg)
|
|
|
|
m.VCTool("VCBuildTool", cfg, "PreLink")
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCPostBuildEventTool(cfg)
|
|
|
|
m.VCTool("VCBuildTool", cfg, "PostBuild")
|
|
|
|
end
|
|
|
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
m.elements.VCResourceCompilerTool = function(cfg)
|
|
|
|
return {
|
|
|
|
m.additionalResourceOptions,
|
|
|
|
m.resourcePreprocessorDefinitions,
|
|
|
|
m.additionalResourceIncludeDirectories,
|
|
|
|
m.culture,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCResourceCompilerTool(cfg)
|
|
|
|
m.VCTool("VCResourceCompilerTool", cfg)
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
m.elements.VCX360DeploymentTool = function(cfg)
|
|
|
|
return {
|
|
|
|
m.deploymentType,
|
|
|
|
m.additionalDeploymentOptions,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCX360DeploymentTool(cfg)
|
|
|
|
m.VCTool("VCX360DeploymentTool", cfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
------------
|
|
|
|
|
2014-03-20 15:21:02 +00:00
|
|
|
m.elements.VCX360ImageTool = function(cfg)
|
|
|
|
return {
|
|
|
|
m.additionalImageOptions,
|
|
|
|
m.outputFileName,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.VCX360ImageTool(cfg)
|
|
|
|
m.VCTool("VCX360ImageTool", cfg)
|
|
|
|
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-02-18 15:59:56 +00:00
|
|
|
------------
|
2014-01-24 18:06:52 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-18 14:38:00 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
-- Support functions
|
|
|
|
--
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
--
|
|
|
|
-- 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
|
2015-06-16 15:44:18 +00:00
|
|
|
if cfg.editandcontinue == p.OFF or
|
|
|
|
config.isOptimizedBuild(cfg) or
|
|
|
|
cfg.clr ~= p.OFF or
|
|
|
|
cfg.architecture == p.X86_64
|
2013-10-18 14:38:00 +00:00
|
|
|
then
|
|
|
|
return 3
|
|
|
|
else
|
|
|
|
return 4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-20 15:21:02 +00:00
|
|
|
|
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-04-03 15:00:47 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.additionalDependencies(cfg, toolset)
|
|
|
|
if #cfg.links == 0 then return end
|
|
|
|
|
|
|
|
local ex = vstudio.needsExplicitLink(cfg)
|
|
|
|
|
|
|
|
local links
|
|
|
|
if not toolset then
|
2015-02-14 19:56:02 +00:00
|
|
|
links = vstudio.getLinks(cfg, ex)
|
2014-03-06 15:11:08 +00:00
|
|
|
for i, link in ipairs(links) do
|
|
|
|
if link:find(" ", 1, true) then
|
|
|
|
link = '"' .. link .. '"'
|
|
|
|
end
|
|
|
|
links[i] = path.translate(link)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
links = toolset.getlinks(cfg, not ex)
|
|
|
|
end
|
|
|
|
|
|
|
|
if #links > 0 then
|
|
|
|
p.x('AdditionalDependencies="%s"', table.concat(links, " "))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
|
|
|
|
function m.additionalDeploymentOptions(cfg)
|
|
|
|
if #cfg.deploymentoptions > 0 then
|
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.deploymentoptions, " "))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
function m.additionalImageOptions(cfg)
|
|
|
|
if #cfg.imageoptions > 0 then
|
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.imageoptions, " "))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.additionalIncludeDirectories(cfg)
|
|
|
|
if #cfg.includedirs > 0 then
|
2015-05-08 21:08:41 +00:00
|
|
|
local dirs = vstudio.path(cfg, cfg.includedirs)
|
|
|
|
p.x('AdditionalIncludeDirectories="%s"', 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
|
2015-05-08 21:08:41 +00:00
|
|
|
local dirs = vstudio.path(cfg, cfg.libdirs)
|
|
|
|
p.x('AdditionalLibraryDirectories="%s"', table.concat(dirs, ";"))
|
2012-11-30 19:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
function m.additionalLinkerOptions(cfg, toolset)
|
2014-05-24 00:10:34 +00:00
|
|
|
local flags
|
2014-04-03 15:00:47 +00:00
|
|
|
if toolset then
|
2014-11-05 21:25:58 +00:00
|
|
|
flags = table.join(toolset.getldflags(cfg), cfg.linkoptions)
|
2014-05-24 00:10:34 +00:00
|
|
|
else
|
|
|
|
flags = cfg.linkoptions
|
2014-04-03 15:00:47 +00:00
|
|
|
end
|
|
|
|
if #flags > 0 then
|
|
|
|
p.x('AdditionalOptions="%s"', table.concat(flags, " "))
|
2014-03-14 14:24:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
function m.additionalManifestFiles(cfg)
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
function m.additionalResourceIncludeDirectories(cfg)
|
|
|
|
local dirs = table.join(cfg.includedirs, cfg.resincludedirs)
|
|
|
|
if #dirs > 0 then
|
2015-05-08 21:08:41 +00:00
|
|
|
dirs = vstudio.path(cfg, dirs)
|
|
|
|
p.x('AdditionalIncludeDirectories="%s"', table.concat(dirs, ";"))
|
2014-03-14 14:24:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
function m.additionalResourceOptions(cfg)
|
|
|
|
if #cfg.resoptions > 0 then
|
|
|
|
p.x('AdditionalOptions="%s"', table.concat(cfg.resoptions, " "))
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
function m.assemblySearchPath(cfg)
|
|
|
|
p.w('AssemblySearchPath=""')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.basicRuntimeChecks(cfg)
|
2014-04-03 15:00:47 +00:00
|
|
|
local cfg, filecfg = config.normalize(cfg)
|
|
|
|
if not filecfg
|
|
|
|
and not config.isOptimizedBuild(cfg)
|
2014-11-12 00:29:28 +00:00
|
|
|
and cfg.clr == p.OFF
|
2013-03-07 15:45:33 +00:00
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
function m.buildCommandLine(cfg)
|
2014-11-29 19:51:49 +00:00
|
|
|
local cmds = os.translateCommands(cfg.buildcommands, p.WINDOWS)
|
|
|
|
p.x('BuildCommandLine="%s"', table.concat(cmds, "\r\n"))
|
2014-03-11 16:10:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
function m.cleanCommandLine(cfg)
|
2014-11-29 19:51:49 +00:00
|
|
|
local cmds = os.translateCommands(cfg.cleancommands, p.WINDOWS)
|
|
|
|
cmds = table.concat(cmds, "\r\n")
|
|
|
|
p.x('CleanCommandLine="%s"', cmds)
|
2014-03-11 16:10:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
function m.commandLine(cfg, stage)
|
|
|
|
local field = stage:lower()
|
|
|
|
local steps = cfg[field .. "commands"]
|
|
|
|
local msg = cfg[field .. "message"]
|
|
|
|
if #steps > 0 then
|
|
|
|
if msg then
|
|
|
|
p.x('Description="%s"', msg)
|
|
|
|
end
|
2014-11-29 19:51:49 +00:00
|
|
|
steps = os.translateCommands(steps, p.WINDOWS)
|
2014-03-14 14:24:48 +00:00
|
|
|
p.x('CommandLine="%s"', table.implode(steps, "", "", "\r\n"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.compileAs(cfg, toolset)
|
2014-04-03 15:00:47 +00:00
|
|
|
local cfg, filecfg = config.normalize(cfg)
|
|
|
|
local c = project.isc(cfg)
|
|
|
|
if filecfg then
|
|
|
|
if path.iscfile(filecfg.name) ~= c then
|
|
|
|
if path.iscppfile(filecfg.name) then
|
2014-02-11 16:11:46 +00:00
|
|
|
local value = iif(c, 2, 1)
|
2014-02-04 21:04:36 +00:00
|
|
|
p.w('CompileAs="%s"', value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
local compileAs
|
|
|
|
if toolset then
|
|
|
|
compileAs = "0"
|
2014-02-11 16:11:46 +00:00
|
|
|
elseif c then
|
2014-02-04 21:04:36 +00:00
|
|
|
compileAs = "1"
|
|
|
|
end
|
|
|
|
if compileAs then
|
|
|
|
p.w('CompileAs="%s"', compileAs)
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
|
2015-03-09 23:53:46 +00:00
|
|
|
function m.disableSpecificWarnings(cfg)
|
2015-03-10 10:59:28 +00:00
|
|
|
if #cfg.disablewarnings > 0 then
|
|
|
|
p.x('DisableSpecificWarnings="%s"', table.concat(cfg.disablewarnings, ";"))
|
2015-03-09 23:53:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
function m.compileAsManaged(cfg)
|
|
|
|
p.w('CompileAsManaged=""')
|
|
|
|
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-02-06 20:38:51 +00:00
|
|
|
|
|
|
|
function m.culture(cfg)
|
|
|
|
local value = vstudio.cultureForLocale(cfg.locale)
|
|
|
|
if value then
|
|
|
|
p.w('Culture="%d"', value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
function m.customBuildTool(cfg)
|
|
|
|
local cfg, filecfg = config.normalize(cfg)
|
|
|
|
if filecfg and fileconfig.hasCustomBuildRule(filecfg) then
|
2014-11-29 19:51:49 +00:00
|
|
|
local cmds = os.translateCommands(filecfg.buildcommands, p.WINDOWS)
|
|
|
|
p.x('CommandLine="%s"', table.concat(cmds,'\r\n'))
|
2013-04-09 19:12:04 +00:00
|
|
|
|
|
|
|
local outputs = project.getrelative(filecfg.project, filecfg.buildoutputs)
|
2015-01-28 08:26:57 +00:00
|
|
|
p.x('Outputs="%s"', table.concat(outputs, ';'))
|
2014-09-25 09:00:17 +00:00
|
|
|
|
|
|
|
if filecfg.buildinputs and #filecfg.buildinputs > 0 then
|
|
|
|
local inputs = project.getrelative(filecfg.project, filecfg.buildinputs)
|
|
|
|
p.x('AdditionalDependencies="%s"', table.concat(inputs, ';'))
|
|
|
|
end
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.debugInformationFormat(cfg, toolset)
|
2014-04-03 15:00:47 +00:00
|
|
|
local prjcfg, filecfg = config.normalize(cfg)
|
|
|
|
if not filecfg then
|
|
|
|
local fmt = iif(toolset, "0", m.symbols(cfg))
|
|
|
|
p.w('DebugInformationFormat="%s"', fmt)
|
|
|
|
end
|
2014-02-04 21:04:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
function m.deploymentType(cfg)
|
|
|
|
p.w('DeploymentType="0"')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-08 18:33:01 +00:00
|
|
|
function m.detect64BitPortabilityProblems(cfg)
|
|
|
|
local prjcfg, filecfg = config.normalize(cfg)
|
2014-11-12 00:29:28 +00:00
|
|
|
if _ACTION < "vs2008" and cfg.clr == p.OFF and cfg.warnings ~= p.OFF and not filecfg then
|
2014-04-08 18:33:01 +00:00
|
|
|
p.w('Detect64BitPortabilityProblems="%s"', tostring(not cfg.flags.No64BitChecks))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.enableCOMDATFolding(cfg, toolset)
|
|
|
|
if config.isOptimizedBuild(cfg) and not toolset then
|
|
|
|
p.w('EnableCOMDATFolding="2"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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]
|
2015-04-10 13:02:19 +00:00
|
|
|
if value and cfg.system ~= "Xbox360" and cfg.architecture ~= "x86_64" 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-03-11 16:10:33 +00:00
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.enableFunctionLevelLinking(cfg)
|
2014-04-03 15:00:47 +00:00
|
|
|
local cfg, filecfg = config.normalize(cfg)
|
|
|
|
if not filecfg then
|
|
|
|
p.w('EnableFunctionLevelLinking="true"')
|
|
|
|
end
|
2014-02-04 21:04:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.entryPointSymbol(cfg, toolset)
|
|
|
|
if (cfg.kind == "ConsoleApp" or cfg.kind == "WindowedApp") and
|
|
|
|
not cfg.flags.WinMain and
|
|
|
|
not toolset
|
|
|
|
then
|
|
|
|
p.w('EntryPointSymbol="mainCRTStartup"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.exceptionHandling(cfg)
|
2015-06-16 15:44:18 +00:00
|
|
|
if cfg.exceptionhandling == p.OFF then
|
2014-02-04 21:04:36 +00:00
|
|
|
p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0))
|
2015-06-23 23:03:28 +00:00
|
|
|
elseif cfg.exceptionhandling == "SEH" and _ACTION > "vs2003" then
|
2014-02-04 21:04:36 +00:00
|
|
|
p.w('ExceptionHandling="2"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
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
|
2015-05-08 21:08:41 +00:00
|
|
|
local includes = vstudio.path(cfg, 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
|
2015-05-08 21:08:41 +00:00
|
|
|
local usings = vstudio.path(cfg, 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-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
function m.forcedIncludes(cfg)
|
|
|
|
p.w('ForcedIncludes=""')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function m.forcedUsingAssemblies(cfg)
|
|
|
|
p.w('ForcedUsingAssemblies=""')
|
|
|
|
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
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.clr ~= p.OFF then managed = true end
|
2013-10-23 14:51:11 +00:00
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.generateDebugInformation(cfg, toolset)
|
|
|
|
if not toolset then
|
2014-03-14 14:24:48 +00:00
|
|
|
p.w('GenerateDebugInformation="%s"', tostring(m.symbols(cfg) ~= 0))
|
2014-03-06 15:11:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.generateManifest(cfg, toolset)
|
|
|
|
if cfg.flags.NoManifest or toolset then
|
2014-03-14 14:24:48 +00:00
|
|
|
p.w('GenerateManifest="false"')
|
2014-03-06 15:11:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.ignoreImportLibrary(cfg, toolset)
|
|
|
|
if cfg.flags.NoImportLib and not toolset then
|
2014-03-14 14:24:48 +00:00
|
|
|
p.w('IgnoreImportLibrary="true"')
|
2014-03-06 15:11:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.importLibrary(cfg, toolset)
|
|
|
|
if cfg.kind == p.SHAREDLIB and not toolset 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
|
|
|
|
|
2015-05-08 21:08:41 +00:00
|
|
|
implibdir = vstudio.path(cfg, implibdir)
|
|
|
|
p.x('ImportLibrary="%s"', implibdir)
|
2014-03-06 15:11:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
function m.includeSearchPath(cfg)
|
|
|
|
p.w('IncludeSearchPath=""')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.intermediateDirectory(cfg)
|
2014-02-18 15:59:56 +00:00
|
|
|
local objdir
|
|
|
|
if not cfg.fake then
|
2015-05-08 21:08:41 +00:00
|
|
|
objdir = vstudio.path(cfg, cfg.objdir)
|
2014-02-18 15:59:56 +00:00
|
|
|
else
|
2015-05-08 21:08:41 +00:00
|
|
|
objdir = "$(PlatformName)\\$(ConfigurationName)"
|
2014-02-18 15:59:56 +00:00
|
|
|
end
|
2015-05-08 21:08:41 +00:00
|
|
|
p.x('IntermediateDirectory="%s"', objdir)
|
2013-10-28 15:01:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.linkIncremental(cfg, toolset)
|
|
|
|
local value
|
|
|
|
if not toolset then
|
|
|
|
value = iif(config.canLinkIncremental(cfg) , 2, 1)
|
|
|
|
else
|
|
|
|
value = 0
|
|
|
|
end
|
|
|
|
p.w('LinkIncremental="%s"', value)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.linkLibraryDependencies(cfg, toolset)
|
|
|
|
if vstudio.needsExplicitLink(cfg) and not toolset then
|
|
|
|
p.w('LinkLibraryDependencies="false"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.managedExtensions(cfg)
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.clr ~= p.OFF then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('ManagedExtensions="1"')
|
2013-10-28 15:01:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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
|
2014-11-12 00:29:28 +00:00
|
|
|
cfg.clr == p.OFF and
|
2013-03-07 15:45:33 +00:00
|
|
|
not cfg.flags.MultiProcessorCompile
|
|
|
|
then
|
2014-03-14 14:24:48 +00:00
|
|
|
p.w('MinimalRebuild="true"')
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.moduleDefinitionFile(cfg, toolset)
|
|
|
|
if not toolset then
|
|
|
|
local deffile = config.findfile(cfg, ".def")
|
|
|
|
if deffile then
|
|
|
|
p.w('ModuleDefinitionFile="%s"', deffile)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-04-03 18:09:39 +00:00
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
function m.objectFile(cfg)
|
|
|
|
local cfg, filecfg = config.normalize(cfg)
|
|
|
|
if filecfg and 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-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.omitDefaultLib(cfg)
|
|
|
|
if cfg.flags.OmitDefaultLibrary then
|
|
|
|
p.w('OmitDefaultLibName="true"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.omitFramePointers(cfg)
|
|
|
|
if cfg.flags.NoFramePointer then
|
2014-03-14 14:24:48 +00:00
|
|
|
p.w('OmitFramePointers="true"')
|
2014-02-04 21:04:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.optimizeReferences(cfg, toolset)
|
|
|
|
if config.isOptimizedBuild(cfg) and not toolset then
|
|
|
|
p.w('OptimizeReferences="2"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
function m.output(cfg)
|
|
|
|
p.w('Output="$(OutDir)%s"', cfg.buildtarget.name)
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.outputFile(cfg)
|
|
|
|
p.x('OutputFile="$(OutDir)\\%s"', cfg.buildtarget.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
2014-03-14 14:24:48 +00:00
|
|
|
function m.outputFileName(cfg)
|
|
|
|
if cfg.imagepath ~= nil then
|
|
|
|
p.x('OutputFileName="%s"', path.translate(cfg.imagepath))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.platforms(prj)
|
2014-04-08 18:33:01 +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
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<Platforms>')
|
2014-04-08 18:33:01 +00:00
|
|
|
table.foreachi(architectures, 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-03-11 16:10:33 +00:00
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.preprocessorDefinitions(cfg)
|
2014-03-11 16:10:33 +00:00
|
|
|
if #cfg.defines > 0 or vstudio.isMakefile(cfg) then
|
2014-02-04 21:04:36 +00:00
|
|
|
p.x('PreprocessorDefinitions="%s"', table.concat(cfg.defines, ";"))
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-09 22:49:19 +00:00
|
|
|
function m.undefinePreprocessorDefinitions(cfg)
|
2015-03-10 10:41:44 +00:00
|
|
|
if #cfg.undefines > 0 then
|
2015-03-09 22:49:19 +00:00
|
|
|
p.x('UndefinePreprocessorDefinitions="%s"', table.concat(cfg.undefines, ";"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
function m.programDatabaseFile(cfg, toolset)
|
|
|
|
if toolset then
|
|
|
|
p.w('ProgramDatabaseFile=""')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.programDataBaseFileName(cfg, toolset)
|
|
|
|
if toolset then
|
|
|
|
p.w('ProgramDataBaseFileName=""')
|
|
|
|
end
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
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"
|
2015-08-12 18:53:12 +00:00
|
|
|
-- to be relative to the *workspace*, 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
|
2015-08-12 18:53:12 +00:00
|
|
|
-- in more than one workspace. But that's how they do it.
|
2013-05-23 15:46:50 +00:00
|
|
|
|
2014-01-18 19:54:46 +00:00
|
|
|
for i, dep in ipairs(deps) do
|
2015-08-12 18:53:12 +00:00
|
|
|
local relpath = vstudio.path(prj.workspace, 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
|
2015-05-08 21:08:41 +00:00
|
|
|
relpath = ".\\" .. relpath
|
2013-05-23 15:46:50 +00:00
|
|
|
end
|
|
|
|
|
2014-01-31 16:40:09 +00:00
|
|
|
p.push('<ProjectReference')
|
|
|
|
p.w('ReferencedProjectIdentifier="{%s}"', dep.uuid)
|
2015-05-08 21:08:41 +00:00
|
|
|
p.w('RelativePathToProject="%s"', relpath)
|
2014-01-31 16:40:09 +00:00
|
|
|
p.pop('/>')
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
|
|
|
function m.reBuildCommandLine(cfg)
|
|
|
|
commands = table.concat(cfg.rebuildcommands, "\r\n")
|
|
|
|
p.x('ReBuildCommandLine="%s"', commands)
|
2014-03-06 15:11:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.resourcePreprocessorDefinitions(cfg)
|
|
|
|
local defs = table.join(cfg.defines, cfg.resdefines)
|
|
|
|
if #defs > 0 then
|
|
|
|
p.x('PreprocessorDefinitions="%s"', table.concat(defs, ";"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
|
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-03-11 16:10:33 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.runtimeLibrary(cfg)
|
2014-04-03 15:00:47 +00:00
|
|
|
local cfg, filecfg = config.normalize(cfg)
|
|
|
|
if not filecfg then
|
|
|
|
local runtimes = {
|
|
|
|
StaticRelease = 0,
|
|
|
|
StaticDebug = 1,
|
|
|
|
SharedRelease = 2,
|
|
|
|
SharedDebug = 3,
|
|
|
|
}
|
|
|
|
p.w('RuntimeLibrary="%s"', runtimes[config.getruntime(cfg)])
|
|
|
|
end
|
2013-03-27 15:12:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-04-03 15:00:47 +00:00
|
|
|
|
2014-01-28 15:42:49 +00:00
|
|
|
function m.runtimeTypeInfo(cfg)
|
2015-06-16 15:44:18 +00:00
|
|
|
if cfg.rtti == p.OFF and cfg.clr == p.OFF then
|
2014-01-31 16:40:09 +00:00
|
|
|
p.w('RuntimeTypeInfo="false"')
|
2015-06-16 15:44:18 +00:00
|
|
|
elseif cfg.rtti == p.ON then
|
|
|
|
p.w('RuntimeTypeInfo="true"')
|
2013-09-27 19:12:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
function m.stringPooling(cfg)
|
|
|
|
if config.isOptimizedBuild(cfg) then
|
2014-03-14 14:24:48 +00:00
|
|
|
p.w('StringPooling="true"')
|
2014-02-04 21:04:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-06 15:11:08 +00:00
|
|
|
function m.subSystem(cfg, toolset)
|
|
|
|
if not toolset then
|
|
|
|
p.w('SubSystem="%s"', iif(cfg.kind == "ConsoleApp", 1, 2))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-11 16:10:33 +00:00
|
|
|
function m.targetEnvironment(cfg)
|
2015-04-10 13:02:19 +00:00
|
|
|
if cfg.architecture == "x86_64" then
|
2014-03-11 16:10:33 +00:00
|
|
|
p.w('TargetEnvironment="3"')
|
|
|
|
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-03-06 15:11:08 +00:00
|
|
|
function m.targetMachine(cfg, toolset)
|
|
|
|
if not toolset then
|
2015-04-10 13:02:19 +00:00
|
|
|
p.w('TargetMachine="%d"', iif(cfg.architecture == "x86_64", 17, 1))
|
2014-03-06 15:11:08 +00:00
|
|
|
end
|
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-02-04 21:04:36 +00:00
|
|
|
function m.usePrecompiledHeader(cfg)
|
2014-02-11 16:11:46 +00:00
|
|
|
local prj, file = config.normalize(cfg)
|
|
|
|
if file then
|
|
|
|
if prj.pchsource == file.abspath and
|
|
|
|
not prj.flags.NoPCH and
|
2014-12-08 21:04:41 +00:00
|
|
|
prj.system == p.WINDOWS
|
2014-02-11 16:11:46 +00:00
|
|
|
then
|
|
|
|
p.w('UsePrecompiledHeader="1"')
|
|
|
|
end
|
2014-02-04 21:04:36 +00:00
|
|
|
else
|
2014-02-11 16:11:46 +00:00
|
|
|
if not prj.flags.NoPCH and prj.pchheader then
|
2014-02-04 21:04:36 +00:00
|
|
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
|
2014-02-11 16:11:46 +00:00
|
|
|
p.x('PrecompiledHeaderThrough="%s"', prj.pchheader)
|
2014-02-04 21:04:36 +00:00
|
|
|
else
|
2014-02-11 16:11:46 +00:00
|
|
|
p.w('UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or prj.flags.NoPCH, 0, 2))
|
2014-02-04 21:04:36 +00:00
|
|
|
end
|
2013-03-12 22:26:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-02-04 21:04:36 +00:00
|
|
|
|
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-04-08 18:33:01 +00:00
|
|
|
|
|
|
|
function m.warnAsError(cfg)
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then
|
2014-04-08 18:33:01 +00:00
|
|
|
p.w('WarnAsError="true"')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function m.warningLevel(cfg)
|
2014-04-03 15:00:47 +00:00
|
|
|
local prjcfg, filecfg = config.normalize(cfg)
|
|
|
|
|
|
|
|
local level
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.warnings == p.OFF then
|
2014-04-03 15:00:47 +00:00
|
|
|
level = "0"
|
|
|
|
elseif cfg.warnings == "Extra" then
|
|
|
|
level = "4"
|
|
|
|
elseif not filecfg then
|
|
|
|
level = "3"
|
|
|
|
end
|
|
|
|
|
|
|
|
if level then
|
|
|
|
p.w('WarningLevel="%s"', level)
|
|
|
|
end
|
2013-03-07 15:45:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-04-08 18:33:01 +00:00
|
|
|
|
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
|