blob: c938cd6c62faf1cb4c7cfeaaf845ed77f0589d82 [file] [log] [blame] [view]
Primiano Tucci8f266ad2018-01-15 16:52:38 +00001# Perfetto - Build instructions
2
3Perfetto can be built both from the Android tree and standalone.
4Standalone builds are meant only for local testing and are not shipped.
5Due to the reduced dependencies they are faster to iterate on and the
6suggested way to work on Perfetto.
7
8# Prerequisites
9All dependent libraries are self-hosted and pulled by the
10`tools/install-build-deps` script.
11The only requirements on the host are
12python and git:
13
14```
15$ sudo apt-get update && sudo apt-get install git python
16```
17
18
19# Standalone checkout
20
21Get the code
22------------
23```
24$ git clone https://android.googlesource.com/platform/external/perfetto.git
25```
26
27Build
28-----
29If you are a chromium developer and have depot_tools installed you can avoid
30the `tools/` prefix below and just use gn/ninja from depot_tools.
31
32`$ tools/install-build-deps` to install third-party build deps (NDK etc)
33
34`$ tools/gn args out/android` to generate build files and enter in the editor:
35
36```
37target_os = "android" # Leave empty for local testing
38target_cpu = "arm" or "arm64" # Only when building for Android
39```
40
41(See the [Build Configurations](#build-configurations) section below for more)
42
43```
44$ tools/ninja -C out/android all
45```
46
47This will generate artifacts under `out/android`.
48
49
50# Inside the Android tree
51
52Get the code
53------------
54See https://source.android.com/setup/building.
55Perfetto lives in `external/perfetto` in the Android tree.
56
57Build
58-----
59`$ mmma external/perfetto`
60or
61`$ m perfetto traced traced_probes # put other target names here`
62
63This will generate artifacts `out/target/product/XXX/system/`.
64Executables and shared libraries are stripped by default by the Android build
65system. The unstripped versions are kept into `out/target/product/XXX/symbols`.
66
67# GN -> Android.bp generator
68The source of truth of our build file is in the BUILD.gn files, which are based on [GN][gn-quickstart].
69The Android build file ([Android.bp](../Android.bp)) is autogenerated from the GN files
70through `tools/gen_android_bp`, which needs to be invoked whenever a change
71touches GN files or introduces new ones.
72A presubmit check checks that the Android.bp is consistent with GN files when
73submitting a CL through `git cl upload`.
74The generator has a whitelist of root targets that will be translated into the
75Android.bp file. If you are adding a new target, add a new entry to the
76`default_targets` variable inside [tools/gen_android_bp](../tools/gen_android_bp).
77
78
79# Build configurations
80The following [GN args][gn-quickstart] are supported:
81
82`target_os = "android" | "linux" | "mac"`:
83Defaults to the current host, set "android" to build for Android.
84
85`target_cpu = "arm" | "arm64" | "x86" | "x64"`:
86Defaults to `"arm"` when `target_os` == `"android"`, `"x64"` when targeting the
87host. 32-bit host builds are not supported.
88
89`is_debug = true | false`:
90Toggles Debug (default) / Release mode.
91
92`is_clang = true | false`:
93Use Clang (default) / GCC. It requires clang 3.5+ to be installed on the host.
94Clang is the default compiler on Mac (% having installed Xcode).
95On Linux: `sudo apt-get update && sudo apt-get install clang`
96
Florian Mayerea4fcdb2018-01-16 16:56:55 +000097`is_hermetic_clang = true | false`:
98Use bundled toolchain from `buildtools/` rather than system-wide one.
99
Primiano Tucci8f266ad2018-01-15 16:52:38 +0000100`cc = "gcc" / cxx = "g++"`:
101Uses a different compiler binary (default: autodetected depending on is_clang).
102
103`is_asan = true`:
104Enables [Address Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer)
105
106`is_lsan = true`:
107Enables [Leak Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer)
108(Linux/Mac only)
109
110`is_msan = true`:
111Enables [Memory Sanitizer](https://github.com/google/sanitizers/wiki/MemorySanitizer)
112(Linux only)
113
114`is_tsan = true`:
115Enables [Thread Sanitizer](https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual)
116(Linux/Mac only)
117
118`is_ubsan = true`:
119Enables [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html)
120
121
122[gn-quickstart]: https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/quick_start.md