diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 6d724cb6..1a923db2 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -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,19 +343,34 @@ api.register { name = "editandcontinue", scope = "config", - kind = "boolean", + kind = "string", + allowed = { + "Default", + "On", + "Off", + }, } api.register { name = "exceptionhandling", scope = "config", - kind = "boolean", + kind = "string", + allowed = { + "Default", + "On", + "Off", + }, } api.register { name = "rtti", scope = "config", - kind = "boolean", + kind = "string", + allowed = { + "Default", + "On", + "Off", + }, } api.register { @@ -1276,9 +1291,6 @@ ----------------------------------------------------------------------------- clr "Off" - editandcontinue "On" - exceptionhandling "On" - rtti "On" -- Setting a default language makes some validation easier later diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index c6eef724..3e002b1f 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -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.exceptionhandling == false 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.rtti == false 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 diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 114b974c..c7cf6960 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -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,9 +1098,9 @@ function m.exceptionHandling(cfg) - if cfg.exceptionhandling == false then + if cfg.exceptionhandling == p.OFF then p.w('false') - elseif cfg.exceptionhandling == true then + elseif cfg.exceptionhandling == p.ON or cfg.flags.SEH then if cfg.flags.SEH then p.w('Async') else @@ -1625,9 +1626,9 @@ end function m.runtimeTypeInfo(cfg) - if cfg.rtti == false and cfg.clr == p.OFF then + if cfg.rtti == p.OFF and cfg.clr == p.OFF then p.w('false') - elseif cfg.rtti == true then + elseif cfg.rtti == p.ON then p.w('true') end end diff --git a/src/base/_foundation.lua b/src/base/_foundation.lua index f9d123be..ec0153f6 100644 --- a/src/base/_foundation.lua +++ b/src/base/_foundation.lua @@ -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" diff --git a/src/base/config.lua b/src/base/config.lua index 78b85778..996b3765 100755 --- a/src/base/config.lua +++ b/src/base/config.lua @@ -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 diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index a2ecfa74..190c8af0 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -115,10 +115,10 @@ function gcc.getcxxflags(cfg) local flags = config.mapFlags(cfg, gcc.cxxflags) - if not cfg.exceptionhandling then + if cfg.exceptionhandling == p.OFF then table.insert(flags, '-fno-exceptions') end - if not cfg.rtti then + if cfg.rtti == p.OFF then table.insert(flags, '-fno-rtti') end return flags diff --git a/src/tools/msc.lua b/src/tools/msc.lua index d2727132..0a0712a4 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -106,11 +106,16 @@ function msc.getcxxflags(cfg) local flags = {} - if cfg.rtti == false then + if cfg.rtti == premake.OFF then table.insert(flags, "/GR-") end - if not cfg.flags.SEH and cfg.exceptionhandling then - table.insert(flags, "/EHsc") + + 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 diff --git a/src/tools/snc.lua b/src/tools/snc.lua index 1894abd0..ded30fb1 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -45,15 +45,15 @@ local flags = {} -- turn on exceptions and RTTI by default, to match other toolsets - if cfg.exceptionhandling then + if cfg.exceptionhandling == p.ON then table.insert(flags, "-Xc+=exceptions") - else + elseif cfg.exceptionhandling == p.OFF then table.insert(flags, "-Xc-=exceptions") end - if cfg.rtti then + if cfg.rtti == p.ON then table.insert(flags, "-Xc+=rtti") - else + elseif cfg.rtti == p.OFF then table.insert(flags, "-Xc-=rtti") end diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/tests/actions/vstudio/vc2010/test_compile_settings.lua index 17c26c97..17a295bc 100644 --- a/tests/actions/vstudio/vc2010/test_compile_settings.lua +++ b/tests/actions/vstudio/vc2010/test_compile_settings.lua @@ -36,8 +36,6 @@ NotUsing Level3 Disabled - Sync - true ]] end @@ -223,8 +221,6 @@ NotUsing Level3 Disabled - Sync - true ]] end @@ -237,8 +233,6 @@ NotUsing Level3 Disabled - Sync - true ]] end @@ -300,8 +294,6 @@ NotUsing Level3 Disabled - Sync - true /xyz /abc %(AdditionalOptions) ]] end @@ -448,8 +440,6 @@ Level3 EditAndContinue Disabled - Sync - true ]] end @@ -485,8 +475,6 @@ NotUsing Level3 Disabled - Sync - true true ]] end @@ -499,8 +487,6 @@ NotUsing Level3 Disabled - Sync - true false ]] end @@ -542,7 +528,6 @@ NotUsing Level3 Disabled - Sync false ]] end @@ -555,8 +540,6 @@ NotUsing Level3 Disabled - Sync - true false ]] end @@ -703,8 +686,6 @@ Level3 Disabled false - Sync - true true ]] end diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 9987e304..6b133245 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -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()