Skip to content

Commit 82532a9

Browse files
committed
improve cosmocc
1 parent e96c315 commit 82532a9

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

xmake/toolchains/cosmocc/check.lua

+15-14
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,25 @@ function main(toolchain)
3333

3434
-- find cross toolchain from external envirnoment
3535
local envs
36-
local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir})
37-
if not cross_toolchain then
38-
-- find it from packages
39-
for _, package in ipairs(toolchain:packages()) do
40-
local installdir = package:installdir()
41-
if installdir and os.isdir(installdir) then
42-
cross_toolchain = find_cross_toolchain(installdir)
43-
if cross_toolchain then
44-
-- we need to bind msys2 shell envirnoments for calling cosmocc,
45-
-- @see https://github.com/xmake-io/xmake/issues/5552
46-
if is_subhost("windows") then
47-
envs = package:envs()
48-
end
49-
break
36+
local cross_toolchain
37+
-- find it from packages first, because we need bind msys2 envirnoments from package.
38+
for _, package in ipairs(toolchain:packages()) do
39+
local installdir = package:installdir()
40+
if installdir and os.isdir(installdir) then
41+
cross_toolchain = find_cross_toolchain(installdir)
42+
if cross_toolchain then
43+
-- we need to bind msys2 shell envirnoments for calling cosmocc,
44+
-- @see https://github.com/xmake-io/xmake/issues/5552
45+
if is_subhost("windows") then
46+
envs = package:envs()
5047
end
48+
break
5149
end
5250
end
5351
end
52+
if not cross_toolchain then
53+
cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir})
54+
end
5455
if not cross_toolchain then
5556
local cosmocc = find_tool("cosmocc", {force = true})
5657
if cosmocc and cosmocc.program then

0 commit comments

Comments
 (0)