Skip to content

Commit

Permalink
Merge pull request #491 from matrix-org/master
Browse files Browse the repository at this point in the history
Read architecture from node-gyp correctly
  • Loading branch information
dherman authored May 16, 2020
2 parents 0271c62 + fe3bdfc commit 8a716b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
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));
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

0 comments on commit 8a716b1

Please sign in to comment.