diff options
| author | ruki <[email protected]> | 2022-11-05 00:57:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-11-05 00:57:10 +0800 |
| commit | 4889bfdb1fc75dfaa90a702f26d07715cb592d15 (patch) | |
| tree | 8eed62eb4c116e9068a1a151924e4db63f7ac0c1 | |
| parent | 5cf20abdd48b4dfe645a9564975f4367e4494240 (diff) | |
add set_exceptions
| -rw-r--r-- | xmake/core/project/target.lua | 1 | ||||
| -rw-r--r-- | xmake/languages/c++/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 13 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 21 |
4 files changed, 36 insertions, 0 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index ddbd2927a..080b8249b 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2284,6 +2284,7 @@ function target.apis() , "target.set_languages" , "target.set_toolchains" , "target.set_runargs" + , "target.set_exceptions" -- target.add_xxx , "target.add_deps" , "target.add_rules" diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua index 6d4b48b2b..e28bb2733 100644 --- a/xmake/languages/c++/xmake.lua +++ b/xmake/languages/c++/xmake.lua @@ -47,6 +47,7 @@ language("c++") , "target.undefines" , "target.frameworkdirs" , "target.frameworks" + , "target.exceptions" , "target.pcheader" , "target.pcxxheader" , "toolchain.includedirs" diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 7cce576ae..a20e4d85b 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -298,6 +298,19 @@ function nf_sysincludedir(self, dir) end end +-- make the exception flag +-- +-- e.g. +-- set_exceptions("cxx") +-- set_exceptions("no-cxx") +function nf_exception(self, exp) + local maps = { + cxx = "/EHsc", + ["no-cxx"] = "/EHsc-" + } + return maps[exp] +end + -- make the c precompiled header flag function nf_pcheader(self, pcheaderfile, target) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index a3888ac34..cd11743c7 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -302,6 +302,27 @@ function nf_frameworkdir(self, frameworkdir) return {"-F" .. path.translate(frameworkdir)} 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 + -- make the c precompiled header flag function nf_pcheader(self, pcheaderfile, target) if self:kind() == "cc" then |
