From 700bbd63332362bdcd953631abe4233b016d07af Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 18 Feb 2020 15:15:01 +0000 Subject: [PATCH 1/3] Attempt to fix architecture detection It was executing node-gyp configure and trying to read the arch from the output, but was doing so by looking at a string that printed was platform gyp was running on rather than the target platform. node-gyp --build does output the target architecture though, so parse it from that. --- crates/neon-sys/build.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/neon-sys/build.rs b/crates/neon-sys/build.rs index e156b3201..3ae6ea6e3 100644 --- a/crates/neon-sys/build.rs +++ b/crates/neon-sys/build.rs @@ -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\d+\.\d+\.\d+)\s+\|\s+(?P\w+)\s+\|\s(?Pia32|x64)").unwrap(); + let version_regex = Regex::new(r"gyp verb architecture (?Pia32|x64)").unwrap(); let captures = version_regex.captures(&node_gyp_output).unwrap(); String::from(&captures["arch"]) } @@ -164,18 +164,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. From 606825b647e11a102e6d542f78c1c8ddca28638f Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 18 Feb 2020 19:43:28 +0000 Subject: [PATCH 2/3] Need verbose flag to build to output architecture --- crates/neon-sys/native/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/neon-sys/native/package.json b/crates/neon-sys/native/package.json index b01ff4c97..13217fea1 100644 --- a/crates/neon-sys/native/package.json +++ b/crates/neon-sys/native/package.json @@ -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", From fe3bdfc949350c0b3f4f7d549fa4e63e5ce5ec75 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 18 Feb 2020 21:12:06 +0000 Subject: [PATCH 3/3] Put node_gyp_output back That line needs to stay for the root dir / lib file --- crates/neon-sys/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/neon-sys/build.rs b/crates/neon-sys/build.rs index 3ae6ea6e3..2db6d0d77 100644 --- a/crates/neon-sys/build.rs +++ b/crates/neon-sys/build.rs @@ -164,6 +164,7 @@ mod build { } if cfg!(windows) { + let node_gyp_output = String::from_utf8_lossy(&output.stderr); println!("cargo:node_root_dir={}", parse_node_root_dir(&node_gyp_output)); println!("cargo:node_lib_file={}", parse_node_lib_file(&node_gyp_output)); }