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