Skip to content

Commit

Permalink
android: use original .bin for native modules
Browse files Browse the repository at this point in the history
Uses the original project's .bin folder when building native modules
for Android. Gradle's copy tasks resolve the symbolic links instead
of preserving them, which causes fails while building modules that
depend on linked build tools, such as node-pre-gyp. With this change,
the native modules build step will try to use the original project's
linked binaries.
  • Loading branch information
jaimecbernardo committed Jun 27, 2018
1 parent 209f541 commit ded08e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ if ("1".equals(shouldRebuildNativeModules)) {
copy {
from "${rootProject.projectDir}/../nodejs-assets/nodejs-project/"
into "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/"
// Symlinks to binaries will be resolved by Gradle during the copy, causing build time errors.
// The original project's .bin folder will be added to the path while building in the BuildNpmModules tasks.
exclude "**/.bin"
}
if (OperatingSystem.current().isMacOsX()) {
// Copy the helper scripts for calling npm and node when building in Android Studio on macOS.
Expand Down Expand Up @@ -302,6 +305,15 @@ if ("1".equals(shouldRebuildNativeModules)) {
environment ('npm_config_arch', temp_arch)
environment ('npm_config_platform', 'android')
environment ('npm_config_format', 'make-android')

// Adds the original project .bin to the path. It's a workaround
// to correctly build some modules that depend on symlinked modules,
// like node-pre-gyp.
String original_project_bin = "${rootProject.projectDir}/../nodejs-assets/nodejs-project/node_modules/.bin";
if(file(original_project_bin).exists()) {
environment ('PATH', "${original_project_bin}" + System.getProperty("path.separator") + "${System.env.PATH}")
}

environment ('TOOLCHAIN',"${standalone_toolchain}")
environment ('AR',"${npm_toolchain_ar}")
environment ('CC',"${npm_toolchain_cc}")
Expand Down

0 comments on commit ded08e5

Please sign in to comment.