Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fold //brave/browser:browser_process GN target into //chrome/browser #8538

Merged
merged 14 commits into from
Apr 23, 2021

Conversation

mariospr
Copy link
Contributor

@mariospr mariospr commented Apr 14, 2021

This implements first step that will make it easier to fix GN deps by allowing
us to get rid of the //brave/browser:browser_process and moving its contents
into //chrome/browser, so that we can more easily work on breaking cycles on
other //brave/browser/* targets once this is in place.

More specifically, this patch implements the following sequence of ideas:

  1. Move contents from //brave/browser:browser_process into //chrome/browser.

  2. Identify logical subsets of sources from Brave's browser_process target and
    move them into separate .gni files with proper dependencies for each of them.

  3. Cleanup the result //brave/browser/sources.gni after that, making sure that
    the dependencies there are the one actually needed by the remaining sources.

Resolves brave/brave-browser#12623

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

@mariospr mariospr self-assigned this Apr 14, 2021
"//brave/components/cosmetic_filters/browser",
"//brave/components/cosmetic_filters/common:mojom",
"//brave/components/crypto_dot_com/browser/buildflags",
"//brave/components/crypto_dot_com/browser",
Copy link
Contributor

@iefremov iefremov Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we add this only if the buildflag is enabled? also, this and similar entries are injected below with `brave_chrome_browser_deps += brave_browser_crypto_dot_com_deps``

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I think you're right, looks like I need to make a few other adjustments here, will adapt + fix other platforms (ios / Mac) and will ping you back. Thanks for the review!

@mariospr mariospr force-pushed the fix-gn-deps-brave_browser_process branch 2 times, most recently from 20193c1 to 43861a7 Compare April 20, 2021 15:55
@bridiver bridiver mentioned this pull request Apr 20, 2021
24 tasks
@mariospr mariospr force-pushed the fix-gn-deps-brave_browser_process branch 4 times, most recently from 4a4ba34 to 2dd065f Compare April 21, 2021 10:55
brave_browser_autocomplete_deps = [
"//base",
"//brave/common",
"//brave/components/brave_webtorrent/browser",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one and "//brave/components/ipfs" should be added conditionally, depending on the buildflags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@mariospr mariospr force-pushed the fix-gn-deps-brave_browser_process branch from 2dd065f to e0d2abe Compare April 21, 2021 11:43
]

brave_browser_autocomplete_deps = [
"//base",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of sources.gni has this dependency, while others are not - I'm guessing we can actually omit it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this particular case it's because of the #include "base/strings/string_util.h" include from brave/browser/autocomplete/brave_autocomplete_scheme_classifier.cc.

As for the inconsistency with other files, I think I might have made a mistake and didn't notice because the gn_check step didn't catch it now that this has been assimilated into the main //chrome/browser target. I'll do another pass over all these new sources.gni file and will add what's missing (vs removing them, as I think it's more interesting, see my comment in #8538 (comment))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done another pass and fix a few missing deps (sorry not having noticed earlier), put the difference as fixup commits on top of this PR to ease review (will squash them before merge).

"//brave/common",
"//brave/components/brave_webtorrent/browser/buildflags",
"//brave/components/ipfs/buildflags",
"//chrome/browser/profiles:profile",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering whether we actually need this one and similar chrome dependencies, given that we inject our sources into the target that has them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's ok to you, I think it's better to keep them because that way it's clearer what exactly a given subset of sources depend on, which IMHO makes it harder for people to forget about adding new deps as needed when adding new files to these sources.gni in the future. WDYT?

@mariospr mariospr force-pushed the fix-gn-deps-brave_browser_process branch 2 times, most recently from 4df80d1 to 7845c76 Compare April 21, 2021 15:10
@mariospr mariospr requested a review from bridiver April 21, 2021 20:14
@mariospr
Copy link
Contributor Author

@tmancey since this has already been reviewed by @simonhong and @iefremov, I'm adding @bridiver to the reviewers list in case he can cover the files you own, so that we can land this asap (as other PRs conflict with it). Hope that's ok!

@mariospr mariospr force-pushed the fix-gn-deps-brave_browser_process branch 2 times, most recently from ee3ddf1 to aacf937 Compare April 22, 2021 16:41
Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This is the very first step towards a clearer way to organize and
state dependencies between targets: for now we just remove this
target and fold everything into //chrome/browser via a massive
dump into browser/sources.gni with no further changes, plus the
necessary adaptations wherever the old target was referenced.

Once this is in place, next steps will extract different subsets
of the sources dumped in there into separate .gni files, so that
it can be more clearly stated which dependencies are actually
related to which subset of source files, instead of having the
giant merge of dependencies we had until now in a single target.

Once those separate .gni files are in place, and each of them
with their own clear set of dependencies, we should be in a much
better position to reorganize things and see what can be moved
around into independent GN targets instead of being part of the
//chrome/browser main target.

Finally, this change also makes the //brave/browser target a group
instead of a source_set and adjust visibility rules in a more
precise way, so that we can still reference //brave/browser from
different places in Brave (vs having to reference //chrome/browser).
List the source files from browser/sources.gni related to
//brave/browser/brave_rewards in a separate sources.gni file,
being explicit on the actual list of dependencies required by
this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/ipfs in a separate sources.gni file, being
explicit on the actual list of dependencies required by this
subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/binance in a separate sources.gni file, being
explicit on the actual list of dependencies required by this
subset of source files.
mariospr added 10 commits April 23, 2021 08:13
List the source files from browser/sources.gni related to
//brave/browser/greaselion in a separate sources.gni file,
being explicit on the actual list of dependencies required
by this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/speedreader in a separate sources.gni file,
being explicit on the actual list of dependencies required
by this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/decentralized_dns in a separate sources.gni file,
being explicit on the actual list of dependencies required by this
subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/crypto_dot_com in a separate sources.gni file,
being explicit on the actual list of dependencies required by
this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/gemini in a separate sources.gni file, being
explicit on the actual list of dependencies required by this
subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/autocomplete in a separate sources.gni file,
being explicit on the actual list of dependencies required
by this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/brave_shields in a separate sources.gni file,
being explicit on the actual list of dependencies required by
this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/component_updater in a separate sources.gni
file, being explicit on the actual list of dependencies
required by this subset of source files.
List the source files from browser/sources.gni related to
//brave/browser/search_engines in a separate sources.gni file,
being explicit on the actual list of dependencies required by
this subset of source files.
Remove imports that are not actually needed and update the list of
dependencies for the sources included directly from this .gni file
so that we're only including what it's needed, and also adding those
dependencies that were missing before.
@mariospr mariospr force-pushed the fix-gn-deps-brave_browser_process branch from aacf937 to 71900a5 Compare April 23, 2021 06:14
@mariospr
Copy link
Contributor Author

Errors are unrelated, so merging. Thank you all for the reviews!

@mariospr mariospr merged commit 343e8cf into master Apr 23, 2021
@mariospr mariospr deleted the fix-gn-deps-brave_browser_process branch April 23, 2021 09:14
@mariospr mariospr added this to the 1.25.x - Nightly milestone Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix deps browser_process target in //brave/browser/
5 participants