Skip to content

Commit

Permalink
🔧 upgrade RN
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvain-abadie committed Sep 22, 2022
1 parent fcbc9b1 commit 6803c26
Show file tree
Hide file tree
Showing 10 changed files with 1,240 additions and 1,333 deletions.
1 change: 1 addition & 0 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.9.0)
project(react-native-leveldb)

set (PACKAGE_NAME "react-native-leveldb")
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
Expand Down
107 changes: 36 additions & 71 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ def nodeModules = findNodeModules(projectDir)
logger.warn("LevelDB: node_modules/ found at: ${nodeModules}")
def reactNative = new File("$nodeModules/react-native")


def sourceBuild = false
def defaultDir = null
def androidSourcesDir = null
def androidSourcesName = 'React Native sources'

if (rootProject.ext.has('reactNativeAndroidRoot')) {
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
androidSourcesDir = defaultDir.parentFile.toString()
} else if (findProject(':ReactAndroid') != null) {
sourceBuild = true
defaultDir = project(':ReactAndroid').projectDir
androidSourcesDir = defaultDir.parentFile.toString()
} else {
defaultDir = file("$nodeModules/react-native/android")
androidSourcesDir = defaultDir.parentFile.toString()
}

android {
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
buildToolsVersion getExtOrDefault('buildToolsVersion')
Expand All @@ -67,10 +85,6 @@ android {
}
}

dexOptions {
javaMaxHeapSize "4g"
}

externalNativeBuild {
cmake {
path "CMakeLists.txt"
Expand Down Expand Up @@ -104,69 +118,9 @@ repositories {
mavenCentral()
google()

def found = false
def defaultDir = null
def androidSourcesName = 'React Native sources'

if (rootProject.ext.has('reactNativeAndroidRoot')) {
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
} else {
defaultDir = new File(
projectDir,
'/../../../node_modules/react-native/android'
)
}

if (defaultDir.exists()) {
maven {
url defaultDir.toString()
name androidSourcesName
}

logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
found = true
} else {
def parentDir = rootProject.projectDir

1.upto(5, {
if (found) return true
parentDir = parentDir.parentFile

def androidSourcesDir = new File(
parentDir,
'node_modules/react-native'
)

def androidPrebuiltBinaryDir = new File(
parentDir,
'node_modules/react-native/android'
)

if (androidPrebuiltBinaryDir.exists()) {
maven {
url androidPrebuiltBinaryDir.toString()
name androidSourcesName
}

logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
found = true
} else if (androidSourcesDir.exists()) {
maven {
url androidSourcesDir.toString()
name androidSourcesName
}

logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
found = true
}
})
}

if (!found) {
throw new GradleException(
"${project.name}: unable to locate React Native android sources. " +
"Ensure you have you installed React Native as a dependency in your project and try again."
)
maven {
url defaultDir.toString()
name androidSourcesName
}
}

Expand All @@ -178,9 +132,18 @@ dependencies {
extractHeaders("com.facebook.fbjni:fbjni:+:headers")
//noinspection GradleDynamicVersion
extractJNI("com.facebook.fbjni:fbjni:+")

def rnAAR = fileTree("${nodeModules}/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile
extractJNI(files(rnAAR))

if (!sourceBuild) {
def buildType = "debug"
tasks.all({ task ->
if (task.name == "buildCMakeRelease") {
buildType = "release"
}
})
def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
def rnAAR = fileTree("${defaultDir.toString()}").matching({ it.include rnAarMatcher }).singleFile
extractJNI(files(rnAAR))
}
}


Expand Down Expand Up @@ -210,7 +173,9 @@ task createNativeDepsDirectories {
}

task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
src("https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz")
def transformedVersion = BOOST_VERSION.replace("_", ".")
def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
src(srcUrl)
onlyIfNewer(true)
overwrite(false)
dest(boost_file)
Expand Down
7 changes: 4 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
//noinspection GradleDynamicVersion
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
exclude group:'com.facebook.fbjni'
}
} else {
implementation jscFlavor
}
Expand Down
2 changes: 2 additions & 0 deletions example/ios/LeveldbExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
};
name = Debug;
Expand Down Expand Up @@ -809,6 +810,7 @@
"\"$(inherited)\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

target 'LeveldbExample' do
Expand Down
Loading

0 comments on commit 6803c26

Please sign in to comment.