# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. declare_args() { ark_standalone_build = true use_musl = true build_root = "//arkcompiler/toolchain/build" run_with_qemu = false enable_lto = true } if (host_os == "linux") { host_platform_dir = "linux-x86_64" } else { assert(false, "Unsupported host_os: $host_os") } declare_args() { # Debug build. Enabling official builds automatically sets is_debug to false. is_debug = false is_standard_system = false } declare_args() { host_toolchain = "" custom_toolchain = "" target_toolchain = "" is_clang = current_os != "linux" || (current_cpu != "s390x" && current_cpu != "s390" && current_cpu != "ppc64" && current_cpu != "ppc" && current_cpu != "mips" && current_cpu != "mips64") target_platform = "phone" is_official_build = false is_component_build = false } is_wearable_product = "${target_platform}" == "wearable" is_emulator = false if (target_os == "ohos" && target_cpu == "x86_64") { is_emulator = true } # Determine host_toolchain. (like a constant in a build on a certain host) if (host_toolchain == "") { if (host_os == "linux") { if (target_os != "linux") { host_toolchain = "$build_root/toolchain/linux:clang_$host_cpu" } else if (is_clang) { host_toolchain = "$build_root/toolchain/linux:clang_$host_cpu" } else { host_toolchain = "$build_root/toolchain/linux:$host_cpu" } } else { assert(false, "Unsupported host_os: $host_os") } } # Determine default_toolchain. # (like a constant in a build for a certain target on a certain host) _default_toolchain = host_toolchain if (target_os == "ohos") { _default_toolchain = "$build_root/toolchain/ark:ark_clang_${target_cpu}" } else if (target_os == "linux" && target_cpu == "x64") { _default_toolchain = "$build_root/toolchain/linux:clang_x64" } else if (target_os == "linux" && target_cpu == "x86") { _default_toolchain = "$build_root/toolchain/linux:clang_x86" } else if (target_os == "mingw" && target_cpu == "x86_64") { _default_toolchain = "$build_root/toolchain/mingw:mingw_x86_64" } else if (target_os == "android" && target_cpu == "arm64") { _default_toolchain = "$build_root/toolchain/aosp:aosp_clang_arm64" } if (custom_toolchain != "") { set_default_toolchain(custom_toolchain) } else if (_default_toolchain != "") { set_default_toolchain(_default_toolchain) } # Determine current_cpu and current_os. # (like a variable which could be changed during tracing deps) if (current_cpu == "") { current_cpu = target_cpu } if (current_os == "") { current_os = target_os } # Variables like "is_..." are already used to represent for # "current_os == "..."" in most of the repositories. Thus, we need to make them # change with the change of current_os. if (current_os == "ohos") { is_ohos = true is_linux = false is_mac = false is_posix = true is_win = false is_mingw = false is_android = false is_ios = false } else if (current_os == "linux") { is_ohos = false is_linux = true is_mac = false is_posix = true is_win = false is_mingw = false is_android = false is_ios = false } else if (current_os == "mingw") { is_ohos = false is_linux = false is_mac = false is_posix = true is_win = false is_mingw = true is_android = false is_ios = false } else if (current_os == "android") { is_ohos = false is_linux = false is_mac = false is_posix = true is_win = false is_mingw = false is_android = true is_ios = false } default_compiler_configs = [ "$build_root/config/compiler:default_warnings", "$build_root/config/compiler:compiler", "$build_root/config/compiler:default_include_dirs", "$build_root/config/compiler:default_optimization", "$build_root/config/compiler:runtime_config", "$build_root/config:default_libs", "$build_root/config/compiler:ark_code", "$build_root/config/compiler:no_rtti", ] default_static_library_configs = default_compiler_configs default_source_set_configs = default_compiler_configs default_shared_library_configs = default_compiler_configs default_executable_configs = default_compiler_configs + [ "$build_root/config:executable_config" ] set_defaults("executable") { configs = default_executable_configs } set_defaults("static_library") { configs = default_static_library_configs } set_defaults("shared_library") { configs = default_shared_library_configs } set_defaults("source_set") { configs = default_source_set_configs } target_list = [ "static_library", "shared_library", "source_set", "executable", ] foreach(target, target_list) { template(target) { target(target, target_name) { forward_variables_from(invoker, "*", [ "no_default_deps" ]) if (!defined(deps)) { deps = [] } if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) { deps += [ "$build_root/config:${target}_deps" ] } } } }