Switched PS3 builds from GCC to SNC

This commit is contained in:
Jason Perkins 2010-12-02 06:56:35 -05:00
parent 8e469cf3a5
commit b8f2684004
6 changed files with 240 additions and 28 deletions

View File

@ -1,15 +1,9 @@
-------
4.4 (in progress)
-------
* Patch 2963313: Enable setting .NET framework version (Justen Hyde)
-------
4.4 (in progress)
-------
* Bug 3119793: Fixed ClCompile blocks with vs10 and PCH (Dan Dunham)
* Patch 2963313: Enable setting .NET framework version (Justen Hyde)
* Switched PS3 builds from GCC to SNC
-------

View File

@ -28,6 +28,7 @@
"tools/gcc.lua",
"tools/msc.lua",
"tools/ow.lua",
"tools/snc.lua",
"base/validate.lua",
"base/help.lua",
"base/premake.lua",

View File

@ -212,16 +212,32 @@
output(indent, "<File")
attrib(indent, "RelativePath", path.translate(fname, "\\"))
output(indent, "\t>")
if (not prj.flags.NoPCH and prj.pchsource == fname) then
for _, cfginfo in ipairs(prj.solution.vstudio_configs) do
if cfginfo.isreal then
local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
local usePCH = (not prj.flags.NoPCH and prj.pchsource == fname)
if (usePCH) then
output(indent, "\t<FileConfiguration")
attrib(indent, "\tName", cfginfo.name)
output(indent, "\t\t>")
output(indent, "\t\t<Tool")
attrib(indent, "\t\tName", iif(cfg.system == "Xbox360", "VCCLX360CompilerTool", "VCCLCompilerTool"))
if (usePCH) then
if (cfg.system == "PS3") then
-- TODO: do we really need all the build flags here? Or can we just
-- add the additional option --create_pch, and let the rest of the
-- flags get picked up from the main compiler config block?
local buildoptions = table.join(premake.snc.getcflags(cfg), premake.snc.getcxxflags(cfg), cfg.buildoptions)
local additionalOptions = table.concat(buildoptions, " ");
additionalOptions = additionalOptions .. " --create_pch=\"" .. path.getname(cfg.pchheader) .. ".pch" .. "\""
attrib(indent, "\t\tAdditionalOptions", premake.esc(additionalOptions))
else
attrib(indent, "\t\tUsePrecompiledHeader", "1")
end
end
output(indent, "\t\t/>")
output(indent, "\t</FileConfiguration>")
end

View File

