Merge pull request #102 from Blizzard/exceptionhandling

add new exceptionhandling and rtti API's, deprecate the corresponding flags.
This commit is contained in:
starkos 2015-06-21 19:28:27 -04:00
commit fe1f9b4531
10 changed files with 111 additions and 43 deletions

View File

@ -24,14 +24,14 @@
kind = "string",
allowed = {
"universal",
"x86",
"x86_64",
p.X86,
p.X86_64,
},
aliases = {
i386 = "x86",
amd64 = "x86_64",
x32 = "x86", -- these should be DEPRECATED
x64 = "x86_64",
i386 = p.X86,
amd64 = p.X86_64,
x32 = p.X86, -- these should be DEPRECATED
x64 = p.X86_64,
},
}
@ -343,7 +343,34 @@
api.register {
name = "editandcontinue",
scope = "config",
kind = "boolean",
kind = "string",
allowed = {
"Default",
"On",
"Off",
},
}
api.register {
name = "exceptionhandling",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off",
},
}
api.register {
name = "rtti",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off",
},
}
api.register {
@ -416,7 +443,7 @@
"No64BitChecks",
"NoCopyLocal",
"NoEditAndContinue", -- DEPRECATED
"NoExceptions",
"NoExceptions", -- DEPRECATED
"NoFramePointer",
"NoImplicitLink",
"NoImportLib",
@ -426,7 +453,7 @@
"NoNativeWChar", -- DEPRECATED
"NoPCH",
"NoRuntimeChecks",
"NoRTTI",
"NoRTTI", -- DEPRECATED
"NoBufferSecurityCheck",
"NoWarnings", -- DEPRECATED
"OmitDefaultLibrary",
@ -1118,6 +1145,24 @@
end)
api.deprecateValue("flags", "NoExceptions", nil,
function(value)
exceptionhandling "Off"
end,
function(value)
exceptionhandling "On"
end)
api.deprecateValue("flags", "NoRTTI", nil,
function(value)
rtti "Off"
end,
function(value)
rtti "On"
end)
api.deprecateValue("flags", "Unsafe", nil,
function(value)
clr "Unsafe"
@ -1234,7 +1279,6 @@
-----------------------------------------------------------------------------
clr "Off"
editandcontinue "On"
-- Setting a default language makes some validation easier later

View File

@ -753,10 +753,10 @@
return 1
else
-- Edit-and-continue doesn't work for some configurations
if not cfg.editandcontinue or
config.isOptimizedBuild(cfg) or
cfg.clr ~= p.OFF or
cfg.architecture == p.X86_64
if cfg.editandcontinue == p.OFF or
config.isOptimizedBuild(cfg) or
cfg.clr ~= p.OFF or
cfg.architecture == p.X86_64
then
return 3
else
@ -1122,7 +1122,7 @@
function m.exceptionHandling(cfg)
if cfg.flags.NoExceptions then
if cfg.exceptionhandling == p.OFF then
p.w('ExceptionHandling="%s"', iif(_ACTION < "vs2005", "FALSE", 0))
elseif cfg.flags.SEH and _ACTION > "vs2003" then
p.w('ExceptionHandling="2"')
@ -1519,8 +1519,10 @@
function m.runtimeTypeInfo(cfg)
if cfg.flags.NoRTTI and cfg.clr == p.OFF then
if cfg.rtti == p.OFF and cfg.clr == p.OFF then
p.w('RuntimeTypeInfo="false"')
elseif cfg.rtti == p.ON then
p.w('RuntimeTypeInfo="true"')
end
end

View File

@ -919,6 +919,7 @@
end
end
function m.additionalUsingDirectories(cfg)
if #cfg.usingdirs > 0 then
local dirs = table.concat(vstudio.path(cfg, cfg.usingdirs), ";")
@ -1041,7 +1042,7 @@
elseif cfg.architecture == "x86_64" or
cfg.clr ~= p.OFF or
config.isOptimizedBuild(cfg) or
not cfg.editandcontinue
cfg.editandcontinue == p.OFF
then
value = "ProgramDatabase"
else
@ -1097,10 +1098,14 @@
function m.exceptionHandling(cfg)
if cfg.flags.NoExceptions then
if cfg.exceptionhandling == p.OFF then
p.w('<ExceptionHandling>false</ExceptionHandling>')
elseif cfg.flags.SEH then
p.w('<ExceptionHandling>Async</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
end
end
@ -1608,8 +1613,10 @@
end
function m.runtimeTypeInfo(cfg)
if cfg.flags.NoRTTI and cfg.clr == p.OFF then
_p(3,'<RuntimeTypeInfo>false</RuntimeTypeInfo>')
if cfg.rtti == p.OFF and cfg.clr == p.OFF then
p.w('<RuntimeTypeInfo>false</RuntimeTypeInfo>')
elseif cfg.rtti == p.ON then
p.w('<RuntimeTypeInfo>true</RuntimeTypeInfo>')
end
end

View File

@ -30,6 +30,8 @@
premake.MACOSX = "macosx"
premake.MAKEFILE = "Makefile"
premake.NONE = "None"
premake.DEFAULT = "Default"
premake.ON = "On"
premake.OFF = "Off"
premake.POSIX = "posix"
premake.PS3 = "ps3"

View File

@ -320,7 +320,7 @@
function config.getruntime(cfg)
local linkage = iif(cfg.flags.StaticRuntime, "Static", "Shared")
if (cfg.runtime == nil) then
if not cfg.runtime then
return linkage .. iif(config.isDebugBuild(cfg), "Debug", "Release")
else
return linkage .. cfg.runtime

View File

@ -107,8 +107,6 @@
gcc.cxxflags = {
flags = {
NoExceptions = "-fno-exceptions",
NoRTTI = "-fno-rtti",
NoBufferSecurityCheck = "-fno-stack-protector",
["C++11"] = "-std=c++11",
["C++14"] = "-std=c++14",
@ -117,6 +115,12 @@
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

@ -103,17 +103,19 @@
-- Returns list of C++ compiler flags for a configuration.
--
msc.cxxflags = {
flags = {
NoRTTI = "/GR-",
}
}
function msc.getcxxflags(cfg)
local flags = config.mapFlags(cfg, msc.cxxflags)
local flags = {}
if not cfg.flags.SEH and not cfg.flags.NoExceptions then
table.insert(flags, "/EHsc")
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

View File

@ -41,20 +41,20 @@
-- Retrieve the CXXFLAGS for a specific configuration.
--
snc.cxxflags = {
NoExceptions = "-Xc-=exceptions",
NoRTTI = "-Xc-=rtti",
}
function snc.getcxxflags(cfg)
local flags = table.translate(cfg.flags, snc.cxxflags)
local flags = {}
-- turn on exceptions and RTTI by default, to match other toolsets
if not cfg.flags.NoExceptions then
if cfg.exceptionhandling == p.ON then
table.insert(flags, "-Xc+=exceptions")
elseif cfg.exceptionhandling == p.OFF then
table.insert(flags, "-Xc-=exceptions")
end
if not cfg.flags.NoRTTI then
if cfg.rtti == p.ON then
table.insert(flags, "-Xc+=rtti")
elseif cfg.rtti == p.OFF then
table.insert(flags, "-Xc-=rtti")
end
return flags

View File

@ -532,7 +532,7 @@
]]
end
function suite.runtimeTypeInfo_onNoRTTI()
function suite.runtimeTypeInfo_onNoBufferSecurityCheck()
flags "NoBufferSecurityCheck"
prepare()
test.capture [[

View File

@ -228,10 +228,17 @@
--
function suite.cflags_onExceptions()
exceptionhandling "on"
prepare()
test.contains("/EHsc", msc.getcxxflags(cfg))
end
function suite.cflags_onSEH()
flags "SEH"
prepare()
test.contains("/EHa", msc.getcxxflags(cfg))
end
function suite.cflags_onNoExceptions()
flags "NoExceptions"
prepare()