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") 12 13declare_args() { 14 # Whether unstripped binaries, i.e. compiled with debug symbols, should be 15 # considered runtime_deps rather than stripped ones. 16 android_unstripped_runtime_outputs = true 17} 18 19template("android_clang_toolchain") { 20 clang_toolchain(target_name) { 21 assert(defined(invoker.toolchain_args), 22 "toolchain_args must be defined for android_clang_toolchain()") 23 24 toolchain_args = { 25 forward_variables_from(invoker.toolchain_args, "*") 26 current_os = "android" 27 use_debug_fission = false 28 is_high_end_android = is_high_end_android_secondary_toolchain 29 } 30 31 # Output linker map files for binary size analysis. 32 enable_linker_map = true 33 34 strip = rebase_path("$clang_base_path/bin/llvm-strip", root_build_dir) 35 36 use_unstripped_as_runtime_outputs = android_unstripped_runtime_outputs 37 38 # Don't use .cr.so for loadable_modules since they are always loaded via 39 # absolute path. 40 loadable_module_extension = ".so" 41 42 # We propagate configs to allow cross-toolchain JNI include directories to 43 # work. This flag does not otherwise affect our build, but if applied to 44 # non-android toolchains, it causes unwanted configs from perfetto to 45 # propagate from host_toolchain deps. 46 propagates_configs = true 47 } 48} 49 50android_clang_toolchain("android_clang_x86") { 51 toolchain_args = { 52 current_cpu = "x86" 53 54 # This turns off all of the LaCrOS-specific flags. A LaCrOS related build 55 # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are 56 # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a 57 # subdirectory, and because chromeos toolchain uses android toolchain, which 58 # eventually resulted in that android toolchains being used inside a LaCrOS 59 # build. 60 also_build_ash_chrome = false 61 also_build_lacros_chrome = false 62 chromeos_is_browser_only = false 63 ozone_platform = "" 64 ozone_platform_wayland = false 65 } 66} 67 68android_clang_toolchain("android_clang_arm") { 69 toolchain_args = { 70 current_cpu = "arm" 71 } 72} 73 74android_clang_toolchain("android_clang_mipsel") { 75 toolchain_args = { 76 current_cpu = "mipsel" 77 } 78} 79 80android_clang_toolchain("android_clang_x64") { 81 toolchain_args = { 82 current_cpu = "x64" 83 84 # This turns off all of the LaCrOS-specific flags. A LaCrOS related build 85 # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are 86 # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a 87 # subdirectory, and because chromeos toolchain uses android toolchain, which 88 # eventually resulted in that android toolchains being used inside a LaCrOS 89 # build. 90 also_build_ash_chrome = false 91 also_build_lacros_chrome = false 92 chromeos_is_browser_only = false 93 ozone_platform = "" 94 ozone_platform_wayland = false 95 } 96} 97 98android_clang_toolchain("android_clang_arm64") { 99 toolchain_args = { 100 current_cpu = "arm64" 101 } 102} 103 104android_clang_toolchain("android_clang_arm64_hwasan") { 105 toolchain_args = { 106 current_cpu = "arm64" 107 is_hwasan = true 108 android64_ndk_api_level = 29 109 } 110} 111 112android_clang_toolchain("android_clang_mips64el") { 113 toolchain_args = { 114 current_cpu = "mips64el" 115 } 116} 117 118# Placeholder for riscv64 support, not tested since the toolchain is not ready. 119android_clang_toolchain("android_clang_riscv64") { 120 toolchain_args = { 121 current_cpu = "riscv64" 122 } 123} 124 125# Toolchain for creating native libraries that can be used by 126# robolectric_binary targets. It does not emulate NDK APIs nor make available 127# NDK header files. 128# Targets that opt into defining JNI entrypoints should use the 129# //third_party/jdk:jdk config to make jni.h available. 130# This toolchain will set: 131# is_linux = true 132# is_android = false 133# is_robolectric = true 134clang_toolchain("robolectric_$host_cpu") { 135 toolchain_args = { 136 current_os = host_os 137 current_cpu = host_cpu 138 is_robolectric = true 139 } 140 141 # TODO(crbug.com/1487407): Figure out why robolectric tests fail with component builds. 142 toolchain_args.is_component_build = false 143 shlib_extension = ".so" 144} 145