Skip to content

Commit 598e011

Browse files
committed
refactor(xtask): 重写 xtask
- 若 binutils 不存在,将自动安装 - 自动处理文件扩展名、应用程序路径等问题以支持 windows 上开发 Signed-off-by: YdrMaster <ydrml@hotmail.com>
1 parent cbbb8a7 commit 598e011

File tree

10 files changed

+347
-408
lines changed

10 files changed

+347
-408
lines changed

.cargo/config.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[alias]
2-
xtask = "run --package xtask --"
2+
xtask = "run --package xtask --release --"
33
make = "xtask make"
4-
qemu = "xtask qemu"
54
asm = "xtask asm"
6-
size = "xtask size"
7-
debug = "xtask debug"
8-
gdb = "xtask gdb"
5+
qemu = "xtask qemu"

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
**/.*/*
2+
!/.github/*
3+
!/.cargo/*
4+
!/.vscode/settings.json
5+
16
/target
7+
/*.asm

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{
1+
{
22
// Prevent "can't find crate for `test`" error on no_std
33
// Ref: https://github.com/rust-lang/vscode-rust/issues/729
44
// For vscode-rust plugin users:
55
"rust.target": "riscv64imac-unknown-none-elf",
66
"rust.all_targets": false,
77
// For Rust Analyzer plugin users:
88
"rust-analyzer.cargo.target": "riscv64imac-unknown-none-elf",
9-
"rust-analyzer.checkOnSave.allTargets": false
9+
"rust-analyzer.checkOnSave.enable": false
1010
}

Cargo.lock

Lines changed: 144 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rustsbi-qemu/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[package]
22
name = "rustsbi-qemu"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = "2021"
5-
readme = "README.md"
65

76
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
87

test-kernel/.cargo/config.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
[target.riscv64imac-unknown-none-elf]
2-
rustflags = [
3-
"-C", "link-arg=-Tlinker64.ld",
4-
]
5-
6-
[target.riscv32imac-unknown-none-elf]
7-
rustflags = [
8-
"-C", "link-arg=-Tlinker32.ld",
9-
]
1+
[build]
2+
target = "riscv64imac-unknown-none-elf"

test-kernel/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "test-kernel"
3-
version = "0.1.0"
4-
authors = ["luojia65 <me@luojia.cc>"]
3+
version = "0.2.0"
4+
authors = ["Luo Jia <me@luojia.cc>", "YdrMaster <ydrml@hotmail.com>"]
55
edition = "2021"
66
publish = false
77

test-kernel/build.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
use std::{
2-
env, fs,
3-
io::{Result, Write},
4-
path::PathBuf,
5-
};
6-
7-
fn main() -> Result<()> {
8-
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
9-
10-
// Put the linker script somewhere the linker can find it
11-
fs::File::create(out_dir.join("linker64.ld"))?.write_all(include_bytes!("src/linker64.ld"))?;
12-
fs::File::create(out_dir.join("linker32.ld"))?.write_all(include_bytes!("src/linker32.ld"))?;
13-
println!("cargo:rustc-link-search={}", out_dir.display());
14-
1+
fn main() {
152
println!("cargo:rerun-if-changed=build.rs");
16-
println!("cargo:rerun-if-changed=src/linker64.ld");
17-
println!("cargo:rerun-if-changed=src/linker32.ld");
18-
19-
Ok(())
3+
#[cfg(target_pointer_width = "64")]
4+
println!("cargo:rustc-link-arg=-Ttest-kernel/src/linker64.ld");
5+
#[cfg(target_pointer_width = "32")]
6+
println!("cargo:rustc-link-arg=-Ttest-kernel/src/linker32.ld");
207
}

0 commit comments

Comments
 (0)