Implemented platform flags for GCC; added "native" platform support

This commit is contained in:
starkos 2009-04-20 19:06:48 +00:00
parent e0073aa42a
commit 02b874db57
7 changed files with 48 additions and 38 deletions

View File

@ -1,6 +1,6 @@
solution "PremakeTestbox" solution "PremakeTestbox"
configurations { "Debug", "Release" } configurations { "Debug", "Release" }
platforms { "x32", "xbox360" } platforms { "native", "x64", "xbox360" }
objdir "obj" objdir "obj"
@ -27,7 +27,7 @@ solution "PremakeTestbox"
include "CppSharedLib" include "CppSharedLib"
include "CppStaticLib" include "CppStaticLib"
if _ACTION ~= "codeblocks" then if _ACTION ~= "codeblocks" and _ACTION ~= "codelite" then
include "CsSharedLib" include "CsSharedLib"
include "CsConsoleApp" include "CsConsoleApp"
end end

View File

@ -8,12 +8,15 @@
-- create a shortcut to the compiler interface -- create a shortcut to the compiler interface
local cc = premake[_OPTIONS.cc] local cc = premake[_OPTIONS.cc]
-- build a list of supported target platforms that also includes a generic build
local platforms = premake.filterplatforms(prj.solution, cc.platforms)
-- write a quick header -- write a quick header
_p('# %s project makefile autogenerated by Premake', premake.actions[_ACTION].shortname) _p('# %s project makefile autogenerated by Premake', premake.actions[_ACTION].shortname)
-- set up the environment -- set up the environment
_p('ifndef config') _p('ifndef config')
_p(' config=%s', _MAKE.esc(prj.configurations[1]:lower())) _p(' config=%s%s', _MAKE.esc(prj.configurations[1]:lower()), cc.platforms[platforms[1]].suffix)
_p('endif') _p('endif')
_p('') _p('')
@ -22,14 +25,10 @@
_p('endif') _p('endif')
_p('') _p('')
-- build a list of supported target platforms that also includes a generic build
local platforms = premake.filterplatforms(prj.solution, cc.platforms)
table.insert(platforms, 1, "")
-- list the configurations -- list the configurations
for _, platform in ipairs(platforms) do for _, platform in ipairs(platforms) do
for cfg in premake.eachconfig(prj, platform) do for cfg in premake.eachconfig(prj, platform) do
_p('ifeq ($(config),%s)', table.concat({ _MAKE.esc(cfg.name:lower()), cfg.platform}, ":")) _p('ifeq ($(config),%s%s)', _MAKE.esc(cfg.name:lower()), cc.platforms[platform].suffix)
_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(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir)) _p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))

View File

@ -8,15 +8,24 @@
-- create a shortcut to the compiler interface -- create a shortcut to the compiler interface
local cc = premake[_OPTIONS.cc] local cc = premake[_OPTIONS.cc]
-- build a list of supported target platforms that also includes a generic build
local platforms = premake.filterplatforms(sln, cc.platforms)
-- write a header showing the build options -- write a header showing the build options
local cfgpairs = { }
for _, platform in ipairs(platforms) do
for _, cfg in ipairs(sln.configurations) do
table.insert(cfgpairs, cfg .. cc.platforms[platform].suffix)
end
end
_p('# %s solution makefile autogenerated by Premake', premake.actions[_ACTION].shortname) _p('# %s solution makefile autogenerated by Premake', premake.actions[_ACTION].shortname)
_p('# Usage: make [ config=config_name ]') _p('# Usage: make [ config=config_name ]')
_p('# Where {config_name} is one of: %s.', table.implode(sln.configurations, '"', '"', ', '):lower()) _p('# Where {config_name} is one of: %s.', table.implode(cfgpairs, '"', '"', ', '):lower())
_p('') _p('')
-- set a default configuration -- set a default configuration
_p('ifndef config') _p('ifndef config')
_p(' config=%s', _MAKE.esc(sln.configurations[1]:lower())) _p(' config=%s%s', _MAKE.esc(sln.configurations[1]:lower()), cc.platforms[platforms[1]].suffix)
_p('endif') _p('endif')
_p('export config') _p('export config')
_p('') _p('')
@ -29,10 +38,6 @@
_p('all: $(PROJECTS)') _p('all: $(PROJECTS)')
_p('') _p('')
-- build a list of supported target platforms that also includes a generic build
local platforms = premake.filterplatforms(sln, cc.platforms)
table.insert(platforms, 1, "")
-- write the project build rules -- write the project build rules
for _, prj in ipairs(sln.projects) do for _, prj in ipairs(sln.projects) do
@ -40,7 +45,7 @@
-- these dependencies change, the project needs to be rebuilt -- these dependencies change, the project needs to be rebuilt
for _, platform in ipairs(platforms) do for _, platform in ipairs(platforms) do
for cfg in premake.eachconfig(prj, platform) do for cfg in premake.eachconfig(prj, platform) do
_p('ifeq ($(config),%s)', table.concat({ _MAKE.esc(cfg.name:lower()), cfg.platform}, ":")) _p('ifeq ($(config),%s%s)', _MAKE.esc(cfg.name:lower()), cc.platforms[platform].suffix)
_p(' DEPENDENCIES := %s', table.concat(_MAKE.esc(table.extract(premake.getdependencies(cfg), "name")), " ")) _p(' DEPENDENCIES := %s', table.concat(_MAKE.esc(table.extract(premake.getdependencies(cfg), "name")), " "))
_p('endif') _p('endif')
end end

