Patch 3021550: Add Wii homebrew platform (Pathogen David)

This commit is contained in:
Jason Perkins 2011-09-15 16:45:48 -04:00
parent 4eeb4f76f3
commit dfda94d862
12 changed files with 227 additions and 33 deletions

View File

@ -29,6 +29,7 @@
* Bug 3277343: SM_SERVERR2 is not always defined by default (Martin Ridgers) * Bug 3277343: SM_SERVERR2 is not always defined by default (Martin Ridgers)
* Added os.stat * Added os.stat
* Bug 3381149: Path of PCH source file in VS10 not being translated (intyuh) * Bug 3381149: Path of PCH source file in VS10 not being translated (intyuh)
* Patch 3021550: Add Wii homebrew platform (Pathogen David)
------- -------
4.3 4.3

View File

@ -1,11 +1,12 @@
-- --
-- _make.lua -- _make.lua
-- Define the makefile action(s). -- Define the makefile action(s).
-- Copyright (c) 2002-2010 Jason Perkins and the Premake project -- Copyright (c) 2002-2011 Jason Perkins and the Premake project
-- --
_MAKE = { } _MAKE = { }
premake.make = { } premake.make = { }
local make = premake.make
-- --
-- Escape a string so it can be written to a makefile. -- Escape a string so it can be written to a makefile.
@ -99,7 +100,26 @@
return result return result
end end
--
-- Write out the raw settings blocks.
--
function make.settings(cfg, cc)
if #cfg.makesettings > 0 then
for _, value in ipairs(cfg.makesettings) do
_p(value)
end
end
local toolsettings = cc.platforms[cfg.platform].cfgsettings
if toolsettings then
_p(toolsettings)
end
end
-- --
-- Register the "gmake" action -- Register the "gmake" action
-- --

View File

@ -1,11 +1,12 @@
-- --
-- make_cpp.lua -- make_cpp.lua
-- Generate a C/C++ project makefile. -- Generate a C/C++ project makefile.
-- Copyright (c) 2002-2009 Jason Perkins and the Premake project -- Copyright (c) 2002-2011 Jason Perkins and the Premake project
-- --
premake.make.cpp = { } premake.make.cpp = { }
local _ = premake.make.cpp local cpp = premake.make.cpp
local make = premake.make
function premake.make_cpp(prj) function premake.make_cpp(prj)
@ -106,7 +107,7 @@
_p('') _p('')
-- precompiler header rule -- precompiler header rule
_.pchrules(prj) cpp.pchrules(prj)
-- per-file rules -- per-file rules
for _, file in ipairs(prj.files) do for _, file in ipairs(prj.files) do
@ -166,7 +167,7 @@
_p('') _p('')
end end
-- --
-- Write a block of configuration settings. -- Write a block of configuration settings.
-- --
@ -175,33 +176,22 @@
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname)) _p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))
-- if this platform requires a special compiler or linker, list it now -- if this platform requires a special compiler or linker, list it here
local platform = cc.platforms[cfg.platform] cpp.platformtools(cfg, cc)
if platform.cc then
_p(' CC = %s', platform.cc)
end
if platform.cxx then
_p(' CXX = %s', platform.cxx)
end
if platform.ar then
_p(' AR = %s', platform.ar)
end
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir)) _p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory)) _p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))
_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name)) _p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))
_p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), " ")) _p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), " "))
_p(' INCLUDES += %s', table.concat(cc.getincludedirs(cfg.includedirs), " ")) _p(' INCLUDES += %s', table.concat(cc.getincludedirs(cfg.includedirs), " "))
_p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), " "))
-- CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, and RESFLAGS
cpp.flags(cfg, cc)
-- set up precompiled headers -- set up precompiled headers
_.pchconfig(cfg) cpp.pchconfig(cfg)
_p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), " "))
_p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " "))
_p(' LDFLAGS += %s', table.concat(table.join(cc.getldflags(cfg), cfg.linkoptions, cc.getlibdirflags(cfg)), " "))
_p(' LIBS += %s', table.concat(cc.getlinkflags(cfg), " ")) _p(' LIBS += %s', table.concat(cc.getlinkflags(cfg), " "))
_p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s', table.concat(table.join(cc.getdefines(cfg.resdefines), cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " "))
_p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")), " ")) _p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")), " "))
if cfg.kind == "StaticLib" then if cfg.kind == "StaticLib" then
@ -237,16 +227,52 @@
end end
_p(' endef') _p(' endef')
-- write out config-level makesettings blocks
make.settings(cfg, cc)
_p('endif') _p('endif')
_p('') _p('')
end end
--
-- Platform support
--
function cpp.platformtools(cfg, cc)
local platform = cc.platforms[cfg.platform]
if platform.cc then
_p(' CC = %s', platform.cc)
end
if platform.cxx then
_p(' CXX = %s', platform.cxx)
end
if platform.ar then
_p(' AR = %s', platform.ar)
end
end
--
-- Configurations
--
function cpp.flags(cfg, cc)
_p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), " "))
_p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), " "))
_p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " "))
_p(' LDFLAGS += %s', table.concat(table.join(cc.getldflags(cfg), cfg.linkoptions, cc.getlibdirflags(cfg)), " "))
_p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s',
table.concat(table.join(cc.getdefines(cfg.resdefines),
cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " "))
end
-- --
-- Precompiled header support -- Precompiled header support
-- --
function _.pchconfig(cfg) function cpp.pchconfig(cfg)
if not cfg.flags.NoPCH and cfg.pchheader then if not cfg.flags.NoPCH and cfg.pchheader then
_p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader))) _p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader)))
_p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader))) _p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader)))
@ -254,7 +280,7 @@
end end
end end
function _.pchrules(prj) function cpp.pchrules(prj)
_p('ifneq (,$(PCH))') _p('ifneq (,$(PCH))')
_p('$(GCH): $(PCH)') _p('$(GCH): $(PCH)')
_p('\t@echo $(notdir $<)') _p('\t@echo $(notdir $<)')

