summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-14 11:09:52 +0800
committerruki <[email protected]>2022-08-14 11:09:52 +0800
commit4560a3458148449eaa959a8a3a62e2c63cfaabba (patch)
treecc4a0e797647cca38167e232890cffbd4c97d869
parent63bdc1bfaff58ba837e325574c6aa5a8151c8ba8 (diff)
remove repeat for compile_commands
-rw-r--r--xmake/plugins/project/clang/compile_commands.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua
index 15cbcfeb9..3e00db6f6 100644
--- a/xmake/plugins/project/clang/compile_commands.lua
+++ b/xmake/plugins/project/clang/compile_commands.lua
@@ -111,6 +111,15 @@ function _make_arguments(jsonfile, arguments, sourcefile)
table.insert(arguments_escape, _escape_path(arg))
end
+ -- remove repeat
+ -- this is because some rules will repeatedly bind the same sourcekind, e.g. `rule("c++.build.modules.builder")`
+ local key = hash.uuid(os.args(arguments_escape) .. sourcefile)
+ local map = _g.map or {}
+ _g.map = map
+ if map[key] then
+ return
+ end
+
-- make body
jsonfile:printf(
[[%s{
@@ -121,6 +130,7 @@ function _make_arguments(jsonfile, arguments, sourcefile)
-- clear first line marks
_g.firstline = false
+ map[key] = true
end
-- make commands for target