Allow GCC to provide both system and architecture specific flags (instead of one or the other)
This commit is contained in:
parent
a651c0deea
commit
6ad4ec1506
@ -36,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
universal = {
|
universal = {
|
||||||
cppflags = "",
|
cppflags = "", -- block default -MMD -MP flags
|
||||||
},
|
},
|
||||||
|
|
||||||
wii = {
|
wii = {
|
||||||
@ -51,16 +51,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function gcc.getsysflags(cfg, field)
|
||||||
|
local result = {}
|
||||||
|
|
||||||
|
-- merge in system-level flags
|
||||||
|
local system = gcc.sysflags[cfg.system]
|
||||||
|
if system then
|
||||||
|
result = table.join(result, system[field])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- merge in architecture-level flags
|
||||||
|
local arch = gcc.sysflags[cfg.architecture]
|
||||||
|
if arch then
|
||||||
|
result = table.join(result, arch[field])
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Returns list of CPPFLAGS for a specific configuration.
|
-- Returns list of CPPFLAGS for a specific configuration.
|
||||||
--
|
--
|
||||||
|
|
||||||
function gcc.getcppflags(cfg)
|
function gcc.getcppflags(cfg)
|
||||||
local flags = {}
|
local flags = gcc.getsysflags(cfg, 'cppflags')
|
||||||
local sysflags = gcc.sysflags[cfg.architecture] or gcc.sysflags[cfg.system] or {}
|
|
||||||
|
|
||||||
-- Use -MMD -P by default to generate dependency information
|
-- Use -MMD -P by default to generate dependency information
|
||||||
table.insert(flags, sysflags.cppflags or "-MMD -MP")
|
if #flags == 0 then
|
||||||
|
flags = { "-MMD", "-MP" }
|
||||||
|
end
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
end
|
end
|
||||||
@ -86,8 +106,8 @@
|
|||||||
function gcc.getcflags(cfg)
|
function gcc.getcflags(cfg)
|
||||||
local flags = table.translate(cfg.flags, gcc.cflags)
|
local flags = table.translate(cfg.flags, gcc.cflags)
|
||||||
|
|
||||||
local sysflags = gcc.sysflags[cfg.architecture] or {}
|
local sysflags = gcc.getsysflags(cfg, 'cflags')
|
||||||
flags = table.join(flags, sysflags.cflags)
|
flags = table.join(flags, sysflags)
|
||||||
|
|
||||||
if cfg.system ~= premake.WINDOWS and cfg.kind == premake.SHAREDLIB then
|
if cfg.system ~= premake.WINDOWS and cfg.kind == premake.SHAREDLIB then
|
||||||
table.insert(flags, "-fPIC")
|
table.insert(flags, "-fPIC")
|
||||||
@ -176,8 +196,8 @@
|
|||||||
table.insert(flags, "-mwindows")
|
table.insert(flags, "-mwindows")
|
||||||
end
|
end
|
||||||
|
|
||||||
local sysflags = gcc.sysflags[cfg.architecture] or gcc.sysflags[cfg.system] or {}
|
local sysflags = gcc.getsysflags(cfg, 'ldflags')
|
||||||
flags = table.join(flags, sysflags.ldflags)
|
flags = table.join(flags, sysflags)
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
function suite.cppflags_defaultWithMMD()
|
function suite.cppflags_defaultWithMMD()
|
||||||
prepare()
|
prepare()
|
||||||
test.isequal({"-MMD -MP"}, gcc.getcppflags(cfg))
|
test.isequal({"-MMD", "-MP"}, gcc.getcppflags(cfg))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user