Merge pull request #127 from starkos/exception-rtti-fixes

Finish switching to exceptionhandling() and rtti()
This commit is contained in:
starkos 2015-06-25 15:35:05 -04:00
commit 5ce2bc0a7b
9 changed files with 67 additions and 61 deletions

View File

@ -359,17 +359,7 @@
"Default", "Default",
"On", "On",
"Off", "Off",
}, "SEH"
}
api.register {
name = "rtti",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off",
}, },
} }
@ -462,7 +452,7 @@
"OptimizeSpeed", -- DEPRECATED "OptimizeSpeed", -- DEPRECATED
"RelativeLinks", "RelativeLinks",
"ReleaseRuntime", -- DEPRECATED "ReleaseRuntime", -- DEPRECATED
"SEH", "SEH", -- DEPRECATED
"ShadowedVariables", "ShadowedVariables",
"StaticRuntime", "StaticRuntime",
"Symbols", "Symbols",
@ -842,6 +832,17 @@
tokens = true, tokens = true,
} }
api.register {
name = "rtti",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off",
},
}
api.register { api.register {
name = "rules", name = "rules",
scope = "project", scope = "project",
@ -1145,7 +1146,7 @@
end) end)
api.deprecateValue("flags", "NoExceptions", nil, api.deprecateValue("flags", "NoExceptions", 'Use `exceptionhandling "Off"` instead',
function(value) function(value)
exceptionhandling "Off" exceptionhandling "Off"
end, end,
@ -1154,7 +1155,7 @@
end) end)
api.deprecateValue("flags", "NoRTTI", nil, api.deprecateValue("flags", "NoRTTI", 'Use `rtti "Off"` instead',
function(value) function(value)
rtti "Off" rtti "Off"
end, end,
@ -1162,6 +1163,13 @@
rtti "On" rtti "On"
end) end)
api.deprecateValue("flags", "SEH", 'Use `exceptionhandling "SEH"` instead',
function(value)
exceptionhandling "SEH"
end,
function(value)
exceptionhandling "Default"
end)
api.deprecateValue("flags", "Unsafe", nil, api.deprecateValue("flags", "Unsafe", nil,
function(value) function(value)
@ -1279,6 +1287,8 @@
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
clr "Off" clr "Off"
exceptionhandling "Default"
rtti "Default"
-- Setting a default language makes some validation easier later -- Setting a default language makes some validation easier later

View File

@ -1124,7 +1124,7 @@
function m.exceptionHandling(cfg) function m.exceptionHandling(cfg)
if cfg.exceptionhandling == p.OFF then if cfg.exceptionhandling == p.OFF then
p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0)) p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0))
elseif cfg.flags.SEH and _ACTION > "vs2003" then elseif cfg.exceptionhandling == "SEH" and _ACTION > "vs2003" then
p.w('ExceptionHandling="2"') p.w('ExceptionHandling="2"')
end end
end end

View File

@ -1097,14 +1097,11 @@
function m.exceptionHandling(cfg) function m.exceptionHandling(cfg)
local value
if cfg.exceptionhandling == p.OFF then if cfg.exceptionhandling == p.OFF then
p.w('<ExceptionHandling>false</ExceptionHandling>') p.w('<ExceptionHandling>false</ExceptionHandling>')
elseif cfg.exceptionhandling == p.ON or cfg.flags.SEH then elseif cfg.exceptionhandling == "SEH" then
if cfg.flags.SEH then p.w('<ExceptionHandling>Async</ExceptionHandling>')
p.w('<ExceptionHandling>Async</ExceptionHandling>')
else
p.w('<ExceptionHandling>Sync</ExceptionHandling>')
end
end end
end end

View File

@ -106,21 +106,21 @@
-- --
gcc.cxxflags = { gcc.cxxflags = {
exceptionhandling = {
Off = "-fno-exceptions"
},
flags = { flags = {
NoBufferSecurityCheck = "-fno-stack-protector", NoBufferSecurityCheck = "-fno-stack-protector",
["C++11"] = "-std=c++11", ["C++11"] = "-std=c++11",
["C++14"] = "-std=c++14", ["C++14"] = "-std=c++14",
},
rtti = {
Off = "-fno-rtti"
} }
} }
function gcc.getcxxflags(cfg) function gcc.getcxxflags(cfg)
local flags = config.mapFlags(cfg, gcc.cxxflags) local flags = config.mapFlags(cfg, gcc.cxxflags)
if cfg.exceptionhandling == p.OFF then
table.insert(flags, '-fno-exceptions')
end
if cfg.rtti == p.OFF then
table.insert(flags, '-fno-rtti')
end
return flags return flags
end end

View File

