diff options
| author | ruki <[email protected]> | 2020-10-07 22:53:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-07 22:53:15 +0800 |
| commit | d99942591281a478ae97e90163eb2bc83a7f5010 (patch) | |
| tree | cf0a3ee328238525de19e3d0c5e71b7daf5bf648 /xmake/toolchains | |
| parent | 272052e6545c85c5fcc90cd7fd81177cbb431de1 (diff) | |
add ifort compiler
Diffstat (limited to 'xmake/toolchains')
| -rw-r--r-- | xmake/toolchains/icc/check.lua | 10 | ||||
| -rw-r--r-- | xmake/toolchains/icc/load.lua | 1 | ||||
| -rw-r--r-- | xmake/toolchains/ifort/check.lua | 73 | ||||
| -rw-r--r-- | xmake/toolchains/ifort/load.lua | 104 | ||||
| -rw-r--r-- | xmake/toolchains/ifort/xmake.lua | 35 |
5 files changed, 217 insertions, 6 deletions
diff --git a/xmake/toolchains/icc/check.lua b/xmake/toolchains/icc/check.lua index 4cbc9f5d2..7f8b04deb 100644 --- a/xmake/toolchains/icc/check.lua +++ b/xmake/toolchains/icc/check.lua @@ -21,7 +21,7 @@ -- imports import("core.base.option") import("core.project.config") -import("detect.sdks.find_intel") +import("detect.sdks.find_iccenv") import("lib.detect.find_tool") -- check intel on windows @@ -32,10 +32,10 @@ function _check_intel_on_windows(toolchain) return true end - -- find intel - local intel = find_intel() - if intel and intel.iclvars then - local iclvarsall = intel.iclvars + -- find intel c/c++ compiler environment + local iccenv = find_iccenv() + if iccenv and iccenv.iclvars then + local iclvarsall = iccenv.iclvars local iclenv = iclvarsall[toolchain:arch()] if iclenv and iclenv.PATH and iclenv.INCLUDE and iclenv.LIB then diff --git a/xmake/toolchains/icc/load.lua b/xmake/toolchains/icc/load.lua index c854b7b91..b3dbf589f 100644 --- a/xmake/toolchains/icc/load.lua +++ b/xmake/toolchains/icc/load.lua @@ -99,7 +99,6 @@ function _load_intel_on_linux(toolchain) end if march then toolchain:add("cxflags", march) - toolchain:add("mxflags", march) toolchain:add("asflags", march) toolchain:add("ldflags", march) toolchain:add("shflags", march) diff --git a/xmake/toolchains/ifort/check.lua b/xmake/toolchains/ifort/check.lua new file mode 100644 index 000000000..f87ea3d9e --- /dev/null +++ b/xmake/toolchains/ifort/check.lua @@ -0,0 +1,73 @@ +--!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_ifortenv") +import("lib.detect.find_tool") + +-- check intel on windows +function _check_intel_on_windows(toolchain) + + -- have been checked? + if config.get("__ifortvarsall") then + return true + end + + -- find intel fortran compiler environment + local ifortenv = find_ifortenv() + if ifortenv and ifortenv.ifortvars then + local ifortvarsall = ifortenv.ifortvars + local ifortenv = ifortvarsall[toolchain:arch()] + if ifortenv and ifortenv.PATH and ifortenv.INCLUDE and ifortenv.LIB then + + -- save ifortvars + config.set("__ifortvarsall", ifortvarsall) + + -- check compiler + local program = nil + local tool = find_tool("ifort.exe", {force = true, envs = ifortenv, version = true}) + if tool then + program = tool.program + end + if program then + cprint("checking for Intel Fortran 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("ifort") +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/ifort/load.lua b/xmake/toolchains/ifort/load.lua new file mode 100644 index 000000000..7144b62c4 --- /dev/null +++ b/xmake/toolchains/ifort/load.lua @@ -0,0 +1,104 @@ +--!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 ifort environment +function _add_ifortenv(toolchain, name) + + -- get ifortvarsall + local ifortvarsall = config.get("__ifortvarsall") + if not ifortvarsall then + return + end + + -- get ifort environment for the current arch + local arch = toolchain:arch() + local ifortenv = ifortvarsall[arch] or {} + + -- get the paths for the ifort environment + local env = ifortenv[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", "fc", "ifort.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", "fcld", "ifort.exe") + toolchain:set("toolset", "fcsh", "ifort.exe") + toolchain:set("toolset", "ar", "link.exe") + toolchain:set("toolset", "ex", "lib.exe") + else + toolchain:set("toolset", "fc", "ifort") + toolchain:set("toolset", "fcld", "ifort") + toolchain:set("toolset", "fcsh", "ifort") + end + + -- add ifort environments + _add_ifortenv(toolchain, "PATH") + _add_ifortenv(toolchain, "LIB") + _add_ifortenv(toolchain, "INCLUDE") + _add_ifortenv(toolchain, "LIBPATH") +end + +-- load intel on linux +function _load_intel_on_linux(toolchain) + + -- set toolset + toolchain:set("toolset", "fc", "ifort") + toolchain:set("toolset", "fcld", "ifort") + toolchain:set("toolset", "fcsh", "ifort") + + -- 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("fcflags", march) + toolchain:add("fcldflags", march) + toolchain:add("fcshflags", march) + 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/ifort/xmake.lua b/xmake/toolchains/ifort/xmake.lua new file mode 100644 index 000000000..4dc531baa --- /dev/null +++ b/xmake/toolchains/ifort/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("ifort") + + -- set homepage + set_homepage("https://software.intel.com/content/www/us/en/develop/tools/compilers/fortran-compilers.html") + set_description("Intel Fortran Compiler") + + -- mark as standalone toolchain + set_kind("standalone") + + -- check toolchain + on_check("check") + + -- on load + on_load("load") |
