mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
use OUT_DIR in wasm repl module building
This commit is contained in:
parent
a75af513c1
commit
f0707fd92b
2 changed files with 12 additions and 5 deletions
|
@ -6,7 +6,6 @@ use roc_builtins::bitcode;
|
|||
use wasi_libc_sys::{WASI_COMPILER_RT_PATH, WASI_LIBC_PATH};
|
||||
|
||||
const PLATFORM_FILENAME: &str = "repl_platform";
|
||||
const PRE_LINKED_BINARY: [&str; 2] = ["src", "pre_linked_binary.o"];
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
@ -20,9 +19,11 @@ fn main() {
|
|||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let platform_obj = build_wasm_platform(&out_dir, &source_path);
|
||||
|
||||
let pre_linked_binary_path: PathBuf = PRE_LINKED_BINARY.iter().collect();
|
||||
let mut pre_linked_binary_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
pre_linked_binary_path.extend(&["pre_linked_binary"]);
|
||||
pre_linked_binary_path.set_extension("o");
|
||||
|
||||
Command::new(&zig_executable())
|
||||
let output = Command::new(&zig_executable())
|
||||
.args([
|
||||
"wasm-ld",
|
||||
bitcode::BUILTINS_WASM32_OBJ_PATH,
|
||||
|
@ -37,6 +38,10 @@ fn main() {
|
|||
])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
assert!(output.status.success(), "{:#?}", output);
|
||||
assert!(output.stdout.is_empty(), "{:#?}", output);
|
||||
assert!(output.stderr.is_empty(), "{:#?}", output);
|
||||
}
|
||||
|
||||
fn zig_executable() -> String {
|
||||
|
|
|
@ -155,12 +155,14 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
const PRE_LINKED_BINARY: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/pre_linked_binary.o")) as &[_];
|
||||
|
||||
pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
|
||||
#[cfg(feature = "console_error_panic_hook")]
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
let arena = &Bump::new();
|
||||
let pre_linked_binary: &'static [u8] = include_bytes!("pre_linked_binary.o");
|
||||
|
||||
// Compile the app
|
||||
let target_info = TargetInfo::default_wasm32();
|
||||
|
@ -210,7 +212,7 @@ pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
|
|||
};
|
||||
|
||||
let (mut module, called_preload_fns, main_fn_index) = {
|
||||
let host_module = roc_gen_wasm::parse_host(env.arena, pre_linked_binary).unwrap();
|
||||
let host_module = roc_gen_wasm::parse_host(env.arena, PRE_LINKED_BINARY).unwrap();
|
||||
roc_gen_wasm::build_app_module(
|
||||
&env,
|
||||
&mut interns, // NOTE: must drop this mutable ref before jit_to_ast
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue