Refactored handling of configuration names
This commit is contained in:
parent
457744c27e
commit
edc74bc237
@ -25,12 +25,7 @@
|
||||
_p('\t\t<Build>')
|
||||
for _, platform in ipairs(platforms) do
|
||||
for cfg in premake.eachconfig(prj, platform) do
|
||||
|
||||
local name = cfg.name
|
||||
if platform ~= "Native" then
|
||||
name = name .. "|" .. platform
|
||||
end
|
||||
_p('\t\t\t<Target title="%s">', premake.esc(name))
|
||||
_p('\t\t\t<Target title="%s">', premake.esc(cfg.longname))
|
||||
|
||||
_p('\t\t\t\t<Option output="%s" prefix_auto="0" extension_auto="0" />', premake.esc(cfg.buildtarget.fullpath))
|
||||
_p('\t\t\t\t<Option object_output="%s" />', premake.esc(cfg.objectsdir))
|
||||
|
@ -22,11 +22,8 @@
|
||||
local platforms = premake.filterplatforms(prj.solution, premake.gcc.platforms, "Native")
|
||||
|
||||
for _, platform in ipairs(platforms) do
|
||||
for cfg in premake.eachconfig(prj) do
|
||||
local name = premake.esc(cfg.name)
|
||||
if platform ~= "Native" then
|
||||
name = name .. "|" .. platform
|
||||
end
|
||||
for cfg in premake.eachconfig(prj, platform) do
|
||||
local name = premake.esc(cfg.longname)
|
||||
local compiler = iif(cfg.language == "C", "gcc", "g++")
|
||||
_p(' <Configuration Name="%s" CompilerType="gnu %s" DebuggerType="GNU gdb debugger" Type="%s">', name, compiler, types[cfg.kind])
|
||||
|
||||
@ -110,12 +107,8 @@
|
||||
_p(' </Settings>')
|
||||
|
||||
for _, platform in ipairs(platforms) do
|
||||
for _,cfgname in ipairs(prj.configurations) do
|
||||
local name = premake.esc(cfgname)
|
||||
if platform ~= "Native" then
|
||||
name = name .. "|" .. platform
|
||||
end
|
||||
_p(' <Dependencies name="%s">', name)
|
||||
for cfg in premake.eachconfig(prj, platform) do
|
||||
_p(' <Dependencies name="%s">', cfg.longname)
|
||||
for _,dep in ipairs(premake.getdependencies(prj)) do
|
||||
_p(' <Project Name="%s"/>', dep.name)
|
||||
end
|
||||
|
@ -21,16 +21,11 @@
|
||||
_p(' <BuildMatrix>')
|
||||
for _, platform in ipairs(platforms) do
|
||||
for _, cfgname in ipairs(sln.configurations) do
|
||||
local name = cfgname
|
||||
if platform ~= "Native" then
|
||||
name = name .. "|" .. platform
|
||||
end
|
||||
local name = premake.getconfigname(cfgname, platform)
|
||||
_p(' <WorkspaceConfiguration Name="%s" Selected="yes">', name)
|
||||
|
||||
for _,prj in ipairs(sln.projects) do
|
||||
_p(' <Project Name="%s" ConfigName="%s"/>', prj.name, name)
|
||||
end
|
||||
|
||||
_p(' </WorkspaceConfiguration>')
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
-- set up the environment
|
||||
_p('ifndef config')
|
||||
_p(' config=%s%s', _MAKE.esc(prj.configurations[1]:lower()), cc.platforms[platforms[1]].suffix)
|
||||
_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.configurations[1], platforms[1], true)))
|
||||
_p('endif')
|
||||
_p('')
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
-- list the configurations
|
||||
for _, platform in ipairs(platforms) do
|
||||
for cfg in premake.eachconfig(prj, platform) do
|
||||
premake.gmake_cpp_config(cfg)
|
||||
premake.gmake_cpp_config(cfg, cc)
|
||||
end
|
||||
end
|
||||
|
||||
@ -151,11 +151,9 @@
|
||||
-- Write a block of configuration settings.
|
||||
--
|
||||
|
||||
function premake.gmake_cpp_config(cfg)
|
||||
local cc = premake[_OPTIONS.cc]
|
||||
local platform = cc.platforms[cfg.platform or "Native"].suffix
|
||||
function premake.gmake_cpp_config(cfg, cc)
|
||||
|
||||
_p('ifeq ($(config),%s%s)', _MAKE.esc(cfg.name:lower()), platform)
|
||||
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))
|
||||
_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))
|
||||
_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))
|
||||
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
|
||||
|
@ -14,18 +14,18 @@
|
||||
-- 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)
|
||||
for _, cfgname in ipairs(sln.configurations) do
|
||||
table.insert(cfgpairs, premake.getconfigname(cfgname, platform, true))
|
||||
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(cfgpairs, '"', '"', ', '):lower())
|
||||
_p('# Where {config_name} is one of: %s.', table.implode(cfgpairs, '"', '"', ', '))
|
||||
_p('')
|
||||
|
||||
-- set a default configuration
|
||||
_p('ifndef config')
|
||||
_p(' config=%s%s', _MAKE.esc(sln.configurations[1]:lower()), cc.platforms[platforms[1]].suffix)
|
||||
_p(' config=%s', _MAKE.esc(premake.getconfigname(sln.configurations[1], platforms[1], true)))
|
||||
_p('endif')
|
||||
_p('export config')
|
||||
_p('')
|
||||
@ -45,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%s)', _MAKE.esc(cfg.name:lower()), cc.platforms[platform].suffix)
|
||||
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))
|
||||
_p(' DEPENDENCIES := %s', table.concat(_MAKE.esc(table.extract(premake.getdependencies(cfg), "name")), " "))
|
||||
_p('endif')
|
||||
end
|
||||
|
@ -206,6 +206,15 @@
|
||||
"Universal32",
|
||||
"Universal64",
|
||||
"Xbox360"
|
||||
},
|
||||
shortnames = {
|
||||
Native = "",
|
||||
x32 = "32",
|
||||
x64 = "64",
|
||||
Universal = "univ",
|
||||
Universal32 = "univ32",
|
||||
Universal64 = "univ64",
|
||||
Xbox360 = "360",
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -197,10 +197,12 @@
|
||||
terms.platform = pltname:lower()
|
||||
terms.config = (cfgname or ""):lower()
|
||||
|
||||
local cfg = buildconfig(prj, terms)
|
||||
cfg.name = cfgname
|
||||
cfg.platform = pltname
|
||||
cfg.project = prj
|
||||
local cfg = buildconfig(prj, terms)
|
||||
cfg.name = cfgname
|
||||
cfg.platform = pltname
|
||||
cfg.shortname = premake.getconfigname(cfgname, pltname, true)
|
||||
cfg.longname = premake.getconfigname(cfgname, pltname)
|
||||
cfg.project = prj
|
||||
|
||||
-- set the project location, if not already set
|
||||
cfg.location = cfg.location or cfg.basedir
|
||||
|
@ -187,6 +187,28 @@
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Build a name from a build configuration/platform pair. The short name
|
||||
-- is good for makefiles or anywhere a user will have to type it in. The
|
||||
-- long name is more readable.
|
||||
--
|
||||
|
||||
function premake.getconfigname(cfgname, platform, useshortname)
|
||||
if cfgname then
|
||||
local name = cfgname
|
||||
if platform and platform ~= "Native" then
|
||||
if useshortname then
|
||||
name = name .. premake.fields.platforms.shortnames[platform]
|
||||
else
|
||||
name = name .. "|" .. platform
|
||||
end
|
||||
end
|
||||
return iif(useshortname, name:lower(), name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Returns a list of sibling projects on which the specified
|
||||
-- configuration depends. This is used to specify project
|
||||
|
@ -32,39 +32,33 @@
|
||||
|
||||
|
||||
--
|
||||
-- Support platforms, mapped to build configuration suffix
|
||||
-- Map platforms to flags
|
||||
--
|
||||
|
||||
premake.gcc.platforms =
|
||||
{
|
||||
Native = {
|
||||
suffix = "",
|
||||
cppflags = "-MMD",
|
||||
},
|
||||
x32 = {
|
||||
suffix = "32",
|
||||
cppflags = "-MMD",
|
||||
flags = "-m32",
|
||||
ldflags = "-L/usr/lib32",
|
||||
},
|
||||
x64 = {
|
||||
suffix = "64",
|
||||
cppflags = "-MMD",
|
||||
flags = "-m64",
|
||||
ldflags = "-L/usr/lib64",
|
||||
},
|
||||
Universal = {
|
||||
suffix = "univ",
|
||||
cppflags = "",
|
||||
flags = "-arch i386 -arch x86_64 -arch ppc -arch ppc64",
|
||||
},
|
||||
Universal32 = {
|
||||
suffix = "univ32",
|
||||
cppflags = "",
|
||||
flags = "-arch i386 -arch ppc",
|
||||
},
|
||||
Universal64 = {
|
||||
suffix = "univ64",
|
||||
cppflags = "",
|
||||
flags = "-arch x86_64 -arch ppc64",
|
||||
},
|
||||
|
@ -36,7 +36,9 @@
|
||||
|
||||
premake.ow.platforms =
|
||||
{
|
||||
Native = { suffix="", cflags="" },
|
||||
Native = {
|
||||
flags = ""
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,3 +64,13 @@
|
||||
end
|
||||
|
||||
|
||||
function T.configs.BuildsShortName()
|
||||
local r = premake.getconfig(prj, "Debug", "x32").shortname
|
||||
test.isequal("debug32", r)
|
||||
end
|
||||
|
||||
function T.configs.BuildsLongName()
|
||||
local r = premake.getconfig(prj, "Debug", "x32").longname
|
||||
test.isequal("Debug|x32", r)
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
kind "ConsoleApp"
|
||||
|
||||
_ACTION = "gmake"
|
||||
_OPTIONS.cc = "gcc"
|
||||
_OPTIONS.os = "linux"
|
||||
end
|
||||
|
||||
@ -35,7 +34,7 @@
|
||||
function T.gmake_cpp.BasicCfgBlock()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug")
|
||||
premake.gmake_cpp_config(cfg)
|
||||
premake.gmake_cpp_config(cfg, premake.gcc)
|
||||
test.capture [[
|
||||
ifeq ($(config),debug)
|
||||
TARGETDIR = .
|
||||
@ -65,7 +64,7 @@ endif
|
||||
function T.gmake_cpp.PlatformSpecificBlock()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x64")
|
||||
premake.gmake_cpp_config(cfg)
|
||||
premake.gmake_cpp_config(cfg, premake.gcc)
|
||||
test.capture [[
|
||||
ifeq ($(config),debug64)
|
||||
TARGETDIR = .
|
||||
|
Loading…
Reference in New Issue
Block a user