View File

@ -254,6 +254,12 @@
scope = "container", scope = "container",
}, },
makesettings =
{
kind = "list",
scope = "config",
},
objdir = objdir =
{ {
kind = "path", kind = "path",

View File

@ -22,7 +22,14 @@
projects = true, projects = true,
__configs = true, __configs = true,
} }
-- do not cascade these fields from projects to configurations
local nocascade =
{
makesettings = true,
}
-- leave these paths as absolute, rather than converting to project relative -- leave these paths as absolute, rather than converting to project relative
local keeprelative = local keeprelative =

View File

@ -45,6 +45,12 @@
nosharedlibs = true, nosharedlibs = true,
namestyle = "PS3", namestyle = "PS3",
}, },
WiiDev =
{
cfgsuffix = "wii",
iscrosscompiler = true,
namestyle = "PS3",
},
Xbox360 = Xbox360 =
{ {
cfgsuffix = "xbox360", cfgsuffix = "xbox360",

View File

@ -79,7 +79,16 @@
cxx = "ppu-lv2-g++", cxx = "ppu-lv2-g++",
ar = "ppu-lv2-ar", ar = "ppu-lv2-ar",
cppflags = "-MMD", cppflags = "-MMD",
} },
WiiDev = {
cppflags = "-MMD -MP -I$(LIBOGC_INC) $(MACHDEP)",
ldflags = "-L$(LIBOGC_LIB) $(MACHDEP)",
cfgsettings = [[
ifeq ($(strip $(DEVKITPPC)),)
$(error "DEVKITPPC environment variable is not set")'
endif
include $(DEVKITPPC)/wii_rules']],
},
} }
local platforms = premake.gcc.platforms local platforms = premake.gcc.platforms
@ -118,9 +127,8 @@
local result = table.translate(cfg.flags, cxxflags) local result = table.translate(cfg.flags, cxxflags)
return result return result
end end
-- --
-- Returns a list of linker flags, based on the supplied configuration. -- Returns a list of linker flags, based on the supplied configuration.
-- --
@ -240,3 +248,13 @@
end end
return result return result
end end
--
-- Return platform specific project and configuration level
-- makesettings blocks.
--
function premake.gcc.getcfgsettings(cfg)
return platforms[cfg.platform].cfgsettings
end

View File

@ -0,0 +1,51 @@
--
-- tests/actions/make/test_makesettings.lua
-- Tests makesettings lists in generated makefiles.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.make_settings = { }
local suite = T.make_settings
local make = premake.make
local sln, prj, cfg
function suite.setup()
_ACTION = "gmake"
sln = solution("MySolution")
configurations { "Debug", "Release" }
makesettings { "SOLUTION_LEVEL_SETTINGS" }
project("MyProject")
makesettings { "PROJECT_LEVEL_SETTINGS" }
configuration { "Debug" }
makesettings { "DEBUG_LEVEL_SETTINGS" }
configuration { "Release" }
makesettings { "RELEASE_LEVEL_SETTINGS" }
premake.bake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
cfg = premake.getconfig(prj, "Debug")
end
function suite.writesProjectSettings()
make.settings(prj, premake.gcc)
test.capture [[
SOLUTION_LEVEL_SETTINGS
PROJECT_LEVEL_SETTINGS
]]
end
function suite.writesConfigSettings()
make.settings(cfg, premake.gcc)
test.capture [[
DEBUG_LEVEL_SETTINGS
]]
end

