Patch 3317329: Support vstudio CompileAs for mixed-language projects (xpol)
This commit is contained in:
parent
7c3716fc77
commit
b7fac3f46e
@ -34,6 +34,7 @@
|
||||
* Patch 3138574: NoImportLib ignored in Windows makefiles dependencies (rjmyst3)
|
||||
* Patch 3367641: Remove warnings in Xcode 4
|
||||
* Patch 3372345: Gmake action's PCHs don't work with Mingw (Martin Ridgers)
|
||||
* Patch 3317329: Support vstudio CompileAs for mixed-language projects (xpol)
|
||||
|
||||
|
||||
-------
|
||||
|
@ -122,8 +122,10 @@
|
||||
|
||||
-- source files are handled at the leaves
|
||||
onleaf = function(node, depth)
|
||||
local fname = node.cfg.name
|
||||
|
||||
_p(depth, '<File')
|
||||
_p(depth, '\tRelativePath="%s"', path.translate(node.cfg.name, "\\"))
|
||||
_p(depth, '\tRelativePath="%s"', path.translate(fname, "\\"))
|
||||
_p(depth, '\t>')
|
||||
depth = depth + 1
|
||||
|
||||
@ -134,21 +136,33 @@
|
||||
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
|
||||
|
||||
local usePCH = (not prj.flags.NoPCH and prj.pchsource == node.cfg.name)
|
||||
if (usePCH) then
|
||||
local useCompileAs = (path.iscfile(fname) ~= premake.project.iscproject(prj))
|
||||
|
||||
if usePCH or useCompileAs then
|
||||
_p(depth, '<FileConfiguration')
|
||||
_p(depth, '\tName="%s"', cfginfo.name)
|
||||
_p(depth, '\t>')
|
||||
_p(depth, '\t<Tool')
|
||||
_p(depth, '\t\tName="%s"', iif(cfg.system == "Xbox360", "VCCLX360CompilerTool", "VCCLCompilerTool"))
|
||||
_p(depth, '\t\tName="%s"', iif(cfg.system == "Xbox360",
|
||||
"VCCLX360CompilerTool",
|
||||
"VCCLCompilerTool"))
|
||||
|
||||
if cfg.system == "PS3" then
|
||||
local options = table.join(premake.snc.getcflags(cfg), premake.snc.getcxxflags(cfg), cfg.buildoptions)
|
||||
options = table.concat(options, " ");
|
||||
options = options .. ' --create_pch="$(IntDir)/$(TargetName).pch"'
|
||||
_p(depth, '\t\tAdditionalOptions="%s"', premake.esc(options))
|
||||
else
|
||||
_p(depth, '\t\tUsePrecompiledHeader="1"')
|
||||
end
|
||||
if useCompileAs then
|
||||
_p(depth, '\t\tCompileAs="%s"', iif(path.iscfile(fname), 1, 2))
|
||||
end
|
||||
|
||||
if usePCH then
|
||||
if cfg.system == "PS3" then
|
||||
local options = table.join(premake.snc.getcflags(cfg),
|
||||
premake.snc.getcxxflags(cfg),
|
||||
cfg.buildoptions)
|
||||
options = table.concat(options, " ");
|
||||
options = options .. ' --create_pch="$(IntDir)/$(TargetName).pch"'
|
||||
_p(depth, '\t\tAdditionalOptions="%s"', premake.esc(options))
|
||||
else
|
||||
_p(depth, '\t\tUsePrecompiledHeader="1"')
|
||||
end
|
||||
end
|
||||
|
||||
_p(depth, '\t/>')
|
||||
_p(depth, '</FileConfiguration>')
|
||||
|
@ -621,6 +621,15 @@
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Returns true if the project use the C language.
|
||||
--
|
||||
|
||||
function premake.project.iscproject(prj)
|
||||
return prj.language == "C"
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Returns true if the project uses a C/C++ language.
|
||||
--
|
||||
|
@ -32,18 +32,18 @@
|
||||
--
|
||||
|
||||
function suite.SimpleSourceFile()
|
||||
files { "hello.c" }
|
||||
files { "hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.c"
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
</File>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.SingleFolderLevel()
|
||||
files { "src/hello.c" }
|
||||
files { "src/hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Filter
|
||||
@ -51,7 +51,7 @@
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="src\hello.c"
|
||||
RelativePath="src\hello.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@ -59,7 +59,7 @@
|
||||
end
|
||||
|
||||
function suite.MultipleFolderLevels()
|
||||
files { "src/greetings/hello.c" }
|
||||
files { "src/greetings/hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Filter
|
||||
@ -71,7 +71,7 @@
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="src\greetings\hello.c"
|
||||
RelativePath="src\greetings\hello.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@ -80,6 +80,67 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Mixed language support
|
||||
--
|
||||
|
||||
function suite.CompileAsC_InCppProject()
|
||||
language "c++"
|
||||
files { "hello.c" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.CompileAsCpp_InCProject()
|
||||
language "c"
|
||||
files { "hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- PCH support
|
||||
--
|
||||
|
@ -40,8 +40,8 @@ local vc200x = premake.vstudio.vc200x
|
||||
--
|
||||
|
||||
function suite.Filter_UsesVirtualForm_OnVpath()
|
||||
files { "src/hello.c" }
|
||||
vpaths { ["Source Files"] = "**.c" }
|
||||
files { "src/hello.cpp" }
|
||||
vpaths { ["Source Files"] = "**.cpp" }
|
||||
prepare()
|
||||
vc200x.Files(prj)
|
||||
test.capture [[
|
||||
@ -50,7 +50,7 @@ local vc200x = premake.vstudio.vc200x
|
||||
Filter=""
|
||||
>
|
||||
<File
|
||||
RelativePath="src\hello.c"
|
||||
RelativePath="src\hello.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
|
Loading…
Reference in New Issue
Block a user