diff --git a/crates/neon-build/src/lib.rs b/crates/neon-build/src/lib.rs index 0856f6409..c780cf78a 100644 --- a/crates/neon-build/src/lib.rs +++ b/crates/neon-build/src/lib.rs @@ -1,4 +1,5 @@ use std::env; +use std::path::Path; /// Set up the build environment by setting Cargo configuration variables. pub fn setup() { @@ -7,7 +8,9 @@ pub fn setup() { let configuration = if debug { "Debug" } else { "Release" }; let node_root_dir = env::var("DEP_NEON_RUNTIME_NODE_ROOT_DIR").unwrap(); let node_lib_file = env::var("DEP_NEON_RUNTIME_NODE_LIB_FILE").unwrap(); + let node_lib_path = Path::new(&node_lib_file); println!("cargo:rustc-link-search={}\\{}", node_root_dir, configuration); - println!("cargo:rustc-link-lib={}", node_lib_file); + println!("cargo:rustc-link-search=native={}", &node_lib_path.parent().unwrap().display()); + println!("cargo:rustc-link-lib={}", &node_lib_path.file_stem().unwrap().to_str().unwrap()); } } diff --git a/crates/neon-runtime/build.rs b/crates/neon-runtime/build.rs index d0d311976..968cccf04 100644 --- a/crates/neon-runtime/build.rs +++ b/crates/neon-runtime/build.rs @@ -57,8 +57,9 @@ fn build_object_file() { .find(node_lib_file_flag_pattern) .map(|i| i + node_lib_file_flag_pattern.len()) .expect("Couldn't find node_lib_file in node-gyp output."); - let node_lib_file_end_index = node_gyp_output[node_lib_file_start_index..].find(".lib").unwrap() + node_lib_file_start_index; - println!("cargo:node_lib_file={}", &node_gyp_output[node_lib_file_start_index..node_lib_file_end_index]); + let node_lib_file_end_index = node_gyp_output[node_lib_file_start_index..].find("'").unwrap() + node_lib_file_start_index; + let node_lib_file = &node_gyp_output[node_lib_file_start_index..node_lib_file_end_index]; + println!("cargo:node_lib_file={}", node_lib_file); } // Run `node-gyp build`.