View File

@ -0,0 +1,56 @@
--
-- tests/actions/make/test_wiidev.lua
-- Tests for Wii homebrew support in makefiles.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.make_wiidev = { }
local suite = T.make_wiidev
local make = premake.make
local cpp = premake.make.cpp
local sln, prj, cfg
function suite.setup()
_ACTION = "gmake"
sln = solution("MySolution")
configurations { "Debug", "Release" }
platforms { "WiiDev" }
prj = project("MyProject")
premake.bake.buildconfigs()
cfg = premake.getconfig(prj, "Debug", "WiiDev")
end
--
-- Make sure that the Wii-specific flags are passed to the tools.
--
function suite.writesCorrectFlags()
cpp.flags(cfg, premake.gcc)
test.capture [[
CPPFLAGS += -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) -MP $(DEFINES) $(INCLUDES)
CFLAGS += $(CPPFLAGS) $(ARCH)
CXXFLAGS += $(CFLAGS)
LDFLAGS += -s lwiiuse -lbte -logc -lm -L$(LIBOGC_LIB) $(MACHDEP)
RESFLAGS += $(DEFINES) $(INCLUDES)
]]
end
--
-- Make sure the dev kit include is written to each Wii build configuration.
--
function suite.writesIncludeBlock()
make.settings(cfg, premake.gcc)
test.capture [[
ifeq ($(strip $(DEVKITPPC)),)
$(error "DEVKITPPC environment variable is not set")'
endif
include $(DEVKITPPC)/wii_rules'
]]
end

View File

@ -112,7 +112,9 @@
dofile("actions/make/test_make_escaping.lua") dofile("actions/make/test_make_escaping.lua")
dofile("actions/make/test_make_pch.lua") dofile("actions/make/test_make_pch.lua")
dofile("actions/make/test_make_linking.lua") dofile("actions/make/test_make_linking.lua")
-- dofile("actions/make/test_makesettings.lua")
dofile("actions/make/test_wiidev.lua")
-- Xcode3 tests -- Xcode3 tests
dofile("actions/xcode/test_xcode_common.lua") dofile("actions/xcode/test_xcode_common.lua")
dofile("actions/xcode/test_xcode_project.lua") dofile("actions/xcode/test_xcode_project.lua")

View File

@ -82,8 +82,8 @@ ifeq ($(config),debug)
CFLAGS += $(CPPFLAGS) $(ARCH) CFLAGS += $(CPPFLAGS) $(ARCH)
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
LDFLAGS += -s LDFLAGS += -s
LIBS +=
RESFLAGS += $(DEFINES) $(INCLUDES) RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS += LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
define PREBUILDCMDS define PREBUILDCMDS
@ -116,8 +116,8 @@ ifeq ($(config),debugps3)
CFLAGS += $(CPPFLAGS) $(ARCH) CFLAGS += $(CPPFLAGS) $(ARCH)
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
LDFLAGS += -s LDFLAGS += -s
LIBS +=
RESFLAGS += $(DEFINES) $(INCLUDES) RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS += LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
define PREBUILDCMDS define PREBUILDCMDS
@ -147,8 +147,8 @@ ifeq ($(config),debug64)
CFLAGS += $(CPPFLAGS) $(ARCH) -m64 CFLAGS += $(CPPFLAGS) $(ARCH) -m64
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
LDFLAGS += -s -m64 -L/usr/lib64 LDFLAGS += -s -m64 -L/usr/lib64
LIBS +=
RESFLAGS += $(DEFINES) $(INCLUDES) RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS += LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
define PREBUILDCMDS define PREBUILDCMDS
@ -179,8 +179,8 @@ ifeq ($(config),debuguniv32)
CFLAGS += $(CPPFLAGS) $(ARCH) -arch i386 -arch ppc CFLAGS += $(CPPFLAGS) $(ARCH) -arch i386 -arch ppc
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
LDFLAGS += -s -arch i386 -arch ppc LDFLAGS += -s -arch i386 -arch ppc
LIBS +=
RESFLAGS += $(DEFINES) $(INCLUDES) RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS += LDDEPS +=
LINKCMD = libtool -o $(TARGET) $(OBJECTS) LINKCMD = libtool -o $(TARGET) $(OBJECTS)
define PREBUILDCMDS define PREBUILDCMDS

View File

@ -199,6 +199,7 @@
_OPTIONS = { } _OPTIONS = { }
premake.solution.list = { } premake.solution.list = { }
io.indent = nil io.indent = nil
io.eol = "\n"
-- reset captured I/O values -- reset captured I/O values
test.value_openedfilename = nil test.value_openedfilename = nil