From 98aac22f41b987bb38d4e5f82da86276895b3a93 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sat, 9 Sep 2023 17:35:52 +0800 Subject: improve windows asan program --- xmake/rules/mode/xmake.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index 2bc812d2e..3733805e8 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -208,6 +208,15 @@ rule("mode.asan") target:add("mxflags", "-fsanitize=address") 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(import("lib.detect.find_tool").find_tool("cl", {envs = envs}), "cl not found!") + target:add("runenvs", "PATH", path.directory(cl.program)) + end + end end end) -- cgit v1.3.1 From eb5e31d06f3085bc86925b7ad19e9835458340d7 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sat, 9 Sep 2023 17:44:43 +0800 Subject: fix find_tool --- xmake/rules/mode/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index 3733805e8..790ce011f 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -213,7 +213,7 @@ rule("mode.asan") 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(import("lib.detect.find_tool").find_tool("cl", {envs = envs}), "cl not found!") + local cl = assert(import("lib.detect.find_tool")("cl", {envs = envs}), "cl not found!") target:add("runenvs", "PATH", path.directory(cl.program)) end end -- cgit v1.3.1 From 147deb01313f6c6523883a6dd34d771d3df426bb Mon Sep 17 00:00:00 2001 From: star9029 Date: Sat, 9 Sep 2023 17:48:29 +0800 Subject: improve xmake.lua --- xmake/rules/mode/xmake.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index 790ce011f..a230c5fc5 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -18,6 +18,8 @@ -- @file xmake.lua -- +import("lib.detect.find_tool") + -- define rule: debug mode rule("mode.debug") on_config(function (target) @@ -213,7 +215,7 @@ rule("mode.asan") 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(import("lib.detect.find_tool")("cl", {envs = envs}), "cl not found!") + local cl = assert(find_tool("cl", {envs = envs}), "cl not found!") target:add("runenvs", "PATH", path.directory(cl.program)) end end -- cgit v1.3.1 From a7d1f2636f91ab5758cee05c100ef7803bc9a224 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 9 Sep 2023 23:13:39 +0800 Subject: Update xmake.lua --- xmake/rules/mode/xmake.lua | 18 ++++++++++-------- 1 file 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 -- cgit v1.3.1 From 26d160af0e6ef9aa303ff70aa13b763a63b3ff97 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 10 Sep 2023 19:05:57 +0800 Subject: improve vs asan version --- xmake/rules/mode/xmake.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index ab1df212a..e2bfc298b 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -186,6 +186,7 @@ rule("mode.coverage") rule("mode.asan") on_config(function (target) import("lib.detect.find_tool") + import("core.base.semver") -- is asan mode now? xmake f -m asan if is_mode("asan") then @@ -215,7 +216,7 @@ rule("mode.asan") 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 + if vscmd_ver and semver.match(vscmd_ver):ge("17.7") then local cl = assert(find_tool("cl", {envs = envs}), "cl not found!") target:add("runenvs", "PATH", path.directory(cl.program)) end -- cgit v1.3.1