summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/toolchain/android/BUILD.gn
blob: a611a09f4642b9a7add01207314b2c9d3228dbb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright 2013 The Chromium Authors. All rights reserved.
# 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
}

# The Android clang toolchains share most of the same parameters, so we have this
# wrapper around gcc_toolchain to avoid duplication of logic.
#
# Parameters:
#  - binary_prefix
#      Prefix of compiler executables.
template("android_clang_toolchain") {
  gcc_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

    _android_tool_prefix =
        "$android_toolchain_root/bin/${invoker.binary_prefix}-"

    # The tools should be run relative to the build dir.
    _tool_prefix = rebase_path("$_android_tool_prefix", root_build_dir)

    _prefix = rebase_path("$clang_base_path/bin", root_build_dir)
    cc = "$_prefix/clang"
    cxx = "$_prefix/clang++"
    ar = "$_prefix/llvm-ar"
    ld = cxx
    readelf = _tool_prefix + "readelf"
    nm = "$_prefix/llvm-nm"
    strip = "$_prefix/llvm-strip"
    if (_use_debug_fission) {
      dwp = _tool_prefix + "dwp"
    }
    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"
  }
}

android_clang_toolchain("android_clang_x86") {
  binary_prefix = "i686-linux-android"
  toolchain_args = {
    target_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") {
  binary_prefix = "arm-linux-androideabi"
  toolchain_args = {
    target_cpu = "arm"
  }
}

android_clang_toolchain("android_clang_mipsel") {
  binary_prefix = "mipsel-linux-android"
  toolchain_args = {
    target_cpu = "mipsel"
  }
}

android_clang_toolchain("android_clang_x64") {
  binary_prefix = "x86_64-linux-android"
  toolchain_args = {
    target_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") {
  binary_prefix = "aarch64-linux-android"
  toolchain_args = {
    target_cpu = "arm64"
  }
}

android_clang_toolchain("android_clang_arm64_hwasan") {
  binary_prefix = "aarch64-linux-android"
  toolchain_args = {
    target_cpu = "arm64"
    is_hwasan = true
    android64_ndk_api_level = 29
  }
}

android_clang_toolchain("android_clang_mips64el") {
  binary_prefix = "mips64el-linux-android"
  toolchain_args = {
    target_cpu = "mips64el"
  }
}