@ -274,17 +274,22 @@ local vcproj = premake.vstudio.vcproj
--
-- Compiler and linker blocks for the PS3 platform, which uses GCC.
-- Compiler and linker blocks for the PS3 platform, which uses Sony's SNC.
--
function premake.vs200x_vcproj_VCCLCompilerTool_GCC(cfg)
function premake.vs200x_vcproj_VCCLCompilerTool_PS3(cfg)
_p(3,'<Tool')
_p(4,'Name="VCCLCompilerTool"')
local buildoptions = table.join(premake.gcc.getcflags(cfg), premake.gcc.getcxxflags(cfg), cfg.buildoptions)
if #buildoptions > 0 then
_p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " ")))
local buildoptions = table.join(premake.snc.getcflags(cfg), premake.snc.getcxxflags(cfg), cfg.buildoptions)
if not cfg.flags.NoPCH and cfg.pchheader then
_p(4,'UsePrecompiledHeader="%s"', iif(_ACTION < "vs2005", 3, 2))
_p(4,'PrecompiledHeaderThrough="%s"', path.getname(cfg.pchheader))
table.insert(buildoptions, "--use_pch=\"" .. path.getname(cfg.pchheader) .. ".pch" .. "\"")
else
_p(4,'UsePrecompiledHeader="%s"', iif(_ACTION > "vs2003" or cfg.flags.NoPCH, 0, 2))
end
_p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " ")))
if #cfg.includedirs > 0 then
_p(4,'AdditionalIncludeDirectories="%s"', premake.esc(path.translate(table.concat(cfg.includedirs, ";"), '\\')))
@ -300,12 +305,12 @@ local vcproj = premake.vstudio.vcproj
_p(3,'/>')
end
function premake.vs200x_vcproj_VCLinkerTool_GCC(cfg)
function premake.vs200x_vcproj_VCLinkerTool_PS3(cfg)
_p(3,'<Tool')
if cfg.kind ~= "StaticLib" then
_p(4,'Name="VCLinkerTool"')
local buildoptions = table.join(premake.gcc.getldflags(cfg), cfg.linkoptions)
local buildoptions = table.join(premake.snc.getldflags(cfg), cfg.linkoptions)
if #buildoptions > 0 then
_p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " ")))
end
@ -324,7 +329,7 @@ local vcproj = premake.vstudio.vcproj
else
_p(4,'Name="VCLibrarianTool"')
local buildoptions = table.join(premake.gcc.getldflags(cfg), cfg.linkoptions)
local buildoptions = table.join(premake.snc.getldflags(cfg), cfg.linkoptions)
if #buildoptions > 0 then
_p(4,'AdditionalOptions="%s"', premake.esc(table.concat(buildoptions, " ")))
end
@ -432,9 +437,9 @@ local vcproj = premake.vstudio.vcproj
local blockmap =
{
VCCLCompilerTool = premake.vs200x_vcproj_VCCLCompilerTool,
VCCLCompilerTool_GCC = premake.vs200x_vcproj_VCCLCompilerTool_GCC,
VCCLCompilerTool_PS3 = premake.vs200x_vcproj_VCCLCompilerTool_PS3,
VCLinkerTool = premake.vs200x_vcproj_VCLinkerTool,
VCLinkerTool_GCC = premake.vs200x_vcproj_VCLinkerTool_GCC,
VCLinkerTool_PS3 = premake.vs200x_vcproj_VCLinkerTool_PS3,
VCManifestTool = premake.vs200x_vcproj_VCManifestTool,
VCMIDLTool = premake.vs200x_vcproj_VCMIDLTool,
VCResourceCompilerTool = premake.vs200x_vcproj_VCResourceCompilerTool,
@ -504,11 +509,11 @@ local vcproj = premake.vstudio.vcproj
"VCXMLDataGeneratorTool",
"VCWebServiceProxyGeneratorTool",
"VCMIDLTool",
"VCCLCompilerTool_GCC",
"VCCLCompilerTool_PS3",
"VCManagedResourceCompilerTool",
"VCResourceCompilerTool",
"VCPreLinkEventTool",
"VCLinkerTool_GCC",
"VCLinkerTool_PS3",
"VCALinkTool",
"VCManifestTool",
"VCXDCMakeTool",

195
src/tools/snc.lua Normal file
View File

@ -0,0 +1,195 @@
--
-- snc.lua
-- Provides Sony SNC-specific configuration strings.
-- Copyright (c) 2010 Jason Perkins and the Premake project
--
premake.snc = { }
-- TODO: Will cfg.system == "windows" ever be true for SNC? If
-- not, remove the conditional blocks that use this test.
--
-- Set default tools
--
premake.snc.cc = "snc"
premake.snc.cxx = "g++"
premake.snc.ar = "ar"
--
-- Translation of Premake flags into SNC flags
--
local cflags =
{
EnableSSE = "-msse",
EnableSSE2 = "-msse2",
ExtraWarnings = "-Wall",
FatalWarnings = "-Werror",
FloatFast = "-ffast-math",
FloatStrict = "-ffloat-store",
NoFramePointer = "-fomit-frame-pointer",
Optimize = "-O2",
OptimizeSize = "-Os",
OptimizeSpeed = "-O3",
Symbols = "-g",
}
local cxxflags =
{
NoExceptions = "", -- No exceptions is the default in the SNC compiler.
NoRTTI = "-Xc-=rtti",
}
--
-- Map platforms to flags
--
premake.snc.platforms =
{
Native = {
cppflags = "-MMD -MP",
},
x32 = {
cppflags = "-MMD -MP",
flags = "-m32",
ldflags = "-L/usr/lib32",
},
x64 = {
cppflags = "-MMD -MP",
flags = "-m64",
ldflags = "-L/usr/lib64",
},
PS3 = {
cc = "ppu-lv2-g++",
cxx = "ppu-lv2-g++",
ar = "ppu-lv2-ar",
cppflags = "-MMD -MP",
}
}
local platforms = premake.snc.platforms
--
-- Returns a list of compiler flags, based on the supplied configuration.
--
function premake.snc.getcppflags(cfg)
local result = { }
table.insert(result, platforms[cfg.platform].cppflags)
return result
end
function premake.snc.getcflags(cfg)
local result = table.translate(cfg.flags, cflags)
table.insert(result, platforms[cfg.platform].flags)
if cfg.system ~= "windows" and cfg.kind == "SharedLib" then
table.insert(result, "-fPIC")
end
return result
end
function premake.snc.getcxxflags(cfg)
local result = table.translate(cfg.flags, cxxflags)
return result
end
--
-- Returns a list of linker flags, based on the supplied configuration.
--
function premake.snc.getldflags(cfg)
local result = { }
if not cfg.flags.Symbols then
table.insert(result, "-s")
end
if cfg.kind == "SharedLib" then
table.insert(result, "-shared")
if cfg.system == "windows" and not cfg.flags.NoImportLib then
table.insert(result, '-Wl,--out-implib="' .. cfg.linktarget.fullpath .. '"')
end
end
if cfg.kind == "WindowedApp" and cfg.system == "windows" then
table.insert(result, "-mwindows")
end
local platform = platforms[cfg.platform]
table.insert(result, platform.flags)
table.insert(result, platform.ldflags)
return result
end
--
-- Return a list of library search paths. Technically part of LDFLAGS but need to
-- be separated because of the way Visual Studio calls SNC for the PS3. See bug
-- #1729227 for background on why library paths must be split.
--
function premake.snc.getlibdirflags(cfg)
local result = { }
for _, value in ipairs(premake.getlinks(cfg, "all", "directory")) do
table.insert(result, '-L' .. _MAKE.esc(value))
end
return result
end
--
-- Returns a list of linker flags for library search directories and library
-- names. See bug #1729227 for background on why the path must be split.
--
function premake.snc.getlinkflags(cfg)
local result = { }
for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do
if path.getextension(value) == ".framework" then
table.insert(result, '-framework ' .. _MAKE.esc(path.getbasename(value)))
else
table.insert(result, '-l' .. _MAKE.esc(value))
end
end
return result
end
--
-- Decorate defines for the SNC command line.
--
function premake.snc.getdefines(defines)
local result = { }
for _,def in ipairs(defines) do
table.insert(result, '-D' .. def)
end
return result
end
--
-- Decorate include file search paths for the SNC command line.
--
function premake.snc.getincludedirs(includedirs)
local result = { }
for _,dir in ipairs(includedirs) do
table.insert(result, "-I" .. _MAKE.esc(dir))
end
return result
end

View File

@ -361,10 +361,11 @@
includedirs { "include/pkg1", "include/pkg2" }
defines { "DEFINE1", "DEFINE2" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool_GCC(premake.getconfig(prj, "Debug", "PS3"))
premake.vs200x_vcproj_VCCLCompilerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
AdditionalOptions="-g"
AdditionalIncludeDirectories="include\pkg1;include\pkg2"
PreprocessorDefinitions="DEFINE1;DEFINE2"
@ -378,7 +379,7 @@
function suite.LinkerBlock_OnPS3ConsoleApp()
platforms { "PS3" }
prepare()
premake.vs200x_vcproj_VCLinkerTool_GCC(premake.getconfig(prj, "Debug", "PS3"))
premake.vs200x_vcproj_VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
<Tool
Name="VCLinkerTool"
@ -398,7 +399,7 @@
platforms { "PS3" }
kind "StaticLib"
prepare()
premake.vs200x_vcproj_VCLinkerTool_GCC(premake.getconfig(prj, "Debug", "PS3"))
premake.vs200x_vcproj_VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
<Tool
Name="VCLibrarianTool"
@ -415,7 +416,7 @@
language "C++"
kind "SharedLib"
prepare()
premake.vs200x_vcproj_VCLinkerTool_GCC(premake.getconfig(prj, "Debug", "PS3"))
premake.vs200x_vcproj_VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
<Tool