From 4eeaaaa589f2fff682bf56fa32489a5aedcb6463 Mon Sep 17 00:00:00 2001 From: 小鸡快跑 <2283572185@qq.com> Date: Mon, 12 Aug 2024 17:52:02 +0800 Subject: fix(plugin/project): Generate compile_commands for tests 1. Implement the get_tests_table as a function 2. Generate compile_commands for tests --- xmake/plugins/project/clang/compile_commands.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'xmake/plugins') diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 059173c45..45ef1c4fe 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -28,6 +28,7 @@ import("private.utils.batchcmds") import("private.utils.executable_path") import("private.utils.rule_groups") import("plugins.project.utils.target_cmds", {rootdir = os.programdir()}) +import("actions.test.main", {rootdir = os.programdir(), alias = "test_action"}) -- escape path function _escape_path(p) @@ -288,11 +289,19 @@ end function _add_targets(jsonfile) jsonfile:print("[") _g.firstline = true + for _, target in pairs(project.targets()) do if not target:is_phony() then _add_target(jsonfile, target) end end + -- https://github.com/xmake-io/xmake/issues/4750 + for _, test in pairs(test_action.get_tests_table()) do + local target = test.target + if not target:is_phony() then + _add_target(jsonfile, target) + end + end jsonfile:print("]") end -- cgit v1.3.1