BUILD.gn (3845B)
1 # Copyright 2013 The Chromium Authors 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import("//chromium/build/config/android/config.gni") 6 import("//chromium/build/config/chrome_build.gni") 7 import("//chromium/build/config/clang/clang.gni") 8 import("//chromium/build/config/compiler/compiler.gni") 9 import("//chromium/build/config/ozone.gni") 10 import("//chromium/build/config/sysroot.gni") # Imports android/config.gni. 11 import("//chromium/build/toolchain/gcc_toolchain.gni") 12 if (build_with_chromium) { 13 import("//third_party/jni_zero/jni_zero.gni") 14 } 15 16 declare_args() { 17 # Whether unstripped binaries, i.e. compiled with debug symbols, should be 18 # considered runtime_deps rather than stripped ones. 19 android_unstripped_runtime_outputs = true 20 } 21 22 template("android_clang_toolchain") { 23 clang_toolchain(target_name) { 24 assert(defined(invoker.toolchain_args), 25 "toolchain_args must be defined for android_clang_toolchain()") 26 27 toolchain_args = { 28 forward_variables_from(invoker.toolchain_args, "*") 29 current_os = "android" 30 use_debug_fission = false 31 is_high_end_android = is_high_end_android_secondary_toolchain 32 } 33 34 # Output linker map files for binary size analysis. 35 enable_linker_map = true 36 37 strip = rebase_path("$clang_base_path/bin/llvm-strip", root_build_dir) 38 39 use_unstripped_as_runtime_outputs = android_unstripped_runtime_outputs 40 41 # Don't use .cr.so for loadable_modules since they are always loaded via 42 # absolute path. 43 loadable_module_extension = ".so" 44 45 # We propagate configs to allow cross-toolchain JNI include directories to 46 # work. This flag does not otherwise affect our build, but if applied to 47 # non-android toolchains, it causes unwanted configs from perfetto to 48 # propagate from host_toolchain deps. 49 propagates_configs = true 50 } 51 } 52 53 android_clang_toolchain("android_clang_x86") { 54 toolchain_args = { 55 target_cpu = "x86" 56 } 57 } 58 59 android_clang_toolchain("android_clang_arm") { 60 toolchain_args = { 61 target_cpu = "arm" 62 } 63 } 64 65 android_clang_toolchain("android_clang_mipsel") { 66 toolchain_args = { 67 target_cpu = "mipsel" 68 } 69 } 70 71 android_clang_toolchain("android_clang_x64") { 72 toolchain_args = { 73 target_cpu = "x64" 74 } 75 } 76 77 android_clang_toolchain("android_clang_arm64") { 78 toolchain_args = { 79 target_cpu = "arm64" 80 } 81 } 82 83 android_clang_toolchain("android_clang_arm64_hwasan") { 84 toolchain_args = { 85 target_cpu = "arm64" 86 is_hwasan = true 87 android64_ndk_api_level = 29 88 } 89 } 90 91 android_clang_toolchain("android_clang_mips64el") { 92 toolchain_args = { 93 target_cpu = "mips64el" 94 } 95 } 96 97 # Placeholder for riscv64 support, not tested since the toolchain is not ready. 98 android_clang_toolchain("android_clang_riscv64") { 99 toolchain_args = { 100 target_cpu = "riscv64" 101 } 102 } 103 104 # Toolchain for creating native libraries that can be used by 105 # robolectric_binary targets. It does not emulate NDK APIs nor make available 106 # NDK header files. 107 # Targets that opt into defining JNI entrypoints should use the 108 # //third_party/jdk:jdk config to make jni.h available. 109 # This toolchain will set: 110 # is_linux = true 111 # is_android = false 112 # is_robolectric = true 113 clang_toolchain("robolectric_$host_cpu") { 114 toolchain_args = { 115 current_os = host_os 116 target_cpu = host_cpu 117 is_robolectric = true 118 if (build_with_chromium) { 119 # Forwarding this value from the primary toolchain to the secondary 120 # robolectric toolchain, since the default depends on is_component_build 121 # which can be different between primary and robolectric. 122 enable_jni_multiplexing = enable_jni_multiplexing 123 } 124 } 125 126 # TODO(crbug.com/40283271): Figure out why robolectric tests fail with component builds. 127 toolchain_args.is_component_build = false 128 shlib_extension = ".so" 129 }