Files
brave-core/docs/gni_sources.md
T
2024-08-28 17:13:26 +02:00

1.4 KiB

Use of sources.gni should be limited to sources that would otherwise have circular dependencies that cannot be easily resolved, in other cases files should be added a new or existing BUILD.gn targets. The chromium ios code is a good model for separating out dependencies and sometimes makes use of interface/implementation patterns. A good example in desktop/android code is //chrome/browser/profiles target https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/profiles/BUILD.gn;l=8 which has a minimal set of dependencies and the bulk of the implementation that would likely trigger a lot of circular deps is in profile_impl.cc in the //chrome/browser target. This reduces the number of sources/targets that either depend on //chrome/browser or have to be added to //chrome/browser sources list. Other strategies used to break //chrome dependencies in components can also sometimes be applied to //brave/browser code to avoid circular dependencies https://www.chromium.org/developers/design-documents/cookbook/#dependency-inversion. Do not use check_includes = false.

This does not mean that you cannot use sources.gni to inject sources into existing targets, but please try to avoid it when practical.