git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:/path/to/depot_tools"
export PATH="$PATH:${HOME}/depot_tools"
mkdir ~/chromium && cd ~/chromium
fetch --nohooks chromium
cd src
./build/install-build-deps.sh
gclient runhooks
gn gen out/Default
autoninja -C out/Default chrome
out/Default/chrome
git checkout master
git checkout -b feature
// hack hack hack
git commit -a -m ''
Here is my workflow for code reviewing:
- upload
- start review
- get feedback
- code, go back to step (1)
- kick off, go back to step (1)
- sync, go back to step (1)
- get
[OWNERS](#owners)
, go back to step (1) - submit using the gerrit UI
git cl format
git cl upload
Address feedback, hack hack hack and go back to the previous step.
Once the feedback is resolve, sync to a more recent point in the codebase.
git checkout master
git pull
git checkout feature
git merge master
gclient sync
Hack hack hack to address build and tests queue, and sync again.
Address owernship approvals:
git cl owners
Often, you run into feedback on code reviews that is worth de-coupling into a separate changelist: things that you'd like to do (i.e. feedback is directionally correct, e.g. refactorings or better test coverage) but don't want to block your submission on (i.e. tactically, you want to de-couple the steps, e.g. your cl is getting big, it blocks other team mates, it blocks manual testing on canaries, etc).
A powerful way you can go about this is to branch from your current branch, and kick off a changelist that starts from where you are working.
It helps to unblock yourself by:
- enabling your cl to the submitted
- being able to work on top of a cl that is still in progress / under review
It helps your reviewer by:
- showing your are serious about addressing their feedback
- showing that it is an orthogonal change
- showing that it can increase substantially your cl size (e.g. it makes it harder to go through the CQ, get approvals and/or )
To start, branch off from your existing branch, say feature-base
, using the vanilla git branch command:
git branch
* master
[*] feature-base
git checkout -b feature-new
hack hack hack and send it for review:
git cl upload
You can go back and forth between branches as your review progresses. Once feature-base
is submitted, you want to merge it into master by pulling from HEAD
.
# move back to master
git checkout master
# pull from upstream
git pull
# pull submodules
gclient sync
Your master should now contain the submitted changelist of feature-base
. Once that's the case, jump into your branch and merge it.
# jump into your branch of a branch
git checkout feature-new
# merge with master
git merge master
# sets upstream to master so that git cl upload doesn't complain
git branch --set-upstream-to=master
# sanity check that your changes seem correct with regards to upstream
git diff origin/master
# upload the rebase
git cl upload
From here, I typically use the CQ in the gerrit UI to submit the CL.
More info here:
Say you were working on two features:
master
|- a
|- b
And it turns out that feature b depends on feature a, which you'd like to turn into:
master
|- a
|- b
You can rebase b into a to accomplish this.
git checkout b
# turn all commits in branch b into a single commit
git reset --soft master
git add -A && git commit -m "squashing"
Now, your branch "b" is ahead of "master" by a single commit, which should make rebasing simpler:
git rebase a
Now, resolve the conflicts between a and b and commit.
To fix gerrit's parent relationship, you want to:
git branch --set-upstream-to=a
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
Sometimes you need to clean your build (e.g. there are generated files that are not relevant anymore).
You can use the following:
gn clean out/Default
autoninja -C out/Default image_diff
third_party/blink/tools/run_web_tests.py -t Default third_party/blink/web_tests/webexposed/global-interface-listing.html
Another example:
third_party/blink/tools/run_web_tests.py -t Default third_party/blink/web_tests/external/wpt/credential-management/fedcm-logout-rps.https.html
Debugging:
https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/web_tests.md
// Run http server
third_party/blink/tools/run_blink_wptserve.py -t Default
Run the local chromium build with the right flags:
{
"label": "run chrome",
"type": "shell",
"command": "${workspaceFolder}/out/current_link/Chromium.app/Contents/MacOS/Chromium",
"args": ["--use-mock-keychain", "--disable-features=DialMediaRouteProvider", "--enable-blink-features=MojoJS,MojoJSTest"]
}
And then load the test:
http://localhost:8081/credential-management/fedcm-logout-rps.https.html