summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-28 23:14:06 +0800
committerruki <[email protected]>2020-04-28 13:24:37 +0800
commitdf52e7f88a9a572d9bce365a654c83a859f01325 (patch)
tree930cc6a97cf70595a8751f225dcf9a578d36187c
parent1d823deb69ae3909aeb2a81dee96d10977613838 (diff)
add msan and lsan
-rw-r--r--xmake/rules/mode/xmake.lua56
-rw-r--r--xmake/rules/utils/check_targets/check_targets.lua2
2 files changed, 57 insertions, 1 deletions
diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua
index 6dfa4b0f2..5fb0dc0ff 100644
--- a/xmake/rules/mode/xmake.lua
+++ b/xmake/rules/mode/xmake.lua
@@ -173,6 +173,62 @@ rule("mode.tsan")
end
end)
+-- define rule: msan mode
+rule("mode.msan")
+ after_load(function (target)
+
+ -- is msan mode now? xmake f -m msan
+ if is_mode("msan") then
+
+ -- enable the debug symbols
+ if not target:get("symbols") then
+ target:set("symbols", "debug")
+ end
+
+ -- enable optimization
+ if not target:get("optimize") then
+ if is_plat("android", "iphoneos") then
+ target:set("optimize", "smallest")
+ else
+ target:set("optimize", "fastest")
+ end
+ end
+
+ -- enable msan checker
+ target:add("cxflags", "-fsanitize=memory")
+ target:add("mxflags", "-fsanitize=memory")
+ target:add("ldflags", "-fsanitize=memory")
+ end
+ end)
+
+-- define rule: lsan mode
+rule("mode.lsan")
+ after_load(function (target)
+
+ -- is lsan mode now? xmake f -m lsan
+ if is_mode("lsan") then
+
+ -- enable the debug symbols
+ if not target:get("symbols") then
+ target:set("symbols", "debug")
+ end
+
+ -- enable optimization
+ if not target:get("optimize") then
+ if is_plat("android", "iphoneos") then
+ target:set("optimize", "smallest")
+ else
+ target:set("optimize", "fastest")
+ end
+ end
+
+ -- enable lsan checker
+ target:add("cxflags", "-fsanitize=leak")
+ target:add("mxflags", "-fsanitize=leak")
+ target:add("ldflags", "-fsanitize=leak")
+ end
+ end)
+
-- define rule: ubsan mode
rule("mode.ubsan")
after_load(function (target)
diff --git a/xmake/rules/utils/check_targets/check_targets.lua b/xmake/rules/utils/check_targets/check_targets.lua
index 3c9b992fd..fd8373d81 100644
--- a/xmake/rules/utils/check_targets/check_targets.lua
+++ b/xmake/rules/utils/check_targets/check_targets.lua
@@ -54,7 +54,7 @@ function main(target)
for _, value in ipairs(_get_values_from_target(target, name)) do
if not os.isdir(value) then
local sourceinfo = (target:get("__sourceinfo_" .. name) or {})[value] or {}
- cprint("${color.warning}%s(%s).add_%s(\"%s\"): path not found at %s:%d", target:type(), target:name(), name, value, sourceinfo.file or "", sourceinfo.line or -1)
+ cprint("${color.warning}${text.warning}: %s(%s).add_%s(\"%s\") path not found at %s:%d", target:type(), target:name(), name, value, sourceinfo.file or "", sourceinfo.line or -1)
end
end
end