Skip to content

Commit db31872

Browse files
committed
Fix linking neon-runtime on windows.
-l is only intended to communicate the names of libraries See rust-lang/rust#38850 for more details.
1 parent dc91f46 commit db31872

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

crates/neon-build/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::env;
2+
use std::path::Path;
23

34
/// Set up the build environment by setting Cargo configuration variables.
45
pub fn setup() {
@@ -7,7 +8,10 @@ pub fn setup() {
78
let configuration = if debug { "Debug" } else { "Release" };
89
let node_root_dir = env::var("DEP_NEON_RUNTIME_NODE_ROOT_DIR").unwrap();
910
let node_lib_file = env::var("DEP_NEON_RUNTIME_NODE_LIB_FILE").unwrap();
11+
let node_lib_path = Path::new(&node_lib_file);
1012
println!("cargo:rustc-link-search={}\\{}", node_root_dir, configuration);
11-
println!("cargo:rustc-link-lib={}", node_lib_file);
13+
//println!("cargo:rustc-link-search=native={}", &node_lib_path.parent().unwrap().display());
14+
println!("cargo:rustc-link-search=native={}", "C:\\Users\\Languages\\.node-gyp\\8.2.1\\x64");
15+
println!("cargo:rustc-link-lib={}", &node_lib_path.file_stem().unwrap().to_str().unwrap());
1216
}
1317
}

crates/neon-runtime/build.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ fn build_object_file() {
5757
.find(node_lib_file_flag_pattern)
5858
.map(|i| i + node_lib_file_flag_pattern.len())
5959
.expect("Couldn't find node_lib_file in node-gyp output.");
60-
let node_lib_file_end_index = node_gyp_output[node_lib_file_start_index..].find(".lib").unwrap() + node_lib_file_start_index;
61-
println!("cargo:node_lib_file={}", &node_gyp_output[node_lib_file_start_index..node_lib_file_end_index]);
60+
let node_lib_file_end_index = node_gyp_output[node_lib_file_start_index..].find("'").unwrap() + node_lib_file_start_index;
61+
let node_lib_file = &node_gyp_output[node_lib_file_start_index..node_lib_file_end_index];
62+
println!("cargo:node_lib_file={}", node_lib_file);
6263
}
6364

6465
// Run `node-gyp build`.

0 commit comments

Comments
 (0)