summaryrefslogtreecommitdiff
path: root/xmake/toolchains
diff options
context:
space:
mode:
authorruki <[email protected]>2020-10-07 00:34:30 +0800
committerruki <[email protected]>2020-10-07 00:34:30 +0800
commitacc4c79235d585c6c3f05aaf3d2c6e11adb076ff (patch)
treed43ad6f5322733c54495b0d0195f1817915d925d /xmake/toolchains
parentb3693176780c056c66fb2aa1e6e2f251242368c4 (diff)
add find_intel
Diffstat (limited to 'xmake/toolchains')
-rw-r--r--xmake/toolchains/icc/check.lua44
-rw-r--r--xmake/toolchains/icc/load.lua103
-rw-r--r--xmake/toolchains/icc/xmake.lua61
3 files changed, 149 insertions, 59 deletions
diff --git a/xmake/toolchains/icc/check.lua b/xmake/toolchains/icc/check.lua
new file mode 100644
index 000000000..a5254f20f
--- /dev/null
+++ b/xmake/toolchains/icc/check.lua
@@ -0,0 +1,44 @@
+--!A cross-toolchain 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-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("detect.sdks.find_intel")
+import("lib.detect.find_tool")
+
+-- check intel on windows
+function _check_intel_on_windows(toolchain)
+end
+
+-- check intel on linux
+function _check_intel_on_linux(toolchain)
+ return find_tool("icc")
+end
+
+-- main entry
+function main(toolchain)
+ if is_host("windows") then
+ return _check_intel_on_windows(toolchain)
+ else
+ return _check_intel_on_linux(toolchain)
+ end
+end
+
diff --git a/xmake/toolchains/icc/load.lua b/xmake/toolchains/icc/load.lua
new file mode 100644
index 000000000..1265ac731
--- /dev/null
+++ b/xmake/toolchains/icc/load.lua
@@ -0,0 +1,103 @@
+--!A cross-toolchain 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-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+
+-- load intel on windows
+function _load_intel_on_windows(toolchain)
+
+ -- set toolset
+ if toolchain:is_plat("windows") then
+ toolchain:set("toolset", "cc", "icl.exe")
+ toolchain:set("toolset", "cxx", "icl.exe")
+ toolchain:set("toolset", "mrc", "rc.exe")
+ if toolchain:is_arch("x64") then
+ toolchain:set("toolset", "as", "ml64.exe")
+ else
+ toolchain:set("toolset", "as", "ml.exe")
+ end
+ toolchain:set("toolset", "ld", "link.exe")
+ toolchain:set("toolset", "sh", "link.exe")
+ toolchain:set("toolset", "ar", "link.exe")
+ toolchain:set("toolset", "ex", "lib.exe")
+ else
+ toolchain:set("toolset", "cc", "icc")
+ toolchain:set("toolset", "cxx", "icpc", "icc")
+ toolchain:set("toolset", "ld", "icpc", "icc")
+ toolchain:set("toolset", "sh", "icpc", "icc")
+ toolchain:set("toolset", "ar", "ar")
+ toolchain:set("toolset", "ex", "ar")
+ toolchain:set("toolset", "strip", "strip")
+ toolchain:set("toolset", "as", "icc")
+ end
+end
+
+-- load intel on linux
+function _load_intel_on_linux(toolchain)
+
+ -- set toolset
+ toolchain:set("toolset", "cc", "icc")
+ toolchain:set("toolset", "cxx", "icpc", "icc")
+ toolchain:set("toolset", "ld", "icpc", "icc")
+ toolchain:set("toolset", "sh", "icpc", "icc")
+ toolchain:set("toolset", "ar", "ar")
+ toolchain:set("toolset", "ex", "ar")
+ toolchain:set("toolset", "strip", "strip")
+ toolchain:set("toolset", "as", "icc")
+
+ -- add march flags
+ local march
+ if toolchain:is_arch("x86_64", "x64") then
+ march = "-m64"
+ elseif toolchain:is_arch("i386", "x86") then
+ march = "-m32"
+ end
+ if march then
+ toolchain:add("cxflags", march)
+ toolchain:add("mxflags", march)
+ toolchain:add("asflags", march)
+ toolchain:add("ldflags", march)
+ toolchain:add("shflags", march)
+ end
+
+ -- add includedirs and linkdirs
+ for _, includedir in ipairs({"/usr/local/include", "/usr/include"}) do
+ if os.isdir(includedir) then
+ toolchain:add("includedirs", includedir)
+ end
+ end
+ for _, linkdir in ipairs({"/usr/local/lib", "/usr/lib"}) do
+ if os.isdir(linkdir) then
+ toolchain:add("linkdirs", linkdir)
+ end
+ end
+end
+
+-- main entry
+function main(toolchain)
+ if is_host("windows") then
+ return _load_intel_on_windows(toolchain)
+ else
+ return _load_intel_on_linux(toolchain)
+ end
+end
+
diff --git a/xmake/toolchains/icc/xmake.lua b/xmake/toolchains/icc/xmake.lua
index 93a851562..2cf971f0c 100644
--- a/xmake/toolchains/icc/xmake.lua
+++ b/xmake/toolchains/icc/xmake.lua
@@ -29,64 +29,7 @@ toolchain("icc")
set_kind("standalone")
-- check toolchain
- on_check(function (toolchain)
- return import("lib.detect.find_tool")(toolchain:is_plat("windows") and "icl" or "icc")
- end)
+ on_check("check")
-- on load
- on_load(function (toolchain)
-
- -- set toolset
- if toolchain:is_plat("windows") then
- toolchain:set("toolset", "cc", "icl.exe")
- toolchain:set("toolset", "cxx", "icl.exe")
- toolchain:set("toolset", "mrc", "rc.exe")
- if toolchain:is_arch("x64") then
- toolchain:set("toolset", "as", "ml64.exe")
- else
- toolchain:set("toolset", "as", "ml.exe")
- end
- toolchain:set("toolset", "ld", "link.exe")
- toolchain:set("toolset", "sh", "link.exe")
- toolchain:set("toolset", "ar", "link.exe")
- toolchain:set("toolset", "ex", "lib.exe")
- else
- toolchain:set("toolset", "cc", "icc")
- toolchain:set("toolset", "cxx", "icpc", "icc")
- toolchain:set("toolset", "ld", "icpc", "icc")
- toolchain:set("toolset", "sh", "icpc", "icc")
- toolchain:set("toolset", "ar", "ar")
- toolchain:set("toolset", "ex", "ar")
- toolchain:set("toolset", "strip", "strip")
- toolchain:set("toolset", "as", "icc")
- end
-
- -- add march flags
- local march
- if toolchain:is_arch("x86_64", "x64") then
- march = "-m64"
- elseif toolchain:is_arch("i386", "x86") then
- march = "-m32"
- end
- if march then
- toolchain:add("cxflags", march)
- toolchain:add("mxflags", march)
- toolchain:add("asflags", march)
- toolchain:add("ldflags", march)
- toolchain:add("shflags", march)
- end
-
- -- add includedirs and linkdirs
- if not toolchain:is_plat("windows") and os.isdir("/usr") then
- for _, includedir in ipairs({"/usr/local/include", "/usr/include"}) do
- if os.isdir(includedir) then
- toolchain:add("includedirs", includedir)
- end
- end
- for _, linkdir in ipairs({"/usr/local/lib", "/usr/lib"}) do
- if os.isdir(linkdir) then
- toolchain:add("linkdirs", linkdir)
- end
- end
- end
- end)
+ on_load("load")