Files
phs_v1.0.1.0/build/rust/rustc_toolchain.gni
2024-09-27 19:16:49 +08:00

64 lines
2.0 KiB
Plaintext

# 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.
import("//build/config/clang/clang.gni")
import("//build/config/ohos/config.gni")
import("//build/config/ohos/musl.gni")
declare_args() {
enable_rust = true
use_ohos_rust_toolchain = true
rustc_version = ""
rust_sysroot_absolute = ""
rust_default_edition = "2021"
is_rust_nightly = false
is_rust_stable = false
}
if (enable_rust) {
if (rust_sysroot_absolute != "") {
rust_sysroot = get_path_info(rust_sysroot_absolute, "abspath")
} else if (use_ohos_rust_toolchain) {
rust_sysroot = "//prebuilts/rustc/linux-x86_64/current"
is_rust_stable = true
is_rust_nightly = false
} else {
rust_sysroot = "//prebuilts/rustc/linux-x86_64/nightly"
is_rust_stable = false
is_rust_nightly = true
}
}
rust_base = rebase_path("//prebuilts/rustc", root_build_dir)
if (is_rust_nightly) {
rust_version = "nightly"
} else {
rust_version = "current"
}
rust_path = "${rust_base}/${host_platform_dir}/${rust_version}"
rust_bin = "${rust_path}/bin"
rustc = "${rust_bin}/rustc"
clippy_driver = "${rust_bin}/clippy-driver"
stdlib_host_path = "${rust_path}/lib"
clang = rebase_path("${default_clang_base_path}/bin/clang", root_build_dir)
musl_path = rebase_path("${musl_sysroot}", root_build_dir)
if (defined(abi_target)) {
musllib = rebase_path("${musl_sysroot}/usr/lib/${abi_target}", root_build_dir)
}
llvm_strip =
rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip",
root_build_dir)