Skip to content

Commit 6608ea6

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

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-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: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
//!
55
//! Also see the docs in `asm.rs`.
66
7+
use std::path::Path;
78
use std::collections::BTreeMap;
89
use std::env::current_dir;
910
use std::fs::{self, File};
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,7 @@ 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().unwrap().join("cortex-m").as_os_str().to_os_string();
4950
dir.push("=.");
5051
cmd.arg("--remap-path-prefix").arg(dir);
5152

@@ -70,25 +71,29 @@ fn assemble_really(target: &str, cfgs: &[&str], plugin_lto: bool) {
7071
// Pass output and input file.
7172
cmd.arg("-o").arg(&obj_file);
7273
cmd.arg("asm/lib.rs");
74+
cmd.current_dir("cortex-m");
7375

7476
println!("{:?}", cmd);
7577
let status = cmd.status().unwrap();
7678
assert!(status.success());
7779

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

8186
// Use `append`, not `append_path`, to avoid adding any filesystem metadata (modification times,
8287
// etc.).
83-
let file = fs::read(&obj_file).unwrap();
88+
let file = fs::read(&full_obj_file_path).unwrap();
8489
builder
8590
.append(
8691
&ar::Header::new(obj_file.as_bytes().to_vec(), file.len() as u64),
8792
&*file,
8893
)
8994
.unwrap();
9095

91-
fs::remove_file(&obj_file).unwrap();
96+
fs::remove_file(&full_obj_file_path).unwrap();
9297
}
9398

9499
fn assemble(target: &str, cfgs: &[&str]) {
@@ -157,7 +162,7 @@ pub fn assemble_blobs() {
157162
pub fn check_blobs() {
158163
// Load each `.a` file in `bin` into memory.
159164
let mut files_before = BTreeMap::new();
160-
for entry in fs::read_dir("bin").unwrap() {
165+
for entry in fs::read_dir("cortex-m/bin").unwrap() {
161166
let entry = entry.unwrap();
162167
if entry.path().extension().unwrap() == "a" {
163168
files_before.insert(
@@ -176,7 +181,7 @@ pub fn check_blobs() {
176181
assemble_blobs();
177182

178183
let mut files_after = BTreeMap::new();
179-
for entry in fs::read_dir("bin").unwrap() {
184+
for entry in fs::read_dir("cortex-m/bin").unwrap() {
180185
let entry = entry.unwrap();
181186
if entry.path().extension().unwrap() == "a" {
182187
files_after.insert(

0 commit comments

Comments
 (0)