29 Star 68 Fork 25

openEuler/rust_shyper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.rs 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
chen weiming 提交于 2023-12-03 11:38 . fix: remove live_update and migrate
// Copyright (c) 2023 Beihang University, Huawei Technologies Co.,Ltd. All rights reserved.
// Rust-Shyper is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
use std::env::var;
use std::process::Command;
// get text_start by arch and platform
fn get_text_start() -> u64 {
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if target_arch == "aarch64" {
if cfg!(feature = "tx2") {
0x83000000_u64
} else if cfg!(feature = "pi4") {
0xf0080000_u64
} else if cfg!(feature = "qemu") {
0x40080000_u64
} else if cfg!(feature = "rk3588") {
0x00400000_u64
} else {
panic!("Unsupported platform!");
}
} else if target_arch == "riscv64" {
0x80200000_u64
} else {
panic!("Unsupported arch {}!", target_arch);
}
}
fn main() {
let arch = var("CARGO_CFG_TARGET_ARCH").unwrap();
let text_start = get_text_start();
println!("cargo:rustc-link-arg=-Tlinkers/{arch}.ld");
println!("cargo:rustc-link-arg=--defsym=TEXT_START={text_start}");
let commit_hash = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap();
let commit_hash = String::from_utf8(commit_hash.stdout).unwrap();
println!("cargo:rustc-env=GIT_COMMIT={}", commit_hash.trim());
// note: add error checking yourself.
let build_time = chrono::offset::Local::now().format("%Y-%m-%d %H:%M:%S %Z");
println!("cargo:rustc-env=BUILD_TIME={}", build_time);
let hostname = gethostname::gethostname();
println!("cargo:rustc-env=HOSTNAME={}", hostname.into_string().unwrap());
built::write_built_file().expect("Failed to acquire build-time information");
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler/rust_shyper.git
git@gitee.com:openeuler/rust_shyper.git
openeuler
rust_shyper
rust_shyper
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385