Skip to content

Commit

Permalink
plugin: use nodejs-mobile-gyp for native modules
Browse files Browse the repository at this point in the history
Adds nodejs-mobile-gyp as a dependency and uses it to build native
modules for greater compatibility.
  • Loading branch information
jaimecbernardo committed Feb 14, 2018
1 parent 3041ede commit 488974d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions install/hooks/ios/after-plugin-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ module.exports = function(context) {
var rebuildNativeModulesBuildPhaseScript = `
if [ "1" != "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then exit 0; fi
set -e
# Get the nodejs-mobile-gyp location
NODEJS_MOBILE_GYP_DIR="$( cd "$PROJECT_DIR" && cd ../../plugins/nodejs-mobile-cordova/node_modules/nodejs-mobile-gyp/ && pwd )"
NODEJS_MOBILE_GYP_BIN_FILE="$NODEJS_MOBILE_GYP_DIR"/bin/node-gyp.js
# Rebuild modules with right environment
NODEJS_HEADERS_DIR="$( cd "$( dirname "$PRODUCT_SETTINGS_PATH" )" && cd Plugins/nodejs-mobile-cordova/ && pwd )"
pushd $CODESIGNING_FOLDER_PATH/www/nodejs-project/
if [ "$PLATFORM_NAME" == "iphoneos" ]
then
GYP_DEFINES="OS=ios" npm_config_nodedir="$NODEJS_HEADERS_DIR" npm_config_platform="ios" npm_config_node_engine="chakracore" npm_config_arch="arm64" npm --verbose rebuild --build-from-source
GYP_DEFINES="OS=ios" npm_config_nodedir="$NODEJS_HEADERS_DIR" npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" npm_config_platform="ios" npm_config_node_engine="chakracore" npm_config_arch="arm64" npm --verbose rebuild --build-from-source
else
GYP_DEFINES="OS=ios" npm_config_nodedir="$NODEJS_HEADERS_DIR" npm_config_platform="ios" npm_config_node_engine="chakracore" npm_config_arch="x64" npm --verbose rebuild --build-from-source
GYP_DEFINES="OS=ios" npm_config_nodedir="$NODEJS_HEADERS_DIR" npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" npm_config_platform="ios" npm_config_node_engine="chakracore" npm_config_arch="x64" npm --verbose rebuild --build-from-source
fi
popd
`
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"author": "janeasystems",
"license": "MIT",
"dependencies": {
"nodejs-mobile-gyp": "^0.1.0",
"tar.gz2": "^1.0.0"
},
"homepage": "https://code.janeasystems.com/nodejs-mobile",
Expand Down
1 change: 1 addition & 0 deletions src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ if ("1".equals(System.getenv('NODEJS_MOBILE_BUILD_NATIVE_MODULES'))) {
//environment ('PATH', "${npm_toolchain_add_to_path}" + System.getProperty("path.separator") + "${System.env.PATH}")
environment ('npm_config_node_engine', 'v8' )
environment ('npm_config_nodedir', "${project.projectDir}/src/com/janeasystems/cdvnodejsmobile/jni/libnode/" )
environment ('npm_config_node_gyp', "${rootProject.projectDir}/../../plugins/nodejs-mobile-cordova/node_modules/nodejs-mobile-gyp/bin/node-gyp.js" )
environment ('npm_config_arch', temp_arch)
environment ('npm_config_platform', 'android')
environment ('npm_config_format', 'make-android')
Expand Down

0 comments on commit 488974d

Please sign in to comment.