summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-09 22:49:00 +0800
committerruki <[email protected]>2024-07-09 22:49:00 +0800
commitcbb8f14330263b94a467102ae96c2ae00f79ce33 (patch)
tree6a1fff4eccc34538f66a335d47df2d0820ffe9a1
parent695b6728210692855a7b5cdeb666a926dac175d7 (diff)
add ifx toolchain
-rw-r--r--xmake/modules/detect/sdks/find_ifxenv.lua145
-rw-r--r--xmake/modules/detect/tools/find_icx.lua14
-rw-r--r--xmake/modules/detect/tools/find_ifx.lua46
-rw-r--r--xmake/modules/detect/tools/ifx/has_flags.lua23
-rw-r--r--xmake/toolchains/icc/check.lua5
-rw-r--r--xmake/toolchains/icx/check.lua5
-rw-r--r--xmake/toolchains/ifort/check.lua5
-rw-r--r--xmake/toolchains/ifx/check.lua161
-rw-r--r--xmake/toolchains/ifx/load.lua156
-rw-r--r--xmake/toolchains/ifx/xmake.lua35
10 files changed, 573 insertions, 22 deletions
diff --git a/xmake/modules/detect/sdks/find_ifxenv.lua b/xmake/modules/detect/sdks/find_ifxenv.lua
new file mode 100644
index 000000000..2c327b70b
--- /dev/null
+++ b/xmake/modules/detect/sdks/find_ifxenv.lua
@@ -0,0 +1,145 @@
+--!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 find_ifxenv.lua
+--
+
+-- imports
+import("lib.detect.find_file")
+import("lib.detect.find_tool")
+
+-- init ifx variables
+local ifxvars = {"path",
+ "lib",
+ "libpath",
+ "include",
+ "DevEnvdir",
+ "VSInstallDir",
+ "VCInstallDir",
+ "WindowsSdkDir",
+ "WindowsLibPath",
+ "WindowsSDKVersion",
+ "WindowsSdkBinPath",
+ "UniversalCRTSdkDir",
+ "UCRTVersion"}
+
+-- load ifxvars_bat environment variables
+function _load_ifxvars(ifxvars_bat, arch, opt)
+
+ -- make the genifxvars.bat
+ opt = opt or {}
+ local genifxvars_bat = os.tmpfile() .. "_genifxvars.bat"
+ local genifxvars_dat = os.tmpfile() .. "_genifxvars.txt"
+ local file = io.open(genifxvars_bat, "w")
+ file:print("@echo off")
+ file:print("call \"%s\" -arch %s > nul", ifxvars_bat, arch)
+ for idx, var in ipairs(ifxvars) do
+ file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genifxvars_dat)
+ end
+ file:close()
+
+ -- run genifxvars.bat
+ os.run(genifxvars_bat)
+
+ -- load all envirnoment variables
+ local variables = {}
+ for _, line in ipairs((io.readfile(genifxvars_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(ifxvars) 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 llvm c/c++ envirnoment on windows
+function _find_intel_on_windows(opt)
+ opt = opt or {}
+
+ -- find ifxvars_bat.bat
+ local paths = {"$(env ONEAPI_ROOT)"}
+ local ifxvars_bat = find_file("setvars.bat", paths)
+ if not ifxvars_bat then
+ paths = {}
+ local keys = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Intel\\DPCPPSuites\\**\\DPC++")
+ for _, key in ipairs(keys) do
+ table.insert(paths, format("$(reg %s;ProductDir)", key))
+ end
+ ifxvars_bat = find_file("../../setvars.bat", paths)
+ end
+ if ifxvars_bat then
+ local ifxvars_x86 = _load_ifxvars(ifxvars_bat, "ia32", opt)
+ local ifxvars_x64 = _load_ifxvars(ifxvars_bat, "intel64", opt)
+ return {ifxvars_bat = ifxvars_bat, ifxvars = {x86 = ifxvars_x86, x64 = ifxvars_x64}}
+ end
+end
+
+-- find intel llvm c/c++ envirnoment on linux
+function _find_intel_on_linux(opt)
+
+ -- attempt to find the sdk directory
+ local oneapi_rootdirs = {"~/intel/oneapi/compiler", "/opt/intel/oneapi/compiler"}
+ paths = {}
+ for _, rootdir in ipairs(oneapi_rootdirs) do
+ table.insert(paths, path.join(rootdir, "*", is_host("macosx") and "mac" or "linux", "bin"))
+ table.insert(paths, path.join(rootdir, "*", "bin"))
+ end
+ if #paths > 0 then
+ local ifx = find_file("ifx", paths)
+ if ifx then
+ local bindir = path.directory(ifx)
+ local sdkdir = path.directory(path.directory(bindir))
+ return {sdkdir = sdkdir, bindir = bindir}
+ end
+ end
+end
+
+-- find intel c/c++ 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_icx.lua b/xmake/modules/detect/tools/find_icx.lua
index 1d70a2967..bafc15c23 100644
--- a/xmake/modules/detect/tools/find_icx.lua
+++ b/xmake/modules/detect/tools/find_icx.lua
@@ -15,14 +15,14 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki
--- @file find_icc.lua
+-- @file find_icx.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
--- find icc
+-- find icx
--
-- @param opt the argument options, e.g. {version = true}
--
@@ -30,20 +30,14 @@ import("lib.detect.find_programver")
--
-- @code
--
--- local icc = find_icc()
--- local icc, version, hintname = find_icc({program = "icc", version = true})
+-- local icx = find_icx()
+-- local icx, version, hintname = find_icx({program = "icx", version = true})
--
-- @endcode
--
function main(opt)
-
- -- init options
opt = opt or {}
-
- -- find program
local program = find_program(opt.program or "icx", opt)
-
- -- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
diff --git a/xmake/modules/detect/tools/find_ifx.lua b/xmake/modules/detect/tools/find_ifx.lua
new file mode 100644
index 000000000..a59a02927
--- /dev/null
+++ b/xmake/modules/detect/tools/find_ifx.lua
@@ -0,0 +1,46 @@
+--!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 find_ifx.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find ifx
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local ifx = find_ifx()
+-- local ifx, version, hintname = find_ifx({program = "ifx", version = true})
+--
+-- @endcode
+--
+function main(opt)
+ opt = opt or {}
+ local program = find_program(opt.program or "icx", opt)
+ 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/ifx/has_flags.lua b/xmake/modules/detect/tools/ifx/has_flags.lua
new file mode 100644
index 000000000..d8c6f2792
--- /dev/null
+++ b/xmake/modules/detect/tools/ifx/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.clang.has_flags")
+
diff --git a/xmake/toolchains/icc/check.lua b/xmake/toolchains/icc/check.lua
index 9ca496a63..ece7f1292 100644
--- a/xmake/toolchains/icc/check.lua
+++ b/xmake/toolchains/icc/check.lua
@@ -89,7 +89,7 @@ end
-- check the visual studio
function _check_vstudio(toolchain)
- local vs, cl = _check_vsenv(toolchain)
+ local vs = _check_vsenv(toolchain)
if vs then
if toolchain:is_global() then
config.set("vs", vs, {force = true, readonly = true})
@@ -97,9 +97,6 @@ function _check_vstudio(toolchain)
toolchain:config_set("vs", vs)
toolchain:configs_save()
cprint("checking for Microsoft Visual Studio (%s) version ... ${color.success}%s", toolchain:arch(), vs)
- if cl and cl.version then
- cprint("checking for LLVM Clang C/C++ Compiler (%s) version ... ${color.success}%s", toolchain:arch(), cl.version)
- end
else
cprint("checking for Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", toolchain:arch())
end
diff --git a/xmake/toolchains/icx/check.lua b/xmake/toolchains/icx/check.lua
index c65e3ff81..30afed6f6 100644
--- a/xmake/toolchains/icx/check.lua
+++ b/xmake/toolchains/icx/check.lua
@@ -89,7 +89,7 @@ end
-- check the visual studio
function _check_vstudio(toolchain)
- local vs, cl = _check_vsenv(toolchain)
+ local vs = _check_vsenv(toolchain)
if vs then
if toolchain:is_global() then
config.set("vs", vs, {force = true, readonly = true})
@@ -97,9 +97,6 @@ function _check_vstudio(toolchain)
toolchain:config_set("vs", vs)
toolchain:configs_save()
cprint("checking for Microsoft Visual Studio (%s) version ... ${color.success}%s", toolchain:arch(), vs)
- if cl and cl.version then
- cprint("checking for LLVM Clang C/C++ Compiler (%s) version ... ${color.success}%s", toolchain:arch(), cl.version)
- end
else
cprint("checking for Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", toolchain:arch())
end
diff --git a/xmake/toolchains/ifort/check.lua b/xmake/toolchains/ifort/check.lua
index 8ba2a3881..2c8b52c5b 100644
--- a/xmake/toolchains/ifort/check.lua
+++ b/xmake/toolchains/ifort/check.lua
@@ -89,7 +89,7 @@ end
-- check the visual studio
function _check_vstudio(toolchain)
- local vs, cl = _check_vsenv(toolchain)
+ local vs = _check_vsenv(toolchain)
if vs then
if toolchain:is_global() then
config.set("vs", vs, {force = true, readonly = true})
@@ -97,9 +97,6 @@ function _check_vstudio(toolchain)
toolchain:config_set("vs", vs)
toolchain:configs_save()
cprint("checking for Microsoft Visual Studio (%s) version ... ${color.success}%s", toolchain:arch(), vs)
- if cl and cl.version then
- cprint("checking for LLVM Clang C/C++ Compiler (%s) version ... ${color.success}%s", toolchain:arch(), cl.version)
- end
else
cprint("checking for Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", toolchain:arch())
end
diff --git a/xmake/toolchains/ifx/check.lua b/xmake/toolchains/ifx/check.lua
new file mode 100644
index 000000000..e4bed2706
--- /dev/null
+++ b/xmake/toolchains/ifx/check.lua
@@ -0,0 +1,161 @@
+--!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-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("detect.sdks.find_ifxenv")
+import("detect.sdks.find_vstudio")
+import("lib.detect.find_tool")
+
+-- attempt to check vs environment
+function _check_vsenv(toolchain)
+
+ -- has been checked?
+ local vs = toolchain:config("vs") or config.get("vs")
+ if vs then
+ vs = tostring(vs)
+ end
+ local vcvars = toolchain:config("vcvars")
+ if vs and vcvars then
+ return vs
+ end
+
+ -- find vstudio
+ local vs_toolset = toolchain:config("vs_toolset") or config.get("vs_toolset")
+ local vs_sdkver = toolchain:config("vs_sdkver") or config.get("vs_sdkver")
+ local vstudio = find_vstudio({vcvars_ver = vs_toolset, sdkver = vs_sdkver})
+ if vstudio then
+
+ -- make order vsver
+ local vsvers = {}
+ for vsver, _ in pairs(vstudio) do
+ if not vs or vs ~= vsver then
+ table.insert(vsvers, vsver)
+ end
+ end
+ table.sort(vsvers, function (a, b) return tonumber(a) > tonumber(b) end)
+ if vs then
+ table.insert(vsvers, 1, vs)
+ end
+
+ -- get vcvarsall
+ for _, vsver in ipairs(vsvers) do
+ local vcvarsall = (vstudio[vsver] or {}).vcvarsall or {}
+ local vcvars = vcvarsall[toolchain:arch()]
+ if vcvars and vcvars.PATH and vcvars.INCLUDE and vcvars.LIB then
+
+ -- save vcvars
+ toolchain:config_set("vcvars", vcvars)
+ toolchain:config_set("vcarchs", table.orderkeys(vcvarsall))
+ toolchain:config_set("vs_toolset", vcvars.VCToolsVersion)
+ toolchain:config_set("vs_sdkver", vcvars.WindowsSDKVersion)
+
+ -- check compiler
+ local program
+ local paths
+ local pathenv = os.getenv("PATH")
+ if pathenv then
+ paths = path.splitenv(pathenv)
+ end
+ local tool = find_tool("cl.exe", {version = true, force = true, paths = paths, envs = vcvars})
+ if tool then
+ program = tool.program
+ end
+ if program then
+ return vsver, tool
+ end
+ end
+ end
+ end
+end
+
+-- check the visual studio
+function _check_vstudio(toolchain)
+ local vs = _check_vsenv(toolchain)
+ if vs then
+ if toolchain:is_global() then
+ config.set("vs", vs, {force = true, readonly = true})
+ end
+ toolchain:config_set("vs", vs)
+ toolchain:configs_save()
+ cprint("checking for Microsoft Visual Studio (%s) version ... ${color.success}%s", toolchain:arch(), vs)
+ else
+ cprint("checking for Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", toolchain:arch())
+ end
+ return vs
+end
+
+-- check intel on windows
+function _check_intel_on_windows(toolchain)
+
+ -- have been checked?
+ local varsall = toolchain:config("varsall")
+ if varsall then
+ return true
+ end
+
+ -- find intel llvm c/c++ compiler environment
+ local ifxenv = find_ifxenv()
+ if ifxenv and ifxenv.ifxvars then
+ local ifxvarsall = ifxenv.ifxvars
+ local ifxenv = ifxvarsall[toolchain:arch()]
+ if ifxenv and ifxenv.PATH and ifxenv.INCLUDE and ifxenv.LIB then
+ local tool = find_tool("ifx.exe", {force = true, envs = ifxenv, version = true})
+ if tool then
+ cprint("checking for Intel LLVM Fortran Compiler (%s) ... ${color.success}${text.success}", toolchain:arch())
+ toolchain:config_set("varsall", ifxvarsall)
+ toolchain:configs_save()
+ return _check_vstudio(toolchain)
+ end
+ end
+ end
+end
+
+-- check intel on linux
+function _check_intel_on_linux(toolchain)
+ local ifxenv = toolchain:config("ifxenv")
+ if ifxenv then
+ return true
+ end
+ ifxenv = find_ifxenv()
+ if ifxenv then
+ local ldname = is_host("macosx") and "DYLD_LIBRARY_PATH" or "LD_LIBRARY_PATH"
+ local tool = find_tool("ifx", {force = true, envs = {[ldname] = ifxenv.libdir}, paths = ifxenv.bindir})
+ if tool then
+ cprint("checking for Intel Fortran Compiler (%s) ... ${color.success}${text.success}", toolchain:arch())
+ toolchain:config_set("ifxenv", ifxenv)
+ toolchain:config_set("bindir", ifxenv.bindir)
+ toolchain:configs_save()
+ return true
+ end
+ return true
+ end
+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/ifx/load.lua b/xmake/toolchains/ifx/load.lua
new file mode 100644
index 000000000..90fc7910c
--- /dev/null
+++ b/xmake/toolchains/ifx/load.lua
@@ -0,0 +1,156 @@
+--!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-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("detect.sdks.find_vstudio")
+
+-- add the given vs environment
+function _add_vsenv(toolchain, name, curenvs)
+
+ -- get vcvars
+ local vcvars = toolchain:config("vcvars")
+ if not vcvars then
+ return
+ end
+
+ -- get the paths for the vs environment
+ local new = vcvars[name]
+ if new then
+ -- fix case naming conflict for cmake/msbuild between the new msvc envs and current environment, if we are running xmake in vs prompt.
+ -- @see https://github.com/xmake-io/xmake/issues/4751
+ for k, c in pairs(curenvs) do
+ if name:lower() == k:lower() and name ~= k then
+ name = k
+ break
+ end
+ end
+ toolchain:add("runenvs", name, table.unpack(path.splitenv(new)))
+ end
+end
+
+-- add the given ifx environment
+function _add_ifxenv(toolchain, name, curenvs)
+
+ -- get ifxvarsall
+ local ifxvarsall = toolchain:config("varsall")
+ if not ifxvarsall then
+ return
+ end
+
+ -- get ifx environment for the current arch
+ local arch = toolchain:arch()
+ local ifxenv = ifxvarsall[arch] or {}
+
+ -- get the paths for the ifx environment
+ local new = ifxenv[name]
+ if new then
+ -- fix case naming conflict for cmake/msbuild between the new msvc envs and current environment, if we are running xmake in vs prompt.
+ -- @see https://github.com/xmake-io/xmake/issues/4751
+ for k, c in pairs(curenvs) do
+ if name:lower() == k:lower() and name ~= k then
+ name = k
+ break
+ end
+ end
+ toolchain:add("runenvs", name, table.unpack(path.splitenv(new)))
+ end
+end
+
+-- load intel on windows
+function _load_intel_on_windows(toolchain)
+
+ -- set toolset
+ if toolchain:is_plat("windows") then
+ toolchain:set("toolset", "cc", "ifx.exe")
+ toolchain:set("toolset", "cxx", "ifx.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")
+ else
+ toolchain:set("toolset", "cc", "ifx")
+ toolchain:set("toolset", "cxx", "icpx", "ifx")
+ toolchain:set("toolset", "ld", "icpx", "ifx")
+ toolchain:set("toolset", "sh", "icpx", "ifx")
+ toolchain:set("toolset", "ar", "ar")
+ toolchain:set("toolset", "strip", "strip")
+ toolchain:set("toolset", "as", "ifx")
+ end
+
+ -- add vs/ifx environments
+ local expect_vars = {"PATH", "LIB", "INCLUDE", "LIBPATH"}
+ local curenvs = os.getenvs()
+ for _, name in ipairs(expect_vars) do
+ _add_vsenv(toolchain, name, curenvs)
+ _add_ifxenv(toolchain, name, curenvs)
+ end
+ for _, name in ipairs(find_vstudio.get_vcvars()) do
+ if not table.contains(expect_vars, name:upper()) then
+ _add_vsenv(toolchain, name, curenvs)
+ end
+ end
+end
+
+-- load intel on linux
+function _load_intel_on_linux(toolchain)
+
+ -- set toolset
+ toolchain:set("toolset", "fc", "ifx")
+ toolchain:set("toolset", "fcld", "ifx")
+ toolchain:set("toolset", "fcsh", "ifx")
+ toolchain:set("toolset", "ar", "ar")
+
+ -- 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
+
+ -- get ifx environments
+ local ifxenv = toolchain:config("ifxenv")
+ if ifxenv then
+ local ldname = is_host("macosx") and "DYLD_LIBRARY_PATH" or "LD_LIBRARY_PATH"
+ toolchain:add("runenvs", ldname, ifxenv.libdir)
+ 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/ifx/xmake.lua b/xmake/toolchains/ifx/xmake.lua
new file mode 100644
index 000000000..d853d2b9c
--- /dev/null
+++ b/xmake/toolchains/ifx/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-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define toolchain
+toolchain("icx")
+
+ -- set homepage
+ set_homepage("https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html")
+ set_description("Intel LLVM C/C++ Compiler")
+
+ -- mark as standalone toolchain
+ set_kind("standalone")
+
+ -- check toolchain
+ on_check("check")
+
+ -- on load
+ on_load("load")