diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua
index 2a4d5e18..b3e46d65 100644
--- a/src/actions/vstudio/vs2010_vcxproj.lua
+++ b/src/actions/vstudio/vs2010_vcxproj.lua
@@ -347,6 +347,7 @@
vc2010.customBuildFilesGroup(prj)
end
+
function vc2010.simplefilesgroup(prj, group)
local files = vc2010.getfilegroup(prj, group)
if #files > 0 then
@@ -358,6 +359,7 @@
end
end
+
function vc2010.compilerfilesgroup(prj)
local files = vc2010.getfilegroup(prj, "ClCompile")
if #files > 0 then
@@ -368,18 +370,14 @@
local condition = vc2010.condition(cfg)
local filecfg = config.getfileconfig(cfg, file.abspath)
- if not filecfg or filecfg.flags.ExcludeFromBuild then
- _p(3,'true', condition)
+ vc2010.excludedFromBuild(cfg, filecfg)
+ if filecfg then
+ vc2010.objectFileName(filecfg)
+ vc2010.forceIncludes(filecfg, condition)
+ vc2010.precompiledHeader(cfg, filecfg, condition)
+ vc2010.additionalCompileOptions(filecfg, condition)
end
- local objectname = project.getfileobject(prj, file.abspath)
- if objectname ~= path.getbasename(file.abspath) then
- _p(3,'$(IntDir)\\%s.obj', condition, objectname)
- end
-
- if cfg.pchsource == file.abspath and not cfg.flags.NoPCH then
- _p(3,'Create', condition)
- end
end
_p(2,'')
end
@@ -387,6 +385,7 @@
end
end
+
function vc2010.customBuildFilesGroup(prj)
local files = vc2010.getfilegroup(prj, "CustomBuild")
if #files > 0 then
@@ -413,6 +412,7 @@
end
end
+
function vc2010.getfilegroup(prj, group)
-- check for a cached copy before creating
local groups = prj.vc2010_file_groups
@@ -480,29 +480,6 @@
end
---
--- Format and return a Visual Studio Condition attribute.
---
-
- function vc2010.condition(cfg)
- return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', premake.esc(vstudio.projectConfig(cfg)))
- end
-
-
---
--- Map Premake's project kinds to Visual Studio configuration types.
---
-
- function vc2010.configType(cfg)
- local map = {
- SharedLib = "DynamicLibrary",
- StaticLib = "StaticLibrary",
- ConsoleApp = "Application",
- WindowedApp = "Application"
- }
- return map[cfg.kind]
- end
-
---------------------------------------------------------------------------
--
@@ -548,6 +525,13 @@
end
+ function vc2010.additionalCompileOptions(cfg, condition)
+ if #cfg.buildoptions > 0 then
+ local opts = table.concat(cfg.buildoptions, " ")
+ vc2010.element(3, "AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts)
+ end
+ end
+
function vc2010.additionalLinkOptions(cfg)
if #cfg.linkoptions > 0 then
local opts = table.concat(cfg.linkoptions, " ")
@@ -656,6 +640,13 @@
end
+ function vc2010.excludedFromBuild(cfg, filecfg)
+ if not filecfg or filecfg.flags.ExcludeFromBuild then
+ _p(3,'true', vc2010.condition(cfg))
+ end
+ end
+
+
function vc2010.floatingPointModel(cfg)
if cfg.flags.FloatFast then
_p(3,'Fast')
@@ -665,13 +656,13 @@
end
- function vc2010.forceIncludes(cfg)
+ function vc2010.forceIncludes(cfg, condition)
if #cfg.forceincludes > 0 then
- local includes = project.getrelative(cfg.project, cfg.forceincludes)
- _x(3,'%s', table.concat(includes, ';'))
+ local includes = path.translate(project.getrelative(cfg.project, cfg.forceincludes))
+ vc2010.element(3, "ForcedIncludeFiles", condition, table.concat(includes, ';'))
end
if #cfg.forceusings > 0 then
- local usings = project.getrelative(cfg.project, cfg.forceusings)
+ local usings = path.translate(project.getrelative(cfg.project, cfg.forceusings))
_x(3,'%s', table.concat(usings, ';'))
end
end
@@ -794,6 +785,14 @@
end
+ function vc2010.objectFileName(filecfg)
+ local objectname = project.getfileobject(filecfg.project, filecfg.abspath)
+ if objectname ~= path.getbasename(filecfg.abspath) then
+ _p(3,'$(IntDir)\\%s.obj', vc2010.condition(filecfg.config), objectname)
+ end
+ end
+
+
function vc2010.omitFramePointers(cfg)
if cfg.flags.NoFramePointer then
_p(3,'true')
@@ -844,12 +843,18 @@
end
- function vc2010.precompiledHeader(cfg)
- if not cfg.flags.NoPCH and cfg.pchheader then
- _p(3,'Use')
- _x(3,'%s', path.getname(cfg.pchheader))
+ function vc2010.precompiledHeader(cfg, filecfg, condition)
+ if filecfg then
+ if cfg.pchsource == filecfg.abspath and not cfg.flags.NoPCH then
+ vc2010.element(3, 'PrecompiledHeader', condition, 'Create')
+ end
else
- _p(3,'NotUsing')
+ if not cfg.flags.NoPCH and cfg.pchheader then
+ _p(3,'Use')
+ _x(3,'%s', path.getname(cfg.pchheader))
+ else
+ _p(3,'NotUsing')
+ end
end
end
@@ -965,3 +970,67 @@
end
_p(3,'Level%d', w)
end
+
+
+
+
+---------------------------------------------------------------------------
+--
+-- Support functions
+--
+---------------------------------------------------------------------------
+
+--
+-- Format and return a Visual Studio Condition attribute.
+--
+
+ function vc2010.condition(cfg)
+ return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', premake.esc(vstudio.projectConfig(cfg)))
+ end
+
+
+--
+-- Map Premake's project kinds to Visual Studio configuration types.
+--
+
+ function vc2010.configType(cfg)
+ local map = {
+ SharedLib = "DynamicLibrary",
+ StaticLib = "StaticLibrary",
+ ConsoleApp = "Application",
+ WindowedApp = "Application"
+ }
+ return map[cfg.kind]
+ 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.
+--
+
+ function vc2010.element(depth, name, condition, value, ...)
+ 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
+
+ _x(depth, format, ...)
+ end
diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/tests/actions/vstudio/vc2010/test_compile_settings.lua
index 137a93ac..a3a7b0ce 100644
--- a/tests/actions/vstudio/vc2010/test_compile_settings.lua
+++ b/tests/actions/vstudio/vc2010/test_compile_settings.lua
@@ -551,7 +551,7 @@
NotUsing
Level3
- stdafx.h;include/sys.h
+ stdafx.h;include\sys.h
]]
end
@@ -562,7 +562,7 @@
NotUsing
Level3
- stdafx.h;include/sys.h
+ stdafx.h;include\sys.h
]]
end
diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua
index 9bff6469..537301d1 100755
--- a/tests/actions/vstudio/vc2010/test_files.lua
+++ b/tests/actions/vstudio/vc2010/test_files.lua
@@ -164,3 +164,47 @@
]]
end
+
+
+--
+-- Check handling of per-file forced includes.
+--
+
+ function suite.forcedIncludeFiles()
+ language "C++"
+ files { "hello.cpp" }
+ configuration "**.cpp"
+ forceincludes { "../include/force1.h", "../include/force2.h" }
+
+ prepare()
+ test.capture [[
+
+
+ ..\include\force1.h;..\include\force2.h
+ ..\include\force1.h;..\include\force2.h
+
+
+ ]]
+ end
+
+
+--
+-- Check handling of per-file command line build options.
+--
+
+ function suite.additionalOptions()
+ language "C++"
+ files { "hello.cpp" }
+ configuration "**.cpp"
+ buildoptions { "/Xc" }
+
+ prepare()
+ test.capture [[
+
+
+ /Xc %(AdditionalOptions)
+ /Xc %(AdditionalOptions)
+
+
+ ]]
+ end