File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
1
fn main ( ) {
2
2
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
+ } ;
6
12
}
7
13
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" ;
10
22
let arch = "x64" ;
11
23
let url = format ! (
12
24
"https://nodejs.org/dist/{version}/win-{arch}/node.lib" ,
@@ -17,7 +29,6 @@ fn windows_link_node_import_library() {
17
29
let out_dir = std:: path:: PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
18
30
let node_lib_path = out_dir. join ( "node.lib" ) ;
19
31
std:: fs:: write ( node_lib_path, node_lib_bytes) . unwrap ( ) ;
20
- println ! ( "cargo:rerun-if-changed=build.rs" ) ;
21
32
println ! ( "cargo:rustc-link-search={}" , out_dir. to_str( ) . unwrap( ) ) ;
22
33
println ! ( "cargo:rustc-link-lib=node" ) ;
23
34
}
You can’t perform that action at this time.
0 commit comments