Skip to content

CGQAQ/Chromium_contributing_tips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chromium_contributing_tips (Ubuntu 22.04)

Chromium C++ Codebase contributing tricks & tips for myself. I'm using ubuntu 22.04 right now, so other OS docs are likely not up-to-date.

This is docs for ubuntu 22.04, for other OS, please refer to macOS.md or Windows.md

Get the code

Prerequisits

  1. Git
  2. Python v3.8+

Install depot_tools ref

mkdir -p ~/code/google/
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ~/code/google/depot_tools
export PATH="${HOME}/code/google/depot_tools:$PATH"

Get the code ref

mkdir -p ~/code/google/chromium && cd ~/code/google/chromium
fetch --nohooks chromium
cd src
./build/install-build-deps.sh
gclient runhooks

Setting up builds

gn gen out/Default

Update your checkout ref

~ git rebase-update
~ gclient sync -Df

Build

Faster build ref

gn args out/Default
enable_nacl=false
symbol_level=1
blink_symbol_level=1
v8_symbol_level=0

Start build ref

autoninja -C out/Default chrome

List targets

gn ls out/Default

Run

out/Default/chrome

Generate compile_commands.json ref

# unix like
tools/clang/scripts/generate_compdb.py -p out/Default > compile_commands.json

# powershell
# NOTE: if failed, please check python version, need python3
python tools/clang/scripts/generate_compdb.py -p out/Default | out-file -encoding utf8 compile_commands.json

Debug

Logging ref

  1. ./out/release/chrome.exe --enable-logging=stderr --v=-1
  2. in code
#include "base/logging.h"
// ...
LOG(ERROR) << "YOUR LOG" << YOUR_VARIABLE ;

StackTrace ref

#include "base/debug/stack_trace.h"
// ...
LOG(ERROR) << "StackTrace: " << base::debug::StackTrace{};

need --disable-gpu-sandbox flag if you are debugging gpu process, --no-sandbox flag if you are debugging one of the renderer processes

Unit tests

run unittests locally ref

  1. find subset
~ gn refs out/Default --testonly=true --type=executable --all chrome/browser/ui/browser_list_unittest.cc
//chrome/test:unit_tests
  1. use it without double slash
~ autoninja.bat -C ./out/Default/ 'third_party/blink/renderer/controller:blink_unittests'
ninja: Entering directory `./out/Default/'
[3/3] LINK blink_unittests.exe blink_unittests.exe.pdb
  1. Run it with gtest_filter for example, run TEST(CSSMathExpressionNode, TestProgressNotationComplex)
~ out/Default/unit_tests --gtest_filter="BrowserListUnitTest.*"

Web Tests

Initial setup ref

autoninja -C out/Default blink_tests

Run Web tests ref

third_party/blink/tools/run_web_tests.py -t Default

Stop skip some tests ref

third_party/blink/web_tests/TestExpectations file contains all the skipped tests, you can remove the line end with [Failure] to run the test.

Run only some tests

Caution: don't add './' to web tests path (like ./third_party/blink/...), instead use third_party/blink/...

# To run only some of the tests, specify their directories or filenames as arguments to run_web_tests.py relative to the web test directory (src/third_party/blink/web_tests). For example, to run the fast form tests, use:
third_party/blink/tools/run_web_tests.py fast/forms
# Or you could use the following shorthand:
third_party/blink/tools/run_web_tests.py fast/fo\*

Run WPT tests ref

third_party/blink/tools/run_wpt_tests.py --target=Default --product=headless_shell external/wpt/html/dom

Rebaseline locally ref

third_party/blink/tools/run_web_tests.py --reset-results foo/bar/test.html

About

Chromium C++ Codebase contributing tricks & tips for myself

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published