From 7780f2017817723de53123a268578c89b96235e1 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Mon, 5 Mar 2018 09:54:52 +0000 Subject: [PATCH] plugin: remove native modules detection --- README.md | 18 ------------------ android/build.gradle | 16 ---------------- scripts/module-postlink.js | 16 ---------------- 3 files changed, 50 deletions(-) diff --git a/README.md b/README.md index 1175871..88982ef 100644 --- a/README.md +++ b/README.md @@ -57,24 +57,6 @@ To expedite the process of extracting the assets files, instead of parsing the a Node modules can be added to the project using `npm install` inside `nodejs-assets/nodejs-project/`, as long as there's a `package.json` already present. -#### Native Modules - -On Linux and macOS, there is experimental support for building modules that contain native code. - -The plugin automatically detects native modules inside your `nodejs-project` folder by searching for `.gyp` files. It's recommended to have the build prerequisites mentioned in `nodejs-mobile` for [Android](https://github.com/janeasystems/nodejs-mobile#prerequisites-to-build-the-android-library-on-linux-ubuntudebian) and [iOS](https://github.com/janeasystems/nodejs-mobile#prerequisites-to-build-the-ios-framework-library-on-macos). For Android it's also recommended that you set the `ANDROID_NDK_HOME` environment variable in your system. - -Building native modules for Android can take a long time, since it depends on building a standalone NDK toolchain for each required architecture. The resulting `.node` binaries are then included in the final application in a separate asset path for each architecture and the correct one will be chosen at runtime. - -While the plugin tries to detect automatically the presence of native modules, there's a way to override this detection and turn the native modules build process on or off, by creating the `nodejs-assets/BUILD_NATIVE_MODULES.txt` and setting its contents to `1` or `0`, respectively. This can be used to start your application like this: -```sh -echo "1" > nodejs-assets/BUILD_NATIVE_MODULES.txt -react-native run-android -``` -```sh -echo "1" > nodejs-assets/BUILD_NATIVE_MODULES.txt -react-native run-ios -``` - ### `React-Native` application To communicate with Node.js from your `react-native` application, first import `nodejs-mobile-react-native`. diff --git a/android/build.gradle b/android/build.gradle index 976bc2b..1d0061e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -114,22 +114,6 @@ 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: "${rootProject.projectDir}/../nodejs-assets/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'; diff --git a/scripts/module-postlink.js b/scripts/module-postlink.js index df6bc14..c8dc799 100644 --- a/scripts/module-postlink.js +++ b/scripts/module-postlink.js @@ -154,14 +154,6 @@ NODEJS_ASSETS_DIR="$( cd "$PROJECT_DIR" && cd ../nodejs-assets/ && pwd )" PREFERENCE_FILE_PATH="$NODEJS_ASSETS_DIR/BUILD_NATIVE_MODULES.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/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 @@ -207,14 +199,6 @@ NODEJS_ASSETS_DIR="$( cd "$PROJECT_DIR" && cd ../nodejs-assets/ && pwd )" PREFERENCE_FILE_PATH="$NODEJS_ASSETS_DIR/BUILD_NATIVE_MODULES.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/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