I'm new to Rust and this is on OSX.
I have X86 assembly which normally assembles with nasm using a Makefile. The assembly line looks like:
nasm -f macho64 glue.s -o glue.o
I've rewritten my driver in Rust and that works. Now I'm trying to build everything with Cargo. My build.rs is a pretty straightforward copy of the example from Page Moved
// build.rs
use std::process::Command;
use std::path::Path;
use std::env;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
Command::new("nasm").args(&["src/glue.s", "-fmacho64"]) .arg(&format!("{}/glue.o", out_dir)) .status().unwrap();
Command::new("ar").args(&["crus", "libglue.a", "glue.o"])
.current_dir(&Path::new(&out_dir))
.status().unwrap();
println!("cargo:rustc-link-search=native={}", out_dir); println!("cargo:rustc-link-lib=static=glue");
}
This doesn't work. When I build it with cargo build -vv I get:
Running
..../build-script-build
nasm: error: more than one input file specified
typenasm -h' for help nasm: error: more than one input file specified type
nasm -h' for help
ar: glue.o: No such file or directory
However, I have no idea why nasm is complaining about more than one input file specified. The -vv option doesn't print the offending nasm command just the error message (which is helpful). Again, my build.rs code looks very very similar to the example.
Chris