* The MIT License (MIT)
* Copyright (C) 2024 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
use std::env;
pub fn setup() {
let link_dir = env::var("EMNAPI_LINK_DIR").expect("EMNAPI_LINK_DIR must be set");
println!("cargo:rerun-if-env-changed=EMNAPI_LINK_DIR");
println!("cargo:rerun-if-env-changed=WASI_REGISTER_TMP_PATH");
println!("cargo:rustc-link-search={link_dir}");
println!("cargo:rustc-link-lib=static=emnapi-basic-mt");
println!("cargo:rustc-link-arg=--export-dynamic");
println!("cargo:rustc-link-arg=--export=malloc");
println!("cargo:rustc-link-arg=--export=free");
println!("cargo:rustc-link-arg=--export=napi_register_wasm_v1");
println!("cargo:rustc-link-arg=--export-if-defined=node_api_module_get_api_version_v1");
println!("cargo:rustc-link-arg=--export-table");
println!("cargo:rustc-link-arg=--export=emnapi_async_worker_create");
println!("cargo:rustc-link-arg=--export=emnapi_async_worker_init");
println!("cargo:rustc-link-arg=--import-memory");
println!("cargo:rustc-link-arg=--import-undefined");
println!("cargo:rustc-link-arg=--shared-memory");
println!("cargo:rustc-link-arg=--max-memory=2147483648");
println!("cargo:rustc-link-arg=-zstack-size=0x800000");
println!("cargo:rustc-link-arg=--no-check-features");
if let Ok(setjmp_link_dir) = env::var("SETJMP_LINK_DIR") {
println!("cargo:rustc-link-search={setjmp_link_dir}");
println!("cargo:rustc-link-lib=static=setjmp-mt");
}
}