aboutsummaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-08-26 23:57:12 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-08-26 23:57:12 +0000
commit478418c0eb38b9311e574d18d12cac69d3044e63 (patch)
tree0c3eed1a715253acf3378da4c731781fb72bd0e3 /build.rs
parentdfd0349772763e07b16bcaa13f536bfa381044b8 (diff)
parent945e2683f89a031b44b65d25e1917f3157c49fa1 (diff)
downloadcortex-m-478418c0eb38b9311e574d18d12cac69d3044e63.tar.gz
cortex-m-478418c0eb38b9311e574d18d12cac69d3044e63.tar.zst
cortex-m-478418c0eb38b9311e574d18d12cac69d3044e63.zip
Merge #108
108: remove build dependency on arm-none-eabi-gcc r=adamgreig a=japaric by shipping pre-assembled object files. This is the same approach as the one used in rust-embedded/cortex-m#95 r? @rust-embedded/cortex-m (anyone) Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs49
1 files changed, 10 insertions, 39 deletions
diff --git a/build.rs b/build.rs
index e3797a7..6d08ba9 100644
--- a/build.rs
+++ b/build.rs
@@ -1,48 +1,19 @@
-extern crate cc;
-
-use std::env;
+use std::path::PathBuf;
+use std::{env, fs};
fn main() {
let target = env::var("TARGET").unwrap();
-
- let is_v6 = target.starts_with("thumbv6m-");
+ let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
+ let name = env::var("CARGO_PKG_NAME").unwrap();
if target.starts_with("thumb") && env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
- // NOTE we need to place each routine in a separate assembly file or the linker won't be
- // able to discard the unused routines
- let mut build = cc::Build::new();
- build
- .file("asm/bkpt.s")
- .file("asm/control.s")
- .file("asm/cpsid.s")
- .file("asm/cpsie.s")
- .file("asm/delay.s")
- .file("asm/dmb.s")
- .file("asm/dsb.s")
- .file("asm/isb.s")
- .file("asm/msp_r.s")
- .file("asm/msp_w.s")
- .file("asm/nop.s")
- .file("asm/primask.s")
- .file("asm/psp_r.s")
- .file("asm/psp_w.s")
- .file("asm/sev.s")
- .file("asm/wfe.s")
- .file("asm/wfi.s");
-
- if !is_v6 {
- build.file("asm/basepri_r.s").file("asm/faultmask.s");
-
- if env::var_os("CARGO_FEATURE_CM7_R0P1").is_some() {
- build.file("asm/basepri_max-cm7-r0p1.s");
- build.file("asm/basepri_w-cm7-r0p1.s");
- } else {
- build.file("asm/basepri_max.s");
- build.file("asm/basepri_w.s");
- }
- }
+ fs::copy(
+ format!("bin/{}.a", target),
+ out_dir.join(format!("lib{}.a", name)),
+ ).unwrap();
- build.compile("asm");
+ println!("cargo:rustc-link-lib=static={}", name);
+ println!("cargo:rustc-link-search={}", out_dir.display());
}
if target.starts_with("thumbv6m-") {