2012-08-01 19:28:21 +00:00
|
|
|
--
|
|
|
|
-- vs2010_vcxproj.lua
|
|
|
|
-- Generate a Visual Studio 201x C/C++ project.
|
2014-02-08 15:44:57 +00:00
|
|
|
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
2012-08-01 19:28:21 +00:00
|
|
|
--
|
|
|
|
|
2012-11-27 15:18:06 +00:00
|
|
|
premake.vstudio.vc2010 = {}
|
2013-07-12 15:07:26 +00:00
|
|
|
|
2014-02-08 15:44:57 +00:00
|
|
|
local p = premake
|
|
|
|
local vstudio = p.vstudio
|
|
|
|
local project = p.project
|
|
|
|
local config = p.config
|
|
|
|
local fileconfig = p.fileconfig
|
|
|
|
local tree = p.tree
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
local m = p.vstudio.vc2010
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2013-04-25 15:45:44 +00:00
|
|
|
---
|
2014-05-22 13:55:28 +00:00
|
|
|
-- Add namespace for element definition lists for premake.callArray()
|
2013-04-25 15:45:44 +00:00
|
|
|
---
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements = {}
|
2013-04-25 15:45:44 +00:00
|
|
|
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
--
|
|
|
|
-- Generate a Visual Studio 201x C++ project, with support for the new platforms API.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements.project = function(prj)
|
|
|
|
return {
|
|
|
|
m.projectConfigurations,
|
|
|
|
m.globals,
|
|
|
|
m.importDefaultProps,
|
|
|
|
m.configurationPropertiesGroup,
|
|
|
|
m.importExtensionSettings,
|
|
|
|
m.propertySheetGroup,
|
|
|
|
m.userMacros,
|
|
|
|
m.outputPropertiesGroup,
|
|
|
|
m.itemDefinitionGroups,
|
|
|
|
m.assemblyReferences,
|
|
|
|
m.files,
|
|
|
|
m.projectReferences,
|
2014-06-12 23:05:44 +00:00
|
|
|
m.importExtensionTargets,
|
2014-05-22 13:55:28 +00:00
|
|
|
}
|
|
|
|
end
|
2013-01-17 18:19:49 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.generate(prj)
|
|
|
|
io.utf8()
|
2014-09-12 19:47:22 +00:00
|
|
|
m.xmlDeclaration()
|
2015-01-12 22:17:56 +00:00
|
|
|
m.project()
|
2014-05-22 13:55:28 +00:00
|
|
|
p.callArray(m.elements.project, prj)
|
2014-02-08 15:44:57 +00:00
|
|
|
p.out('</Project>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Output the XML declaration and opening <Project> tag.
|
|
|
|
--
|
|
|
|
|
2015-01-12 22:17:56 +00:00
|
|
|
function m.project()
|
2014-12-29 20:18:07 +00:00
|
|
|
local action = premake.action.current()
|
2015-01-12 22:17:56 +00:00
|
|
|
p.push('<Project DefaultTargets="Build" ToolsVersion="%s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">',
|
|
|
|
action.vstudio.toolsVersion)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Write out the list of project configurations, which pairs build
|
|
|
|
-- configurations with architectures.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.projectConfigurations(prj)
|
2013-04-03 15:53:00 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
-- build a list of all architectures used in this project
|
|
|
|
local platforms = {}
|
|
|
|
for cfg in project.eachconfig(prj) do
|
2012-11-17 20:49:06 +00:00
|
|
|
local arch = vstudio.archFromConfig(cfg, true)
|
2012-08-01 19:28:21 +00:00
|
|
|
if not table.contains(platforms, arch) then
|
|
|
|
table.insert(platforms, arch)
|
|
|
|
end
|
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-11-17 20:49:06 +00:00
|
|
|
local configs = {}
|
2012-08-01 19:28:21 +00:00
|
|
|
_p(1,'<ItemGroup Label="ProjectConfigurations">')
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
for _, arch in ipairs(platforms) do
|
2012-11-17 20:49:06 +00:00
|
|
|
local prjcfg = vstudio.projectConfig(cfg, arch)
|
|
|
|
if not configs[prjcfg] then
|
|
|
|
configs[prjcfg] = prjcfg
|
|
|
|
_x(2,'<ProjectConfiguration Include="%s">', vstudio.projectConfig(cfg, arch))
|
|
|
|
_x(3,'<Configuration>%s</Configuration>', vstudio.projectPlatform(cfg))
|
|
|
|
_p(3,'<Platform>%s</Platform>', arch)
|
|
|
|
_p(2,'</ProjectConfiguration>')
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
_p(1,'</ItemGroup>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-09-30 14:53:16 +00:00
|
|
|
--
|
|
|
|
-- Write out the TargetFrameworkVersion property.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.targetFramework(prj)
|
2014-12-29 20:18:07 +00:00
|
|
|
local action = premake.action.current()
|
|
|
|
local tools = string.format(' ToolsVersion="%s"', action.vstudio.toolsVersion)
|
|
|
|
|
|
|
|
local framework = prj.framework or action.vstudio.targetFramework or "4.0"
|
2013-09-30 14:53:16 +00:00
|
|
|
_p(2,'<TargetFrameworkVersion>v%s</TargetFrameworkVersion>', framework)
|
|
|
|
end
|
|
|
|
|
2014-05-22 14:26:16 +00:00
|
|
|
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
--
|
|
|
|
-- Write out the Globals property group.
|
|
|
|
--
|
|
|
|
|
2014-05-22 14:26:16 +00:00
|
|
|
m.elements.globals = function(prj)
|
|
|
|
return {
|
|
|
|
m.projectGuid,
|
2014-12-08 22:42:00 +00:00
|
|
|
m.ignoreWarnDuplicateFilename,
|
2014-05-22 14:26:16 +00:00
|
|
|
m.keyword,
|
|
|
|
m.projectName,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.globals(prj)
|
|
|
|
m.propertyGroup(nil, "Globals")
|
2014-05-22 14:26:16 +00:00
|
|
|
p.callArray(m.elements.globals, prj)
|
2012-08-01 19:28:21 +00:00
|
|
|
_p(1,'</PropertyGroup>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2013-01-12 16:52:59 +00:00
|
|
|
-- Write out the configuration property group: what kind of binary it
|
2012-08-01 19:28:21 +00:00
|
|
|
-- produces, and some global settings.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements.configurationProperties = function(cfg)
|
2014-07-14 20:48:03 +00:00
|
|
|
if cfg.kind == p.UTILITY then
|
|
|
|
return {
|
|
|
|
m.configurationType,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.configurationType,
|
|
|
|
m.useDebugLibraries,
|
|
|
|
m.useOfMfc,
|
|
|
|
m.useOfAtl,
|
|
|
|
m.clrSupport,
|
|
|
|
m.characterSet,
|
2014-12-08 22:42:00 +00:00
|
|
|
m.platformToolset,
|
2014-07-14 20:48:03 +00:00
|
|
|
m.wholeProgramOptimization,
|
|
|
|
m.nmakeOutDirs,
|
|
|
|
}
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.configurationProperties(cfg)
|
|
|
|
m.propertyGroup(cfg, "Configuration")
|
|
|
|
p.callArray(m.elements.configurationProperties, cfg)
|
|
|
|
_p(1,'</PropertyGroup>')
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.configurationPropertiesGroup(prj)
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
m.configurationProperties(cfg)
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
--
|
2013-04-03 15:53:00 +00:00
|
|
|
-- Write the output property group, which includes the output and intermediate
|
2012-08-01 19:28:21 +00:00
|
|
|
-- directories, manifest, etc.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements.outputProperties = function(cfg)
|
2014-07-14 20:48:03 +00:00
|
|
|
if cfg.kind == p.UTILITY then
|
|
|
|
return {
|
|
|
|
m.outDir,
|
|
|
|
m.intDir,
|
2014-07-16 19:32:08 +00:00
|
|
|
m.extensionsToDeleteOnClean,
|
2014-07-14 20:48:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.linkIncremental,
|
|
|
|
m.ignoreImportLibrary,
|
|
|
|
m.outDir,
|
|
|
|
m.outputFile,
|
|
|
|
m.intDir,
|
|
|
|
m.targetName,
|
|
|
|
m.targetExt,
|
|
|
|
m.imageXexOutput,
|
|
|
|
m.generateManifest,
|
2014-07-16 19:32:08 +00:00
|
|
|
m.extensionsToDeleteOnClean,
|
2015-03-25 16:47:05 +00:00
|
|
|
m.executablePath,
|
2014-07-14 20:48:03 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-22 13:55:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function m.outputProperties(cfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if not vstudio.isMakefile(cfg) then
|
2014-07-22 20:34:40 +00:00
|
|
|
m.propertyGroup(cfg)
|
2014-05-22 13:55:28 +00:00
|
|
|
p.callArray(m.elements.outputProperties, cfg)
|
2013-04-03 15:53:00 +00:00
|
|
|
_p(1,'</PropertyGroup>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.outputPropertiesGroup(prj)
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
m.outputProperties(cfg)
|
|
|
|
m.nmakeProperties(cfg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-04-03 15:53:00 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Write the NMake property group for Makefile projects, which includes the custom
|
|
|
|
-- build commands, output file location, etc.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.nmakeProperties(cfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if vstudio.isMakefile(cfg) then
|
2014-05-22 13:55:28 +00:00
|
|
|
m.propertyGroup(cfg)
|
|
|
|
m.nmakeOutput(cfg)
|
|
|
|
m.nmakeCommandLine(cfg, cfg.buildcommands, "Build")
|
|
|
|
m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild")
|
|
|
|
m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean")
|
2013-04-03 15:53:00 +00:00
|
|
|
_p(1,'</PropertyGroup>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Write a configuration's item definition group, which contains all
|
|
|
|
-- of the per-configuration compile and link settings.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements.itemDefinitionGroup = function(cfg)
|
2014-07-14 20:48:03 +00:00
|
|
|
if cfg.kind == p.UTILITY then
|
|
|
|
return {
|
2014-10-20 19:41:00 +00:00
|
|
|
m.ruleVars,
|
2014-10-14 09:39:54 +00:00
|
|
|
m.buildEvents,
|
2014-07-14 20:48:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.clCompile,
|
|
|
|
m.resourceCompile,
|
2014-08-07 22:07:32 +00:00
|
|
|
m.linker,
|
2014-07-14 20:48:03 +00:00
|
|
|
m.manifest,
|
|
|
|
m.buildEvents,
|
|
|
|
m.imageXex,
|
|
|
|
m.deploy,
|
2014-10-20 19:41:00 +00:00
|
|
|
m.ruleVars,
|
2015-04-28 20:30:23 +00:00
|
|
|
m.buildLog,
|
2014-07-14 20:48:03 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-22 13:55:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function m.itemDefinitionGroup(cfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if not vstudio.isMakefile(cfg) then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.push('<ItemDefinitionGroup %s>', m.condition(cfg))
|
2014-05-22 13:55:28 +00:00
|
|
|
p.callArray(m.elements.itemDefinitionGroup, cfg)
|
2014-06-12 22:39:39 +00:00
|
|
|
p.pop('</ItemDefinitionGroup>')
|
2013-04-03 15:53:00 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
if cfg == project.getfirstconfig(cfg.project) then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<ItemDefinitionGroup>')
|
|
|
|
p.w('</ItemDefinitionGroup>')
|
2013-04-03 15:53:00 +00:00
|
|
|
end
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.itemDefinitionGroups(prj)
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
m.itemDefinitionGroup(cfg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Write the the <ClCompile> compiler settings block.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements.clCompile = function(cfg)
|
|
|
|
return {
|
|
|
|
m.precompiledHeader,
|
|
|
|
m.warningLevel,
|
|
|
|
m.treatWarningAsError,
|
2015-03-09 23:53:46 +00:00
|
|
|
m.disableSpecificWarnings,
|
|
|
|
m.treatSpecificWarningsAsErrors,
|
2014-05-22 13:55:28 +00:00
|
|
|
m.basicRuntimeChecks,
|
|
|
|
m.clCompilePreprocessorDefinitions,
|
2015-03-09 22:49:19 +00:00
|
|
|
m.clCompileUndefinePreprocessorDefinitions,
|
2014-05-22 13:55:28 +00:00
|
|
|
m.clCompileAdditionalIncludeDirectories,
|
|
|
|
m.clCompileAdditionalUsingDirectories,
|
|
|
|
m.forceIncludes,
|
|
|
|
m.debugInformationFormat,
|
|
|
|
m.programDataBaseFileName,
|
|
|
|
m.optimization,
|
|
|
|
m.functionLevelLinking,
|
|
|
|
m.intrinsicFunctions,
|
|
|
|
m.minimalRebuild,
|
|
|
|
m.omitFramePointers,
|
|
|
|
m.stringPooling,
|
|
|
|
m.runtimeLibrary,
|
|
|
|
m.omitDefaultLib,
|
|
|
|
m.exceptionHandling,
|
|
|
|
m.runtimeTypeInfo,
|
|
|
|
m.bufferSecurityCheck,
|
|
|
|
m.treatWChar_tAsBuiltInType,
|
|
|
|
m.floatingPointModel,
|
|
|
|
m.enableEnhancedInstructionSet,
|
|
|
|
m.multiProcessorCompilation,
|
|
|
|
m.additionalCompileOptions,
|
|
|
|
m.compileAs,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.clCompile(cfg)
|
2014-06-12 22:39:39 +00:00
|
|
|
p.push('<ClCompile>')
|
2014-05-22 13:55:28 +00:00
|
|
|
p.callArray(m.elements.clCompile, cfg)
|
2014-06-12 22:39:39 +00:00
|
|
|
p.pop('</ClCompile>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Write out the resource compiler block.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
m.elements.resourceCompile = function(cfg)
|
|
|
|
return {
|
|
|
|
m.resourcePreprocessorDefinitions,
|
|
|
|
m.resourceAdditionalIncludeDirectories,
|
|
|
|
m.culture,
|
|
|
|
}
|
|
|
|
end
|
2013-04-30 16:38:11 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.resourceCompile(cfg)
|
2014-12-24 01:05:40 +00:00
|
|
|
if cfg.system ~= premake.XBOX360 and config.hasResourceFiles(cfg) then
|
|
|
|
local contents = p.capture(function ()
|
|
|
|
p.push()
|
|
|
|
p.callArray(m.elements.resourceCompile, cfg)
|
|
|
|
p.pop()
|
|
|
|
end)
|
|
|
|
|
|
|
|
if #contents > 0 then
|
|
|
|
p.push('<ResourceCompile>')
|
|
|
|
p.outln(contents)
|
|
|
|
p.pop('</ResourceCompile>')
|
|
|
|
end
|
2013-03-07 17:14:03 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Write out the linker tool block.
|
|
|
|
--
|
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
m.elements.linker = function(cfg, explicit)
|
2014-05-22 13:55:28 +00:00
|
|
|
return {
|
2014-08-07 22:07:32 +00:00
|
|
|
m.link,
|
|
|
|
m.lib,
|
|
|
|
m.linkLibraryDependencies,
|
2014-05-22 13:55:28 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
function m.linker(cfg)
|
|
|
|
local explicit = vstudio.needsExplicitLink(cfg)
|
|
|
|
p.callArray(m.elements.linker, cfg, explicit)
|
2014-05-22 13:55:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
m.elements.link = function(cfg, explicit)
|
|
|
|
if cfg.kind == p.STATICLIB then
|
|
|
|
return {
|
|
|
|
m.subSystem,
|
|
|
|
m.generateDebugInformation,
|
|
|
|
m.optimizeReferences,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.subSystem,
|
|
|
|
m.generateDebugInformation,
|
|
|
|
m.optimizeReferences,
|
|
|
|
m.additionalDependencies,
|
|
|
|
m.additionalLibraryDirectories,
|
|
|
|
m.importLibrary,
|
|
|
|
m.entryPointSymbol,
|
|
|
|
m.generateMapFile,
|
|
|
|
m.moduleDefinitionFile,
|
|
|
|
m.treatLinkerWarningAsErrors,
|
|
|
|
m.additionalLinkOptions,
|
|
|
|
}
|
2013-04-03 15:53:00 +00:00
|
|
|
end
|
2014-08-07 22:07:32 +00:00
|
|
|
end
|
2013-04-25 20:05:08 +00:00
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
function m.link(cfg, explicit)
|
|
|
|
local contents = p.capture(function ()
|
|
|
|
p.push()
|
|
|
|
p.callArray(m.elements.link, cfg, explicit)
|
|
|
|
p.pop()
|
|
|
|
end)
|
|
|
|
if #contents > 0 then
|
|
|
|
p.push('<Link>')
|
|
|
|
p.outln(contents)
|
|
|
|
p.pop('</Link>')
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
m.elements.lib = function(cfg, explicit)
|
|
|
|
if cfg.kind == p.STATICLIB then
|
|
|
|
return {
|
|
|
|
m.treatLinkerWarningAsErrors,
|
|
|
|
m.additionalLinkOptions,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
}
|
2013-12-11 22:33:44 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
function m.lib(cfg, explicit)
|
2014-02-08 15:44:57 +00:00
|
|
|
local contents = p.capture(function ()
|
2014-08-07 22:07:32 +00:00
|
|
|
p.push()
|
|
|
|
p.callArray(m.elements.lib, cfg, explicit)
|
|
|
|
p.pop()
|
2013-12-11 22:33:44 +00:00
|
|
|
end)
|
|
|
|
if #contents > 0 then
|
2014-08-07 22:07:32 +00:00
|
|
|
p.push('<Lib>')
|
|
|
|
p.outln(contents)
|
|
|
|
p.pop('</Lib>')
|
2013-06-12 21:03:09 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-08-07 22:07:32 +00:00
|
|
|
|
2013-09-06 15:32:06 +00:00
|
|
|
--
|
|
|
|
-- Write the manifest section.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.manifest(cfg)
|
2013-09-18 08:35:02 +00:00
|
|
|
-- no additional manifests in static lib
|
2013-09-06 15:32:06 +00:00
|
|
|
if cfg.kind == premake.STATICLIB then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-09-18 08:35:02 +00:00
|
|
|
-- get the manifests files
|
2013-09-06 15:32:06 +00:00
|
|
|
local manifests = {}
|
|
|
|
for _, fname in ipairs(cfg.files) do
|
|
|
|
if path.getextension(fname) == ".manifest" then
|
|
|
|
table.insert(manifests, project.getrelative(cfg.project, fname))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- when a project is not using manifest files, visual studio doesn't write the section.
|
|
|
|
if #manifests == 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<Manifest>')
|
|
|
|
m.element("AdditionalManifestFiles", nil, "%s %%(AdditionalManifestFiles)", table.concat(manifests, " "))
|
|
|
|
p.pop('</Manifest>')
|
2013-09-06 15:32:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-15 21:12:29 +00:00
|
|
|
|
|
|
|
---
|
2012-08-01 19:28:21 +00:00
|
|
|
-- Write out the pre- and post-build event settings.
|
2014-01-15 21:12:29 +00:00
|
|
|
---
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.buildEvents(cfg)
|
2014-01-15 21:12:29 +00:00
|
|
|
local write = function (event)
|
|
|
|
local name = event .. "Event"
|
|
|
|
local field = event:lower()
|
|
|
|
local steps = cfg[field .. "commands"]
|
|
|
|
local msg = cfg[field .. "message"]
|
|
|
|
|
|
|
|
if #steps > 0 then
|
2014-11-29 19:51:49 +00:00
|
|
|
steps = os.translateCommands(steps, p.WINDOWS)
|
2014-01-15 21:12:29 +00:00
|
|
|
_p(2,'<%s>', name)
|
|
|
|
_x(3,'<Command>%s</Command>', table.implode(steps, "", "", "\r\n"))
|
|
|
|
if msg then
|
|
|
|
_x(3,'<Message>%s</Message>', msg)
|
|
|
|
end
|
|
|
|
_p(2,'</%s>', name)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
2014-01-15 21:12:29 +00:00
|
|
|
|
|
|
|
write("PreBuild")
|
|
|
|
write("PreLink")
|
|
|
|
write("PostBuild")
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-07-15 15:16:59 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
-- Write out project-level custom rule variables.
|
|
|
|
---
|
|
|
|
|
2014-10-20 19:41:00 +00:00
|
|
|
function m.ruleVars(cfg)
|
2014-10-24 19:35:30 +00:00
|
|
|
for i = 1, #cfg.rules do
|
|
|
|
local rule = p.global.getRule(cfg.rules[i])
|
|
|
|
|
2014-07-15 15:16:59 +00:00
|
|
|
local contents = p.capture(function ()
|
|
|
|
p.push()
|
2014-10-20 22:45:05 +00:00
|
|
|
for prop in p.rule.eachProperty(rule) do
|
|
|
|
local fld = p.rule.getPropertyField(rule, prop)
|
|
|
|
local value = cfg[fld.name]
|
2014-10-24 19:35:30 +00:00
|
|
|
if value ~= nil then
|
2014-10-20 22:45:05 +00:00
|
|
|
value = p.rule.getPropertyString(rule, prop, value)
|
2014-10-24 19:35:30 +00:00
|
|
|
if value ~= nil and #value > 0 then
|
2014-10-20 22:45:05 +00:00
|
|
|
m.element(prop.name, nil, '%s', value)
|
2014-07-15 15:16:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
p.pop()
|
|
|
|
end)
|
|
|
|
|
|
|
|
if #contents > 0 then
|
2014-10-20 19:41:00 +00:00
|
|
|
p.push('<%s>', rule.name)
|
2014-07-15 15:16:59 +00:00
|
|
|
p.outln(contents)
|
2014-10-20 19:41:00 +00:00
|
|
|
p.pop('</%s>', rule.name)
|
2014-07-15 15:16:59 +00:00
|
|
|
end
|
2014-10-20 19:41:00 +00:00
|
|
|
end
|
2014-07-15 15:16:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-04 16:45:27 +00:00
|
|
|
--
|
|
|
|
-- Reference any managed assemblies listed in the links()
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.assemblyReferences(prj)
|
2013-03-05 16:00:32 +00:00
|
|
|
-- Visual Studio doesn't support per-config references; use
|
|
|
|
-- whatever is contained in the first configuration
|
2013-03-04 16:45:27 +00:00
|
|
|
local cfg = project.getfirstconfig(prj)
|
2013-03-05 16:00:32 +00:00
|
|
|
|
2013-03-04 16:45:27 +00:00
|
|
|
local refs = config.getlinks(cfg, "system", "fullpath", "managed")
|
|
|
|
if #refs > 0 then
|
|
|
|
_p(1,'<ItemGroup>')
|
|
|
|
table.foreachi(refs, function(value)
|
2013-03-05 16:00:32 +00:00
|
|
|
|
|
|
|
-- If the link contains a '/' then it is a relative path to
|
|
|
|
-- a local assembly. Otherwise treat it as a system assembly.
|
|
|
|
if value:find('/', 1, true) then
|
|
|
|
_x(2,'<Reference Include="%s">', path.getbasename(value))
|
|
|
|
_x(3,'<HintPath>%s</HintPath>', path.translate(value))
|
|
|
|
_p(2,'</Reference>')
|
|
|
|
else
|
|
|
|
_x(2,'<Reference Include="%s" />', path.getbasename(value))
|
|
|
|
end
|
|
|
|
|
2013-03-04 16:45:27 +00:00
|
|
|
end)
|
|
|
|
_p(1,'</ItemGroup>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
---
|
2012-08-01 19:28:21 +00:00
|
|
|
-- Write out the list of source code files, and any associated configuration.
|
2014-06-11 20:05:25 +00:00
|
|
|
---
|
2014-06-11 17:52:08 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
m.elements.fileGroups = {
|
2014-10-20 22:45:05 +00:00
|
|
|
"clInclude",
|
|
|
|
"clCompile",
|
|
|
|
"none",
|
|
|
|
"resourceCompile",
|
|
|
|
"customBuild",
|
|
|
|
"customRule"
|
2014-06-11 20:05:25 +00:00
|
|
|
}
|
2014-06-10 20:38:16 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
m.elements.files = function(prj, groups)
|
|
|
|
local calls = {}
|
|
|
|
for i, group in ipairs(m.elements.fileGroups) do
|
|
|
|
calls[i] = m[group .. "Files"]
|
2014-06-10 20:38:16 +00:00
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
return calls
|
|
|
|
end
|
|
|
|
|
|
|
|
function m.files(prj)
|
|
|
|
-- Categorize the source files in groups by build rule; each will
|
|
|
|
-- be written to a separate item group by one of the handlers
|
|
|
|
local groups = m.categorizeSources(prj)
|
|
|
|
p.callArray(m.elements.files, prj, groups)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
2013-03-12 23:26:25 +00:00
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
function m.clCompileFiles(prj, group)
|
2014-06-11 20:05:25 +00:00
|
|
|
local files = group.ClCompile or {}
|
2012-08-01 19:28:21 +00:00
|
|
|
if #files > 0 then
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<ItemGroup>')
|
2014-02-11 23:04:07 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
for _, file in ipairs(files) do
|
2014-02-11 23:04:07 +00:00
|
|
|
local contents = p.capture(function ()
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push()
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
local fcfg = fileconfig.getconfig(file, cfg)
|
|
|
|
m.excludedFromBuild(cfg, fcfg)
|
|
|
|
if fcfg then
|
2014-05-22 13:55:28 +00:00
|
|
|
local condition = m.condition(cfg)
|
2014-06-11 20:05:25 +00:00
|
|
|
m.objectFileName(fcfg)
|
|
|
|
m.clCompilePreprocessorDefinitions(fcfg, condition)
|
2015-03-09 22:49:19 +00:00
|
|
|
m.clCompileUndefinePreprocessorDefinitions(fcfg, condition)
|
2014-06-11 20:05:25 +00:00
|
|
|
m.optimization(fcfg, condition)
|
|
|
|
m.forceIncludes(fcfg, condition)
|
|
|
|
m.precompiledHeader(cfg, fcfg, condition)
|
|
|
|
m.enableEnhancedInstructionSet(fcfg, condition)
|
|
|
|
m.additionalCompileOptions(fcfg, condition)
|
2015-03-09 23:53:46 +00:00
|
|
|
m.disableSpecificWarnings(fcfg, condition)
|
|
|
|
m.treatSpecificWarningsAsErrors(fcfg, condition)
|
2014-02-11 23:04:07 +00:00
|
|
|
end
|
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop()
|
2014-02-11 23:04:07 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
if #contents > 0 then
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<ClCompile Include=\"%s\">', path.translate(file.relpath))
|
2014-06-12 22:39:39 +00:00
|
|
|
p.outln(contents)
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ClCompile>')
|
2014-02-11 23:04:07 +00:00
|
|
|
else
|
2014-06-11 20:05:25 +00:00
|
|
|
p.x('<ClCompile Include=\"%s\" />', path.translate(file.relpath))
|
2014-02-11 23:04:07 +00:00
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ItemGroup>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-12 23:26:25 +00:00
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
function m.clIncludeFiles(prj, groups)
|
2014-06-11 20:05:25 +00:00
|
|
|
local files = groups.ClInclude or {}
|
2012-08-01 19:28:21 +00:00
|
|
|
if #files > 0 then
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<ItemGroup>')
|
|
|
|
for i, file in ipairs(files) do
|
|
|
|
p.x('<ClInclude Include=\"%s\" />', path.translate(file.relpath))
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ItemGroup>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-12 23:26:25 +00:00
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
function m.customBuildFiles(prj, groups)
|
2014-06-11 20:05:25 +00:00
|
|
|
local files = groups.CustomBuild or {}
|
2012-08-01 19:28:21 +00:00
|
|
|
if #files > 0 then
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<ItemGroup>')
|
2012-08-01 19:28:21 +00:00
|
|
|
for _, file in ipairs(files) do
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<CustomBuild Include=\"%s\">', path.translate(file.relpath))
|
|
|
|
p.w('<FileType>Document</FileType>')
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2014-05-22 13:55:28 +00:00
|
|
|
local condition = m.condition(cfg)
|
2013-07-12 15:07:26 +00:00
|
|
|
local filecfg = fileconfig.getconfig(file, cfg)
|
|
|
|
if fileconfig.hasCustomBuildRule(filecfg) then
|
2014-05-22 13:55:28 +00:00
|
|
|
m.excludedFromBuild(cfg, filecfg)
|
2014-02-11 23:04:07 +00:00
|
|
|
|
2014-11-29 19:51:49 +00:00
|
|
|
local commands = os.translateCommands(filecfg.buildcommands, p.WINDOWS)
|
|
|
|
commands = table.concat(commands,'\r\n')
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element("Command", condition, '%s', commands)
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2013-04-17 15:54:07 +00:00
|
|
|
local outputs = project.getrelative(prj, filecfg.buildoutputs)
|
2015-02-18 10:33:07 +00:00
|
|
|
m.element("Outputs", condition, '%s', table.concat(outputs, ";"))
|
2013-09-03 11:16:08 +00:00
|
|
|
|
|
|
|
if filecfg.buildmessage then
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element("Message", condition, '%s', filecfg.buildmessage)
|
2013-09-03 11:16:08 +00:00
|
|
|
end
|
2014-09-25 08:41:27 +00:00
|
|
|
|
|
|
|
if filecfg.buildinputs and #filecfg.buildinputs > 0 then
|
|
|
|
local inputs = project.getrelative(prj, filecfg.buildinputs)
|
2014-09-26 13:16:02 +00:00
|
|
|
m.element("AdditionalInputs", condition, '%s', table.concat(inputs, ";"))
|
2014-09-25 08:41:27 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</CustomBuild>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ItemGroup>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-12 23:26:25 +00:00
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
function m.customRuleFiles(prj, groups)
|
2014-10-24 19:35:30 +00:00
|
|
|
for i = 1, #prj.rules do
|
|
|
|
local rule = p.global.getRule(prj.rules[i])
|
2014-10-20 22:45:05 +00:00
|
|
|
local files = groups[rule.name]
|
|
|
|
if files and #files > 0 then
|
2014-06-11 20:05:25 +00:00
|
|
|
p.push('<ItemGroup>')
|
2014-06-10 20:38:16 +00:00
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
for _, file in ipairs(files) do
|
2014-06-11 20:05:25 +00:00
|
|
|
local contents = p.capture(function()
|
|
|
|
p.push()
|
2014-10-20 22:45:05 +00:00
|
|
|
for prop in p.rule.eachProperty(rule) do
|
|
|
|
local fld = p.rule.getPropertyField(rule, prop)
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
local fcfg = fileconfig.getconfig(file, cfg)
|
2014-10-20 22:45:05 +00:00
|
|
|
if fcfg and fcfg[fld.name] then
|
|
|
|
local value = p.rule.getPropertyString(rule, prop, fcfg[fld.name])
|
2014-07-07 21:03:46 +00:00
|
|
|
if value and #value > 0 then
|
2014-10-20 22:45:05 +00:00
|
|
|
m.element(prop.name, m.condition(cfg), '%s', value)
|
2014-06-11 20:05:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-20 22:45:05 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
end
|
|
|
|
p.pop()
|
|
|
|
end)
|
|
|
|
|
|
|
|
if #contents > 0 then
|
2014-10-20 22:45:05 +00:00
|
|
|
p.push('<%s Include=\"%s\">', rule.name, path.translate(file.relpath))
|
2014-06-12 22:39:39 +00:00
|
|
|
p.outln(contents)
|
2014-10-20 22:45:05 +00:00
|
|
|
p.pop('</%s>', rule.name)
|
2014-06-11 20:05:25 +00:00
|
|
|
else
|
2014-10-20 22:45:05 +00:00
|
|
|
p.x('<%s Include=\"%s\" />', rule.name, path.translate(file.relpath))
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
2014-10-20 22:45:05 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ItemGroup>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-02-26 23:43:06 +00:00
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
|
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
function m.noneFiles(prj, groups)
|
2014-06-11 20:05:25 +00:00
|
|
|
local files = groups.None or {}
|
|
|
|
if #files > 0 then
|
|
|
|
p.push('<ItemGroup>')
|
|
|
|
for i, file in ipairs(files) do
|
|
|
|
p.x('<None Include=\"%s\" />', path.translate(file.relpath))
|
|
|
|
end
|
|
|
|
p.pop('</ItemGroup>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-10-20 22:45:05 +00:00
|
|
|
function m.resourceCompileFiles(prj, groups)
|
2014-06-11 20:05:25 +00:00
|
|
|
local files = groups.ResourceCompile or {}
|
|
|
|
if #files > 0 then
|
|
|
|
p.push('<ItemGroup>')
|
|
|
|
for i, file in ipairs(files) do
|
|
|
|
local contents = p.capture(function ()
|
|
|
|
p.push()
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
local condition = m.condition(cfg)
|
|
|
|
local filecfg = fileconfig.getconfig(file, cfg)
|
|
|
|
if cfg.system == premake.WINDOWS then
|
|
|
|
m.excludedFromBuild(cfg, filecfg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
p.pop()
|
|
|
|
end)
|
|
|
|
|
|
|
|
if #contents > 0 then
|
|
|
|
p.push('<ResourceCompile Include=\"%s\">', path.translate(file.relpath))
|
2014-06-12 22:39:39 +00:00
|
|
|
p.outln(contents)
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ResourceCompile>')
|
2014-06-10 20:38:16 +00:00
|
|
|
else
|
2014-06-11 20:05:25 +00:00
|
|
|
p.x('<ResourceCompile Include=\"%s\" />', path.translate(file.relpath))
|
2014-06-10 20:38:16 +00:00
|
|
|
end
|
2014-02-26 23:43:06 +00:00
|
|
|
end
|
2014-06-11 20:05:25 +00:00
|
|
|
p.pop('</ItemGroup>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-06-10 20:38:16 +00:00
|
|
|
function m.categorize(prj, file)
|
2014-10-20 19:41:00 +00:00
|
|
|
-- If any configuration for this file uses a custom build step,
|
|
|
|
-- that's the category to use
|
2014-06-10 20:38:16 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
local fcfg = fileconfig.getconfig(file, cfg)
|
|
|
|
if fileconfig.hasCustomBuildRule(fcfg) then
|
|
|
|
return "CustomBuild"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-20 19:41:00 +00:00
|
|
|
-- If there is a custom rule associated with it, use that
|
2014-10-24 19:35:30 +00:00
|
|
|
local rule = p.global.getRuleForFile(file.name, prj.rules)
|
2014-10-20 19:41:00 +00:00
|
|
|
if rule then
|
|
|
|
return rule.name
|
|
|
|
end
|
|
|
|
|
2014-06-10 20:38:16 +00:00
|
|
|
-- Otherwise use the file extension to deduce a category
|
2014-06-11 20:05:25 +00:00
|
|
|
if path.iscppfile(file.name) then
|
2014-06-10 20:38:16 +00:00
|
|
|
return "ClCompile"
|
2014-06-11 20:05:25 +00:00
|
|
|
elseif path.iscppheader(file.name) then
|
2014-06-10 20:38:16 +00:00
|
|
|
return "ClInclude"
|
2014-06-11 20:05:25 +00:00
|
|
|
elseif path.isresourcefile(file.name) then
|
2014-06-10 20:38:16 +00:00
|
|
|
return "ResourceCompile"
|
|
|
|
else
|
|
|
|
return "None"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.categorizeSources(prj)
|
2014-06-12 20:14:42 +00:00
|
|
|
local groups = prj._vc2010_sources
|
|
|
|
if groups then
|
|
|
|
return groups
|
|
|
|
end
|
|
|
|
|
|
|
|
groups = {}
|
|
|
|
prj._vc2010_sources = groups
|
2014-06-10 20:38:16 +00:00
|
|
|
|
|
|
|
local tr = project.getsourcetree(prj)
|
|
|
|
tree.traverse(tr, {
|
|
|
|
onleaf = function(node)
|
|
|
|
local cat = m.categorize(prj, node)
|
|
|
|
groups[cat] = groups[cat] or {}
|
|
|
|
table.insert(groups[cat], node)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
-- sort by relative-to path; otherwise VS will reorder the files
|
2014-06-10 20:38:16 +00:00
|
|
|
for group, files in pairs(groups) do
|
|
|
|
table.sort(files, function (a, b)
|
|
|
|
return a.relpath < b.relpath
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
return groups
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
--
|
|
|
|
-- Generate the list of project dependencies.
|
|
|
|
--
|
|
|
|
|
2014-10-02 20:21:25 +00:00
|
|
|
m.elements.projectReferences = function(prj, ref)
|
2014-11-12 00:29:28 +00:00
|
|
|
if prj.clr ~= p.OFF then
|
2014-10-02 20:40:28 +00:00
|
|
|
return {
|
|
|
|
m.referenceProject,
|
|
|
|
m.referencePrivate,
|
|
|
|
m.referenceOutputAssembly,
|
|
|
|
m.referenceCopyLocalSatelliteAssemblies,
|
|
|
|
m.referenceLinkLibraryDependencies,
|
|
|
|
m.referenceUseLibraryDependences,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
m.referenceProject,
|
|
|
|
}
|
|
|
|
end
|
2014-10-02 20:21:25 +00:00
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.projectReferences(prj)
|
2014-10-02 20:21:25 +00:00
|
|
|
local refs = project.getdependencies(prj)
|
|
|
|
if #refs > 0 then
|
|
|
|
p.push('<ItemGroup>')
|
|
|
|
for _, ref in ipairs(refs) do
|
|
|
|
local relpath = project.getrelative(prj, vstudio.projectfile(ref))
|
|
|
|
p.push('<ProjectReference Include=\"%s\">', path.translate(relpath))
|
|
|
|
p.callArray(m.elements.projectReferences, prj, ref)
|
|
|
|
p.pop('</ProjectReference>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2014-10-02 20:21:25 +00:00
|
|
|
p.pop('</ItemGroup>')
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-02-11 18:25:33 +00:00
|
|
|
|
2013-03-07 17:14:03 +00:00
|
|
|
---------------------------------------------------------------------------
|
2013-02-11 18:25:33 +00:00
|
|
|
--
|
2013-03-07 17:14:03 +00:00
|
|
|
-- Handlers for individual project elements
|
2012-08-01 19:28:21 +00:00
|
|
|
--
|
2013-03-07 17:14:03 +00:00
|
|
|
---------------------------------------------------------------------------
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.additionalDependencies(cfg, explicit)
|
2012-08-01 19:28:21 +00:00
|
|
|
local links
|
2012-11-30 19:05:19 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
-- check to see if this project uses an external toolset. If so, let the
|
|
|
|
-- toolset define the format of the links
|
2014-02-27 14:54:55 +00:00
|
|
|
local toolset = config.toolset(cfg)
|
2012-08-01 19:28:21 +00:00
|
|
|
if toolset then
|
2012-11-30 19:05:19 +00:00
|
|
|
links = toolset.getlinks(cfg, not explicit)
|
2012-08-01 19:28:21 +00:00
|
|
|
else
|
2015-02-14 19:56:02 +00:00
|
|
|
links = vstudio.getLinks(cfg, explicit)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2013-01-12 16:52:59 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
if #links > 0 then
|
|
|
|
links = path.translate(table.concat(links, ";"))
|
2014-08-07 22:07:32 +00:00
|
|
|
p.x('<AdditionalDependencies>%s;%%(AdditionalDependencies)</AdditionalDependencies>', links)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-25 16:47:05 +00:00
|
|
|
function m.filterEmpty(dirs)
|
|
|
|
return table.translate(dirs, function(val)
|
|
|
|
if val and #val > 0 then
|
|
|
|
return val
|
|
|
|
else
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.additionalIncludeDirectories(cfg, includedirs)
|
2012-08-01 19:28:21 +00:00
|
|
|
if #includedirs > 0 then
|
|
|
|
local dirs = project.getrelative(cfg.project, includedirs)
|
2015-03-25 16:47:05 +00:00
|
|
|
dirs = m.filterEmpty(dirs)
|
|
|
|
|
|
|
|
if #dirs > 0 then
|
|
|
|
table.sort(dirs)
|
|
|
|
p.x('<AdditionalIncludeDirectories>%s;%%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>', table.concat(dirs, ";"))
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.additionalLibraryDirectories(cfg)
|
2012-08-01 19:28:21 +00:00
|
|
|
if #cfg.libdirs > 0 then
|
|
|
|
local dirs = project.getrelative(cfg.project, cfg.libdirs)
|
|
|
|
dirs = path.translate(table.concat(dirs, ";"))
|
|
|
|
_x(3,'<AdditionalLibraryDirectories>%s;%%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>', dirs)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.additionalUsingDirectories(cfg)
|
2013-09-27 23:04:18 +00:00
|
|
|
if #cfg.usingdirs > 0 then
|
|
|
|
local dirs = project.getrelative(cfg.project, cfg.usingdirs)
|
|
|
|
dirs = path.translate(table.concat(dirs, ";"))
|
2014-06-12 22:39:39 +00:00
|
|
|
p.x('<AdditionalUsingDirectories>%s;%%(AdditionalUsingDirectories)</AdditionalUsingDirectories>', dirs)
|
2013-09-27 23:04:18 +00:00
|
|
|
end
|
2013-11-15 22:17:41 +00:00
|
|
|
end
|
2013-09-27 23:04:18 +00:00
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.additionalCompileOptions(cfg, condition)
|
2013-03-12 23:26:25 +00:00
|
|
|
if #cfg.buildoptions > 0 then
|
|
|
|
local opts = table.concat(cfg.buildoptions, " ")
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element("AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts)
|
2013-03-12 23:26:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-03 15:53:00 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.additionalLinkOptions(cfg)
|
2012-08-01 19:28:21 +00:00
|
|
|
if #cfg.linkoptions > 0 then
|
|
|
|
local opts = table.concat(cfg.linkoptions, " ")
|
|
|
|
_x(3, '<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>', opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.basicRuntimeChecks(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.flags.NoRuntimeChecks then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<BasicRuntimeChecks>Default</BasicRuntimeChecks>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2013-02-11 18:25:33 +00:00
|
|
|
|
2015-04-28 20:30:23 +00:00
|
|
|
function m.buildLog(cfg)
|
|
|
|
if cfg.buildlog and #cfg.buildlog > 0 then
|
|
|
|
local relpath = project.getrelative(cfg.project, cfg.buildlog)
|
|
|
|
p.push('<BuildLog>')
|
|
|
|
p.x('<Path>%s</Path>', path.translate(relpath))
|
|
|
|
p.pop('</BuildLog>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.characterSet(cfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if not vstudio.isMakefile(cfg) then
|
2013-04-03 15:53:00 +00:00
|
|
|
_p(2,'<CharacterSet>%s</CharacterSet>', iif(cfg.flags.Unicode, "Unicode", "MultiByte"))
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.wholeProgramOptimization(cfg)
|
2013-08-21 09:58:08 +00:00
|
|
|
if cfg.flags.LinkTimeOptimization then
|
|
|
|
_p(2,'<WholeProgramOptimization>true</WholeProgramOptimization>')
|
|
|
|
end
|
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.clCompileAdditionalIncludeDirectories(cfg)
|
|
|
|
m.additionalIncludeDirectories(cfg, cfg.includedirs)
|
2013-04-30 16:38:11 +00:00
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.clCompileAdditionalUsingDirectories(cfg)
|
|
|
|
m.additionalUsingDirectories(cfg, cfg.usingdirs)
|
2013-11-15 22:17:41 +00:00
|
|
|
end
|
2013-09-27 23:04:18 +00:00
|
|
|
|
2013-04-30 16:38:11 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.clCompilePreprocessorDefinitions(cfg, condition)
|
|
|
|
m.preprocessorDefinitions(cfg, cfg.defines, false, condition)
|
2013-04-30 16:38:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-09 22:49:19 +00:00
|
|
|
function m.clCompileUndefinePreprocessorDefinitions(cfg, condition)
|
|
|
|
m.undefinePreprocessorDefinitions(cfg, cfg.undefines, false, condition)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.clrSupport(cfg)
|
2014-11-12 00:44:44 +00:00
|
|
|
local value
|
|
|
|
if cfg.clr == "On" or cfg.clr == "Unsafe" then
|
|
|
|
value = "true"
|
|
|
|
elseif cfg.clr ~= p.OFF then
|
|
|
|
value = cfg.clr
|
|
|
|
end
|
|
|
|
if value then
|
|
|
|
p.w('<CLRSupport>%s</CLRSupport>', value)
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.compileAs(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.project.language == "C" then
|
|
|
|
_p(3,'<CompileAs>CompileAsC</CompileAs>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.configurationType(cfg)
|
2013-04-03 15:53:00 +00:00
|
|
|
local types = {
|
|
|
|
SharedLib = "DynamicLibrary",
|
|
|
|
StaticLib = "StaticLibrary",
|
|
|
|
ConsoleApp = "Application",
|
|
|
|
WindowedApp = "Application",
|
|
|
|
Makefile = "Makefile",
|
2013-06-25 14:15:39 +00:00
|
|
|
None = "Makefile",
|
2014-03-01 17:20:06 +00:00
|
|
|
Utility = "Utility",
|
2013-04-03 15:53:00 +00:00
|
|
|
}
|
|
|
|
_p(2,'<ConfigurationType>%s</ConfigurationType>', types[cfg.kind])
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.culture(cfg)
|
2014-02-06 20:38:51 +00:00
|
|
|
local value = vstudio.cultureForLocale(cfg.locale)
|
|
|
|
if value then
|
2014-06-11 20:05:25 +00:00
|
|
|
p.w('<Culture>0x%04x</Culture>', value)
|
2014-02-06 20:38:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.debugInformationFormat(cfg)
|
2012-08-01 19:28:21 +00:00
|
|
|
local value
|
|
|
|
if cfg.flags.Symbols then
|
|
|
|
if cfg.debugformat == "c7" then
|
|
|
|
value = "OldStyle"
|
2015-04-10 13:02:19 +00:00
|
|
|
elseif cfg.architecture == "x86_64" or
|
2014-11-12 00:29:28 +00:00
|
|
|
cfg.clr ~= p.OFF or
|
2013-09-13 15:15:36 +00:00
|
|
|
config.isOptimizedBuild(cfg) or
|
2015-05-05 18:46:00 +00:00
|
|
|
not cfg.editandcontinue
|
2012-08-01 19:28:21 +00:00
|
|
|
then
|
|
|
|
value = "ProgramDatabase"
|
|
|
|
else
|
|
|
|
value = "EditAndContinue"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if value then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<DebugInformationFormat>%s</DebugInformationFormat>', value)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.deploy(cfg)
|
2013-03-07 17:14:03 +00:00
|
|
|
if cfg.system == premake.XBOX360 then
|
|
|
|
_p(2,'<Deploy>')
|
|
|
|
_p(3,'<DeploymentType>CopyToHardDrive</DeploymentType>')
|
|
|
|
_p(3,'<DvdEmulationType>ZeroSeekTimes</DvdEmulationType>')
|
|
|
|
_p(3,'<DeploymentFiles>$(RemoteRoot)=$(ImagePath);</DeploymentFiles>')
|
|
|
|
_p(2,'</Deploy>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.enableEnhancedInstructionSet(cfg, condition)
|
2015-03-26 14:22:55 +00:00
|
|
|
local v
|
2014-03-18 20:26:21 +00:00
|
|
|
local x = cfg.vectorextensions
|
2015-03-26 14:22:55 +00:00
|
|
|
if x == "AVX" and _ACTION > "vs2010" then
|
|
|
|
v = "AdvancedVectorExtensions"
|
|
|
|
elseif x == "AVX2" and _ACTION > "vs2012" then
|
|
|
|
v = "AdvancedVectorExtensions2"
|
2014-03-18 20:26:21 +00:00
|
|
|
elseif x == "SSE2" then
|
2015-03-26 14:22:55 +00:00
|
|
|
v = "StreamingSIMDExtensions2"
|
2014-03-18 20:26:21 +00:00
|
|
|
elseif x == "SSE" then
|
2015-03-26 14:22:55 +00:00
|
|
|
v = "StreamingSIMDExtensions"
|
2014-03-18 20:26:21 +00:00
|
|
|
end
|
2015-03-26 14:22:55 +00:00
|
|
|
if v then
|
|
|
|
m.element('EnableEnhancedInstructionSet', condition, v)
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.entryPointSymbol(cfg)
|
2013-04-03 15:53:00 +00:00
|
|
|
if (cfg.kind == premake.CONSOLEAPP or cfg.kind == premake.WINDOWEDAPP) and
|
2013-03-07 17:14:03 +00:00
|
|
|
not cfg.flags.WinMain and
|
2014-11-12 00:29:28 +00:00
|
|
|
cfg.clr == p.OFF and
|
2013-03-07 17:14:03 +00:00
|
|
|
cfg.system ~= premake.XBOX360
|
|
|
|
then
|
2013-02-11 18:25:33 +00:00
|
|
|
_p(3,'<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.exceptionHandling(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.flags.NoExceptions then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<ExceptionHandling>false</ExceptionHandling>')
|
2013-02-11 18:25:33 +00:00
|
|
|
elseif cfg.flags.SEH then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<ExceptionHandling>Async</ExceptionHandling>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.excludedFromBuild(cfg, filecfg)
|
2013-03-12 23:26:25 +00:00
|
|
|
if not filecfg or filecfg.flags.ExcludeFromBuild then
|
2014-06-12 22:39:39 +00:00
|
|
|
m.element("ExcludedFromBuild", m.condition(cfg), "true")
|
2013-03-12 23:26:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-07-16 19:32:08 +00:00
|
|
|
function m.extensionsToDeleteOnClean(cfg)
|
2015-05-05 18:46:00 +00:00
|
|
|
if #cfg.cleanextensions > 0 then
|
|
|
|
local value = table.implode(cfg.cleanextensions, "*", ";", "")
|
2014-07-16 19:32:08 +00:00
|
|
|
m.element("ExtensionsToDeleteOnClean", nil, value .. "$(ExtensionsToDeleteOnClean)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.floatingPointModel(cfg)
|
2013-09-27 18:49:21 +00:00
|
|
|
if cfg.floatingpoint then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<FloatingPointModel>%s</FloatingPointModel>', cfg.floatingpoint)
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.forceIncludes(cfg, condition)
|
2013-02-11 18:25:33 +00:00
|
|
|
if #cfg.forceincludes > 0 then
|
2013-03-12 23:26:25 +00:00
|
|
|
local includes = path.translate(project.getrelative(cfg.project, cfg.forceincludes))
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element("ForcedIncludeFiles", condition, table.concat(includes, ';'))
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
2013-02-20 14:57:37 +00:00
|
|
|
if #cfg.forceusings > 0 then
|
2013-03-12 23:26:25 +00:00
|
|
|
local usings = path.translate(project.getrelative(cfg.project, cfg.forceusings))
|
2014-06-12 22:39:39 +00:00
|
|
|
m.element("ForcedUsingFiles", condition, table.concat(usings, ';'))
|
2013-02-20 14:57:37 +00:00
|
|
|
end
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.functionLevelLinking(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if config.isOptimizedBuild(cfg) then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<FunctionLevelLinking>true</FunctionLevelLinking>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.generateDebugInformation(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
_p(3,'<GenerateDebugInformation>%s</GenerateDebugInformation>', tostring(cfg.flags.Symbols ~= nil))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.generateManifest(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.flags.NoManifest then
|
|
|
|
_p(2,'<GenerateManifest>false</GenerateManifest>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.generateMapFile(cfg)
|
2014-05-01 19:32:50 +00:00
|
|
|
if cfg.flags.Maps then
|
|
|
|
_p(3,'<GenerateMapFile>true</GenerateMapFile>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-12-08 22:42:00 +00:00
|
|
|
function m.ignoreWarnDuplicateFilename(prj)
|
|
|
|
-- VS 2013 warns on duplicate file names, even those files which are
|
|
|
|
-- contained in different, mututally exclusive configurations. See:
|
|
|
|
-- http://connect.microsoft.com/VisualStudio/feedback/details/797460/incorrect-warning-msb8027-reported-for-files-excluded-from-build
|
|
|
|
-- Premake already adds unique object names to conflicting file names, so
|
|
|
|
-- just go ahead and disable that warning.
|
|
|
|
if _ACTION > "vs2012" then
|
|
|
|
p.w('<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.ignoreImportLibrary(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.kind == premake.SHAREDLIB and cfg.flags.NoImportLib then
|
|
|
|
_p(2,'<IgnoreImportLibrary>true</IgnoreImportLibrary>');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.imageXex(cfg)
|
2013-03-07 17:14:03 +00:00
|
|
|
if cfg.system == premake.XBOX360 then
|
|
|
|
_p(2,'<ImageXex>')
|
2015-05-05 18:46:00 +00:00
|
|
|
if cfg.configfile then
|
|
|
|
_p(3,'<ConfigurationFile>%s</ConfigurationFile>', cfg.configfile)
|
2014-09-20 22:32:18 +00:00
|
|
|
else
|
|
|
|
_p(3,'<ConfigurationFile>')
|
|
|
|
_p(3,'</ConfigurationFile>')
|
|
|
|
end
|
2013-03-07 17:14:03 +00:00
|
|
|
_p(3,'<AdditionalSections>')
|
|
|
|
_p(3,'</AdditionalSections>')
|
|
|
|
_p(2,'</ImageXex>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.imageXexOutput(cfg)
|
2013-03-07 17:14:03 +00:00
|
|
|
if cfg.system == premake.XBOX360 then
|
|
|
|
_x(2,'<ImageXexOutput>$(OutDir)$(TargetName).xex</ImageXexOutput>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-06-12 23:05:44 +00:00
|
|
|
function m.importExtensionTargets(prj)
|
|
|
|
p.w('<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />')
|
|
|
|
p.push('<ImportGroup Label="ExtensionTargets">')
|
2014-10-20 19:41:00 +00:00
|
|
|
|
|
|
|
for i = 1, #prj.rules do
|
|
|
|
local rule = p.global.getRule(prj.rules[i])
|
|
|
|
local loc = project.getrelative(prj, premake.filename(rule, ".targets"))
|
|
|
|
p.x('<Import Project="%s" />', path.translate(loc))
|
|
|
|
end
|
|
|
|
|
2014-06-12 23:05:44 +00:00
|
|
|
p.pop('</ImportGroup>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
|
|
|
|
function m.importDefaultProps(prj)
|
|
|
|
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function m.importExtensionSettings(prj)
|
2014-06-10 20:38:16 +00:00
|
|
|
p.w('<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />')
|
|
|
|
p.push('<ImportGroup Label="ExtensionSettings">')
|
2014-10-20 19:41:00 +00:00
|
|
|
|
|
|
|
for i = 1, #prj.rules do
|
|
|
|
local rule = p.global.getRule(prj.rules[i])
|
|
|
|
local loc = project.getrelative(prj, premake.filename(rule, ".props"))
|
|
|
|
p.x('<Import Project="%s" />', path.translate(loc))
|
|
|
|
end
|
|
|
|
|
2014-06-10 20:38:16 +00:00
|
|
|
p.pop('</ImportGroup>')
|
2014-05-22 13:55:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function m.importLibrary(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.kind == premake.SHAREDLIB then
|
|
|
|
_x(3,'<ImportLibrary>%s</ImportLibrary>', path.translate(cfg.linktarget.relpath))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.intDir(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
local objdir = project.getrelative(cfg.project, cfg.objdir)
|
|
|
|
_x(2,'<IntDir>%s\\</IntDir>', path.translate(objdir))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.intrinsicFunctions(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if config.isOptimizedBuild(cfg) then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<IntrinsicFunctions>true</IntrinsicFunctions>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 14:26:16 +00:00
|
|
|
|
|
|
|
function m.keyword(prj)
|
|
|
|
-- try to determine what kind of targets we're building here
|
|
|
|
local isWin, isManaged, isMakefile
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
if cfg.system == premake.WINDOWS then
|
|
|
|
isWin = true
|
|
|
|
end
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.clr ~= p.OFF then
|
2014-05-22 14:26:16 +00:00
|
|
|
isManaged = true
|
|
|
|
end
|
|
|
|
if vstudio.isMakefile(cfg) then
|
|
|
|
isMakefile = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if isWin then
|
|
|
|
if isMakefile then
|
|
|
|
_p(2,'<Keyword>MakeFileProj</Keyword>')
|
|
|
|
else
|
|
|
|
if isManaged then
|
|
|
|
m.targetFramework(prj)
|
|
|
|
_p(2,'<Keyword>ManagedCProj</Keyword>')
|
|
|
|
else
|
|
|
|
_p(2,'<Keyword>Win32Proj</Keyword>')
|
|
|
|
end
|
|
|
|
_p(2,'<RootNamespace>%s</RootNamespace>', prj.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.linkIncremental(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.kind ~= premake.STATICLIB then
|
2013-09-13 15:15:36 +00:00
|
|
|
_p(2,'<LinkIncremental>%s</LinkIncremental>', tostring(config.canLinkIncremental(cfg)))
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.linkLibraryDependencies(cfg, explicit)
|
2013-02-11 18:25:33 +00:00
|
|
|
-- Left to its own devices, VS will happily link against a project dependency
|
|
|
|
-- that has been excluded from the build. As a workaround, disable dependency
|
|
|
|
-- linking and list all siblings explicitly
|
|
|
|
if explicit then
|
|
|
|
_p(2,'<ProjectReference>')
|
|
|
|
_p(3,'<LinkLibraryDependencies>false</LinkLibraryDependencies>')
|
|
|
|
_p(2,'</ProjectReference>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.minimalRebuild(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if config.isOptimizedBuild(cfg) or
|
2013-02-11 18:25:33 +00:00
|
|
|
cfg.flags.NoMinimalRebuild or
|
|
|
|
cfg.flags.MultiProcessorCompile or
|
|
|
|
cfg.debugformat == premake.C7
|
|
|
|
then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<MinimalRebuild>false</MinimalRebuild>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.moduleDefinitionFile(cfg)
|
2013-02-21 15:28:41 +00:00
|
|
|
local df = config.findfile(cfg, ".def")
|
|
|
|
if df then
|
|
|
|
_p(3,'<ModuleDefinitionFile>%s</ModuleDefinitionFile>', df)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.multiProcessorCompilation(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.flags.MultiProcessorCompile then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<MultiProcessorCompilation>true</MultiProcessorCompilation>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.nmakeCommandLine(cfg, commands, phase)
|
2013-04-07 18:30:58 +00:00
|
|
|
if #commands > 0 then
|
2014-11-29 19:51:49 +00:00
|
|
|
commands = os.translateCommands(commands, p.WINDOWS)
|
2014-02-08 15:44:57 +00:00
|
|
|
commands = table.concat(premake.esc(commands), p.eol())
|
2013-04-07 18:30:58 +00:00
|
|
|
_p(2, '<NMake%sCommandLine>%s</NMake%sCommandLine>', phase, commands, phase)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.nmakeOutDirs(cfg)
|
2013-06-26 11:28:57 +00:00
|
|
|
if vstudio.isMakefile(cfg) then
|
2014-05-22 13:55:28 +00:00
|
|
|
m.outDir(cfg)
|
|
|
|
m.intDir(cfg)
|
2013-04-25 15:45:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.nmakeOutput(cfg)
|
2013-04-03 15:53:00 +00:00
|
|
|
_p(2,'<NMakeOutput>$(OutDir)%s</NMakeOutput>', cfg.buildtarget.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
|
|
|
|
function m.objectFileName(fcfg)
|
|
|
|
if fcfg.objname ~= fcfg.basename then
|
|
|
|
p.w('<ObjectFileName %s>$(IntDir)\\%s.obj</ObjectFileName>', m.condition(fcfg.config), fcfg.objname)
|
2013-03-12 23:26:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
|
|
|
|
function m.omitDefaultLib(cfg)
|
|
|
|
if cfg.flags.OmitDefaultLibrary then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<OmitDefaultLibName>true</OmitDefaultLibName>')
|
2014-05-22 13:55:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function m.omitFramePointers(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.flags.NoFramePointer then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<OmitFramePointers>true</OmitFramePointers>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.optimizeReferences(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if config.isOptimizedBuild(cfg) then
|
2013-02-11 18:25:33 +00:00
|
|
|
_p(3,'<EnableCOMDATFolding>true</EnableCOMDATFolding>')
|
|
|
|
_p(3,'<OptimizeReferences>true</OptimizeReferences>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.optimization(cfg, condition)
|
2013-10-16 18:29:49 +00:00
|
|
|
local map = { Off="Disabled", On="Full", Debug="Disabled", Full="Full", Size="MinSpace", Speed="MaxSpeed" }
|
|
|
|
local value = map[cfg.optimize]
|
|
|
|
if value or not condition then
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element('Optimization', condition, value or "Disabled")
|
2013-10-16 18:29:49 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.outDir(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
local outdir = project.getrelative(cfg.project, cfg.buildtarget.directory)
|
|
|
|
_x(2,'<OutDir>%s\\</OutDir>', path.translate(outdir))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.outputFile(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.system == premake.XBOX360 then
|
2013-04-03 15:53:00 +00:00
|
|
|
_p(2,'<OutputFile>$(OutDir)%s</OutputFile>', cfg.buildtarget.name)
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-25 16:47:05 +00:00
|
|
|
function m.executablePath(cfg)
|
|
|
|
local dirs = project.getrelative(cfg.project, cfg.bindirs)
|
|
|
|
dirs = m.filterEmpty(dirs)
|
|
|
|
|
|
|
|
if #dirs > 0 then
|
|
|
|
_x(2,'<ExecutablePath>%s;$(ExecutablePath)</ExecutablePath>', table.concat(dirs, ";"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-12-08 22:42:00 +00:00
|
|
|
function m.platformToolset(cfg)
|
2015-04-28 22:50:56 +00:00
|
|
|
local tool, version = p.config.toolset(cfg)
|
|
|
|
if version then
|
|
|
|
version = "v" .. version
|
|
|
|
else
|
|
|
|
local action = premake.action.current()
|
|
|
|
version = action.vstudio.platformToolset
|
|
|
|
end
|
|
|
|
if version then
|
2014-12-08 22:42:00 +00:00
|
|
|
-- should only be written if there is a C/C++ file in the config
|
|
|
|
for i = 1, #cfg.files do
|
|
|
|
if path.iscppfile(cfg.files[i]) then
|
2015-04-28 22:50:56 +00:00
|
|
|
p.w('<PlatformToolset>%s</PlatformToolset>', version)
|
|
|
|
break
|
2014-12-08 22:42:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.precompiledHeader(cfg, filecfg, condition)
|
2013-03-12 23:26:25 +00:00
|
|
|
if filecfg then
|
|
|
|
if cfg.pchsource == filecfg.abspath and not cfg.flags.NoPCH then
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element('PrecompiledHeader', condition, 'Create')
|
2013-10-16 20:11:39 +00:00
|
|
|
elseif filecfg.flags.NoPCH then
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element('PrecompiledHeader', condition, 'NotUsing')
|
2013-03-12 23:26:25 +00:00
|
|
|
end
|
2013-02-11 18:25:33 +00:00
|
|
|
else
|
2013-03-12 23:26:25 +00:00
|
|
|
if not cfg.flags.NoPCH and cfg.pchheader then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<PrecompiledHeader>Use</PrecompiledHeader>')
|
|
|
|
p.x('<PrecompiledHeaderFile>%s</PrecompiledHeaderFile>', cfg.pchheader)
|
2013-03-12 23:26:25 +00:00
|
|
|
else
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<PrecompiledHeader>NotUsing</PrecompiledHeader>')
|
2013-03-12 23:26:25 +00:00
|
|
|
end
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.preprocessorDefinitions(cfg, defines, escapeQuotes, condition)
|
2012-08-01 19:28:21 +00:00
|
|
|
if #defines > 0 then
|
|
|
|
defines = table.concat(defines, ";")
|
2013-04-30 16:25:25 +00:00
|
|
|
if escapeQuotes then
|
|
|
|
defines = defines:gsub('"', '\\"')
|
|
|
|
end
|
2014-01-28 18:41:58 +00:00
|
|
|
defines = premake.esc(defines) .. ";%%(PreprocessorDefinitions)"
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element('PreprocessorDefinitions', condition, defines)
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-09 22:49:19 +00:00
|
|
|
function m.undefinePreprocessorDefinitions(cfg, undefines, escapeQuotes, condition)
|
|
|
|
if #undefines > 0 then
|
|
|
|
undefines = table.concat(undefines, ";")
|
|
|
|
if escapeQuotes then
|
|
|
|
undefines = undefines:gsub('"', '\\"')
|
|
|
|
end
|
|
|
|
undefines = premake.esc(undefines) .. ";%%(UndefinePreprocessorDefinitions)"
|
|
|
|
m.element('UndefinePreprocessorDefinitions', condition, undefines)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.programDataBaseFileName(cfg)
|
2014-07-28 20:37:45 +00:00
|
|
|
-- just a placeholder for overriding; will use the default VS name
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
|
2013-02-11 18:25:33 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.projectGuid(prj)
|
2013-02-11 18:25:33 +00:00
|
|
|
_p(2,'<ProjectGuid>{%s}</ProjectGuid>', prj.uuid)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.projectName(prj)
|
2013-05-01 16:08:41 +00:00
|
|
|
if prj.name ~= prj.filename then
|
|
|
|
_x(2,'<ProjectName>%s</ProjectName>', prj.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.propertyGroup(cfg, label)
|
2013-02-11 18:25:33 +00:00
|
|
|
local cond
|
|
|
|
if cfg then
|
2014-05-22 13:55:28 +00:00
|
|
|
cond = string.format(' %s', m.condition(cfg))
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2013-02-11 18:25:33 +00:00
|
|
|
|
|
|
|
if label then
|
|
|
|
label = string.format(' Label="%s"', label)
|
|
|
|
end
|
|
|
|
|
|
|
|
_p(1,'<PropertyGroup%s%s>', cond or "", label or "")
|
2012-12-11 16:17:43 +00:00
|
|
|
end
|
2012-08-01 19:28:21 +00:00
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
|
|
|
|
function m.propertySheets(cfg)
|
|
|
|
_p(1,'<ImportGroup Label="PropertySheets" %s>', m.condition(cfg))
|
|
|
|
_p(2,'<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists(\'$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\')" Label="LocalAppDataPlatform" />')
|
|
|
|
_p(1,'</ImportGroup>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.propertySheetGroup(prj)
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
m.propertySheets(cfg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-10-02 20:40:28 +00:00
|
|
|
function m.referenceCopyLocalSatelliteAssemblies(prj, ref)
|
|
|
|
p.w('<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.referenceLinkLibraryDependencies(prj, ref)
|
|
|
|
p.w('<LinkLibraryDependencies>true</LinkLibraryDependencies>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.referenceOutputAssembly(prj, ref)
|
|
|
|
p.w('<ReferenceOutputAssembly>true</ReferenceOutputAssembly>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.referencePrivate(prj, ref)
|
|
|
|
p.w('<Private>true</Private>')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.referenceProject(prj, ref)
|
|
|
|
p.w('<Project>{%s}</Project>', ref.uuid)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function m.referenceUseLibraryDependences(prj, ref)
|
|
|
|
p.w('<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>')
|
|
|
|
end
|
2014-05-22 13:55:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
function m.resourceAdditionalIncludeDirectories(cfg)
|
|
|
|
m.additionalIncludeDirectories(cfg, table.join(cfg.includedirs, cfg.resincludedirs))
|
2013-04-30 16:38:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.resourcePreprocessorDefinitions(cfg)
|
|
|
|
m.preprocessorDefinitions(cfg, table.join(cfg.defines, cfg.resdefines), true)
|
2013-04-30 16:38:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.runtimeLibrary(cfg)
|
2013-03-27 15:12:37 +00:00
|
|
|
local runtimes = {
|
|
|
|
StaticDebug = "MultiThreadedDebug",
|
|
|
|
StaticRelease = "MultiThreaded",
|
|
|
|
}
|
|
|
|
local runtime = runtimes[config.getruntime(cfg)]
|
|
|
|
if runtime then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<RuntimeLibrary>%s</RuntimeLibrary>', runtime)
|
2013-02-08 15:35:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
|
|
|
|
function m.runtimeTypeInfo(cfg)
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.flags.NoRTTI and cfg.clr == p.OFF then
|
2013-02-11 18:25:33 +00:00
|
|
|
_p(3,'<RuntimeTypeInfo>false</RuntimeTypeInfo>')
|
2013-02-08 15:35:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.bufferSecurityCheck(cfg)
|
2013-08-15 22:22:23 +00:00
|
|
|
if cfg.flags.NoBufferSecurityCheck then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<BufferSecurityCheck>false</BufferSecurityCheck>')
|
2013-08-15 22:22:23 +00:00
|
|
|
end
|
|
|
|
end
|
2013-02-08 15:35:14 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.stringPooling(cfg)
|
2013-09-13 15:15:36 +00:00
|
|
|
if config.isOptimizedBuild(cfg) then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<StringPooling>true</StringPooling>')
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.subSystem(cfg)
|
2013-03-07 17:14:03 +00:00
|
|
|
if cfg.system ~= premake.XBOX360 then
|
|
|
|
local subsystem = iif(cfg.kind == premake.CONSOLEAPP, "Console", "Windows")
|
|
|
|
_p(3,'<SubSystem>%s</SubSystem>', subsystem)
|
|
|
|
end
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.targetExt(cfg)
|
2013-05-22 13:06:33 +00:00
|
|
|
local ext = cfg.buildtarget.extension
|
|
|
|
if ext ~= "" then
|
|
|
|
_x(2,'<TargetExt>%s</TargetExt>', ext)
|
|
|
|
else
|
|
|
|
_p(2,'<TargetExt>')
|
|
|
|
_p(2,'</TargetExt>')
|
|
|
|
end
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.targetName(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
_x(2,'<TargetName>%s%s</TargetName>', cfg.buildtarget.prefix, cfg.buildtarget.basename)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.treatLinkerWarningAsErrors(cfg)
|
2014-02-14 17:23:12 +00:00
|
|
|
if cfg.flags.FatalLinkWarnings then
|
2013-12-24 19:01:57 +00:00
|
|
|
local el = iif(cfg.kind == premake.STATICLIB, "Lib", "Linker")
|
|
|
|
_p(3,'<Treat%sWarningAsErrors>true</Treat%sWarningAsErrors>', el, el)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +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-06-12 22:39:39 +00:00
|
|
|
p.w('<TreatWChar_tAsBuiltInType>%s</TreatWChar_tAsBuiltInType>', value)
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.treatWarningAsError(cfg)
|
2014-11-12 00:29:28 +00:00
|
|
|
if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then
|
2014-06-12 22:39:39 +00:00
|
|
|
p.w('<TreatWarningAsError>true</TreatWarningAsError>')
|
2013-01-12 16:52:59 +00:00
|
|
|
end
|
2012-12-11 16:17:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-09 23:53:46 +00:00
|
|
|
function m.disableSpecificWarnings(cfg, condition)
|
|
|
|
if #cfg.disablewarnings > 0 then
|
|
|
|
local warnings = table.concat(cfg.disablewarnings, ";")
|
|
|
|
warnings = premake.esc(warnings) .. ";%%(DisableSpecificWarnings)"
|
|
|
|
m.element('DisableSpecificWarnings', condition, warnings)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-03-26 14:22:55 +00:00
|
|
|
|
2015-03-09 23:53:46 +00:00
|
|
|
function m.treatSpecificWarningsAsErrors(cfg, condition)
|
|
|
|
if #cfg.fatalwarnings > 0 then
|
|
|
|
local fatal = table.concat(cfg.fatalwarnings, ";")
|
|
|
|
fatal = premake.esc(fatal) .. ";%%(TreatSpecificWarningsAsErrors)"
|
|
|
|
m.element('TreatSpecificWarningsAsErrors', condition, fatal)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.useDebugLibraries(cfg)
|
2013-03-27 15:12:37 +00:00
|
|
|
local runtime = config.getruntime(cfg)
|
|
|
|
_p(2,'<UseDebugLibraries>%s</UseDebugLibraries>', tostring(runtime:endswith("Debug")))
|
2013-02-11 18:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.useOfMfc(cfg)
|
2013-02-11 18:25:33 +00:00
|
|
|
if cfg.flags.MFC then
|
|
|
|
_p(2,'<UseOfMfc>%s</UseOfMfc>', iif(cfg.flags.StaticRuntime, "Static", "Dynamic"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.useOfAtl(cfg)
|
2014-02-27 15:47:43 +00:00
|
|
|
if cfg.atl then
|
|
|
|
_p(2,'<UseOfATL>%s</UseOfATL>', cfg.atl)
|
2014-02-27 12:47:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-11 18:25:33 +00:00
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
|
|
|
|
function m.userMacros(cfg)
|
|
|
|
_p(1,'<PropertyGroup Label="UserMacros" />')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function m.warningLevel(cfg)
|
2013-09-29 16:39:07 +00:00
|
|
|
local map = { Off = "TurnOffAllWarnings", Extra = "Level4" }
|
2014-06-11 20:05:25 +00:00
|
|
|
m.element("WarningLevel", nil, "%s", map[cfg.warnings] or "Level3")
|
2012-08-01 19:28:21 +00:00
|
|
|
end
|
2013-03-12 23:26:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-12 19:47:22 +00:00
|
|
|
function m.xmlDeclaration()
|
|
|
|
p.xmlUtf8()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-12 23:26:25 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
-- Support functions
|
|
|
|
--
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Format and return a Visual Studio Condition attribute.
|
|
|
|
--
|
|
|
|
|
2014-05-22 13:55:28 +00:00
|
|
|
function m.condition(cfg)
|
2013-03-12 23:26:25 +00:00
|
|
|
return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', premake.esc(vstudio.projectConfig(cfg)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Output an individual project XML element, with an optional configuration
|
|
|
|
-- condition.
|
|
|
|
--
|
|
|
|
-- @param depth
|
|
|
|
-- How much to indent the element.
|
|
|
|
-- @param name
|
|
|
|
-- The element name.
|
|
|
|
-- @param condition
|
|
|
|
-- An optional configuration condition, formatted with vc2010.condition().
|
|
|
|
-- @param value
|
|
|
|
-- The element value, which may contain printf formatting tokens.
|
|
|
|
-- @param ...
|
|
|
|
-- Optional additional arguments to satisfy any tokens in the value.
|
|
|
|
--
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
function m.element(name, condition, value, ...)
|
2013-03-12 23:26:25 +00:00
|
|
|
if select('#',...) == 0 then
|
|
|
|
value = premake.esc(value)
|
|
|
|
end
|
|
|
|
|
|
|
|
local format
|
|
|
|
if condition then
|
|
|
|
format = string.format('<%s %s>%s</%s>', name, condition, value, name)
|
|
|
|
else
|
|
|
|
format = string.format('<%s>%s</%s>', name, value, name)
|
|
|
|
end
|
|
|
|
|
2014-06-11 20:05:25 +00:00
|
|
|
p.x(format, ...)
|
2013-03-12 23:26:25 +00:00
|
|
|
end
|