require "utils" assert(platform == "ps3") -- determine visual studios version vsver = nil; if _ACTION == "vs2010" then vsver = "10"; elseif _ACTION == "vs2012" then vsver = "11"; else assert("unknown compiler version") end assert(vsver ~= nil) local suffix = "" local compiler = "snc" -- default for PS3, used for PPU PS3CPUConfigurations = { ppu = { ["*"] = { flags = { "PS3_TOCPointerPreservation_NoTOC", "PS3_CPP_Exceptions_RTTI_Not_Using_Exceptions_and_RTII", }, defines = { "SN_TARGET_PS3" }, }, ["Debug"] = { flags = { "PS3_Optimization_NoOptimize" }, }, ["Re*"] = { flags = { "PS3_Optimization_FullOptimize3" }, }, }, spu = { ["*"] = { defines = { "SN_TARGET_PS3_SPU", "SPU", "__SPU__" }, buildoptions = { "-fpic" }, flags = { "PS3_SPU", "PS3_GCC_ExtraWarnings_Yes", "PS3_SPU_FunctionSections_Yes", "PS3_SPU_DataSections_Yes", }, }, ["Debug"] = { flags = { "PS3_GCC_Optimization_Os", "PS3_SPU_StackCheck_Yes" }, }, ["Re*"] = { flags = { "PS3_GCC_Optimization_O3" }, }, } } PS3CompilerConfigurations = { gcc = { ["*"] = { defines = { "_HAS_EXCEPTIONS=0" }, buildoptions = { "-fno-exceptions", "-fmessage-length=0", "-Wuninitialized", }, }, }, snc = { ["*"] = { -- TODO: Add more options... like warnings for example buildoptions = { "-Xaltivec" }, }, } } if eal_impl then eal_impl.suffix = ("_" .. platform .. "_ppu" .. suffix .. "_vc" .. vsver) end require "solution" require "library" local subdir = joindir(platform, "vc" .. vsver) PS3TestProject = TestProject:New() function PS3TestProject:GenerateConfigurations() TestProject.GenerateConfigurations(self) -- TODO: Push this in the configuration itself. -- We need to have a kind+cpu discriminator for this. configuration { "*" } targetextension ".self" if self.library.cpu == "ppu" then if _OPTIONS.spu then defines { "G4_TEST_SPU" } end links { "libsync_stub.a", "libfs_stub.a", "libio_stub.a", "libm.a", "libnet_stub.a", "libnetctl_stub.a", "libspurs_stub.a", "libsysutil_stub.a", "libgcm_cmd.a", "libusbd_stub.a", "libgcm_sys_stub.a", "libdbgfont_gcm.a", "libsysutil_avconf_ext_stub.a", "libsysmodule_stub.a", "librtc_stub.a", "liblv2dbg_stub.a", "libcamera_stub.a", "libperf.a", "libgem_stub.a", "libcgb.a", "libgcm_gpad_stub.a" } end -- Add a post-build step to compile the SPUs tests while skipping it for the gear_testing unit test. -- NOTE: This is a hack and should really be done in the gear_core/premake4.lua file, but the generation -- script organization seems to not be good enough for that. local prjname = project().name local comparisonstr = "gear_testing" if string.sub(prjname, 1, string.len(comparisonstr)) ~= comparisonstr then postbuildcommands { iif(vsver == "11", "\"$(DevEnvDir)devenv.com\" \"$(SolutionPath)\" /build retail /project \"gear_core_ps3_spu (SPU)\"", "\"$(DevEnvDir)devenv.com\" \"$(SolutionPath)\" /build retail /project \"gear_core_ps3_spu\"" ), iif(vsver == "11", "\"$(DevEnvDir)devenv.com\" \"$(SolutionPath)\" /build retail /project \"gear_testing_ps3_spu (SPU)\"", "\"$(DevEnvDir)devenv.com\" \"$(SolutionPath)\" /build retail /project \"gear_testing_ps3_spu\"" ), iif(vsver == "11", "\"$(DevEnvDir)devenv.com\" \"$(SolutionPath)\" /build retail /project \"simpleal_ps3_spu (SPU)\"", "\"$(DevEnvDir)devenv.com\" \"$(SolutionPath)\" /build retail /project \"simpleal_ps3_spu\"" ), "pushd \"$(SolutionDir)..\\..\\..\\buildfolder\\generation\"", "set python=\"$(SolutionDir)..\\..\\..\\private\\tools\\Python27\\python\"", iif(string.sub(prjname, 1, string.len("simpleal")) ~= "simpleal", "%python% -B spuTestBuilder.py -w $(ProjectDir) -i $(ProjectDir)$(IntDir) -o $(ProjectDir)$(OutDir) -r ../../gear_core/tests -v " .. _ACTION ), "popd" } debugargs { "--g4_spuelfs_path=$(ProjectDir)exe" } end end PS3LibProject = LibProject:New{ targetprefix = "lib", } PS3Library = Library:New{ TestProject = PS3TestProject, LibProject = PS3LibProject, libext = ".a", suffix = suffix, compiler = compiler, cpu = "ppu", platform = "ps3_ppu" } function PS3Library:GetConfig(name) local config = Library.GetConfig(self, name) config.includedirs = collect ( config.includedirs, { "$(SN_PS3_PATH)/" .. self.cpu .. "/include/sn", "$(SCE_PS3_ROOT)/target/" .. self.cpu .. "/include" } ) return config end function PS3Library:CreateExternalLib(name, config) local project = Library.CreateExternalLib(self, name, config) project:UpdateConfigurations(PS3CompilerConfigurations[self.compiler]) project:UpdateConfigurations(PS3CPUConfigurations[self.cpu]) return project end function PS3Library:CreateSPULibrary() -- avoid to change our own setting local project = self.SPULibrary:CreateMainProject() project:UpdateConfigurations(PS3CompilerConfigurations[self.SPULibrary.compiler]) project:UpdateConfigurations(PS3CPUConfigurations[self.SPULibrary.cpu]) project:Populate() -- Conflicting options. self.projects.spu_library = project return project end function PS3Library:Initialize() self.platform = "ps3_ppu" Library.Initialize(self) for project in iter(self.projects) do project:UpdateConfigurations(PS3CompilerConfigurations[self.compiler]) project:UpdateConfigurations(PS3CPUConfigurations[self.cpu]) end self.SPULibrary = self:New { cpu = "spu", platform = "ps3_spu", compiler = "gcc", basename = self.name .. "_" .. "ps3_spu" .. self.suffix, TestProject = PS3SPUTestProject } end PS3Solution = Solution:New{ Library = PS3Library, subdir = subdir, suffix = suffix, location = joindir("solutions", subdir), compiler = compiler, PS3Defaults = { flags = { "VS_MultiProcessorCompilation_Yes" }, -- gtest specific defines defines = { "GTEST_HAS_POSIX_RE=0", "GTEST_USE_OWN_TR1_TUPLE=1", "GTEST_HAS_STREAM_REDIRECTION=0", }, } } function PS3Solution:GenerateConfigurations() Solution.GenerateConfigurations(self) self:GenerateConfiguration("*", self.PS3Defaults) end function PS3Solution:Generate() -- A bug in premake generate the -Xc-=rtti even on SPU. self.defaults.flags = collect(difference(self.defaults.flags, { "NoRTTI" })) Solution.Generate(self) end RegisterSolution("ps3", PS3Solution)