# 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() { another_path = true ark_standalone_build = true use_musl = false build_root = "//toolchain/build" } if (target_os == "") { target_os = "ohos" #host_os# } if (target_cpu == "") { if (target_os == "ohos") { target_cpu = "x64" } else { target_cpu = host_cpu } } if (current_cpu == "") { current_cpu = host_cpu } if (current_os == "") { current_os = host_os } # different host platform tools directory. 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 } declare_args() { host_toolchain = "" custom_toolchain = "" is_standard_system = false is_clang = current_os != "linux" || (current_cpu != "s390x" && current_cpu != "s390" && current_cpu != "ppc64" && current_cpu != "ppc" && current_cpu != "mips" && current_cpu != "mips64") } if (current_os == "ohos") { is_ohos = true is_linux = false is_mac = false is_posix = true is_win = false is_mingw = false } else if (current_os == "linux") { is_ohos = false is_linux = true is_mac = false is_posix = true is_win = false is_mingw = false } else if (current_os == "mingw") { is_ohos = false is_linux = false is_mac = false is_posix = true is_win = false is_mingw = true } if (host_toolchain == "") { # This should only happen in the top-level context. # In a specific toolchain context, the toolchain_args() # block should have propagated a value down. 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") } } _default_toolchain = "" if (target_os == "ohos") { assert(host_os == "linux" || host_os == "mac", "ohos builds are only supported on Linux and Mac hosts.") _default_toolchain = "$build_root/toolchain/ark:ark_clang_$target_cpu" } else if (target_os == "linux") { if (is_clang) { _default_toolchain = "$build_root/toolchain/linux:clang_$target_cpu" } else { _default_toolchain = "$build_root/toolchain/linux:$target_cpu" } } else { assert(false, "Unsupported target_os: $target_os") } # If a custom toolchain has been set in the args, set it as default. Otherwise, # set the default toolchain for the platform (if any). if (custom_toolchain != "") { set_default_toolchain(custom_toolchain) } else if (_default_toolchain != "") { set_default_toolchain(_default_toolchain) } _shared_binary_target_configs = [ "$build_root/config:complier_defaults" ] default_compiler_configs = [] set_defaults("executable") { configs = _shared_binary_target_configs configs += [ "$build_root/config:executable_ldconfig" ] } set_defaults("static_library") { configs = _shared_binary_target_configs } set_defaults("shared_library") { configs = _shared_binary_target_configs } set_defaults("source_set") { configs = default_compiler_configs }