Skip to content

Commit 620d3ef

Browse files
committed
Fix-up xtask now that cortex-m crate is in a sub-folder.
Binaries are unchanged.
1 parent d5fb6c3 commit 620d3ef

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

xtask/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ harness = false
1111

1212
[dependencies]
1313
ar = "0.8.0"
14-
cortex-m = { path = "../", features = ["serde", "std"] }
14+
cortex-m = { path = "../cortex-m", features = ["serde", "std"] }
1515
serde_json = "1"

xtask/src/lib.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
use std::collections::BTreeMap;
88
use std::env::current_dir;
99
use std::fs::{self, File};
10+
use std::path::Path;
1011
use std::process::{Command, Stdio};
1112

1213
fn toolchain() -> String {
13-
fs::read_to_string("asm-toolchain")
14+
fs::read_to_string("cortex-m/asm-toolchain")
1415
.unwrap()
1516
.trim()
1617
.to_string()
@@ -45,7 +46,11 @@ fn assemble_really(target: &str, cfgs: &[&str], plugin_lto: bool) {
4546

4647
// We don't want any system-specific paths to show up since we ship the result to other users.
4748
// Add `--remap-path-prefix $(pwd)=.`.
48-
let mut dir = current_dir().unwrap().as_os_str().to_os_string();
49+
let mut dir = current_dir()
50+
.unwrap()
51+
.join("cortex-m")
52+
.as_os_str()
53+
.to_os_string();
4954
dir.push("=.");
5055
cmd.arg("--remap-path-prefix").arg(dir);
5156

@@ -70,25 +75,29 @@ fn assemble_really(target: &str, cfgs: &[&str], plugin_lto: bool) {
7075
// Pass output and input file.
7176
cmd.arg("-o").arg(&obj_file);
7277
cmd.arg("asm/lib.rs");
78+
cmd.current_dir("cortex-m");
7379

7480
println!("{:?}", cmd);
7581
let status = cmd.status().unwrap();
7682
assert!(status.success());
7783

84+
let full_obj_file_path = Path::new("cortex-m").join(&obj_file);
85+
7886
// Archive `target.o` -> `bin/target.a`.
79-
let mut builder = ar::Builder::new(File::create(format!("bin/{}.a", file_stub)).unwrap());
87+
let mut builder =
88+
ar::Builder::new(File::create(format!("cortex-m/bin/{}.a", file_stub)).unwrap());
8089

8190
// Use `append`, not `append_path`, to avoid adding any filesystem metadata (modification times,
8291
// etc.).
83-
let file = fs::read(&obj_file).unwrap();
92+
let file = fs::read(&full_obj_file_path).unwrap();
8493
builder
8594
.append(
8695
&ar::Header::new(obj_file.as_bytes().to_vec(), file.len() as u64),
8796
&*file,
8897
)
8998
.unwrap();
9099

91-
fs::remove_file(&obj_file).unwrap();
100+
fs::remove_file(&full_obj_file_path).unwrap();
92101
}
93102

94103
fn assemble(target: &str, cfgs: &[&str]) {
@@ -157,7 +166,7 @@ pub fn assemble_blobs() {
157166
pub fn check_blobs() {
158167
// Load each `.a` file in `bin` into memory.
159168
let mut files_before = BTreeMap::new();
160-
for entry in fs::read_dir("bin").unwrap() {
169+
for entry in fs::read_dir("cortex-m/bin").unwrap() {
161170
let entry = entry.unwrap();
162171
if entry.path().extension().unwrap() == "a" {
163172
files_before.insert(
@@ -176,7 +185,7 @@ pub fn check_blobs() {
176185
assemble_blobs();
177186

178187
let mut files_after = BTreeMap::new();
179-
for entry in fs::read_dir("bin").unwrap() {
188+
for entry in fs::read_dir("cortex-m/bin").unwrap() {
180189
let entry = entry.unwrap();
181190
if entry.path().extension().unwrap() == "a" {
182191
files_after.insert(

0 commit comments

Comments
 (0)