From 5796e77bdb782277ecc82090496aebcea65aa87f Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 5 Nov 2022 21:36:17 +0800 Subject: improve exceptions --- xmake/modules/core/tools/clang.lua | 22 ++++++++++++++++++++++ xmake/modules/core/tools/gcc.lua | 11 +---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 08822e367..521f31361 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -142,3 +142,25 @@ function nf_symbol(self, level) return _super.nf_symbol(self, level) end end + +-- make the exception flag +-- +-- e.g. +-- set_exceptions("cxx") +-- set_exceptions("objc") +-- set_exceptions("no-cxx") +-- set_exceptions("no-objc") +-- set_exceptions("cxx", "objc") +function nf_exception(self, exp) + local maps = { + cxx = "-fcxx-exceptions", + ["no-cxx"] = "-fno-cxx-exceptions", + objc = "-fobjc-exceptions", + ["no-objc"] = "-fno-objc-exceptions" + } + local value = maps[exp] + if value then + return {exp:startswith("no-") and "-fno-exceptions" or "-fexceptions", value} + end +end + diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index cd11743c7..412a0cdbf 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -311,16 +311,7 @@ end -- set_exceptions("no-objc") -- set_exceptions("cxx", "objc") function nf_exception(self, exp) - local maps = { - cxx = "-fcxx-exceptions", - ["no-cxx"] = "-fno-cxx-exceptions", - objc = "-fobjc-exceptions", - ["no-objc"] = "-fno-objc-exceptions" - } - local value = maps[exp] - if value then - return {exp:startswith("no-") and "-fno-exceptions" or "-fexceptions", value} - end + return exp:startswith("no-") and "-fno-exceptions" or "-fexceptions" end -- make the c precompiled header flag -- cgit v1.3.1