1# Copyright (c) 2022 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. 13declare_args() { 14 ark_standalone_build = true 15 use_musl = true 16 build_root = "//arkcompiler/toolchain/build" 17 run_with_qemu = false 18 so_dir_for_qemu = "common/common/libc" 19 enable_lto_O0 = false 20 disable_force_gc = false 21 timeout = 1200 22} 23 24check_mac_system_and_cpu_script = 25 rebase_path("$build_root/scripts/check_mac_system_and_cpu.py") 26check_darwin_system_result = 27 exec_script(check_mac_system_and_cpu_script, [ "system" ], "string") 28 29if (check_darwin_system_result != "") { 30 check_mac_host_cpu_result = 31 exec_script(check_mac_system_and_cpu_script, [ "cpu" ], "string") 32 if (check_mac_host_cpu_result != "") { 33 host_cpu = "arm64" 34 } 35} 36 37if (host_os == "linux") { 38 if (host_cpu == "arm64") { 39 host_platform_dir = "linux-aarch64" 40 } else { 41 host_platform_dir = "linux-x86_64" 42 } 43} else if (host_os == "mac") { 44 if (host_cpu == "arm64") { 45 host_platform_dir = "darwin-arm64" 46 } else { 47 host_platform_dir = "darwin-x86_64" 48 } 49} else { 50 assert(false, "Unsupported host_os: $host_os") 51} 52 53declare_args() { 54 # Debug build. Enabling official builds automatically sets is_debug to false. 55 is_debug = false 56 is_standard_system = false 57} 58 59declare_args() { 60 # Enable mini debug info, it will add .gnu_debugdata 61 # section in each stripped sofile 62 63 # Currently, we don't publish ohos-adapted python on m1 platform, 64 # So that we disable mini debug info on m1 platform until 65 # ohos-adapted python publishing on m1 platform 66 if (host_os == "mac") { 67 full_mini_debug = false 68 } else { 69 full_mini_debug = true 70 } 71} 72 73declare_args() { 74 host_toolchain = "" 75 custom_toolchain = "" 76 target_toolchain = "" 77 78 is_clang = current_os != "linux" || 79 (current_cpu != "s390x" && current_cpu != "s390" && 80 current_cpu != "ppc64" && current_cpu != "ppc" && 81 current_cpu != "mips" && current_cpu != "mips64") 82 83 target_platform = "phone" 84 85 is_official_build = false 86 87 is_component_build = false 88 89 # build for cross platform 90 is_arkui_x = false 91} 92 93is_wearable_product = "${target_platform}" == "wearable" 94 95is_emulator = false 96 97if (target_os == "ohos" && target_cpu == "x86_64") { 98 is_emulator = true 99} 100 101# Determine host_toolchain. (like a constant in a build on a certain host) 102if (host_toolchain == "") { 103 if (host_os == "linux") { 104 if (target_os != "linux") { 105 host_toolchain = "$build_root/toolchain/linux:clang_$host_cpu" 106 } else if (is_clang) { 107 host_toolchain = "$build_root/toolchain/linux:clang_$host_cpu" 108 } else { 109 host_toolchain = "$build_root/toolchain/linux:$host_cpu" 110 } 111 } else if (host_os == "mac") { 112 host_toolchain = "$build_root/toolchain/mac:clang_$host_cpu" 113 } else { 114 assert(false, "Unsupported host_os: $host_os") 115 } 116} 117 118# Determine default_toolchain. 119# (like a constant in a build for a certain target on a certain host) 120_default_toolchain = host_toolchain 121if (target_os == "ohos") { 122 _default_toolchain = "$build_root/toolchain/ark:ark_clang_${target_cpu}" 123} else if (target_os == "linux" && target_cpu == "x64") { 124 _default_toolchain = "$build_root/toolchain/linux:clang_x64" 125} else if (target_os == "linux" && target_cpu == "x86") { 126 _default_toolchain = "$build_root/toolchain/linux:clang_x86" 127} else if (target_os == "mingw" && target_cpu == "x86_64") { 128 _default_toolchain = "$build_root/toolchain/mingw:mingw_x86_64" 129} else if (target_os == "android" && target_cpu == "arm64") { 130 _default_toolchain = "$build_root/toolchain/aosp:aosp_clang_arm64" 131} else if (target_os == "mac" && target_cpu == "arm64") { 132 _default_toolchain = "$build_root/toolchain/mac:clang_arm64" 133} 134if (custom_toolchain != "") { 135 set_default_toolchain(custom_toolchain) 136} else if (_default_toolchain != "") { 137 set_default_toolchain(_default_toolchain) 138} 139 140# Determine current_cpu and current_os. 141# (like a variable which could be changed during tracing deps) 142if (current_cpu == "") { 143 current_cpu = target_cpu 144} 145if (current_os == "") { 146 current_os = target_os 147} 148 149# Variables like "is_..." are already used to represent for 150# "current_os == "..."" in most of the repositories. Thus, we need to make them 151# change with the change of current_os. 152if (current_os == "mac") { 153 is_aix = false 154 is_ohos = false 155 is_chromeos = false 156 is_linux = false 157 is_mac = true 158 is_nacl = false 159 is_posix = true 160 is_win = false 161 is_mingw = false 162 is_android = false 163 is_ios = false 164} else if (current_os == "ohos") { 165 is_ohos = true 166 is_linux = false 167 is_mac = false 168 is_posix = true 169 is_win = false 170 is_mingw = false 171 is_android = false 172 is_ios = false 173} else if (current_os == "linux") { 174 is_ohos = false 175 is_linux = true 176 is_mac = false 177 is_posix = true 178 is_win = false 179 is_mingw = false 180 is_android = false 181 is_ios = false 182} else if (current_os == "mingw") { 183 is_ohos = false 184 is_linux = false 185 is_mac = false 186 is_posix = true 187 is_win = false 188 is_mingw = true 189 is_android = false 190 is_ios = false 191} else if (current_os == "android") { 192 is_ohos = false 193 is_linux = false 194 is_mac = false 195 is_posix = true 196 is_win = false 197 is_mingw = false 198 is_android = true 199 is_ios = false 200} 201 202default_compiler_configs = [ 203 "$build_root/config/compiler:default_warnings", 204 "$build_root/config/compiler:compiler", 205 "$build_root/config/compiler:default_include_dirs", 206 "$build_root/config/compiler:default_optimization", 207 "$build_root/config/compiler:runtime_config", 208 "$build_root/config:default_libs", 209 "$build_root/config/compiler:ark_code", 210 "$build_root/config/compiler:no_rtti", 211] 212 213default_static_library_configs = default_compiler_configs 214default_source_set_configs = default_compiler_configs 215default_shared_library_configs = 216 default_compiler_configs + [ "$build_root/config:shared_library_config" ] 217default_executable_configs = 218 default_compiler_configs + [ "$build_root/config:executable_config" ] 219 220set_defaults("executable") { 221 configs = default_executable_configs 222} 223 224set_defaults("static_library") { 225 configs = default_static_library_configs 226} 227 228set_defaults("shared_library") { 229 configs = default_shared_library_configs 230} 231 232set_defaults("source_set") { 233 configs = default_source_set_configs 234} 235 236target_list = [ 237 "static_library", 238 "shared_library", 239 "source_set", 240 "executable", 241] 242 243foreach(target, target_list) { 244 template(target) { 245 target(target, target_name) { 246 forward_variables_from(invoker, "*", [ "no_default_deps" ]) 247 if (!defined(deps)) { 248 deps = [] 249 } 250 if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) { 251 deps += [ "$build_root/config:${target}_deps" ] 252 } 253 } 254 } 255} 256