blob: ec74c0202a4eb98da47fea01be050c842ee5be53 [file] [log] [blame] [view]
Primiano Tuccib8083732018-04-09 15:38:37 +01001# Perfetto build instructions
Primiano Tucci8f266ad2018-01-15 16:52:38 +00002
Primiano Tuccib8083732018-04-09 15:38:37 +01003The source of truth for the Perfetto codebase currently lives in AOSP:
4https://android.googlesource.com/platform/external/perfetto/
5
6Perfetto can be built both from the Android tree (AOSP) and standalone.
7Standalone builds are meant only for local testing and are not shipped.
Primiano Tucci8f266ad2018-01-15 16:52:38 +00008Due to the reduced dependencies they are faster to iterate on and the
9suggested way to work on Perfetto.
10
Primiano Tucci8f266ad2018-01-15 16:52:38 +000011Get the code
12------------
Primiano Tuccib8083732018-04-09 15:38:37 +010013**Standalone checkout**:
Primiano Tucci8f266ad2018-01-15 16:52:38 +000014```
Primiano Tuccib8083732018-04-09 15:38:37 +010015$ git clone https://android.googlesource.com/platform/external/perfetto/
Primiano Tucci8f266ad2018-01-15 16:52:38 +000016```
17
Primiano Tuccib8083732018-04-09 15:38:37 +010018**Android tree**:
19Perfetto lives in `external/perfetto` in the AOSP tree.
20
21
22Prerequisites
23-------------
24**Standalone checkout**:
25All dependent libraries are self-hosted and pulled through:
26```
Hector Dearman4763d922018-05-23 10:12:03 +010027$ tools/install-build-deps [--no-android] [--ui]
Primiano Tuccib8083732018-04-09 15:38:37 +010028```
29
30**Android tree**:
31See https://source.android.com/setup
32
33
34Building
35--------
36**Standalone checkout**:
Primiano Tucci8f266ad2018-01-15 16:52:38 +000037If you are a chromium developer and have depot_tools installed you can avoid
38the `tools/` prefix below and just use gn/ninja from depot_tools.
39
Primiano Tucci8f266ad2018-01-15 16:52:38 +000040`$ tools/gn args out/android` to generate build files and enter in the editor:
41
42```
Primiano Tuccib8083732018-04-09 15:38:37 +010043target_os = "android" # Only when building for Android
44target_cpu = "arm" / "arm64" / "x64" # Only when building for Android
45is_debug = true / false
Primiano Tucci8f266ad2018-01-15 16:52:38 +000046```
47
48(See the [Build Configurations](#build-configurations) section below for more)
49
50```
Primiano Tuccib8083732018-04-09 15:38:37 +010051$ tools/ninja -C out/android
Primiano Tucci8f266ad2018-01-15 16:52:38 +000052```
53
Hector Dearman4763d922018-05-23 10:12:03 +010054To build the UI (remember to run `tools/install-build-deps --ui` first):
55
56```
57$ tools/ninja -C out/android ui
58```
59
Primiano Tuccib8083732018-04-09 15:38:37 +010060**Android tree**:
Primiano Tucci8f266ad2018-01-15 16:52:38 +000061`$ mmma external/perfetto`
62or
Primiano Tuccib8083732018-04-09 15:38:37 +010063`$ m perfetto traced traced_probes`
Primiano Tucci8f266ad2018-01-15 16:52:38 +000064
65This will generate artifacts `out/target/product/XXX/system/`.
66Executables and shared libraries are stripped by default by the Android build
Primiano Tuccib8083732018-04-09 15:38:37 +010067system. The unstripped artifacts are kept into `out/target/product/XXX/symbols`.
Primiano Tucci8f266ad2018-01-15 16:52:38 +000068
Primiano Tuccib8083732018-04-09 15:38:37 +010069Build files
70-----------
Primiano Tucci8f266ad2018-01-15 16:52:38 +000071The source of truth of our build file is in the BUILD.gn files, which are based on [GN][gn-quickstart].
72The Android build file ([Android.bp](../Android.bp)) is autogenerated from the GN files
73through `tools/gen_android_bp`, which needs to be invoked whenever a change
Primiano Tuccib8083732018-04-09 15:38:37 +010074touches GN files or introduces new ones.
Primiano Tucci8f266ad2018-01-15 16:52:38 +000075A presubmit check checks that the Android.bp is consistent with GN files when
Primiano Tuccib8083732018-04-09 15:38:37 +010076submitting a CL through `git cl upload`.
Primiano Tucci8f266ad2018-01-15 16:52:38 +000077The generator has a whitelist of root targets that will be translated into the
78Android.bp file. If you are adding a new target, add a new entry to the
79`default_targets` variable inside [tools/gen_android_bp](../tools/gen_android_bp).
80
81
Primiano Tuccib8083732018-04-09 15:38:37 +010082Supported platforms
83-------------------
84**Linux desktop** (Debian Rodete):
85 - Hermetic clang + libcxx toolchain (both following chromium's revisions)
86 - GCC-7 and libstdc++ 6
87
88**Android**:
89 - Android's NDK r15c (using NDK's libcxx)
90 - AOSP's in-tree clang (using in-tree libcxx)
91
92**Mac**:
93 - XCode 9 / clang (currently maintained best-effort).
94
95
96
97Build configurations
98--------------------
99*** aside
100`tools/build_all_configs.py` can be used to generate out/XXX folders for most of
101the supported configurations.
102***
103
Primiano Tucci8f266ad2018-01-15 16:52:38 +0000104The following [GN args][gn-quickstart] are supported:
105
106`target_os = "android" | "linux" | "mac"`:
107Defaults to the current host, set "android" to build for Android.
108
109`target_cpu = "arm" | "arm64" | "x86" | "x64"`:
110Defaults to `"arm"` when `target_os` == `"android"`, `"x64"` when targeting the
111host. 32-bit host builds are not supported.
112
113`is_debug = true | false`:
114Toggles Debug (default) / Release mode.
115
116`is_clang = true | false`:
Primiano Tuccib8083732018-04-09 15:38:37 +0100117Use Clang (default: true) or GCC (false).
118On Linux, by default it uses the self-hosted clang (see `is_hermetic_clang`).
119On Android, by default it uses clang from the NDK (in `buildtools/ndk`).
120On Mac, by default it uses the system version of clang (requires Xcode).
Primiano Tucci8f266ad2018-01-15 16:52:38 +0000121
Florian Mayerea4fcdb2018-01-16 16:56:55 +0000122`is_hermetic_clang = true | false`:
123Use bundled toolchain from `buildtools/` rather than system-wide one.
124
Primiano Tucci8f266ad2018-01-15 16:52:38 +0000125`cc = "gcc" / cxx = "g++"`:
126Uses a different compiler binary (default: autodetected depending on is_clang).
127
128`is_asan = true`:
129Enables [Address Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer)
130
131`is_lsan = true`:
132Enables [Leak Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer)
133(Linux/Mac only)
134
135`is_msan = true`:
136Enables [Memory Sanitizer](https://github.com/google/sanitizers/wiki/MemorySanitizer)
137(Linux only)
138
139`is_tsan = true`:
140Enables [Thread Sanitizer](https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual)
141(Linux/Mac only)
142
143`is_ubsan = true`:
144Enables [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html)
145
146
Tom Bridgwaterc6b2cf82018-08-16 12:49:50 -0700147[gn-quickstart]: https://gn.googlesource.com/gn/+/master/docs/quick_start.md