summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-09 00:53:17 +0800
committerruki <[email protected]>2024-03-09 00:53:17 +0800
commit69874353216f145a5a8c1b06ab71085cb3f2a4a0 (patch)
tree3e87e5e8dae436c5f01e8fb0d1ce170d081aa262
parentbafc5ec6449244f20be126beeca903c99f527f1a (diff)
pass msvc envs to autoconf
-rw-r--r--xmake/modules/package/tools/autoconf.lua11
-rw-r--r--xmake/modules/package/tools/cmake.lua2
2 files changed, 12 insertions, 1 deletions
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index bd1b71bbb..8fdf245b9 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -23,6 +23,7 @@ import("core.base.option")
import("core.project.config")
import("core.tool.linker")
import("core.tool.compiler")
+import("core.tool.toolchain")
import("core.cache.memcache")
import("lib.detect.find_tool")
@@ -56,6 +57,13 @@ function _translate_cygwin_paths(package, paths)
return paths
end
+-- get msvc
+function _get_msvc(package)
+ local msvc = package:toolchain("msvc") or toolchain.load("msvc", {plat = package:plat(), arch = package:arch()})
+ assert(msvc:check(), "vs not found!") -- we need to check vs envs if it has been not checked yet
+ return msvc
+end
+
-- translate windows bin path
function _translate_windows_bin_path(bin_path)
if bin_path then
@@ -375,6 +383,9 @@ function buildenvs(package, opt)
name = name:gsub("gcc%-", "g++-")
envs.CXX = dir and path.join(dir, name) or name
end
+ elseif package:is_plat("windows") and not package:config("toolchains") then
+ envs.PATH = os.getenv("PATH") -- we need to reserve PATH on msys2
+ envs = os.joinenvs(envs, _get_msvc(package):runenvs())
end
if is_host("windows") then
envs.CC = _translate_windows_bin_path(envs.CC)
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index b1ebbbef7..7313bb1ea 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -87,7 +87,7 @@ end
-- get msvc
function _get_msvc(package)
- local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()})
+ local msvc = package:toolchain("msvc") or toolchain.load("msvc", {plat = package:plat(), arch = package:arch()})
assert(msvc:check(), "vs not found!") -- we need to check vs envs if it has been not checked yet
return msvc
end