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

View File

@ -1124,7 +1124,7 @@
function m.exceptionHandling(cfg)
if cfg.exceptionhandling == p.OFF then
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"')
end
end

View File

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

View File

@ -106,21 +106,21 @@
--
gcc.cxxflags = {
exceptionhandling = {
Off = "-fno-exceptions"
},
flags = {
NoBufferSecurityCheck = "-fno-stack-protector",
["C++11"] = "-std=c++11",
["C++14"] = "-std=c++14",
},
rtti = {
Off = "-fno-rtti"
}
}
function gcc.getcxxflags(cfg)
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
end

View File

@ -7,10 +7,12 @@
---
premake.tools.msc = {}
local msc = premake.tools.msc
local project = premake.project
local config = premake.config
local p = premake
p.tools.msc = {}
local msc = p.tools.msc
local project = p.project
local config = p.config
--
@ -38,7 +40,6 @@
MultiProcessorCompile = "/MP",
NoFramePointer = "/Oy",
NoMinimalRebuild = "/Gm-",
SEH = "/EHa",
Symbols = "/Z7",
OmitDefaultLibrary = "/Zl",
},
@ -103,21 +104,19 @@
-- 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)
local flags = {}
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
local flags = config.mapFlags(cfg, msc.cxxflags)
return flags
end

View File

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

View File

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

View File

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

View File

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