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)
* Added os.stat
* Bug 3381149: Path of PCH source file in VS10 not being translated (intyuh)
* Patch 3021550: Add Wii homebrew platform (Pathogen David)
-------
4.3

View File

@ -1,11 +1,12 @@
--
-- _make.lua
-- 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 = { }
premake.make = { }
local make = premake.make
--
-- Escape a string so it can be written to a makefile.
@ -99,7 +100,26 @@
return result
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
--

View File

@ -1,11 +1,12 @@
--
-- make_cpp.lua
-- 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 = { }
local _ = premake.make.cpp
local cpp = premake.make.cpp
local make = premake.make
function premake.make_cpp(prj)
@ -106,7 +107,7 @@
_p('')
-- precompiler header rule
_.pchrules(prj)
cpp.pchrules(prj)
-- per-file rules
for _, file in ipairs(prj.files) do
@ -166,7 +167,7 @@
_p('')
end
--
-- Write a block of configuration settings.
--
@ -175,33 +176,22 @@
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))
-- if this platform requires a special compiler or linker, list it now
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
-- if this platform requires a special compiler or linker, list it here
cpp.platformtools(cfg, cc)
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))
_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))
_p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), " "))
_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
_.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(' 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")), " "))
if cfg.kind == "StaticLib" then
@ -237,16 +227,52 @@
end
_p(' endef')
-- write out config-level makesettings blocks
make.settings(cfg, cc)
_p('endif')
_p('')
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
--
function _.pchconfig(cfg)
function cpp.pchconfig(cfg)
if not cfg.flags.NoPCH and cfg.pchheader then
_p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader)))
_p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader)))
@ -254,7 +280,7 @@
end
end
function _.pchrules(prj)
function cpp.pchrules(prj)
_p('ifneq (,$(PCH))')
_p('$(GCH): $(PCH)')
_p('\t@echo $(notdir $<)')

View File

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

View File

@ -22,7 +22,14 @@
projects = 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
local keeprelative =

View File

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

View File

@ -79,7 +79,16 @@
cxx = "ppu-lv2-g++",
ar = "ppu-lv2-ar",
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
@ -118,9 +127,8 @@
local result = table.translate(cfg.flags, cxxflags)
return result
end
--
-- Returns a list of linker flags, based on the supplied configuration.
--
@ -240,3 +248,13 @@
end
return result
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_pch.lua")
dofile("actions/make/test_make_linking.lua")
-- dofile("actions/make/test_makesettings.lua")
dofile("actions/make/test_wiidev.lua")
-- Xcode3 tests
dofile("actions/xcode/test_xcode_common.lua")
dofile("actions/xcode/test_xcode_project.lua")

View File

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

View File

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