diff options
| author | ruki <[email protected]> | 2020-10-06 23:50:13 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-10-06 23:50:13 +0800 |
| commit | 9779cee5d7da7ea01a18141ae5811719d4730410 (patch) | |
| tree | 625bd4f564a99d3d2c50830e8b05cc7722527fb9 | |
| parent | b22465291ce28f752bcb156da735c068ad121c83 (diff) | |
| parent | 0797bc2920576fa61ddf520996e7237569d804b6 (diff) | |
Merge pull request #984 from xmake-io/icc
add icc toolchain
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | README_zh.md | 1 | ||||
| -rw-r--r-- | xmake/modules/core/tools/icc.lua | 31 | ||||
| -rw-r--r-- | xmake/modules/core/tools/icl.lua | 31 | ||||
| -rw-r--r-- | xmake/modules/core/tools/icpc.lua | 28 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_intel.lua | 135 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_icc.lua | 52 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_icl.lua | 56 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_icpc.lua | 52 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/icc/has_flags.lua | 23 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/icl/has_flags.lua | 23 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/icpc/has_flags.lua | 23 | ||||
| -rw-r--r-- | xmake/toolchains/icc/check.lua | 72 | ||||
| -rw-r--r-- | xmake/toolchains/icc/load.lua | 129 | ||||
| -rw-r--r-- | xmake/toolchains/icc/xmake.lua | 35 |
16 files changed, 694 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a9900ba..531e03436 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Upgrade luajit vm and support for runing on mips64 device * [#972](https://github.com/xmake-io/xmake/issues/972): Add `depend.on_changed()` api to simplify adding dependent files * [#981](https://github.com/xmake-io/xmake/issues/981): Add `set_fpmodels()` for math optimization mode +* [#980](https://github.com/xmake-io/xmake/issues/980): Support Intel C/C++ Compiler ### Change @@ -842,6 +843,7 @@ * 升级luajit到v2.1最新分支版本,并且支持mips64上运行xmake * [#972](https://github.com/xmake-io/xmake/issues/972): 添加`depend.on_changed()`去简化依赖文件的处理 * [#981](https://github.com/xmake-io/xmake/issues/981): 添加`set_fpmodels()`去抽象化设置math/float-point编译优化模式 +* [#980](https://github.com/xmake-io/xmake/issues/980): 添加对 Intel C/C++ 编译器的全平台支持 ### 改进 @@ -198,6 +198,7 @@ envs Environment variables toolchain fasm Flat Assembler tinyc Tiny C Compiler emcc A toolchain for compiling to asm.js and WebAssembly +icc Intel C/C++ Compiler ``` ## Supported Languages diff --git a/README_zh.md b/README_zh.md index 5a41d8b4f..d6b96ad22 100644 --- a/README_zh.md +++ b/README_zh.md @@ -201,6 +201,7 @@ envs Environment variables toolchain fasm Flat Assembler tinyc Tiny C Compiler emcc A toolchain for compiling to asm.js and WebAssembly +icc Intel C/C++ Compiler ``` ## 支持语言 diff --git a/xmake/modules/core/tools/icc.lua b/xmake/modules/core/tools/icc.lua new file mode 100644 index 000000000..9a0eabac1 --- /dev/null +++ b/xmake/modules/core/tools/icc.lua @@ -0,0 +1,31 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file icc.lua +-- + +-- inherit gcc +inherit("gcc") + +-- init it +function init(self) + _super.init(self) +end + +-- TODO +-- inherit gcc.lua and override some interfaces in gcc.lua +-- ... diff --git a/xmake/modules/core/tools/icl.lua b/xmake/modules/core/tools/icl.lua new file mode 100644 index 000000000..bd2bd5e14 --- /dev/null +++ b/xmake/modules/core/tools/icl.lua @@ -0,0 +1,31 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file icl.lua +-- + +-- inherit cl +inherit("cl") + +-- init it +function init(self) + +end + +-- TODO +-- inherit cl.lua and override some interfaces in cl.lua +-- ... diff --git a/xmake/modules/core/tools/icpc.lua b/xmake/modules/core/tools/icpc.lua new file mode 100644 index 000000000..6639bfcfe --- /dev/null +++ b/xmake/modules/core/tools/icpc.lua @@ -0,0 +1,28 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file icpc.lua +-- + +-- inherit gcc +inherit("gcc") + +-- init it +function init(self) + _super.init(self) +end + diff --git a/xmake/modules/detect/sdks/find_intel.lua b/xmake/modules/detect/sdks/find_intel.lua new file mode 100644 index 000000000..f6edfaafd --- /dev/null +++ b/xmake/modules/detect/sdks/find_intel.lua @@ -0,0 +1,135 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_intel.lua +-- + +-- imports +import("lib.detect.find_file") +import("lib.detect.find_tool") + +-- init vc variables +local iclvars = {"path", + "lib", + "libpath", + "include", + "DevEnvdir", + "VSInstallDir", + "VCInstallDir", + "WindowsSdkDir", + "WindowsLibPath", + "WindowsSDKVersion", + "WindowsSdkBinPath", + "UniversalCRTSdkDir", + "UCRTVersion"} + +-- load iclvars_bat environment variables +function _load_iclvars(iclvars_bat, arch, opt) + + -- make the geniclvars.bat + opt = opt or {} + local geniclvars_bat = os.tmpfile() .. "_geniclvars.bat" + local geniclvars_dat = os.tmpfile() .. "_geniclvars.txt" + local file = io.open(geniclvars_bat, "w") + file:print("@echo off") + file:print("call \"%s\" -arch %s > nul", iclvars_bat, arch) + for idx, var in ipairs(iclvars) do + file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", geniclvars_dat) + end + file:close() + + -- run geniclvars.bat + os.run(geniclvars_bat) + + -- load all envirnoment variables + local variables = {} + for _, line in ipairs((io.readfile(geniclvars_dat) or ""):split("\n")) do + local p = line:find('=', 1, true) + if p then + local name = line:sub(1, p - 1):trim() + local value = line:sub(p + 1):trim() + variables[name] = value + end + end + if not variables.path then + return + end + + -- remove some empty entries + for _, name in ipairs(iclvars) do + if variables[name] and #variables[name]:trim() == 0 then + variables[name] = nil + end + end + + -- fix bin path for ia32 + if variables.path and arch == "ia32" then + variables.path = variables.path:gsub("windows\\bin\\intel64;", "windows\\bin\\intel64_ia32;") + end + + -- convert path/lib/include to PATH/LIB/INCLUDE + variables.PATH = variables.path + variables.LIB = variables.lib + variables.LIBPATH = variables.libpath + variables.INCLUDE = variables.include + variables.path = nil + variables.lib = nil + variables.include = nil + variables.libpath = nil + return variables +end + +-- find intel envirnoment on windows +function _find_intel_on_windows(opt) + + -- init options + opt = opt or {} + + -- find iclvars_bat.bat + local paths = {"$(env ICPP_COMPILER20)"} + local iclvars_bat = find_file("bin/iclvars.bat", paths) + if iclvars_bat then + + -- load iclvars_bat + local iclvars_x86 = _load_iclvars(iclvars_bat, "ia32", opt) + local iclvars_x64 = _load_iclvars(iclvars_bat, "intel64", opt) + + -- save results + return {iclvars_bat = iclvars_bat, iclvars = {x86 = iclvars_x86, x64 = iclvars_x64}} + end +end + +-- find intel envirnoment on linux +function _find_intel_on_linux(opt) + + -- attempt to find the sdk directory + local paths = {"/opt/intel/bin", "/usr/local/bin", "/usr/bin"} + local icc = find_file("icc", paths) + if icc then + local sdkdir = path.directory(path.directory(icc)) + return {sdkdir = sdkdir, bindir = path.directory(icc), path.join(sdkdir, "include"), libdir = path.join(sdkdir, "lib")} + end +end + +-- find intel environment +function main(opt) + if is_host("windows") then + return _find_intel_on_windows(opt) + else + return _find_intel_on_linux(opt) + end +end diff --git a/xmake/modules/detect/tools/find_icc.lua b/xmake/modules/detect/tools/find_icc.lua new file mode 100644 index 000000000..789a16a9e --- /dev/null +++ b/xmake/modules/detect/tools/find_icc.lua @@ -0,0 +1,52 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_icc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find icc +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local icc = find_icc() +-- local icc, version, hintname = find_icc({program = "icc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "icc", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_icl.lua b/xmake/modules/detect/tools/find_icl.lua new file mode 100644 index 000000000..ac0008c0e --- /dev/null +++ b/xmake/modules/detect/tools/find_icl.lua @@ -0,0 +1,56 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_icl.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find icl +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local icl = find_icl() +-- local icl, version, hintname = find_icl({program = "icl", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + opt.check = opt.check or function (program) os.runv(program, {"/help"}, {envs = opt.envs}) end + + -- find program + local program = find_program(opt.program or "icl.exe", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + opt.command = opt.command or function () local _, info = os.iorunv(program, {"/help"}, {envs = opt.envs}); return info end + opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end + version = find_programver(program, opt) + end + return program, version +end + diff --git a/xmake/modules/detect/tools/find_icpc.lua b/xmake/modules/detect/tools/find_icpc.lua new file mode 100644 index 000000000..6c806cad6 --- /dev/null +++ b/xmake/modules/detect/tools/find_icpc.lua @@ -0,0 +1,52 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_icpc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find icpc +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local icpc = find_icpc() +-- local icpc, version, hintname = find_icpc({program = "icpc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "icpc", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/icc/has_flags.lua b/xmake/modules/detect/tools/icc/has_flags.lua new file mode 100644 index 000000000..6ac2ce551 --- /dev/null +++ b/xmake/modules/detect/tools/icc/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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file has_flags.lua +-- + +-- imports +inherit("detect.tools.gcc.has_flags") + diff --git a/xmake/modules/detect/tools/icl/has_flags.lua b/xmake/modules/detect/tools/icl/has_flags.lua new file mode 100644 index 000000000..81573039e --- /dev/null +++ b/xmake/modules/detect/tools/icl/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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file has_flags.lua +-- + +-- imports +inherit("detect.tools.cl.has_flags") + diff --git a/xmake/modules/detect/tools/icpc/has_flags.lua b/xmake/modules/detect/tools/icpc/has_flags.lua new file mode 100644 index 000000000..50d4f59d9 --- /dev/null +++ b/xmake/modules/detect/tools/icpc/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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file has_flags.lua +-- + +-- imports +inherit("detect.tools.gxx.has_flags") + diff --git a/xmake/toolchains/icc/check.lua b/xmake/toolchains/icc/check.lua new file mode 100644 index 000000000..4cbc9f5d2 --- /dev/null +++ b/xmake/toolchains/icc/check.lua @@ -0,0 +1,72 @@ +--!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) + + -- have been checked? + if config.get("__iclvarsall") then + return true + end + + -- find intel + local intel = find_intel() + if intel and intel.iclvars then + local iclvarsall = intel.iclvars + local iclenv = iclvarsall[toolchain:arch()] + if iclenv and iclenv.PATH and iclenv.INCLUDE and iclenv.LIB then + + -- save iclvars + config.set("__iclvarsall", iclvarsall) + + -- check compiler + local program = nil + local tool = find_tool("icl.exe", {force = true, envs = iclenv, version = true}) + if tool then + program = tool.program + end + if program then + cprint("checking for Intel C/C++ Compiler (%s) ... ${color.success}${text.success}", toolchain:arch()) + return true + end + end + end +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..c854b7b91 --- /dev/null +++ b/xmake/toolchains/icc/load.lua @@ -0,0 +1,129 @@ +--!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") + +-- add the given icl environment +function _add_iclenv(toolchain, name) + + -- get iclvarsall + local iclvarsall = config.get("__iclvarsall") + if not iclvarsall then + return + end + + -- get icl environment for the current arch + local arch = toolchain:arch() + local iclenv = iclvarsall[arch] or {} + + -- get the paths for the icl environment + local env = iclenv[name] + if env then + toolchain:add("runenvs", name:upper(), path.splitenv(env)) + end +end + +-- 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 + + -- add icl environments + _add_iclenv(toolchain, "PATH") + _add_iclenv(toolchain, "LIB") + _add_iclenv(toolchain, "INCLUDE") + _add_iclenv(toolchain, "LIBPATH") +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 new file mode 100644 index 000000000..2cf971f0c --- /dev/null +++ b/xmake/toolchains/icc/xmake.lua @@ -0,0 +1,35 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- define toolchain +toolchain("icc") + + -- set homepage + set_homepage("https://software.intel.com/content/www/us/en/develop/tools/compilers/c-compilers.html") + set_description("Intel C/C++ Compiler") + + -- mark as standalone toolchain + set_kind("standalone") + + -- check toolchain + on_check("check") + + -- on load + on_load("load") |
