File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11fn main ( ) {
22 let target_os = std:: env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap ( ) ;
3- if target_os == "windows" {
4- windows_link_node_import_library ( ) ;
5- }
3+ match target_os. as_str ( ) {
4+ "macos" => {
5+ macos_setup ( ) ;
6+ }
7+ "windows" => {
8+ windows_setup ( ) ;
9+ }
10+ _ => { }
11+ } ;
612}
713
8- fn windows_link_node_import_library ( ) {
9- let version = "v15.9.0" ;
14+ fn macos_setup ( ) {
15+ println ! ( "cargo:rustc-cdylib-link-arg=-Wl" ) ;
16+ println ! ( "cargo:rustc-cdylib-link-arg=-undefined" ) ;
17+ println ! ( "cargo:rustc-cdylib-link-arg=dynamic_lookup" ) ;
18+ }
19+
20+ fn windows_setup ( ) {
21+ let version = "v16.4.0" ;
1022 let arch = "x64" ;
1123 let url = format ! (
1224 "https://nodejs.org/dist/{version}/win-{arch}/node.lib" ,
@@ -17,7 +29,6 @@ fn windows_link_node_import_library() {
1729 let out_dir = std:: path:: PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
1830 let node_lib_path = out_dir. join ( "node.lib" ) ;
1931 std:: fs:: write ( node_lib_path, node_lib_bytes) . unwrap ( ) ;
20- println ! ( "cargo:rerun-if-changed=build.rs" ) ;
2132 println ! ( "cargo:rustc-link-search={}" , out_dir. to_str( ) . unwrap( ) ) ;
2233 println ! ( "cargo:rustc-link-lib=node" ) ;
2334}
You can’t perform that action at this time.
0 commit comments