Skip to content

Commit

Permalink
apply patches with patch files
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Mar 30, 2024
1 parent e9bbb34 commit 99b2d15
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 43 deletions.
52 changes: 9 additions & 43 deletions nix/deps/nodejs-patched/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

{ stdenv, deps, nodejs, patchMavenSources }:

let
patchesDir = ./../../../patches;
patches = builtins.attrNames (builtins.readDir patchesDir);
in
stdenv.mkDerivation {
name = "${deps.nodejs.name}-patched";
phases = [
"unpackPhase"
"patchGradlePhase"
"patchBuildIdPhase"
"patchKeyChainPhase"
"patchGlogPhase"
"patchNativeNavigationPhase"
"patchRNScriptPhase"
"patchNodeLibsPhase"
"installPhase"
];

Expand Down Expand Up @@ -50,49 +50,15 @@ stdenv.mkDerivation {
done
'';

# Do not add a BuildId to the generated libraries, for reproducibility
patchBuildIdPhase = ''
substituteInPlace ./node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists.txt --replace \
'-Wl,--build-id' \
'-Wl,--build-id=none'
'';

installPhase = ''
mkdir -p $out
cp -R node_modules $out/
'';

# Remove gradle-test-logger-plugin:
# https://github.com/oblador/react-native-keychain/issues/595
# TODO: remove this patch when we this library fixes above issue
patchKeyChainPhase = ''
sed -i -e '/classpath/d' \
-e '/apply plugin: "com\.adarshr\.test-logger"/d' \
./node_modules/react-native-keychain/android/build.gradle
'';

# Fix pod issue after upgrading to MacOS Sonoma and Xcode 15
# https://github.com/status-im/status-mobile/issues/17682
patchGlogPhase = ''
substituteInPlace ./node_modules/react-native/scripts/ios-configure-glog.sh \
--replace 'export CC="' '#export CC="' \
--replace 'export CXX="' '#export CXX="'
'';

# https://github.com/wix/react-native-navigation/issues/7819
patchNativeNavigationPhase = ''
substituteInPlace ./node_modules/react-native-navigation/lib/android/app/build.gradle \
--replace 'JavaVersion.VERSION_1_8' 'JavaVersion.VERSION_17'
substituteInPlace ./node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt \
--replace 'host: View?,' 'host: View,' \
--replace 'info: AccessibilityNodeInfoCompat?' 'info: AccessibilityNodeInfoCompat'
'';

# to fix https://github.com/status-im/status-mobile/issues/18548
patchRNScriptPhase = ''
substituteInPlace ./node_modules/react-native/scripts/react_native_pods_utils/script_phases.sh \
--replace 'cp -R -X' 'cp -R'
patchNodeLibsPhase = ''
for patch in ${toString patches}; do
patch -p1 < ${patchesDir}/$patch
done
'';

# The ELF types are incompatible with the host platform, so let's not even try
Expand Down
11 changes: 11 additions & 0 deletions patches/react-native-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- ./node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists.txt 2024-03-29 18:48:40
+++ ./node_modules/react-native/ReactAndroid/src/main/jni/CMakeLists-patched.txt 2024-03-29 18:51:54
@@ -21,7 +21,7 @@
endif(CCACHE_FOUND)

# Make sure every shared lib includes a .note.gnu.build-id header
-add_link_options(-Wl,--build-id)
+add_link_options(-Wl,--build-id=none)
add_compile_options(-Wall -Werror -std=c++20)

function(add_react_android_subdir relative_path)
20 changes: 20 additions & 0 deletions patches/react-native-keychain.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Remove gradle-test-logger-plugin:
# https://github.com/oblador/react-native-keychain/issues/595
# TODO: remove this patch when we this library fixes above issue

--- ./node_modules/react-native-keychain/android/build.gradle 2024-03-29 16:45:37
+++ ./node_modules/react-native-keychain/android/build-patched.gradle 2024-03-29 18:44:12
@@ -4,13 +4,9 @@
url 'https://plugins.gradle.org/m2/'
}
}
- dependencies {
- classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0'
- }
}

apply plugin: 'com.android.library'
-apply plugin: "com.adarshr.test-logger"

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
22 changes: 22 additions & 0 deletions patches/react-native-navigation-button-presenter.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://github.com/wix/react-native-navigation/issues/7819

--- ./node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt 2024-03-29 15:35:03
+++ ./node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter-patched.kt 2024-03-29 16:05:15
@@ -194,8 +194,8 @@

class WixAccessibilityDelegateCompat: AccessibilityDelegateCompat(){
override fun onInitializeAccessibilityNodeInfo(
- host: View?,
- info: AccessibilityNodeInfoCompat?
+ host: View,
+ info: AccessibilityNodeInfoCompat
) {
super.onInitializeAccessibilityNodeInfo(host, info)

@@ -216,4 +216,4 @@
}


-}
\ No newline at end of file
+}
19 changes: 19 additions & 0 deletions patches/react-native-navigation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://github.com/wix/react-native-navigation/issues/7819

--- ./node_modules/react-native-navigation/lib/android/app/build.gradle 2024-03-29 15:35:04
+++ ./node_modules/react-native-navigation/lib/android/app/build-patched.gradle 2024-03-29 15:39:48
@@ -62,11 +62,11 @@
}
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8
+ jvmTarget = JavaVersion.VERSION_17
}

flavorDimensions "RNN.reactNativeVersion"
13 changes: 13 additions & 0 deletions patches/react-native-script.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# to fix https://github.com/status-im/status-mobile/issues/18548

--- ./node_modules/react-native/scripts/react_native_pods_utils/script_phases.sh 2024-03-29 17:16:30
+++ ./node_modules/react-native/scripts/react_native_pods_utils/script_phases-patched.sh 2024-03-29 17:16:46
@@ -104,7 +104,7 @@
mkdir -p "$RCT_SCRIPT_OUTPUT_DIR"

# Copy all output to output_dir
- cp -R -X "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1
+ cp -R "$TEMP_OUTPUT_DIR/." "$RCT_SCRIPT_OUTPUT_DIR" || exit 1
echo "$LIBRARY_NAME output has been written to $RCT_SCRIPT_OUTPUT_DIR:" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
ls -1 "$RCT_SCRIPT_OUTPUT_DIR" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
}
15 changes: 15 additions & 0 deletions patches/react-native.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fix pod issue after upgrading to MacOS Sonoma and Xcode 15
# https://github.com/status-im/status-mobile/issues/17682

--- ./node_modules/react-native/scripts/ios-configure-glog.sh 2024-03-29 14:43:11
+++ ./node_modules/react-native/scripts/ios-configure-glog-patched.sh 2024-03-29 14:43:11
@@ -42,9 +42,6 @@
patch -p1 config.sub fix_glog_0.3.5_apple_silicon.patch
fi

-export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
-export CXX="$CC"
-
# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
rm test-driver

0 comments on commit 99b2d15

Please sign in to comment.