Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

patch reanimated 2 to support v8

Ammar Ahmed33b0a571406f
diff --git a/apps/mobile/patches/react-native-reanimated+1.13.3.patch b/apps/mobile/patches/react-native-reanimated+1.13.3.patch
deleted file mode 100644
index 246dacdf1..000000000
--- a/apps/mobile/patches/react-native-reanimated+1.13.3.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff --git a/node_modules/react-native-reanimated/android/build.gradle b/node_modules/react-native-reanimated/android/build.gradle
-index 21c386c..bb2b2af 100644
---- a/node_modules/react-native-reanimated/android/build.gradle
-+++ b/node_modules/react-native-reanimated/android/build.gradle
-@@ -18,7 +18,6 @@ buildscript {
- }
-
- apply plugin: 'com.android.library'
--apply plugin: 'maven'
-
- android {
- compileSdkVersion safeExtGet('compileSdkVersion', 28)
-@@ -120,14 +119,4 @@ afterEvaluate { project ->
- archives androidSourcesJar
- archives androidJavadocJar
- }
--
-- task installArchives(type: Upload) {
-- configuration = configurations.archives
-- repositories.mavenDeployer {
-- // Deploy to react-native-event-bridge/maven, ready to publish to npm
-- repository url: "file://${projectDir}/../android/maven"
--
-- configureReactNativePom pom
-- }
-- }
- }
diff --git a/apps/mobile/patches/react-native-reanimated+2.8.0.patch b/apps/mobile/patches/react-native-reanimated+2.8.0.patch
index e1d26451c..8c8341b1a 100644
--- a/apps/mobile/patches/react-native-reanimated+2.8.0.patch
+++ b/apps/mobile/patches/react-native-reanimated+2.8.0.patch
@@ -1,30 +1,201 @@
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock b/node_modules/react-native-reanimated/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock
+deleted file mode 100644
+index 6ac7fe6..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/dependencies-accessors/gc.properties b/node_modules/react-native-reanimated/android/.gradle/7.2/dependencies-accessors/gc.properties
+deleted file mode 100644
+index e69de29..0000000
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/executionHistory/executionHistory.bin b/node_modules/react-native-reanimated/android/.gradle/7.2/executionHistory/executionHistory.bin
+deleted file mode 100644
+index d9dc031..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/executionHistory/executionHistory.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/executionHistory/executionHistory.lock b/node_modules/react-native-reanimated/android/.gradle/7.2/executionHistory/executionHistory.lock
+deleted file mode 100644
+index 97d4dff..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/executionHistory/executionHistory.lock and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/fileChanges/last-build.bin b/node_modules/react-native-reanimated/android/.gradle/7.2/fileChanges/last-build.bin
+deleted file mode 100644
+index f76dd23..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/fileChanges/last-build.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/fileHashes.bin b/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/fileHashes.bin
+deleted file mode 100644
+index ed1f2b7..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/fileHashes.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/fileHashes.lock b/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/fileHashes.lock
+deleted file mode 100644
+index 4879334..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/fileHashes.lock and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/resourceHashesCache.bin b/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/resourceHashesCache.bin
+deleted file mode 100644
+index 5f19386..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/7.2/fileHashes/resourceHashesCache.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/7.2/gc.properties b/node_modules/react-native-reanimated/android/.gradle/7.2/gc.properties
+deleted file mode 100644
+index e69de29..0000000
+diff --git a/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
+deleted file mode 100644
+index 3ec0901..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/cache.properties b/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/cache.properties
+deleted file mode 100644
+index a77fc64..0000000
+--- a/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/cache.properties
++++ /dev/null
+@@ -1,2 +0,0 @@
+-#Thu Apr 21 15:44:53 UTC 2022
+-gradle.version=7.2
+diff --git a/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/outputFiles.bin b/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/outputFiles.bin
+deleted file mode 100644
+index bd1926f..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/buildOutputCleanup/outputFiles.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/checksums/checksums.lock b/node_modules/react-native-reanimated/android/.gradle/checksums/checksums.lock
+deleted file mode 100644
+index 1337501..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/checksums/checksums.lock and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/checksums/md5-checksums.bin b/node_modules/react-native-reanimated/android/.gradle/checksums/md5-checksums.bin
+deleted file mode 100644
+index 9588d7e..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/checksums/md5-checksums.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/checksums/sha1-checksums.bin b/node_modules/react-native-reanimated/android/.gradle/checksums/sha1-checksums.bin
+deleted file mode 100644
+index b104bf9..0000000
+Binary files a/node_modules/react-native-reanimated/android/.gradle/checksums/sha1-checksums.bin and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/.gradle/vcs-1/gc.properties b/node_modules/react-native-reanimated/android/.gradle/vcs-1/gc.properties
+deleted file mode 100644
+index e69de29..0000000
diff --git a/node_modules/react-native-reanimated/android/CMakeLists.txt b/node_modules/react-native-reanimated/android/CMakeLists.txt
-index e6ff5f2..945b1fb 100644
+index e6ff5f2..a0c884f 100644
--- a/node_modules/react-native-reanimated/android/CMakeLists.txt
+++ b/node_modules/react-native-reanimated/android/CMakeLists.txt
-@@ -1,3 +1,4 @@
+@@ -1,49 +1,50 @@
++
+project(Reanimated)
cmake_minimum_required(VERSION 3.5.1)
set (CMAKE_VERBOSE_MAKEFILE ON)
-@@ -13,6 +14,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+ set (CMAKE_CXX_STANDARD 14)
+-set (CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID -DFOR_HERMES=${FOR_HERMES} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare")
++set (CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare")
+
+-if(${NATIVE_DEBUG})
++if (${NATIVE_DEBUG})
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
+-endif()
++endif ()
+
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
- set (PACKAGE_NAME "reanimated")
-+set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
- set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
+-set (PACKAGE_NAME "reanimated")
+-set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
++set(PACKAGE_NAME "reanimated")
++set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
++set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
- if(${CLIENT_SIDE_BUILD})
-@@ -119,26 +121,18 @@ find_library(
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
+-if(${CLIENT_SIDE_BUILD})
+- set (NODE_MODULES_DIR "${CMAKE_SOURCE_DIR}/../../")
+- set (COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common")
+-else()
+- set (NODE_MODULES_DIR "../node_modules")
+- set (COMMON_SRC_DIR "${SRC_DIR}/main/Common")
+-endif()
++if (${CLIENT_SIDE_BUILD})
++ set(COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common")
++else ()
++ set(COMMON_SRC_DIR "${SRC_DIR}/main/Common")
++endif ()
+
+-set (RN_SO_DIR ${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/first-party/react/jni)
+-set (FBJNI_HEADERS_DIR ${RN_SO_DIR}/../../fbjni/headers)
++set(RN_SO_DIR ${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/first-party/react/jni)
++set(FBJNI_HEADERS_DIR ${RN_SO_DIR}/../../fbjni/headers)
+
+ # reanimated shared
+
+-file(GLOB sources_tools "${COMMON_SRC_DIR}/cpp/Tools/*.cpp")
+-file(GLOB sources_native_modules "${COMMON_SRC_DIR}/cpp/NativeModules/*.cpp")
+-file(GLOB sources_shared_items "${COMMON_SRC_DIR}/cpp/SharedItems/*.cpp")
+-file(GLOB sources_registries "${COMMON_SRC_DIR}/cpp/Registries/*.cpp")
+-file(GLOB sources_android "${SRC_DIR}/main/cpp/*.cpp")
+-
+-if(${REACT_NATIVE_TARGET_VERSION} LESS 66)
+- set (
+- INCLUDE_JSI_CPP
+- "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
+- )
+- set (
+- INCLUDE_JSIDYNAMIC_CPP
+- "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/JSIDynamic.cpp"
+- )
+-endif()
++file(GLOB sources_tools "${COMMON_SRC_DIR}/cpp/Tools/*.cpp")
++file(GLOB sources_native_modules "${COMMON_SRC_DIR}/cpp/NativeModules/*.cpp")
++file(GLOB sources_shared_items "${COMMON_SRC_DIR}/cpp/SharedItems/*.cpp")
++file(GLOB sources_registries "${COMMON_SRC_DIR}/cpp/Registries/*.cpp")
++file(GLOB sources_android "${SRC_DIR}/main/cpp/*.cpp")
++
++if (${REACT_NATIVE_TARGET_VERSION} LESS 66)
++ set(
++ INCLUDE_JSI_CPP
++ "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
++ )
++ set(
++ INCLUDE_JSIDYNAMIC_CPP
++ "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/JSIDynamic.cpp"
++ )
++endif ()
+
+ add_library(
+ ${PACKAGE_NAME}
+@@ -67,7 +68,7 @@ add_library(
+
+ # includes
+
+-file (GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR})
++file(GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR})
+
+ target_include_directories(
+ ${PACKAGE_NAME}
+@@ -86,7 +87,6 @@ target_include_directories(
+ "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
+ "${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
+ "${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule"
+- "${NODE_MODULES_DIR}/hermes-engine/android/include/"
+ "${COMMON_SRC_DIR}/cpp/headers/Tools"
+ "${COMMON_SRC_DIR}/cpp/headers/SpecTools"
+ "${COMMON_SRC_DIR}/cpp/headers/NativeModules"
+@@ -100,45 +100,25 @@ target_include_directories(
+
+ # find libraries
+
+-file (GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}")
+-file (GLOB HERMES_DIR "${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}")
++file(GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}")
+
+ find_library(
+ LOG_LIB
+ log
)
-find_library(
+- HERMES_LIB
+- hermes
+- PATHS ${HERMES_DIR}
+- NO_CMAKE_FIND_ROOT_PATH
+-)
+-find_library(
+- JSEXECUTOR_LIB
+- jscexecutor
+- PATHS ${LIBRN_DIR}
+- NO_CMAKE_FIND_ROOT_PATH
+-)
+-find_library(
- FOLLY_JSON_LIB
- folly_json
- PATHS ${LIBRN_DIR}
- NO_CMAKE_FIND_ROOT_PATH
-)
++
find_library(
REACT_NATIVE_JNI_LIB
reactnativejni
@@ -42,30 +213,72 @@ index e6ff5f2..945b1fb 100644
find_library(
FBJNI_LIB
fbjni
-@@ -146,6 +140,22 @@ find_library(
+@@ -146,22 +126,53 @@ find_library(
NO_CMAKE_FIND_ROOT_PATH
)
-+if(${REACT_NATIVE_TARGET_VERSION} LESS 69)
+-if(${REACT_NATIVE_TARGET_VERSION} LESS 66)
+- set (JSI_LIB "")
+-else()
+- find_library(
+- JSI_LIB
+- jsi
+- PATHS ${LIBRN_DIR}
+- NO_CMAKE_FIND_ROOT_PATH
+- )
+-endif()
++if (${REACT_NATIVE_TARGET_VERSION} LESS 69)
+ find_library(
+ FOLLY_LIB
+ folly_json
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+ )
-+else()
++else ()
+ find_library(
+ FOLLY_LIB
+ folly_runtime
+ PATHS ${LIBRN_DIR}
+ NO_CMAKE_FIND_ROOT_PATH
+ )
-+endif()
++endif ()
++
++if (${REACT_NATIVE_TARGET_VERSION} LESS 66)
++ set(JSI_LIB "")
++else ()
++ find_library(
++ JSI_LIB
++ jsi
++ PATHS ${LIBRN_DIR}
++ NO_CMAKE_FIND_ROOT_PATH
++ )
++endif ()
+
+ # build shared lib
+
+ set_target_properties(${PACKAGE_NAME} PROPERTIES LINKER_LANGUAGE CXX)
+
+-if(${FOR_HERMES})
++
++if (${JS_RUNTIME} STREQUAL "hermes")
++ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1")
++ target_include_directories(
++ ${PACKAGE_NAME}
++ PRIVATE
++ "${JS_RUNTIME_DIR}/android/include"
++ )
++ file(GLOB HERMES_DIR "${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}")
++ find_library(
++ HERMES_LIB
++ hermes
++ PATHS ${HERMES_DIR}
++ NO_CMAKE_FIND_ROOT_PATH
++ )
+
- if(${REACT_NATIVE_TARGET_VERSION} LESS 66)
- set (JSI_LIB "")
- else()
-@@ -169,7 +179,7 @@ if(${FOR_HERMES})
+ target_link_libraries(
+ ${PACKAGE_NAME}
+ ${LOG_LIB}
+@@ -169,11 +180,44 @@ if(${FOR_HERMES})
${HERMES_LIB}
${GLOG_LIB}
${FBJNI_LIB}
@@ -74,7 +287,45 @@ index e6ff5f2..945b1fb 100644
${REACT_NATIVE_JNI_LIB}
android
)
-@@ -181,7 +191,7 @@ else()
+-else()
++elseif (${JS_RUNTIME} STREQUAL "v8")
++ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1")
++ target_include_directories(
++ ${PACKAGE_NAME}
++ PRIVATE
++ "${JS_RUNTIME_DIR}/src"
++ )
++ file(GLOB V8_SO_DIR "${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/*/jni/${ANDROID_ABI}")
++ find_library(
++ V8EXECUTOR_LIB
++ v8executor
++ PATHS ${V8_SO_DIR}
++ NO_CMAKE_FIND_ROOT_PATH
++ )
++ target_link_libraries(
++ ${PACKAGE_NAME}
++ ${LOG_LIB}
++ ${JSI_LIB}
++ ${FOLLY_LIB}
++ ${V8EXECUTOR_LIB}
++ ${GLOG_LIB}
++ ${FBJNI_LIB}
++ ${REACT_NATIVE_JNI_LIB}
++ android
++ )
++else ()
++ set(ignoreMe "${JS_RUNTIME_DIR}")
++ string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1")
++ find_library(
++ JSEXECUTOR_LIB
++ jscexecutor
++ PATHS ${LIBRN_DIR}
++ NO_CMAKE_FIND_ROOT_PATH
++ )
+ target_link_libraries(
+ ${PACKAGE_NAME}
+ ${LOG_LIB}
+@@ -181,13 +225,13 @@ else()
${JSEXECUTOR_LIB}
${GLOG_LIB}
${FBJNI_LIB}
@@ -83,8 +334,22 @@ index e6ff5f2..945b1fb 100644
${REACT_NATIVE_JNI_LIB}
android
)
+-endif()
++endif ()
+
+-if(${REACT_NATIVE_TARGET_VERSION} LESS 64)
++if (${REACT_NATIVE_TARGET_VERSION} LESS 64)
+ add_library(
+ turbomodulejsijni
+ # Sets the library as a shared library.
+@@ -195,4 +239,4 @@ if(${REACT_NATIVE_TARGET_VERSION} LESS 64)
+ # Provides a relative path to your source file(s).
+ ./empty.cpp
+ )
+-endif()
++endif ()
diff --git a/node_modules/react-native-reanimated/android/build.gradle b/node_modules/react-native-reanimated/android/build.gradle
-index cc460da..23f491e 100644
+index cc460da..3b86812 100644
--- a/node_modules/react-native-reanimated/android/build.gradle
+++ b/node_modules/react-native-reanimated/android/build.gradle
@@ -1,10 +1,8 @@
@@ -318,17 +583,71 @@ index cc460da..23f491e 100644
def localProps = new Properties()
def localPropertiesFile = file("local.properties")
-@@ -381,8 +182,7 @@ android {
+@@ -309,13 +110,36 @@ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
+ def reactNativeThirdParty = new File("$reactNative/ReactAndroid/src/main/jni/third-party")
+
+ def _stackProtectorFlag = true
+-def FOR_HERMES = ""
+
+-if (findProject(":app")) {
+- FOR_HERMES = project(":app").ext.react.enableHermes;
+-} else {
+- FOR_HERMES = System.getenv("FOR_HERMES") == "True";
+-}
++def CMAKE_NODE_MODULES_DIR = CLIENT_SIDE_BUILD
++ ? project.getProjectDir().getParentFile().getParent()
++ : Paths.get(project.getProjectDir().getParent(), getPlaygroundAppName(), "node_modules").toString()
++
++def JS_RUNTIME = {
++ // Returns the js runtime explicitly requested in the environment variable
++ if (System.getenv("JS_RUNTIME")) {
++ return System.getenv("JS_RUNTIME")
++ }
++
++ // Detect js runtime from project setup
++ def defaultRuntimeType = "jsc";
++ def v8Project = rootProject.getSubprojects().find { project -> project.name == "react-native-v8" }
++ if (v8Project != null) {
++ return "v8"
++ }
++ def appProject = findProject(":app") ? project(":app") : null
++ return appProject?.ext?.react?.enableHermes ? "hermes" : defaultRuntimeType
++}.call()
++
++def jsRuntimeDir = {
++ if (JS_RUNTIME == "hermes") {
++ return Paths.get(CMAKE_NODE_MODULES_DIR, "hermes-engine")
++ } else if (JS_RUNTIME == "v8") {
++ return findProject(":react-native-v8").getProjectDir().getParent()
++ } else {
++ return Paths.get(CMAKE_NODE_MODULES_DIR, "react-native", "ReactCommon", "jsi")
++ }
++}.call()
+
+ def reactNativeArchitectures() {
+ def value = project.getProperties().get("reactNativeArchitectures")
+@@ -376,14 +200,15 @@ android {
+ cmake {
+ arguments "-DANDROID_STL=c++_shared",
+ "-DNATIVE_DEBUG=${debugNativeLibraries}",
+- "-DREACT_NATIVE_TARGET_VERSION=${REACT_VERSION}",
++ "-DREACT_NATIVE_TARGET_VERSION=${rnMinorVersion}",
+ "-DANDROID_TOOLCHAIN=clang",
"-DBOOST_VERSION=${BOOST_VERSION}",
"-DBUILD_DIR=${buildDir}",
- "-DFOR_HERMES=${FOR_HERMES}",
+- "-DFOR_HERMES=${FOR_HERMES}",
- "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
- "--clean-first"
+- abiFilters (*reactNativeArchitectures())
++ "-DNODE_MODULES_DIR=${CMAKE_NODE_MODULES_DIR}",
++ "-DJS_RUNTIME=${JS_RUNTIME}",
++ "-DJS_RUNTIME_DIR=${jsRuntimeDir}",
+ "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}"
- abiFilters (*reactNativeArchitectures())
++ abiFilters(*reactNativeArchitectures())
_stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
}
-@@ -407,6 +207,7 @@ android {
+ }
+@@ -407,10 +232,12 @@ android {
"**/libfbjni.so",
"**/libjsi.so",
"**/libfolly_json.so",
@@ -336,7 +655,12 @@ index cc460da..23f491e 100644
"**/libglog.so",
"**/libhermes.so",
"**/libreactnativejni.so",
-@@ -435,7 +236,7 @@ task cleanCmakeCache() {
+ "**/libjscexecutor.so",
++ "**/libv8executor.so",
+ ]
+ }
+ tasks.withType(JavaCompile) {
+@@ -435,7 +262,7 @@ task cleanCmakeCache() {
}
task printVersions {
@@ -345,7 +669,20 @@ index cc460da..23f491e 100644
println "Gradle: ${project.gradle.gradleVersion}"
}
-@@ -459,7 +260,12 @@ task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
+@@ -446,10 +273,10 @@ task Log {
+ task applyJavaPatches(type: Copy) {
+ def patchDirectory = file("${projectDir}/rnVersionPatch/${rnMinorVersion}")
+ if (patchDirectory.exists()) {
+- from ("${patchDirectory}") {
++ from("${patchDirectory}") {
+ include "**/*.java"
+ }
+- into ("${projectDir}/src/main/java/com/swmansion/reanimated")
++ into("${projectDir}/src/main/java/com/swmansion/reanimated")
+ }
+ }
+
+@@ -459,7 +286,12 @@ task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
}
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
@@ -359,7 +696,26 @@ index cc460da..23f491e 100644
onlyIfNewer(true)
overwrite(false)
dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
-@@ -672,9 +478,29 @@ dependencies {
+@@ -638,7 +470,7 @@ task extractSOFiles {
+ task packageNdkLibs(type: Copy) {
+ from("$buildDir/reanimated-ndk/all")
+ include("**/libreanimated.so")
+- if(REACT_VERSION < 64) {
++ if (REACT_VERSION < 64) {
+ include("**/libturbomodulejsijni.so")
+ }
+ into("$projectDir/src/main/jniLibs")
+@@ -663,8 +495,7 @@ dependencies {
+ implementation "com.facebook.yoga:proguard-annotations:1.19.0"
+ if (isDeveloperMode()) {
+ implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION
+- }
+- else {
++ } else {
+ implementation "com.facebook.fbjni:fbjni-java-only:" + FBJNI_VERSION
+ }
+ implementation "com.facebook.react:react-native:+" // From node_modules
+@@ -672,26 +503,50 @@ dependencies {
extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
@@ -391,16 +747,33 @@ index cc460da..23f491e 100644
}
task downloadNdkBuildDependencies {
-@@ -686,7 +512,7 @@ task downloadNdkBuildDependencies {
- dependsOn(downloadGlog)
+ if (!boostPath) {
+ dependsOn(downloadBoost)
+ }
+- dependsOn(downloadDoubleConversion)
+- dependsOn(downloadFolly)
+- dependsOn(downloadGlog)
++ if (!dependenciesPath) {
++ dependsOn(downloadDoubleConversion)
++ dependsOn(downloadFolly)
++ dependsOn(downloadGlog)
++ }
}
-
+
-task prepareThirdPartyNdkHeaders(dependsOn:[downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog]) {
-+task prepareThirdPartyNdkHeaders(dependsOn:[downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog, unpackReactNativeAAR]) {
++
++task prepareThirdPartyNdkHeaders(dependsOn: [downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog, unpackReactNativeAAR]) {
}
def nativeBuildDependsOn(dependsOnTask) {
-@@ -702,11 +528,17 @@ afterEvaluate {
+ def buildTasks = tasks.findAll({ task ->
+- !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) })
++ !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake"))
++ })
+ buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
+ }
+
+@@ -702,11 +557,30 @@ afterEvaluate {
nativeBuildDependsOn(prepareThirdPartyNdkHeaders)
nativeBuildDependsOn(extractAARHeaders)
nativeBuildDependsOn(extractSOFiles)
@@ -410,6 +783,19 @@ index cc460da..23f491e 100644
+ task.dependsOn(packageNdkLibs)
+ }
+ })
++
++ if (JS_RUNTIME == "hermes") {
++ extractAARHeaders.dependsOn(prepareHermes)
++ extractSOFiles.dependsOn(prepareHermes)
++ } else if (JS_RUNTIME == "v8") {
++ def buildTasks = tasks.findAll({ task ->
++ !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake") || task.name.startsWith("generateJsonModel"))
++ })
++ buildTasks.forEach { task ->
++ def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
++ task.dependsOn(":react-native-v8:copy${buildType}JniLibsProjectOnly")
++ }
++ }
}
if (CLIENT_SIDE_BUILD) {
@@ -418,4 +804,54 @@ index cc460da..23f491e 100644
+ def aar = file("${aarDir}/android-debug.aar")
if (aar == null) {
throw GradleScriptException("AAR build failed. No AAR found in ${aarDir}.")
- }
\ No newline at end of file
+ }
+diff --git a/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.jar b/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.jar
+deleted file mode 100644
+index 7454180..0000000
+Binary files a/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
+diff --git a/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.properties b/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.properties
+deleted file mode 100644
+index ffed3a2..0000000
+--- a/node_modules/react-native-reanimated/android/gradle/wrapper/gradle-wrapper.properties
++++ /dev/null
+@@ -1,5 +0,0 @@
+-distributionBase=GRADLE_USER_HOME
+-distributionPath=wrapper/dists
+-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+-zipStoreBase=GRADLE_USER_HOME
+-zipStorePath=wrapper/dists
+diff --git a/node_modules/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp b/node_modules/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp
+index efa6463..8ac8931 100644
+--- a/node_modules/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp
++++ b/node_modules/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp
+@@ -7,8 +7,10 @@
+ #include <memory>
+ #include <string>
+
+-#if FOR_HERMES
++#if JS_RUNTIME_HERMES
+ #include <hermes/hermes.h>
++#elif JS_RUNTIME_V8
++#include <v8runtime/V8RuntimeFactory.h>
+ #else
+ #include <jsi/JSCRuntime.h>
+ #endif
+@@ -136,11 +138,17 @@ void NativeProxy::installJSIBindings() {
+ auto setGestureStateFunction = [this](int handlerTag, int newState) -> void {
+ setGestureState(handlerTag, newState);
+ };
+-#if FOR_HERMES
++#if JS_RUNTIME_HERMES
+ auto config =
+ ::hermes::vm::RuntimeConfig::Builder().withEnableSampleProfiling(false);
+ std::shared_ptr<jsi::Runtime> animatedRuntime =
+ facebook::hermes::makeHermesRuntime(config.build());
++#elif JS_RUNTIME_V8
++ auto config = std::make_unique<rnv8::V8RuntimeConfig>();
++ config->enableInspector = false;
++ config->appName = "reanimated";
++ std::shared_ptr<jsi::Runtime> animatedRuntime =
++ rnv8::createSharedV8Runtime(runtime_, std::move(config));
+ #else
+ std::shared_ptr<jsi::Runtime> animatedRuntime =
+ facebook::jsc::makeJSCRuntime();