Implemented platform flags for GCC; added "native" platform support
This commit is contained in:
parent
e0073aa42a
commit
02b874db57
@ -1,6 +1,6 @@
|
||||
solution "PremakeTestbox"
|
||||
configurations { "Debug", "Release" }
|
||||
platforms { "x32", "xbox360" }
|
||||
platforms { "native", "x64", "xbox360" }
|
||||
|
||||
objdir "obj"
|
||||
|
||||
@ -27,7 +27,7 @@ solution "PremakeTestbox"
|
||||
include "CppSharedLib"
|
||||
include "CppStaticLib"
|
||||
|
||||
if _ACTION ~= "codeblocks" then
|
||||
if _ACTION ~= "codeblocks" and _ACTION ~= "codelite" then
|
||||
include "CsSharedLib"
|
||||
include "CsConsoleApp"
|
||||
end
|
||||
|
@ -8,12 +8,15 @@
|
||||
-- create a shortcut to the compiler interface
|
||||
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
|
||||
_p('# %s project makefile autogenerated by Premake', premake.actions[_ACTION].shortname)
|
||||
|
||||
-- set up the environment
|
||||
_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('')
|
||||
|
||||
@ -22,14 +25,10 @@
|
||||
_p('endif')
|
||||
_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
|
||||
for _, platform in ipairs(platforms) 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(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))
|
||||
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
|
||||
|
@ -8,15 +8,24 @@
|
||||
-- create a shortcut to the compiler interface
|
||||
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
|
||||
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('# 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('')
|
||||
|
||||
-- set a default configuration
|
||||
_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('export config')
|
||||
_p('')
|
||||
@ -29,10 +38,6 @@
|
||||
_p('all: $(PROJECTS)')
|
||||
_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
|
||||
for _, prj in ipairs(sln.projects) do
|
||||
|
||||
@ -40,7 +45,7 @@
|
||||
-- these dependencies change, the project needs to be rebuilt
|
||||
for _, platform in ipairs(platforms) 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('endif')
|
||||
end
|
||||
|
@ -199,11 +199,13 @@
|
||||
kind = "list",
|
||||
scope = "solution",
|
||||
allowed = {
|
||||
"Native",
|
||||
"x32",
|
||||
"x64",
|
||||
"ppc",
|
||||
"ppc64",
|
||||
"xbox360"
|
||||
"Universal",
|
||||
"Universal32",
|
||||
"Universal64",
|
||||
"Xbox360"
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -32,15 +32,17 @@
|
||||
|
||||
|
||||
--
|
||||
-- Support platforms, mapped to GCC architectures
|
||||
-- Support platforms, mapped to build configuration suffix
|
||||
--
|
||||
|
||||
premake.gcc.platforms =
|
||||
{
|
||||
x32 = "i386",
|
||||
x64 = "x64_86",
|
||||
ppc = "ppc",
|
||||
ppc64 = "ppc64",
|
||||
Native = { suffix="", cflags="" },
|
||||
x32 = { suffix="32", cflags="-m32" },
|
||||
x64 = { suffix="64", cflags="-m64" },
|
||||
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
|
||||
table.insert(result, "-fPIC")
|
||||
end
|
||||
table.insert(result, premake.gcc.platforms[cfg.platform].cflags)
|
||||
return result
|
||||
end
|
||||
|
||||
@ -103,6 +106,7 @@
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(result, premake.gcc.platforms[cfg.platform].cflags)
|
||||
return result
|
||||
end
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
premake.ow.platforms =
|
||||
{
|
||||
Native = { suffix="", cflags="" },
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,27 +34,26 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that values only get applied to the right configurations.
|
||||
--
|
||||
|
||||
function T.configs.RootValues()
|
||||
local cfg = premake.getconfig(prj).defines
|
||||
test.istrue(#cfg == 1 and cfg[1] == "GLOBAL") -- maybe table.compare instead?
|
||||
local r = premake.getconfig(prj).defines
|
||||
test.isequal("GLOBAL", table.concat(r,":"))
|
||||
end
|
||||
|
||||
|
||||
function T.configs.ConfigValues()
|
||||
local cfg = premake.getconfig(prj, "Debug").defines
|
||||
test.istrue(#cfg == 2 and cfg[1] == "GLOBAL" and cfg[2] == "DEBUG")
|
||||
local r = premake.getconfig(prj, "Debug").defines
|
||||
test.isequal("GLOBAL:DEBUG", table.concat(r,":"))
|
||||
end
|
||||
|
||||
|
||||
function T.configs.PlatformValues()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x32").defines
|
||||
test.istrue(#cfg == 3 and cfg[1] == "GLOBAL" and cfg[2] == "DEBUG" and cfg[3] == "X86_32")
|
||||
local r = premake.getconfig(prj, "Debug", "x32").defines
|
||||
test.isequal("GLOBAL:DEBUG:X86_32", table.concat(r,":"))
|
||||
end
|
||||
|
||||
function T.configs.DefaultPlaformNotInSolution()
|
||||
local cfg = premake.getconfig(prj, "Debug", "xbox360").defines
|
||||
test.isequal("GLOBAL:DEBUG", table.concat(cfg, ":"))
|
||||
|
||||
function T.configs.PlaformNotInSolution()
|
||||
local r = premake.getconfig(prj, "Debug", "xbox360").defines
|
||||
test.isequal("GLOBAL", table.concat(cfg, ":"))
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user