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 5import("//build/config/android/config.gni") 6import("//build/config/chrome_build.gni") 7import("//build/config/clang/clang.gni") 8import("//build/config/compiler/compiler.gni") 9import("//build/config/ozone.gni") 10import("//build/config/sysroot.gni") # Imports android/config.gni. 11import("//build/toolchain/gcc_toolchain.gni") 12if (build_with_chromium) { 13 import("//third_party/jni_zero/jni_zero.gni") 14} 15 16declare_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 22template("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 53android_clang_toolchain("android_clang_x86") { 54 toolchain_args = { 55 current_cpu = "x86" 56 } 57} 58 59android_clang_toolchain("android_clang_arm") { 60 toolchain_args = { 61 current_cpu = "arm" 62 } 63} 64 65android_clang_toolchain("android_clang_mipsel") { 66 toolchain_args = { 67 current_cpu = "mipsel" 68 } 69} 70 71android_clang_toolchain("android_clang_x64") { 72 toolchain_args = { 73 current_cpu = "x64" 74 } 75} 76 77android_clang_toolchain("android_clang_arm64") { 78 toolchain_args = { 79 current_cpu = "arm64" 80 } 81} 82 83android_clang_toolchain("android_clang_arm64_hwasan") { 84 toolchain_args = { 85 current_cpu = "arm64" 86 is_hwasan = true 87 android64_ndk_api_level = 29 88 } 89} 90 91android_clang_toolchain("android_clang_mips64el") { 92 toolchain_args = { 93 current_cpu = "mips64el" 94 } 95} 96 97# Placeholder for riscv64 support, not tested since the toolchain is not ready. 98android_clang_toolchain("android_clang_riscv64") { 99 toolchain_args = { 100 current_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 113clang_toolchain("robolectric_$host_cpu") { 114 toolchain_args = { 115 current_os = host_os 116 current_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} 130