summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-20 22:12:04 +0800
committerruki <[email protected]>2022-08-20 22:12:04 +0800
commit32fa15ce715e20617c01a1cfb02babd50a92e293 (patch)
treecefaf3f99f4d2a1b97c17511da9685fcc4a253ba
parentdb90d109c6ccf2545e8a3ae186ddfea1c99be61f (diff)
add has_flags for armclang
-rw-r--r--xmake/modules/detect/tools/armclang/has_flags.lua23
-rw-r--r--xmake/modules/detect/tools/gcc/has_flags.lua24
2 files changed, 45 insertions, 2 deletions
diff --git a/xmake/modules/detect/tools/armclang/has_flags.lua b/xmake/modules/detect/tools/armclang/has_flags.lua
new file mode 100644
index 000000000..6464e10b6
--- /dev/null
+++ b/xmake/modules/detect/tools/armclang/has_flags.lua
@@ -0,0 +1,23 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file has_flags.lua
+--
+
+-- imports
+inherit("detect.tools.gcc.has_flags")
+
diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua
index b8e63423a..8f019a36a 100644
--- a/xmake/modules/detect/tools/gcc/has_flags.lua
+++ b/xmake/modules/detect/tools/gcc/has_flags.lua
@@ -73,6 +73,21 @@ function _get_extension(opt)
return (opt.program:endswith("++") or opt.flagkind == "cxxflags") and ".cpp" or (table.wrap(language.sourcekinds()[opt.toolkind or "cc"])[1] or ".c")
end
+-- has `-S` flag?
+function _has_flag_S(opt)
+ local has_flag_S = _g.has_flag_S
+ if has_flag_S == nil then
+ if opt.program:find("armclang", 1, true) then
+ -- it is disallowed in ARM compiler
+ has_flag_S = false
+ else
+ has_flag_S = true
+ end
+ _g.has_flag_S = has_flag_S
+ end
+ return has_flag_S
+end
+
-- try running to check flags
function _check_try_running(flags, opt, islinker)
@@ -83,13 +98,18 @@ function _check_try_running(flags, opt, islinker)
end
-- check flags for linker
+ local tmpfile = os.tmpfile()
if islinker then
- return _try_running(opt.program, table.join(flags, "-o", os.tmpfile(), sourcefile), opt)
+ return _try_running(opt.program, table.join(flags, "-o", tmpfile, sourcefile), opt)
end
-- check flags for compiler
-- @note we cannot use os.nuldev() as the output file, maybe run failed for some flags, e.g. --coverage
- return _try_running(opt.program, table.join(flags, "-S", "-o", os.tmpfile(), sourcefile), opt)
+ local extraflags = {}
+ if _has_flag_S(opt) then
+ table.insert(extraflags, "-S")
+ end
+ return _try_running(opt.program, table.join(flags, extraflags, "-o", tmpfile, sourcefile), opt)
end
-- has_flags(flags)?