From 0eed2ba2e4918499a11519c30c079ad3d7a2feaa Mon Sep 17 00:00:00 2001 From: Chanchan Date: Thu, 5 Jan 2023 19:46:15 +0800 Subject: [PATCH] feat : xmake add valgrind --- test/xmake.lua | 8 ++++++++ xmake.lua | 1 + 2 files changed, 9 insertions(+) diff --git a/test/xmake.lua b/test/xmake.lua index 8f57f4bb..aa8d97d0 100644 --- a/test/xmake.lua +++ b/test/xmake.lua @@ -33,4 +33,12 @@ for _, test in ipairs(all_tests()) do target(test[1]) set_kind("binary") add_files(test[2]) + if has_config("memcheck") then + on_run(function (target) + local argv = {} + table.insert(argv, target:targetfile()) + table.insert(argv, "--leak-check=full") + os.execv("valgrind", argv) + end) + end end diff --git a/xmake.lua b/xmake.lua index 598d33b1..578d92b8 100644 --- a/xmake.lua +++ b/xmake.lua @@ -8,6 +8,7 @@ option("consul", {description = "build consul component", default = true} option("mysql", {description = "build mysql component", default = true}) option("redis", {description = "build redis component", default = true}) option("upstream", {description = "build upstream component", default = true}) +option("memcheck", {description = "valgrind memcheck", default = false}) add_rules("mode.release", "mode.debug") set_languages("c90", "c++11")