From 4560a3458148449eaa959a8a3a62e2c63cfaabba Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 14 Aug 2022 11:09:52 +0800 Subject: remove repeat for compile_commands --- xmake/plugins/project/clang/compile_commands.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.3.1