@ -7,10 +7,12 @@
--- ---
premake.tools.msc = {} local p = premake
local msc = premake.tools.msc
local project = premake.project p.tools.msc = {}
local config = premake.config local msc = p.tools.msc
local project = p.project
local config = p.config
-- --
@ -38,7 +40,6 @@
MultiProcessorCompile = "/MP", MultiProcessorCompile = "/MP",
NoFramePointer = "/Oy", NoFramePointer = "/Oy",
NoMinimalRebuild = "/Gm-", NoMinimalRebuild = "/Gm-",
SEH = "/EHa",
Symbols = "/Z7", Symbols = "/Z7",
OmitDefaultLibrary = "/Zl", OmitDefaultLibrary = "/Zl",
}, },
@ -103,21 +104,19 @@
-- Returns list of C++ compiler flags for a configuration. -- Returns list of C++ compiler flags for a configuration.
-- --
msc.cxxflags = {
exceptionhandling = {
Default = "/EHsc",
On = "/EHsc",
SEH = "/EHa",
},
rtti = {
Off = "/GR-"
}
}
function msc.getcxxflags(cfg) function msc.getcxxflags(cfg)
local flags = {} local flags = config.mapFlags(cfg, msc.cxxflags)
if cfg.rtti == premake.OFF then
table.insert(flags, "/GR-")
end
if cfg.exceptionhandling == premake.ON or cfg.flags.SEH then
if cfg.flags.SEH then
table.insert(flags, "/EHa")
else
table.insert(flags, "/EHsc")
end
end
return flags return flags
end end

View File

@ -497,7 +497,7 @@
-- --
function suite.exceptions_onNoExceptions() function suite.exceptions_onNoExceptions()
flags "NoExceptions" exceptionhandling "Off"
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile> <ClCompile>
@ -509,7 +509,7 @@
end end
function suite.exceptions_onSEH() function suite.exceptions_onSEH()
flags "SEH" exceptionhandling "SEH"
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile> <ClCompile>
@ -521,7 +521,7 @@
end end
function suite.runtimeTypeInfo_onNoRTTI() function suite.runtimeTypeInfo_onNoRTTI()
flags "NoRTTI" rtti "Off"
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile> <ClCompile>

View File

@ -175,15 +175,15 @@
function suite.remove_onExactValueMatch() function suite.remove_onExactValueMatch()
local f = field.get("flags") local f = field.get("flags")
configset.store(cset, f, { "Symbols", "WinMain", "NoRTTI" }) configset.store(cset, f, { "Symbols", "WinMain", "MFC" })
configset.remove(cset, f, { "WinMain" }) configset.remove(cset, f, { "WinMain" })
test.isequal({ "Symbols", "NoRTTI" }, configset.fetch(cset, f, {})) test.isequal({ "Symbols", "MFC" }, configset.fetch(cset, f, {}))
end end
function suite.remove_onMultipleValues() function suite.remove_onMultipleValues()
local f = field.get("flags") local f = field.get("flags")
configset.store(cset, f, { "Symbols", "NoExceptions", "WinMain", "NoRTTI" }) configset.store(cset, f, { "Symbols", "Maps", "WinMain", "MFC" })
configset.remove(cset, f, { "NoExceptions", "NoRTTI" }) configset.remove(cset, f, { "Maps", "MFC" })
test.isequal({ "Symbols", "WinMain" }, configset.fetch(cset, f, {})) test.isequal({ "Symbols", "WinMain" }, configset.fetch(cset, f, {}))
end end

View File

@ -199,7 +199,7 @@
-- --
function suite.cflags_onNoExceptions() function suite.cflags_onNoExceptions()
flags { "NoExceptions" } exceptionhandling "Off"
prepare() prepare()
test.contains({ "-fno-exceptions" }, gcc.getcxxflags(cfg)) test.contains({ "-fno-exceptions" }, gcc.getcxxflags(cfg))
end end

View File

@ -227,26 +227,26 @@
-- Check handling of C++ language features. -- Check handling of C++ language features.
-- --
function suite.cflags_onExceptions() function suite.cxxflags_onExceptions()
exceptionhandling "on" exceptionhandling "on"
prepare() prepare()
test.contains("/EHsc", msc.getcxxflags(cfg)) test.contains("/EHsc", msc.getcxxflags(cfg))
end end
function suite.cflags_onSEH() function suite.cxxflags_onSEH()
flags "SEH" exceptionhandling "SEH"
prepare() prepare()
test.contains("/EHa", msc.getcxxflags(cfg)) test.contains("/EHa", msc.getcxxflags(cfg))
end end
function suite.cflags_onNoExceptions() function suite.cxxflags_onNoExceptions()
flags "NoExceptions" exceptionhandling "Off"
prepare() prepare()
test.missing("/EHsc", msc.getcxxflags(cfg)) test.missing("/EHsc", msc.getcxxflags(cfg))
end end
function suite.cflags_onNoRTTI() function suite.cxxflags_onNoRTTI()
flags "NoRTTI" rtti "Off"
prepare() prepare()
test.contains("/GR-", msc.getcxxflags(cfg)) test.contains("/GR-", msc.getcxxflags(cfg))
end end