diff --git a/install/hooks/ios/after-plugin-install.js b/install/hooks/ios/after-plugin-install.js index 54820a8..fec9b7d 100644 --- a/install/hooks/ios/after-plugin-install.js +++ b/install/hooks/ios/after-plugin-install.js @@ -25,6 +25,14 @@ if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then PREFERENCE_FILE_PATH="$CODESIGNING_FOLDER_PATH/www/NODEJS_MOBILE_BUILD_NATIVE_MODULES_VALUE.txt" if [ -f "$PREFERENCE_FILE_PATH" ]; then NODEJS_MOBILE_BUILD_NATIVE_MODULES="$(cat $PREFERENCE_FILE_PATH | xargs)" + fi +fi +if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then +# If build native modules preference is not set, try to find .gyp files +#to turn it on. + gypfiles=($(find "$CODESIGNING_FOLDER_PATH/www/nodejs-project/" -type f -name "*.gyp")) + if [ \${#gypfiles[@]} -gt 0 ]; then + NODEJS_MOBILE_BUILD_NATIVE_MODULES=1 else NODEJS_MOBILE_BUILD_NATIVE_MODULES=0 fi @@ -80,6 +88,14 @@ if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then NODEJS_MOBILE_BUILD_NATIVE_MODULES="$(cat $PREFERENCE_FILE_PATH | xargs)" # Remove the preference file so it doesn't get in the application package. rm "$PREFERENCE_FILE_PATH" + fi +fi +if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then +# If build native modules preference is not set, try to find .gyp files +#to turn it on. + gypfiles=($(find "$CODESIGNING_FOLDER_PATH/www/nodejs-project/" -type f -name "*.gyp")) + if [ \${#gypfiles[@]} -gt 0 ]; then + NODEJS_MOBILE_BUILD_NATIVE_MODULES=1 else NODEJS_MOBILE_BUILD_NATIVE_MODULES=0 fi diff --git a/src/android/build.gradle b/src/android/build.gradle index 202e51a..365d716 100644 --- a/src/android/build.gradle +++ b/src/android/build.gradle @@ -57,6 +57,22 @@ if (shouldRebuildNativeModules==null) { } } +if (shouldRebuildNativeModules==null) { +// If build native modules preference is not set, try to find .gyp files to turn it on. + shouldRebuildNativeModules="0"; + def gyp_files_tree = fileTree( + dir: "${project.projectDir}/assets/www/nodejs-project/", + include: "**/*.gyp" + ); + gyp_files_tree.visit { gypFile -> + if (!gypFile.isDirectory()) { + // It's a .gyp file. + shouldRebuildNativeModules="1"; + gypFile.stopVisiting(); + } + } +} + if ("1".equals(shouldRebuildNativeModules)) { String npmCommandName = 'npm';