summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-09 23:13:39 +0800
committerGitHub <[email protected]>2023-09-09 23:13:39 +0800
commita7d1f2636f91ab5758cee05c100ef7803bc9a224 (patch)
tree1573d512b720fb0309cd10a640d587d691518ba1
parent147deb01313f6c6523883a6dd34d771d3df426bb (diff)
Update xmake.lua
-rw-r--r--xmake/rules/mode/xmake.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua
index a230c5fc5..ab1df212a 100644
--- a/xmake/rules/mode/xmake.lua
+++ b/xmake/rules/mode/xmake.lua
@@ -18,8 +18,6 @@
-- @file xmake.lua
--
-import("lib.detect.find_tool")
-
-- define rule: debug mode
rule("mode.debug")
on_config(function (target)
@@ -187,6 +185,7 @@ rule("mode.coverage")
-- define rule: asan mode
rule("mode.asan")
on_config(function (target)
+ import("lib.detect.find_tool")
-- is asan mode now? xmake f -m asan
if is_mode("asan") then
@@ -211,12 +210,15 @@ rule("mode.asan")
target:add("ldflags", "-fsanitize=address")
target:add("shflags", "-fsanitize=address")
- if target:is_plat("windows") and target:kind() == "binary" then
- local envs = target:toolchain("msvc"):runenvs()
- local vscmd_ver = envs["VSCMD_VER"]
- if vscmd_ver and vscmd_ver:startswith("17.7") then
- local cl = assert(find_tool("cl", {envs = envs}), "cl not found!")
- target:add("runenvs", "PATH", path.directory(cl.program))
+ if target:is_plat("windows") and target:is_binary() then
+ local msvc = target:toolchain("msvc")
+ if msvc then
+ local envs = msvc:runenvs()
+ local vscmd_ver = envs and envs.VSCMD_VER
+ if vscmd_ver and vscmd_ver:startswith("17.7") then
+ local cl = assert(find_tool("cl", {envs = envs}), "cl not found!")
+ target:add("runenvs", "PATH", path.directory(cl.program))
+ end
end
end
end