Skip to content

Commit

Permalink
Tweak build for nix-provided toolchain also
Browse files Browse the repository at this point in the history
Prebuilt toolchain from ARM is still supported.
  • Loading branch information
jonored authored and yhql committed Jan 26, 2023
1 parent 7785e32 commit 8e86632
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,25 @@ fn main() -> Result<(), Box<dyn Error>> {

let output = Command::new("arm-none-eabi-gcc")
.arg("-print-sysroot")
.output()
.expect("failed");
.output().ok();
let sysroot = output
.as_ref().and_then(|o|std::str::from_utf8(&o.stdout).ok())
.unwrap_or("").trim();

let sysroot = std::str::from_utf8(&output.stdout).unwrap().trim();
let gcc_toolchain = if sysroot.is_empty() {
String::from("/usr/include/")
} else {
format!("{sysroot}/include")
};

let mut command = cc::Build::new()
.compiler("clang")
let mut command = cc::Build::new();
if env::var_os("CC").is_none() {
command.compiler("clang");
} else {
// Let cc::Build determine CC from the environment variable
}

command
.file("./src/c/src.c")
.file("./src/c/sjlj.s")
.file(format!("{bolos_sdk}/src/os_io_usb.c"))
Expand Down Expand Up @@ -197,8 +204,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.flag("-fno-jump-tables")
.flag("-fshort-enums")
.flag("-mno-unaligned-access")
.flag("-Wno-unused-command-line-argument")
.clone();
.flag("-Wno-unused-command-line-argument");

#[cfg(feature = "ccid")]
{
Expand Down

0 comments on commit 8e86632

Please sign in to comment.