mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-25 14:07:58 +00:00
e83e4f04e6
Signed-off-by: xermicus <cyrill@parity.io>
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use std::{env, fs, path::Path, process::Command};
|
|
|
|
fn compile(source_path: &str, output_path: &str) {
|
|
let output = Command::new("llc")
|
|
.args([
|
|
"-O3",
|
|
"-filetype=asm",
|
|
"-mattr=+zbb,+e",
|
|
source_path,
|
|
"-o",
|
|
output_path,
|
|
])
|
|
.output()
|
|
.expect("should be able to invoke llc");
|
|
|
|
assert!(
|
|
output.status.success(),
|
|
"failed to compile {}: {:?}",
|
|
source_path,
|
|
output
|
|
);
|
|
}
|
|
|
|
fn main() {
|
|
let in_file = "bswap.ll";
|
|
let out_file = "bswap.s";
|
|
let out_dir = env::var_os("OUT_DIR").expect("env should have $OUT_DIR");
|
|
let out_path = Path::new(&out_dir).join(out_file);
|
|
compile(
|
|
in_file,
|
|
out_path.to_str().expect("$OUT_DIR should be UTF-8"),
|
|
);
|
|
|
|
let src_path = Path::new(&out_dir).join("bswap.rs");
|
|
let src = format!("pub static ASSEMBLY: &str = include_str!(\"{out_file}\");");
|
|
fs::write(src_path, src).expect("should be able to write in $OUT_DIR");
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed=bswap.ll");
|
|
}
|