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 # This turns off all of the LaCrOS-specific flags. A LaCrOS related build 58 # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are 59 # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a 60 # subdirectory, and because chromeos toolchain uses android toolchain, which 61 # eventually resulted in that android toolchains being used inside a LaCrOS 62 # build. 63 also_build_ash_chrome = false 64 also_build_lacros_chrome = false 65 chromeos_is_browser_only = false 66 ozone_platform = "" 67 ozone_platform_wayland = false 68 } 69} 70 71android_clang_toolchain("android_clang_arm") { 72 toolchain_args = { 73 current_cpu = "arm" 74 } 75} 76 77android_clang_toolchain("android_clang_mipsel") { 78 toolchain_args = { 79 current_cpu = "mipsel" 80 } 81} 82 83android_clang_toolchain("android_clang_x64") { 84 toolchain_args = { 85 current_cpu = "x64" 86 87 # This turns off all of the LaCrOS-specific flags. A LaCrOS related build 88 # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are 89 # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a 90 # subdirectory, and because chromeos toolchain uses android toolchain, which 91 # eventually resulted in that android toolchains being used inside a LaCrOS 92 # build. 93 also_build_ash_chrome = false 94 also_build_lacros_chrome = false 95 chromeos_is_browser_only = false 96 ozone_platform = "" 97 ozone_platform_wayland = false 98 } 99} 100 101android_clang_toolchain("android_clang_arm64") { 102 toolchain_args = { 103 current_cpu = "arm64" 104 } 105} 106 107android_clang_toolchain("android_clang_arm64_hwasan") { 108 toolchain_args = { 109 current_cpu = "arm64" 110 is_hwasan = true 111 android64_ndk_api_level = 29 112 } 113} 114 115android_clang_toolchain("android_clang_mips64el") { 116 toolchain_args = { 117 current_cpu = "mips64el" 118 } 119} 120 121# Placeholder for riscv64 support, not tested since the toolchain is not ready. 122android_clang_toolchain("android_clang_riscv64") { 123 toolchain_args = { 124 current_cpu = "riscv64" 125 } 126} 127 128# Toolchain for creating native libraries that can be used by 129# robolectric_binary targets. It does not emulate NDK APIs nor make available 130# NDK header files. 131# Targets that opt into defining JNI entrypoints should use the 132# //third_party/jdk:jdk config to make jni.h available. 133# This toolchain will set: 134# is_linux = true 135# is_android = false 136# is_robolectric = true 137clang_toolchain("robolectric_$host_cpu") { 138 toolchain_args = { 139 current_os = host_os 140 current_cpu = host_cpu 141 is_robolectric = true 142 if (build_with_chromium) { 143 # Forwarding this value from the primary toolchain to the secondary 144 # robolectric toolchain, since the default depends on is_component_build 145 # which can be different between primary and robolectric. 146 enable_jni_multiplexing = enable_jni_multiplexing 147 } 148 } 149 150 # TODO(crbug.com/40283271): Figure out why robolectric tests fail with component builds. 151 toolchain_args.is_component_build = false 152 shlib_extension = ".so" 153} 154