Clarify usage of target_name list in --export-compile-commands Clarify that the list of target_name applies to the 'name' of targets in all build files that are processed by GN. Change-Id: I9a704f95051fdfc791ccbb958918f037aa306932 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/10841 Reviewed-by: Brett Wilson <brettw@chromium.org> Commit-Queue: Aaron Wood <aaronwood@google.com>
diff --git a/docs/reference.md b/docs/reference.md index 68bd12c..06ab5a0 100644 --- a/docs/reference.md +++ b/docs/reference.md
@@ -845,11 +845,18 @@ Produces a compile_commands.json file in the root of the build directory containing an array of “command objects”, where each command object specifies one way a translation unit is compiled in the project. If a list - of target_name is supplied, only targets that are reachable from the list - of target_name will be used for “command objects” generation, otherwise - all available targets will be used. This is used for various Clang-based - tooling, allowing for the replay of individual compilations independent - of the build system. + of target_name is supplied, only targets that are reachable from any + target in any build file whose name is target_name will be used for + “command objects” generation, otherwise all available targets will be used. + This is used for various Clang-based tooling, allowing for the replay of + individual compilations independent of the build system. + e.g. "foo" will match: + - "//path/to/src:foo" + - "//other/path:foo" + - "//foo:foo" + and not match: + - "//foo:bar" + ``` ### <a name="cmd_help"></a>**gn help <anything>**
diff --git a/src/gn/command_gen.cc b/src/gn/command_gen.cc index a014298..7c7fd01 100644 --- a/src/gn/command_gen.cc +++ b/src/gn/command_gen.cc
@@ -488,11 +488,17 @@ Produces a compile_commands.json file in the root of the build directory containing an array of “command objects”, where each command object specifies one way a translation unit is compiled in the project. If a list - of target_name is supplied, only targets that are reachable from the list - of target_name will be used for “command objects” generation, otherwise - all available targets will be used. This is used for various Clang-based - tooling, allowing for the replay of individual compilations independent - of the build system. + of target_name is supplied, only targets that are reachable from any + target in any build file whose name is target_name will be used for + “command objects” generation, otherwise all available targets will be used. + This is used for various Clang-based tooling, allowing for the replay of + individual compilations independent of the build system. + e.g. "foo" will match: + - "//path/to/src:foo" + - "//other/path:foo" + - "//foo:foo" + and not match: + - "//foo:bar" )"; int RunGen(const std::vector<std::string>& args) {