Skip to content

Commit

Permalink
refactor(xtask): 重写 xtask
Browse files Browse the repository at this point in the history
- 若 binutils 不存在,将自动安装
- 自动处理文件扩展名、应用程序路径等问题以支持 windows 上开发

Signed-off-by: YdrMaster <ydrml@hotmail.com>
  • Loading branch information
YdrMaster committed Jun 23, 2022
1 parent cbbb8a7 commit 598e011
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 408 deletions.
7 changes: 2 additions & 5 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[alias]
xtask = "run --package xtask --"
xtask = "run --package xtask --release --"
make = "xtask make"
qemu = "xtask qemu"
asm = "xtask asm"
size = "xtask size"
debug = "xtask debug"
gdb = "xtask gdb"
qemu = "xtask qemu"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
**/.*/*
!/.github/*
!/.cargo/*
!/.vscode/settings.json

/target
/*.asm
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
{
// Prevent "can't find crate for `test`" error on no_std
// Ref: https://github.com/rust-lang/vscode-rust/issues/729
// For vscode-rust plugin users:
"rust.target": "riscv64imac-unknown-none-elf",
"rust.all_targets": false,
// For Rust Analyzer plugin users:
"rust-analyzer.cargo.target": "riscv64imac-unknown-none-elf",
"rust-analyzer.checkOnSave.allTargets": false
"rust-analyzer.checkOnSave.enable": false
}
192 changes: 144 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rustsbi-qemu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[package]
name = "rustsbi-qemu"
version = "0.1.1"
version = "0.2.0"
edition = "2021"
readme = "README.md"

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

Expand Down
11 changes: 2 additions & 9 deletions test-kernel/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
[target.riscv64imac-unknown-none-elf]
rustflags = [
"-C", "link-arg=-Tlinker64.ld",
]

[target.riscv32imac-unknown-none-elf]
rustflags = [
"-C", "link-arg=-Tlinker32.ld",
]
[build]
target = "riscv64imac-unknown-none-elf"
4 changes: 2 additions & 2 deletions test-kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "test-kernel"
version = "0.1.0"
authors = ["luojia65 <me@luojia.cc>"]
version = "0.2.0"
authors = ["Luo Jia <me@luojia.cc>", "YdrMaster <ydrml@hotmail.com>"]
edition = "2021"
publish = false

Expand Down
23 changes: 5 additions & 18 deletions test-kernel/build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
use std::{
env, fs,
io::{Result, Write},
path::PathBuf,
};

fn main() -> Result<()> {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

// Put the linker script somewhere the linker can find it
fs::File::create(out_dir.join("linker64.ld"))?.write_all(include_bytes!("src/linker64.ld"))?;
fs::File::create(out_dir.join("linker32.ld"))?.write_all(include_bytes!("src/linker32.ld"))?;
println!("cargo:rustc-link-search={}", out_dir.display());

fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/linker64.ld");
println!("cargo:rerun-if-changed=src/linker32.ld");

Ok(())
#[cfg(target_pointer_width = "64")]
println!("cargo:rustc-link-arg=-Ttest-kernel/src/linker64.ld");
#[cfg(target_pointer_width = "32")]
println!("cargo:rustc-link-arg=-Ttest-kernel/src/linker32.ld");
}
Loading

0 comments on commit 598e011

Please sign in to comment.