View File

@ -199,11 +199,13 @@
kind = "list", kind = "list",
scope = "solution", scope = "solution",
allowed = { allowed = {
"Native",
"x32", "x32",
"x64", "x64",
"ppc", "Universal",
"ppc64", "Universal32",
"xbox360" "Universal64",
"Xbox360"
} }
}, },

View File

@ -32,15 +32,17 @@
-- --
-- Support platforms, mapped to GCC architectures -- Support platforms, mapped to build configuration suffix
-- --
premake.gcc.platforms = premake.gcc.platforms =
{ {
x32 = "i386", Native = { suffix="", cflags="" },
x64 = "x64_86", x32 = { suffix="32", cflags="-m32" },
ppc = "ppc", x64 = { suffix="64", cflags="-m64" },
ppc64 = "ppc64", Universal = { suffix="univ", cflags="-arch i386 -arch x64_64 -arch ppc -arch ppc64" },
Universal32 = { suffix="univ32", cflags="-arch i386 -arch ppc" },
Universal64 = { suffix="univ64", cflags="-arch x64_64 -arch ppc64" },
} }
@ -60,6 +62,7 @@
if (cfg.kind == "SharedLib" and not os.is("windows")) then if (cfg.kind == "SharedLib" and not os.is("windows")) then
table.insert(result, "-fPIC") table.insert(result, "-fPIC")
end end
table.insert(result, premake.gcc.platforms[cfg.platform].cflags)
return result return result
end end
@ -103,6 +106,7 @@
end end
end end
table.insert(result, premake.gcc.platforms[cfg.platform].cflags)
return result return result
end end

View File

@ -36,6 +36,7 @@
premake.ow.platforms = premake.ow.platforms =
{ {
Native = { suffix="", cflags="" },
} }

View File

@ -34,27 +34,26 @@
end end
--
-- Make sure that values only get applied to the right configurations.
--
function T.configs.RootValues() function T.configs.RootValues()
local cfg = premake.getconfig(prj).defines local r = premake.getconfig(prj).defines
test.istrue(#cfg == 1 and cfg[1] == "GLOBAL") -- maybe table.compare instead? test.isequal("GLOBAL", table.concat(r,":"))
end end
function T.configs.ConfigValues() function T.configs.ConfigValues()
local cfg = premake.getconfig(prj, "Debug").defines local r = premake.getconfig(prj, "Debug").defines
test.istrue(#cfg == 2 and cfg[1] == "GLOBAL" and cfg[2] == "DEBUG") test.isequal("GLOBAL:DEBUG", table.concat(r,":"))
end end
function T.configs.PlatformValues() function T.configs.PlatformValues()
local cfg = premake.getconfig(prj, "Debug", "x32").defines local r = premake.getconfig(prj, "Debug", "x32").defines
test.istrue(#cfg == 3 and cfg[1] == "GLOBAL" and cfg[2] == "DEBUG" and cfg[3] == "X86_32") test.isequal("GLOBAL:DEBUG:X86_32", table.concat(r,":"))
end end
function T.configs.DefaultPlaformNotInSolution()
local cfg = premake.getconfig(prj, "Debug", "xbox360").defines function T.configs.PlaformNotInSolution()
test.isequal("GLOBAL:DEBUG", table.concat(cfg, ":")) local r = premake.getconfig(prj, "Debug", "xbox360").defines
test.isequal("GLOBAL", table.concat(cfg, ":"))
end end