diff options
| author | ruki <[email protected]> | 2022-08-17 23:22:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-17 23:22:27 +0800 |
| commit | 437c4ab00991749fb8db108cb2b14f4dff81333c (patch) | |
| tree | 673349a836b68c33a1222effd4318edb0546ff41 | |
| parent | 53049fbbe417b7fa85c773fc7c9bb83d3be1115b (diff) | |
fix compile_comands
| -rw-r--r-- | xmake/plugins/project/clang/compile_commands.lua | 20 | ||||
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 3145b71b6..c94f399a2 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -30,6 +30,17 @@ function _escape_path(p) return os.args(p, {escape = true, nowrap = true}) end +-- this sourcebatch is built? +function _sourcebatch_is_built(sourcebatch) + -- we can only use rulename to filter them because sourcekind may be bound to multiple rules + local rulename = sourcebatch.rulename + if rulename == "c.build" or rulename == "c++.build" + or rulename == "asm.build" or rulename == "cuda.build" + or rulename == "objc.build" or rulename == "objc++.build" then + return true + end +end + -- translate external/system include flags, because some tools (vscode) do not support them yet. -- https://github.com/xmake-io/xmake/issues/1050 function _translate_arguments(arguments) @@ -157,6 +168,11 @@ end -- make commands for object rules function _make_commands_for_objectrules(jsonfile, target, sourcebatch, suffix) + -- we ignore all built sourcebatches + if _sourcebatch_is_built(sourcebatch) then + return + end + -- get rule local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!") local ruleinst = assert(project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename) @@ -197,10 +213,12 @@ function _make_commands_for_objectrules(jsonfile, target, sourcebatch, suffix) end end + + -- make commands for objects function _make_commands_for_objects(jsonfile, target, sourcebatch) local sourcekind = sourcebatch.sourcekind - if sourcekind then + if sourcekind and _sourcebatch_is_built(sourcebatch) then for index, sourcefile in ipairs(sourcebatch.sourcefiles) do local objectfile = sourcebatch.objectfiles[index] local arguments = table.join(compiler.compargv(sourcefile, objectfile, {target = target, sourcekind = sourcekind})) diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 5154956e6..55b3fba01 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -115,7 +115,9 @@ end function _sourcebatch_is_built(sourcebatch) -- we can only use rulename to filter them because sourcekind may be bound to multiple rules local rulename = sourcebatch.rulename - if rulename == "c.build" or rulename == "c++.build" or rulename == "asm.build" or rulename == "cuda.build" then + if rulename == "c.build" or rulename == "c++.build" + or rulename == "asm.build" or rulename == "cuda.build" + or rulename == "objc.build" or rulename == "objc++.build" then return true end end |
