Phased out sysflag tables from tool adapters

This commit is contained in:
Jason Perkins 2013-10-31 10:57:25 -04:00
parent b5e7a345fb
commit 91d003a82f
6 changed files with 63 additions and 98 deletions

View File

@ -207,17 +207,12 @@
-- default value should be used.
--
clang.tools = {
cc = "clang",
cxx = "clang++",
ar = "ar"
}
function clang.gettoolname(cfg, tool)
-- Real simple implementation for now, buying time until I
-- get a chance to rewrite (and possibly sufficient?)
if tool == "ar" then
return "ar"
elseif tool == "cc" then
return "clang"
elseif tool == "cxx" then
return "clang++"
end
return clang.tools[tool]
end

View File

@ -10,65 +10,19 @@
local config = premake.config
--
-- GCC flags for specific systems and architectures.
-- I am in the process of phasing this out for the more detailed
-- flag tables below (i.e. gcc.cflags).
--
gcc.sysflags = {
haiku = {
cppflags = "-MMD"
},
ps3 = {
cc = "ppu-lv2-g++",
cxx = "ppu-lv2-g++",
ar = "ppu-lv2-ar",
},
universal = {
cppflags = "", -- block default -MMD -MP flags
},
wii = {
cppflags = "-MMD -MP -I$(LIBOGC_INC) $(MACHDEP)",
cfgsettings = [[
ifeq ($(strip $(DEVKITPPC)),)
$(error "DEVKITPPC environment variable is not set")'
endif
include $(DEVKITPPC)/wii_rules']],
},
}
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 C preprocessor flags for a configuration.
--
gcc.cppflags = {
system = {
haiku = "-MMD",
wii = { "-MMD", "-MP", "-I$(LIBOGC_INC)", "$(MACHDEP)" }
}
}
function gcc.getcppflags(cfg)
local flags = gcc.getsysflags(cfg, 'cppflags')
local flags = config.mapFlags(cfg, gcc.cppflags)
-- Use -MMD -P by default to generate dependency information
if #flags == 0 then
@ -135,13 +89,15 @@
--
gcc.cxxflags = {
NoExceptions = "-fno-exceptions",
NoRTTI = "-fno-rtti",
NoBufferSecurityCheck = "-fno-stack-protector"
flags = {
NoExceptions = "-fno-exceptions",
NoRTTI = "-fno-rtti",
NoBufferSecurityCheck = "-fno-stack-protector"
}
}
function gcc.getcxxflags(cfg)
local flags = table.translate(cfg.flags, gcc.cxxflags)
local flags = config.mapFlags(cfg, gcc.cxxflags)
return flags
end
@ -210,7 +166,7 @@
}
function gcc.getldflags(cfg)
local flags = {}
local flags = config.mapFlags(cfg, gcc.ldflags)
-- Scan the list of linked libraries. If any are referenced with
-- paths, add those to the list of library search paths
@ -243,7 +199,7 @@
table.insert(flags, "-mwindows")
end
return table.join(flags, config.mapFlags(cfg, gcc.ldflags))
return flags
end
@ -283,9 +239,19 @@
-- Returns makefile-specific configuration rules.
--
gcc.makesettings = {
system = {
wii = [[
ifeq ($(strip $(DEVKITPPC)),)
$(error "DEVKITPPC environment variable is not set")'
endif
include $(DEVKITPPC)/wii_rules']]
}
}
function gcc.getmakesettings(cfg)
local sysflags = gcc.sysflags[cfg.architecture] or gcc.sysflags[cfg.system] or {}
return sysflags.cfgsettings
local settings = config.mapFlags(cfg, gcc.makesettings)
return table.concat(settings)
end
@ -303,12 +269,22 @@
-- default value should be used.
--
gcc.tools = {
ps3 = {
cc = "ppu-lv2-g++",
cxx = "ppu-lv2-g++",
ar = "ppu-lv2-ar",
},
}
function gcc.gettoolname(cfg, tool)
local names = gcc.tools[cfg.architecture] or gcc.tools[cfg.system] or {}
local name = names[tool]
if tool == "rc" then
return "windres"
name = name or "windres"
end
local sysflags = gcc.sysflags[cfg.architecture] or gcc.sysflags[cfg.system] or {}
return sysflags[tool]
return name
end

View File

@ -65,13 +65,10 @@
}
function msc.getcxxflags(cfg)
return table.translate(cfg.flags, msc.cxxflags)
local flags = config.mapFlags(cfg, msc.cxxflags)
return flags
end
msc.ldflags = {
Symbols = "/DEBUG",
}
--
-- Decorate defines for the MSVC command line.
@ -127,11 +124,13 @@
-- Return a list of linker flags for a specific configuration.
--
msc.ldflags = {
Symbols = "/DEBUG",
flags = {
Symbols = "/DEBUG",
}
}
function msc.getldflags(cfg)
local flags = table.translate(cfg.flags, msc.ldflags)
local flags = config.mapFlags(cfg, msc.ldflags)
if not cfg.flags.NoManifest and cfg.kind ~= premake.STATICLIB then
table.insert(flags, "/MANIFEST")

View File

@ -10,13 +10,6 @@
local config = premake.config
--
-- SNC flags for specific systems and architectures.
--
snc.sysflags = {}
--
-- Retrieve the CFLAGS for a specific configuration.
--
@ -135,8 +128,10 @@
-- default value should be used.
--
function snc.gettoolname(cfg, tool)
local sysflags = snc.sysflags[cfg.architecture] or snc.sysflags[cfg.system] or {}
return sysflags[tool]
end
snc.tools = {
}
function snc.gettoolname(cfg, tool)
local names = snc.tools[cfg.architecture] or snc.tools[cfg.system] or {}
return names[tool]
end

View File

@ -36,7 +36,7 @@
function suite.writesCorrectLinkerFlags()
make.ldFlags(cfg, premake.tools.gcc)
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s -L$(LIBOGC_LIB) $(MACHDEP)
ALL_LDFLAGS += $(LDFLAGS) -L$(LIBOGC_LIB) $(MACHDEP) -s
]]
end

View File

@ -247,7 +247,7 @@
function suite.ldflags_onX32()
architecture "x32"
prepare()
test.isequal({ "-s", "-m32", "-L/usr/lib32" }, gcc.getldflags(cfg))
test.isequal({ "-m32", "-L/usr/lib32", "-s" }, gcc.getldflags(cfg))
end
function suite.cflags_onX64()
@ -259,7 +259,7 @@
function suite.ldflags_onX64()
architecture "x64"
prepare()
test.isequal({ "-s", "-m64", "-L/usr/lib64" }, gcc.getldflags(cfg))
test.isequal({ "-m64", "-L/usr/lib64", "-s" }, gcc.getldflags(cfg))
end