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. 13 14import("//build/config/clang/clang.gni") 15import("//build/config/ohos/config.gni") 16import("//build/config/ohos/musl.gni") 17 18declare_args() { 19 enable_rust = true 20 use_ohos_rust_toolchain = true 21 rustc_version = "" 22 rust_sysroot_absolute = "" 23 rust_default_edition = "2021" 24 is_rust_nightly = false 25 is_rust_stable = false 26} 27if (enable_rust) { 28 if (rust_sysroot_absolute != "") { 29 rust_sysroot = get_path_info(rust_sysroot_absolute, "abspath") 30 } else if (use_ohos_rust_toolchain) { 31 rust_sysroot = "//prebuilts/rustc/linux-x86_64/current" 32 is_rust_stable = true 33 is_rust_nightly = false 34 } else { 35 rust_sysroot = "//prebuilts/rustc/linux-x86_64/nightly" 36 is_rust_stable = false 37 is_rust_nightly = true 38 } 39} 40 41rust_base = rebase_path("//prebuilts/rustc", root_build_dir) 42 43if (is_rust_nightly) { 44 rust_version = "nightly" 45} else { 46 rust_version = "current" 47} 48 49rust_path = "${rust_base}/${host_platform_dir}/${rust_version}" 50rust_bin = "${rust_path}/bin" 51rustc = "${rust_bin}/rustc" 52clippy_driver = "${rust_bin}/clippy-driver" 53 54stdlib_host_path = "${rust_path}/lib" 55 56clang = rebase_path("${default_clang_base_path}/bin/clang", root_build_dir) 57musl_path = rebase_path("${musl_sysroot}", root_build_dir) 58if (defined(abi_target)) { 59 musllib = rebase_path("${musl_sysroot}/usr/lib/${abi_target}", root_build_dir) 60} 61llvm_strip = 62 rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip", 63 root_build_dir) 64