Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Patch nodejs-mobile to specify NDK version #757

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ jobs:
with:
java-version: "openjdk8"
architecture: "x64"
# Our build will otherwise use NDK 22, which does not work.
- name: Delete newer NDK version
run: rm -rf $ANDROID_HOME/ndk/22*
- name: Install node_modules
run: |
mkdir -p nodejs-assets
Expand Down
4 changes: 4 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ assets (e.g. presets)

Patch the build process to use the prebuilt toolchain that is now included in NDK, rather than build the toolchain as part of the build process. This increases build speed and avoids errors trying to build the toolchain.

### Specify NDK version

`nodejs-mobile-react-native` seems to fail with NDK version 22 and 23. The patch specifies the NDK version in the `nodejs-mobile-react-native` `build.gradle`.

## `react-native`

This patch adds an environment variable `APP_VARIANT` with the app variant name
Expand Down
30 changes: 19 additions & 11 deletions patches/nodejs-mobile-react-native+0.6.1.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
diff --git a/node_modules/nodejs-mobile-react-native/android/build.gradle b/node_modules/nodejs-mobile-react-native/android/build.gradle
index b6dccc4..44ba494 100644
index b6dccc4..9f69488 100644
--- a/node_modules/nodejs-mobile-react-native/android/build.gradle
+++ b/node_modules/nodejs-mobile-react-native/android/build.gradle
@@ -261,51 +261,59 @@ if ("1".equals(shouldRebuildNativeModules)) {
@@ -50,6 +50,7 @@ def _isCorrectSTLDefinedByApp = DoesAppAlreadyDefineWantedSTL()
android {
compileSdkVersion ((rootProject?.ext?.properties?.compileSdkVersion) ?: 23)
buildToolsVersion ((rootProject?.ext?.properties?.buildToolsVersion) ?: "23.0.1")
+ ndkVersion "21.4.7075529"

defaultConfig {
minSdkVersion _nodeMinSdkVersion
@@ -261,51 +262,59 @@ if ("1".equals(shouldRebuildNativeModules)) {
String temp_cc_ver = '4.9';
String temp_dest_cpu;
String temp_v8_arch;
Expand Down Expand Up @@ -56,7 +64,7 @@ index b6dccc4..44ba494 100644
throw new GradleException("Unsupported architecture for nodejs-mobile native modules: ${temp_arch}")
break
}

+ String temp_host_tag
+ if (OperatingSystem.current().isMacOsX()) {
+ temp_host_tag = 'darwin-x86_64'
Expand All @@ -79,12 +87,12 @@ index b6dccc4..44ba494 100644
+ String npm_toolchain_cxx = "${toolchain_path}/bin/${temp_compiler_prefix}-clang++"
+ String npm_toolchain_link = "${toolchain_path}/bin/${temp_compiler_prefix}-clang++"
String cargo_target_triple = cargo_build_target.toUpperCase().replaceAll('-', '_')

String npm_gyp_defines = "target_arch=${temp_arch}"
@@ -358,16 +366,8 @@ if ("1".equals(shouldRebuildNativeModules)) {
@@ -358,16 +367,8 @@ if ("1".equals(shouldRebuildNativeModules)) {
}
}

- task "MakeToolchain${abi_name}" (type:Exec) {
- description = "Building a native toolchain to compile nodejs-mobile native modules for ${abi_name}."
- executable = "${ndk_bundle_path}/build/tools/make-standalone-toolchain.sh"
Expand All @@ -98,10 +106,10 @@ index b6dccc4..44ba494 100644
description = "Building native modules for ${abi_name}."
inputs.file "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/copy.timestamp"
outputs.dir "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/"
@@ -398,7 +398,7 @@ if ("1".equals(shouldRebuildNativeModules)) {
@@ -398,7 +399,7 @@ if ("1".equals(shouldRebuildNativeModules)) {
environment ("CARGO_TARGET_${cargo_target_triple}_AR", "${npm_toolchain_ar}")
environment ("CARGO_TARGET_${cargo_target_triple}_LINKER", "${npm_toolchain_link}")

- environment ('TOOLCHAIN',"${standalone_toolchain}")
+ environment ('TOOLCHAIN',"${toolchain_path}")
environment ('AR',"${npm_toolchain_ar}")
Expand All @@ -126,9 +134,9 @@ index e882a0c..d5ed11a 100644
+ private static String nodeJsAssetsPath;
private static String builtinModulesPath;
private static String nativeAssetsPath;

@@ -74,6 +76,7 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements

// The paths where we expect the node project assets to be at runtime.
nodeJsProjectPath = filesDirPath + "/" + NODEJS_PROJECT_DIR;
+ nodeJsAssetsPath = filesDirPath + "/" + NODEJS_ASSETS_DIR;
Expand All @@ -138,7 +146,7 @@ index e882a0c..d5ed11a 100644
@@ -387,6 +390,9 @@ public class RNNodeJsMobileModule extends ReactContextBaseJavaModule implements
// Copy the nodejs built-in modules to the application's data path.
copyAssetFolder("builtin_modules", builtinModulesPath);

+ // Copy nodejs assets (e.g. presets) which can vary between variants
+ copyAssetFolder("nodejs-assets", nodeJsAssetsPath);
+
Expand Down