diff options
| author | ruki <[email protected]> | 2023-09-11 10:08:35 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-11 10:08:35 +0800 |
| commit | 53383cc8a09235f148b99f45c20c29bcc7873977 (patch) | |
| tree | 84d2115fc6d2ab5a7162d4a8d9b326c2198e2b5d | |
| parent | db6354e9644c4c125b653f802ad121bb7d24d51e (diff) | |
| parent | 26d160af0e6ef9aa303ff70aa13b763a63b3ff97 (diff) | |
Merge pull request #4183 from star-hengxing/asan
improve windows asan program
| -rw-r--r-- | xmake/rules/mode/xmake.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index 2bc812d2e..e2bfc298b 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -185,6 +185,8 @@ rule("mode.coverage") -- define rule: asan mode 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 @@ -208,6 +210,18 @@ 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: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 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 + end + end end end) |
