| # Copyright 2013 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/android/config.gni") |
| import("//build/config/clang/clang.gni") |
| import("//build/config/compiler/compiler.gni") |
| import("//build/config/ozone.gni") |
| import("//build/config/sysroot.gni") # Imports android/config.gni. |
| import("//build/toolchain/gcc_toolchain.gni") |
| |
| declare_args() { |
| # Whether unstripped binaries, i.e. compiled with debug symbols, should be |
| # considered runtime_deps rather than stripped ones. |
| android_unstripped_runtime_outputs = true |
| } |
| |
| template("android_clang_toolchain") { |
| clang_toolchain(target_name) { |
| assert(defined(invoker.toolchain_args), |
| "toolchain_args must be defined for android_clang_toolchain()") |
| |
| # Android toolchains need to declare .dwp files as outputs, so need to know |
| # the value of "use_debug_fission" when defining them. |
| # The derived value of "use_debug_fission" varies based on current_os, but |
| # toolchain definitions are evaluated under the default toolchain. |
| # Rather than computing the value under current_os="android", just disable |
| # it if target_os != "android". |
| _use_debug_fission = use_debug_fission && target_os == "android" |
| |
| toolchain_args = { |
| forward_variables_from(invoker.toolchain_args, "*") |
| current_os = "android" |
| use_debug_fission = _use_debug_fission |
| } |
| |
| # Output linker map files for binary size analysis. |
| enable_linker_map = true |
| |
| strip = rebase_path("$clang_base_path/bin/llvm-strip", root_build_dir) |
| if (_use_debug_fission) { |
| # llvm-dwp does not work with thin lto, so use binutils one. |
| # https://crbug.com/1264130 |
| if (toolchain_args.current_cpu == "arm") { |
| _dwp = "arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-dwp" |
| } else if (toolchain_args.current_cpu == "arm64") { |
| _dwp = "aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-dwp" |
| } else if (toolchain_args.current_cpu == "x86") { |
| _dwp = "x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-dwp" |
| } else if (toolchain_args.current_cpu == "x64") { |
| _dwp = "x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-dwp" |
| } else { |
| _dwp = "llvm/prebuilt/linux-x86_64/bin/llvm-dwp" |
| } |
| |
| dwp = rebase_path("$android_ndk_root/toolchains/$_dwp", root_build_dir) |
| } |
| |
| use_unstripped_as_runtime_outputs = android_unstripped_runtime_outputs |
| |
| # Don't use .cr.so for loadable_modules since they are always loaded via |
| # absolute path. |
| loadable_module_extension = ".so" |
| |
| # We propagate configs to allow cross-toolchain JNI include directories to |
| # work. This flag does not otherwise affect our build, but if applied to |
| # non-android toolchains, it causes unwanted configs from perfetto to |
| # propagate from host_toolchain deps. |
| propagates_configs = true |
| } |
| } |
| |
| android_clang_toolchain("android_clang_x86") { |
| toolchain_args = { |
| current_cpu = "x86" |
| |
| # We lack the libclang_rt.profile library for x86 and x86_64, so we cannot |
| # link any binaries that are generated with coverage instrumentation. |
| # Therefore we need to turn off 'use_clang_coverage' for this toolchain. |
| # TODO(crbug.com/865376) |
| use_clang_coverage = false |
| |
| # This turns off all of the LaCrOS-specific flags. A LaCrOS related build |
| # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are |
| # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a |
| # subdirectory, and because chromeos toolchain uses android toolchain, which |
| # eventually resulted in that android toolchains being used inside a LaCrOS |
| # build. |
| also_build_ash_chrome = false |
| also_build_lacros_chrome = false |
| chromeos_is_browser_only = false |
| ozone_platform = "" |
| ozone_platform_wayland = false |
| } |
| } |
| |
| android_clang_toolchain("android_clang_arm") { |
| toolchain_args = { |
| current_cpu = "arm" |
| } |
| } |
| |
| android_clang_toolchain("android_clang_mipsel") { |
| toolchain_args = { |
| current_cpu = "mipsel" |
| } |
| } |
| |
| android_clang_toolchain("android_clang_x64") { |
| toolchain_args = { |
| current_cpu = "x64" |
| |
| # We lack the libclang_rt.profile library for x86 and x86_64, so we cannot |
| # link any binaries that are generated with coverage instrumentation. |
| # Therefore we need to turn off 'use_clang_coverage' for this toolchain. |
| # TODO(crbug.com/865376) |
| use_clang_coverage = false |
| |
| # This turns off all of the LaCrOS-specific flags. A LaCrOS related build |
| # may use |ash_clang_x64| or |lacros_clang_x64| toolchain, which are |
| # chromeos toolchains, to build Ash-Chrome or Lacros-Chrome in a |
| # subdirectory, and because chromeos toolchain uses android toolchain, which |
| # eventually resulted in that android toolchains being used inside a LaCrOS |
| # build. |
| also_build_ash_chrome = false |
| also_build_lacros_chrome = false |
| chromeos_is_browser_only = false |
| ozone_platform = "" |
| ozone_platform_wayland = false |
| } |
| } |
| |
| android_clang_toolchain("android_clang_arm64") { |
| toolchain_args = { |
| current_cpu = "arm64" |
| } |
| } |
| |
| android_clang_toolchain("android_clang_arm64_hwasan") { |
| toolchain_args = { |
| current_cpu = "arm64" |
| is_hwasan = true |
| android64_ndk_api_level = 29 |
| } |
| } |
| |
| android_clang_toolchain("android_clang_mips64el") { |
| toolchain_args = { |
| current_cpu = "mips64el" |
| } |
| } |
| |
| # Toolchain for creating native libraries that can be used by |
| # robolectric_binary targets. It does not emulate NDK APIs nor make available |
| # NDK header files. |
| # Targets that opt into defining JNI entrypoints should use the |
| # //third_party/jdk:jdk config to make jni.h available. |
| # This toolchain will set: |
| # is_linux = true |
| # is_android = false |
| # is_robolectric = true |
| clang_toolchain("robolectric_$host_cpu") { |
| toolchain_args = { |
| current_os = host_os |
| current_cpu = host_cpu |
| is_robolectric = true |
| } |
| } |