• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14assert(is_android)
15
16import("abi.gni")
17
18# Get Android Env used to build Android Library.
19ANDROID_HOME = getenv("ANDROID_HOME")
20if (ANDROID_HOME == "") {
21  assert(
22      false,
23      "Maybe you have not set up android development environment." +
24          " Or some environment variable is named differently. Check, please!" +
25          " Get set-up steps from https://gitee.com/ark_standalone_build/docs")
26} else {
27  print("ANDROID_HOME=$ANDROID_HOME")
28}
29
30# Using a separate declare_args block for only these arguments, so that
31# we can decide if we have to pull in definitions from the internal config
32# early.
33declare_args() {
34  # AOSP API level for 64 bits platforms
35  aosp64_ndk_api_level = 29
36}
37
38if (!defined(default_aosp_ndk_root)) {
39  default_aosp_ndk_root = "${ANDROID_HOME}/ndk/21.3.6528147"
40  default_aosp_ndk_major_version = 16
41} else {
42  assert(defined(default_aosp_ndk_major_version))
43}
44
45declare_args() {
46  aosp_ndk_root = default_aosp_ndk_root
47  aosp_ndk_major_version = default_aosp_ndk_major_version
48
49  # Libc++ library directory. Override to use a custom libc++ binary.
50  aosp_libcpp_lib_dir = ""
51}
52
53# Defines the name the AOSP build gives to the current host CPU
54# architecture, which is different than the names GN uses.
55if (host_cpu == "x64") {
56  aosp_host_arch = "x86_64"
57} else if (host_cpu == "x86") {
58  aosp_host_arch = "x86"
59} else {
60  assert(false, "Need AOSP toolchain support for your build CPU arch.")
61}
62
63# Defines the name the aosp build gives to the current host CPU
64# architecture, which is different than the names GN uses.
65if (host_os == "linux") {
66  aosp_host_os = "linux"
67} else if (host_os == "mac") {
68  aosp_host_os = "darwin"
69} else {
70  assert(false, "Need AOSP toolchain support for your build OS.")
71}
72
73# Directories and files
74arm64_aosp_sysroot_subdir =
75    "platforms/android-${aosp64_ndk_api_level}/arch-arm64"
76
77# # Toolchain root directory for each build. The actual binaries are inside
78# # a "bin" directory inside of these.
79_aosp_toolchain_version = "4.9"
80_aosp_toolchain_detailed_version = "4.9.x"
81arm64_aosp_toolchain_root = "$aosp_ndk_root/toolchains/aarch64-linux-android-${_aosp_toolchain_version}/prebuilt/${aosp_host_os}-${aosp_host_arch}"
82
83# Location of libgcc. This is only needed for the current GN toolchain, so we
84# only need to define the current one, rather than one for every platform
85# like the toolchain roots.
86if (current_cpu == "arm64") {
87  aosp_prebuilt_arch = "android-arm64"
88  _binary_prefix = "aarch64-linux-android"
89  aosp_toolchain_root = "$arm64_aosp_toolchain_root"
90  aosp_libgcc_file = "$aosp_toolchain_root/lib/gcc/aarch64-linux-android/${_aosp_toolchain_detailed_version}/libgcc.a"
91}
92
93aosp_libcpp_root = "$aosp_ndk_root/sources/cxx-stl/llvm-libc++"
94if (aosp_libcpp_lib_dir == "") {
95  aosp_libcpp_lib_dir = "${aosp_libcpp_root}/libs/${aosp_app_abi}"
96}
97