- return false;
-}
-
-// Given a reverse dependency chain where the target chain[0]'s dependent
-// configs don't apply to chain[end], returns the string describing the error.
-// The problematic index is the target where the dependent configs were lost.
-std::string GetDependentConfigChainError(
- const std::vector<const Target*>& chain,
- size_t problematic_index) {
- // Erroneous dependent config chains are always at least three long, since
- // dependent configs would apply if it was length two.
- DCHECK(chain.size() >= 3);
-
- std::string from_label =
- chain[chain.size() - 1]->label().GetUserVisibleName(false);
- std::string to_label =
- chain[0]->label().GetUserVisibleName(false);
- std::string problematic_label =
- chain[problematic_index]->label().GetUserVisibleName(false);
- std::string problematic_upstream_label =
- chain[problematic_index - 1]->label().GetUserVisibleName(false);
-
- return
- "You have the dependency tree: SOURCE -> MID -> DEST\n"
- "Where a file from:\n"
- " SOURCE = " + from_label + "\n"
- "is including a header from:\n"
- " DEST = " + to_label + "\n"
- "\n"
- "DEST has direct_dependent_configs, and they don't apply to SOURCE "
- "because\nSOURCE is more than one hop away. This means that DEST's "
- "headers might not\nreceive the expected compiler flags.\n"
- "\n"
- "To fix this, make SOURCE depend directly on DEST.\n"
- "\n"
- "Alternatively, if the target:\n"
- " MID = " + problematic_label + "\n"
- "exposes DEST as part of its public API, you can declare this by "
- "adding:\n"
- " forward_dependent_configs_from = [\n"
- " \"" + problematic_upstream_label + "\"\n"
- " ]\n"
- "to MID. This will apply DEST's direct dependent configs to SOURCE.\n";