summaryrefslogtreecommitdiff
path: root/xmake/toolchains
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-09 09:50:44 +0800
committerGitHub <[email protected]>2021-12-09 09:50:44 +0800
commit3291cacfdbc8667c4a4a32ef83ea79b79dc01e1c (patch)
treebb4ca2392be6194d33faef89969cc8b4c13e8305 /xmake/toolchains
parent10a3e5bc3ac87081d20b978a0a5eada4a6db17fe (diff)
parent74e0376c16f033d1a72a280808f83c9e4aeb4874 (diff)
Merge pull request #1898 from xmake-io/ifort
improve ifort
Diffstat (limited to 'xmake/toolchains')
-rw-r--r--xmake/toolchains/icc/check.lua32
-rw-r--r--xmake/toolchains/icc/load.lua9
-rw-r--r--xmake/toolchains/ifort/check.lua32
-rw-r--r--xmake/toolchains/ifort/load.lua9
4 files changed, 58 insertions, 24 deletions
diff --git a/xmake/toolchains/icc/check.lua b/xmake/toolchains/icc/check.lua
index 3b9c7b953..9dde538f0 100644
--- a/xmake/toolchains/icc/check.lua
+++ b/xmake/toolchains/icc/check.lua
@@ -28,7 +28,8 @@ import("lib.detect.find_tool")
function _check_intel_on_windows(toolchain)
-- have been checked?
- if config.get("__iclvarsall") then
+ local varsall = toolchain:config("varsall")
+ if varsall then
return true
end
@@ -38,18 +39,11 @@ function _check_intel_on_windows(toolchain)
local iclvarsall = iccenv.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())
+ toolchain:config_set("varsall", iclvarsall)
+ toolchain:configs_save()
return true
end
end
@@ -58,7 +52,23 @@ end
-- check intel on linux
function _check_intel_on_linux(toolchain)
- return find_tool("icc")
+ local iccenv = toolchain:config("iccenv")
+ if iccenv then
+ return true
+ end
+ iccenv = find_iccenv()
+ if iccenv then
+ local ldname = is_host("macosx") and "DYLD_LIBRARY_PATH" or "LD_LIBRARY_PATH"
+ local tool = find_tool("icc", {force = true, envs = {[ldname] = iccenv.libdir}, paths = iccenv.bindir})
+ if tool then
+ cprint("checking for Intel C/C++ Compiler (%s) ... ${color.success}${text.success}", toolchain:arch())
+ toolchain:config_set("iccenv", iccenv)
+ toolchain:config_set("bindir", iccenv.bindir)
+ toolchain:configs_save()
+ return true
+ end
+ return true
+ end
end
-- main entry
diff --git a/xmake/toolchains/icc/load.lua b/xmake/toolchains/icc/load.lua
index 5784fc5c8..e1ceba260 100644
--- a/xmake/toolchains/icc/load.lua
+++ b/xmake/toolchains/icc/load.lua
@@ -26,7 +26,7 @@ import("core.project.config")
function _add_iclenv(toolchain, name)
-- get iclvarsall
- local iclvarsall = config.get("__iclvarsall")
+ local iclvarsall = toolchain:config("varsall")
if not iclvarsall then
return
end
@@ -100,6 +100,13 @@ function _load_intel_on_linux(toolchain)
toolchain:add("ldflags", march)
toolchain:add("shflags", march)
end
+
+ -- get icc environments
+ local iccenv = toolchain:config("iccenv")
+ if iccenv then
+ local ldname = is_host("macosx") and "DYLD_LIBRARY_PATH" or "LD_LIBRARY_PATH"
+ toolchain:add("runenvs", ldname, iccenv.libdir)
+ end
end
-- main entry
diff --git a/xmake/toolchains/ifort/check.lua b/xmake/toolchains/ifort/check.lua
index 67d4e3931..285f5c86c 100644
--- a/xmake/toolchains/ifort/check.lua
+++ b/xmake/toolchains/ifort/check.lua
@@ -28,7 +28,8 @@ import("lib.detect.find_tool")
function _check_intel_on_windows(toolchain)
-- have been checked?
- if config.get("__ifortvarsall") then
+ local varsall = toolchain:config("varsall")
+ if varsall then
return true
end
@@ -38,18 +39,11 @@ function _check_intel_on_windows(toolchain)
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())
+ toolchain:config_set("varsall", ifortvarsall)
+ toolchain:configs_save()
return true
end
end
@@ -58,7 +52,23 @@ end
-- check intel on linux
function _check_intel_on_linux(toolchain)
- return find_tool("ifort")
+ local ifortenv = toolchain:config("ifortenv")
+ if ifortenv then
+ return true
+ end
+ ifortenv = find_ifortenv()
+ if ifortenv then
+ local ldname = is_host("macosx") and "DYLD_LIBRARY_PATH" or "LD_LIBRARY_PATH"
+ local tool = find_tool("ifort", {force = true, envs = {[ldname] = ifortenv.libdir}, paths = ifortenv.bindir})
+ if tool then
+ cprint("checking for Intel Fortran Compiler (%s) ... ${color.success}${text.success}", toolchain:arch())
+ toolchain:config_set("ifortenv", ifortenv)
+ toolchain:config_set("bindir", ifortenv.bindir)
+ toolchain:configs_save()
+ return true
+ end
+ return true
+ end
end
-- main entry
diff --git a/xmake/toolchains/ifort/load.lua b/xmake/toolchains/ifort/load.lua
index 804f3a914..2cb212a57 100644
--- a/xmake/toolchains/ifort/load.lua
+++ b/xmake/toolchains/ifort/load.lua
@@ -26,7 +26,7 @@ import("core.project.config")
function _add_ifortenv(toolchain, name)
-- get ifortvarsall
- local ifortvarsall = config.get("__ifortvarsall")
+ local ifortvarsall = toolchain:config("varsall")
if not ifortvarsall then
return
end
@@ -85,6 +85,13 @@ function _load_intel_on_linux(toolchain)
toolchain:add("fcldflags", march)
toolchain:add("fcshflags", march)
end
+
+ -- get ifort environments
+ local ifortenv = toolchain:config("ifortenv")
+ if ifortenv then
+ local ldname = is_host("macosx") and "DYLD_LIBRARY_PATH" or "LD_LIBRARY_PATH"
+ toolchain:add("runenvs", ldname, ifortenv.libdir)
+ end
end
-- main entry