summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-26 23:30:55 +0800
committerruki <[email protected]>2024-03-26 23:30:55 +0800
commitf1769ddf69ff053809b37b103a91a37231369994 (patch)
tree6112b1a9720a13cd811d49e3b99dd8f728e3f7ad
parentbef5a46b62937a48bf7f50170584e7dd648420d5 (diff)
add compiler envs to package
-rw-r--r--xmake/core/package/package.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index d1a082890..c3cba4407 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -979,9 +979,29 @@ function _instance:_rawenvs()
local envs = self._RAWENVS
if not envs then
envs = {}
+
+ -- add bin PATH
if self:is_binary() or self:is_plat("windows", "mingw") then -- bin/*.dll for windows
envs.PATH = {"bin"}
end
+
+ -- add compiler runtime library directory to $PATH
+ -- @see https://github.com/xmake-io/xmake-repo/pull/3606
+ if is_host("windows") and self:is_plat("windows", "mingw") then -- bin/*.dll for windows
+ local toolchains = self:toolchains()
+ if not toolchains then
+ local platform_inst = platform.load(self:plat(), self:arch())
+ toolchains = platform_inst:toolchains()
+ for _, toolchain_inst in ipairs(toolchains) do
+ local runenvs = toolchain_inst:runenvs()
+ if runenvs then
+ envs.PATH = envs.PATH or {}
+ table.join2(envs.PATH, runenvs.PATH)
+ end
+ end
+ end
+ end
+
-- add LD_LIBRARY_PATH to load *.so directory
if os.host() ~= "windows" and self:is_plat(os.host()) and self:is_arch(os.arch()) then
envs.LD_LIBRARY_PATH = {"lib"}