mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-20 18:56:17 +00:00
Emerge Yul recompiler (#1)
Provide a modified (and incomplete) version of ZKSync zksolc that can compile the most basic contracts
This commit is contained in:
1 parent
d238d8f39e
commit
cffa14a4d2
247 files changed
+35357
-4905
No files matched your search
@@ -0,0 +1,31 @@
|
||||
use std::{env, fs, path::Path, process::Command};
|
||||
|
||||
fn main() {
|
||||
let lib = "stdlib.bc";
|
||||
let out_dir = env::var_os("OUT_DIR").expect("env should have $OUT_DIR");
|
||||
let bitcode_path = Path::new(&out_dir).join(lib);
|
||||
|
||||
let output = Command::new("llvm-as")
|
||||
.args([
|
||||
"-o",
|
||||
bitcode_path.to_str().expect("$OUT_DIR should be UTF-8"),
|
||||
"stdlib.ll",
|
||||
])
|
||||
.output()
|
||||
.expect("should be able to invoke llvm-as");
|
||||
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"failed to assemble the stdlib: {:?}",
|
||||
output
|
||||
);
|
||||
|
||||
let bitcode = fs::read(bitcode_path).expect("bitcode should have been built");
|
||||
let len = bitcode.len();
|
||||
let src_path = Path::new(&out_dir).join("stdlib.rs");
|
||||
let src = format!("pub static BITCODE: &[u8; {len}] = include_bytes!(\"{lib}\");");
|
||||
fs::write(src_path, src).expect("should be able to write in $OUT_DIR");
|
||||
|
||||
println!("cargo:rerun-if-changed=stdlib.ll");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
Reference in new issue
Block a user