Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-09-16 00:45:48 +0400
committerJason Perkins <starkos@industriousone.com>2011-09-16 00:45:48 +0400
commit611014c522a72ea942f5e7fc2097f48ed8e7476d (patch)
treec416c4f8aa3172c058157393575e2c14544cb14a
parent363a445f72d639db58f39d021b2ec4e4af8e27c4 (diff)
Patch 3021550: Add Wii homebrew platform (Pathogen David)
-rw-r--r--CHANGES.txt1
-rw-r--r--src/actions/make/_make.lua22
-rw-r--r--src/actions/make/make_cpp.lua72
-rw-r--r--src/base/api.lua6
-rw-r--r--src/base/bake.lua9
-rw-r--r--src/base/globals.lua6
-rw-r--r--src/tools/gcc.lua24
-rw-r--r--tests/actions/make/test_makesettings.lua51
-rw-r--r--tests/actions/make/test_wiidev.lua56
-rw-r--r--tests/premake4.lua4
-rw-r--r--tests/test_gmake_cpp.lua8
-rw-r--r--tests/testfx.lua1
12 files changed, 227 insertions, 33 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 05224d5..95d539b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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
diff --git a/src/actions/make/_make.lua b/src/actions/make/_make.lua
index 42b84fd..0bf80f6 100644
--- a/src/actions/make/_make.lua
+++ b/src/actions/make/_make.lua
@@ -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
--
diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua
index 790bc63..f2deaef 100644
--- a/src/actions/make/make_cpp.lua
+++ b/src/actions/make/make_cpp.lua
@@ -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 $<)')
diff --git a/src/base/api.lua b/src/base/api.lua
index 3746aa2..c6bfd18 100644
--- a/src/base/api.lua
+++ b/src/base/api.lua
@@ -254,6 +254,12 @@
scope = "container",
},
+ makesettings =
+ {
+ kind = "list",
+ scope = "config",
+ },
+
objdir =
{
kind = "path",
diff --git a/src/base/bake.lua b/src/base/bake.lua
index 77f6192..9276af8 100644
--- a/src/base/bake.lua
+++ b/src/base/bake.lua
@@ -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 =
diff --git a/src/base/globals.lua b/src/base/globals.lua
index 47966ff..99c8ac7 100644
--- a/src/base/globals.lua
+++ b/src/base/globals.lua
@@ -45,6 +45,12 @@
nosharedlibs = true,
namestyle = "PS3",
},
+ WiiDev =
+ {
+ cfgsuffix = "wii",
+ iscrosscompiler = true,
+ namestyle = "PS3",
+ },
Xbox360 =
{
cfgsuffix = "xbox360",
diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua
index caedd52..1e8ed31 100644
--- a/src/tools/gcc.lua
+++ b/src/tools/gcc.lua
@@ -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
diff --git a/tests/actions/make/test_makesettings.lua b/tests/actions/make/test_makesettings.lua
new file mode 100644
index 0000000..8a6f132
--- /dev/null
+++ b/tests/actions/make/test_makesettings.lua
@@ -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
+
diff --git a/tests/actions/make/test_wiidev.lua b/tests/actions/make/test_wiidev.lua
new file mode 100644
index 0000000..9ed707f
--- /dev/null
+++ b/tests/actions/make/test_wiidev.lua
@@ -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
diff --git a/tests/premake4.lua b/tests/premake4.lua
index 00ce43f..7f915c9 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -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")
diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua
index 5730ca9..8c80411 100644
--- a/tests/test_gmake_cpp.lua
+++ b/tests/test_gmake_cpp.lua
@@ -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
diff --git a/tests/testfx.lua b/tests/testfx.lua
index 1182a13..c5b49e5 100644
--- a/tests/testfx.lua
+++ b/tests/testfx.lua
@@ -199,6 +199,7 @@
_OPTIONS = { }
premake.solution.list = { }
io.indent = nil
+ io.eol = "\n"
-- reset captured I/O values
test.value_openedfilename = nil