Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read architecture from node-gyp correctly #491

Merged
merged 3 commits into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions crates/neon-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ mod build {
cmd
}

// The node-gyp output includes platform information in a string
// The node-gyp build output includes platform information in a string
// that looks like:
//
// gyp info using node@8.3.0 | win32 | x64
// gyp verb architecture ia32
fn parse_node_arch(node_gyp_output: &str) -> String {
let version_regex = Regex::new(r"node@(?P<version>\d+\.\d+\.\d+)\s+\|\s+(?P<platform>\w+)\s+\|\s(?P<arch>ia32|x64)").unwrap();
let version_regex = Regex::new(r"gyp verb architecture (?P<arch>ia32|x64)").unwrap();
let captures = version_regex.captures(&node_gyp_output).unwrap();
String::from(&captures["arch"])
}
Expand Down Expand Up @@ -165,17 +165,19 @@ mod build {

if cfg!(windows) {
let node_gyp_output = String::from_utf8_lossy(&output.stderr);
println!("cargo:node_arch={}", parse_node_arch(&node_gyp_output));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_gyp_output no longer exists. Does it need to be passed into this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - that line shouldn't have been deleted - fixed. (For complex dependency reasons I had to backport the fix to 0.3.x to test it and had to manually merge as the indenting level had changed, so must have missed this one).

println!("cargo:node_root_dir={}", parse_node_root_dir(&node_gyp_output));
println!("cargo:node_lib_file={}", parse_node_lib_file(&node_gyp_output));
}

// Run `node-gyp build`.
npm(native_dir)
let build_output = npm(native_dir)
.args(&["run", if debug() { "build-debug" } else { "build-release" }])
.status()
.output()
.ok()
.expect("Failed to run \"node-gyp build\" for neon-sys!");

let node_gyp_build_output = String::from_utf8_lossy(&build_output.stderr);
println!("cargo:node_arch={}", parse_node_arch(&node_gyp_build_output));
}

// Link the built object file into a static library.
Expand Down
4 changes: 2 additions & 2 deletions crates/neon-sys/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"preinstall": "echo 'Skipping node-gyp installation as part of npm install.'",
"configure-release": "node-gyp configure --verbose",
"configure-debug": "node-gyp configure --verbose --debug",
"build-release": "node-gyp build",
"build-debug": "node-gyp build --debug"
"build-release": "node-gyp build --verbose",
"build-debug": "node-gyp build --verbose --debug"
},
"dependencies": {
"bindings": "1.2.1",
Expand Down