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