diff --git a/build.rs b/build.rs index 9b64d49..b42244f 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,19 @@ +use std::{process::Command, env}; + fn main() { println!("cargo:rerun-if-changed=src/syscalls.S"); - nasm_rs::compile_library_args("libsyscalls.a", &["src/syscalls.S"], &["-f elf32"]) - .expect("failed to compile assembly"); + + let out_dir = env::var("OUT_DIR").unwrap(); + + Command::new("fasm") + .arg("src/syscalls.S") + .arg(&format!("{}/libsyscalls.a", out_dir)) + .status().unwrap(); + Command::new("ar") + .arg("crus") + .arg(&format!("{}/libsyscalls.a", out_dir)) + .arg(&format!("{}/libsyscalls.o", out_dir)) + .status().unwrap(); + + println!("cargo:rustc-link-search={}", out_dir) } diff --git a/src/syscalls.S b/src/syscalls.S index 029bfe8..9e86ded 100644 --- a/src/syscalls.S +++ b/src/syscalls.S @@ -1,13 +1,13 @@ -BITS 32 +format ELF -section .text - global _exit - global _start_window_draw - global _end_window_draw - global _define_window - global _display_message - global _wait_event - global _pressed_key +section '.text' + public _exit + public _start_window_draw + public _end_window_draw + public _define_window + public _display_message + public _wait_event + public _pressed_key _exit: mov eax, -1