Skip to content

Commit

Permalink
plugin: use alternative nodejs-mobile-gyp path
Browse files Browse the repository at this point in the history
Tries to use nodejs-mobile-gyp from inside nodejs-mobile-react-native
when npm doesn't flatten node_modules.
  • Loading branch information
jaimecbernardo committed Jun 19, 2018
1 parent 757294e commit 222f953
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,13 @@ if ("1".equals(shouldRebuildNativeModules)) {
commandLine npmCommandName, '--verbose', 'rebuild', '--build-from-source'
environment ('npm_config_node_engine', 'v8' )
environment ('npm_config_nodedir', "${project.projectDir}/libnode/" )
environment ('npm_config_node_gyp', "${project.projectDir}/../../nodejs-mobile-gyp/bin/node-gyp.js" )
String npm_gyp_path_to_use; // Check common paths for nodejs-mobile-gyp
if ( file("${project.projectDir}/../../nodejs-mobile-gyp/bin/node-gyp.js").exists() ) {
npm_gyp_path_to_use = "${project.projectDir}/../../nodejs-mobile-gyp/bin/node-gyp.js";
} else {
npm_gyp_path_to_use = "${project.projectDir}/../node_modules/nodejs-mobile-gyp/bin/node-gyp.js";
}
environment ('npm_config_node_gyp', npm_gyp_path_to_use )
environment ('npm_config_arch', temp_arch)
environment ('npm_config_platform', 'android')
environment ('npm_config_format', 'make-android')
Expand Down
6 changes: 5 additions & 1 deletion scripts/module-postlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ if [ -d "$CODESIGNING_FOLDER_PATH"/nodejs-project/node_modules/ ]; then
node "$PATCH_SCRIPT_DIR"/patch-package.js $NODEJS_PROJECT_MODULES_DIR
fi
# Get the nodejs-mobile-gyp location
NODEJS_MOBILE_GYP_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-gyp/ && pwd )"
if [ -d "$PROJECT_DIR/../node_modules/nodejs-mobile-gyp/" ]; then
NODEJS_MOBILE_GYP_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-gyp/ && pwd )"
else
NODEJS_MOBILE_GYP_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/node_modules/nodejs-mobile-gyp/ && pwd )"
fi
NODEJS_MOBILE_GYP_BIN_FILE="$NODEJS_MOBILE_GYP_DIR"/bin/node-gyp.js
# Rebuild modules with right environment
NODEJS_HEADERS_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/ios/libnode/ && pwd )"
Expand Down

0 comments on commit 222f953

Please sign in to comment.