yac
/
coreutils
Archived
2
0
Fork 0
This repository has been archived on 2024-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
coreutils/build.rs

51 lines
1.1 KiB
Rust

// Copyright (c) 2022 silt <silt@tebibyte.media>
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::env;
use std::process::{Command, exit};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = env::var("OUT_DIR")?;
let mut handler_nasm_true = Command::new("nasm").args([
"-f", "elf",
"src/asm/true.asm",
"-o", &(out_dir.clone() + "/true.o")
]).spawn()?;
let mut handler_nasm_false = Command::new("nasm").args([
"-f", "elf",
"src/asm/false.asm",
"-o", &(out_dir.clone() + "/false.o")
]).spawn()?;
if !handler_nasm_true.wait_with_output()?.stderr.is_empty() {
exit(1);
}
let mut handler_ld_true = Command::new("ld").args([
"-m", "elf_i386",
"src/asm/true.asm",
"-s",
&(out_dir.clone() + "/true.o"),
"-o", &(out_dir.clone() + "/true"),
]).spawn()?;
if !handler_nasm_false.wait_with_output()?.stderr.is_empty() {
exit(1)
}
let mut handler_ld_false = Command::new("ld").args([
"-m", "elf_i386",
"src/asm/false.asm",
"-s",
&(out_dir.clone() + "/false.o"),
"-o", &(out_dir.clone() + "/false"),
]).spawn()?;
handler_ld_true.wait();
handler_ld_false.wait();
Ok(())
}