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