1 | use std::env; |
2 | |
3 | pub fn setup() { |
4 | let link_dir = env::var("EMNAPI_LINK_DIR" ).expect("EMNAPI_LINK_DIR must be set" ); |
5 | println!("cargo:rerun-if-env-changed=EMNAPI_LINK_DIR" ); |
6 | println!("cargo:rerun-if-env-changed=WASI_REGISTER_TMP_PATH" ); |
7 | println!("cargo:rustc-link-search= {link_dir}" ); |
8 | println!("cargo:rustc-link-lib=static=emnapi-basic-mt" ); |
9 | println!("cargo:rustc-link-arg=--export-dynamic" ); |
10 | println!("cargo:rustc-link-arg=--export=malloc" ); |
11 | println!("cargo:rustc-link-arg=--export=free" ); |
12 | println!("cargo:rustc-link-arg=--export=napi_register_wasm_v1" ); |
13 | println!("cargo:rustc-link-arg=--export-if-defined=node_api_module_get_api_version_v1" ); |
14 | println!("cargo:rustc-link-arg=--export-table" ); |
15 | println!("cargo:rustc-link-arg=--export=emnapi_async_worker_create" ); |
16 | println!("cargo:rustc-link-arg=--export=emnapi_async_worker_init" ); |
17 | println!("cargo:rustc-link-arg=--import-memory" ); |
18 | println!("cargo:rustc-link-arg=--import-undefined" ); |
19 | println!("cargo:rustc-link-arg=--shared-memory" ); |
20 | println!("cargo:rustc-link-arg=--max-memory=2147483648" ); |
21 | // lld only allocates 1MiB for the WebAssembly stack, and the array that you're allocating on the stack is exactly 1MiB. |
22 | // 0x800000 bytes = 8MiB |
23 | println!("cargo:rustc-link-arg=-zstack-size=0x800000" ); |
24 | println!("cargo:rustc-link-arg=--no-check-features" ); |
25 | if let Ok(setjmp_link_dir) = env::var("SETJMP_LINK_DIR" ) { |
26 | println!("cargo:rustc-link-search= {setjmp_link_dir}" ); |
27 | println!("cargo:rustc-link-lib=static=setjmp-mt" ); |
28 | } |
29 | } |
30 | |