Skip to content

Commit 250e90d

Browse files
committed
Merge branch 'nitro' into rename-to-nitro-sqlite
2 parents a2064a9 + 1776179 commit 250e90d

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

example/android/app/src/main/java/com/margelo/rnnitrosqlite/example/MainApplication.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1111
import com.facebook.react.defaults.DefaultReactNativeHost
1212
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1313
import com.facebook.soloader.SoLoader
14-
import com.margelo.rnnitrosqlite.RNNitroSQLitePackage
1514

1615
class MainApplication : Application(), ReactApplication {
1716

package/android/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ add_definitions(
88
${SQLITE_FLAGS}
99
)
1010

11-
include_directories(
12-
../cpp
13-
)
14-
1511
file(GLOB_RECURSE cpp_files RELATIVE ${CMAKE_SOURCE_DIR}
1612
"../cpp/**.c"
1713
"../cpp/**.cpp"
@@ -33,6 +29,15 @@ include_directories(
3329
src/main/cpp
3430
)
3531

32+
set_target_properties(
33+
${CMAKE_PROJECT_NAME} PROPERTIES
34+
CXX_STANDARD ${CMAKE_CXX_STANDARD}
35+
CXX_EXTENSIONS OFF
36+
POSITION_INDEPENDENT_CODE ON
37+
)
38+
39+
find_package(ReactAndroid REQUIRED CONFIG)
40+
find_package(fbjni REQUIRED CONFIG)
3641
find_library(LOG_LIB log)
3742

3843
target_link_libraries(

package/android/build.gradle

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ def isNewArchitectureEnabled() {
2323
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
2424
}
2525

26-
apply plugin: "com.android.library"
27-
apply plugin: "kotlin-android"
28-
29-
apply from: '../nitrogen/generated/android/RNNitroSQLite+autolinking.gradle'
30-
31-
if (isNewArchitectureEnabled()) {
32-
apply plugin: "com.facebook.react"
33-
}
34-
3526
def getExtOrDefault(name) {
3627
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNNitroSQLite_" + name]
3728
}
@@ -45,6 +36,12 @@ def safeAppExtGet(prop, fallback) {
4536
appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
4637
}
4738

39+
def resolveBuildType() {
40+
Gradle gradle = getGradle()
41+
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
42+
return tskReqStr.contains('Release') ? 'release' : 'debug'
43+
}
44+
4845
def supportsNamespace() {
4946
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
5047
def major = parsed[0].toInteger()
@@ -66,19 +63,27 @@ def resolveReactNativeDirectory() {
6663
return reactNativePackage.parentFile
6764
}
6865

69-
throw new GradleException("[react-native-live-markdown] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules.")
66+
throw new GradleException("[react-native-quick-sqlite] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules.")
7067
}
7168

72-
def getReactNativeMinorVersion() {
73-
def reactNativeRootDir = resolveReactNativeDirectory()
74-
def reactNativeProperties = new Properties()
75-
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactNativeProperties.load(it) }
76-
def reactNativeVersion = reactNativeProperties.getProperty("VERSION_NAME")
77-
return reactNativeVersion.split("\\.")[1].toInteger()
78-
}
69+
def reactNativeRootDir = resolveReactNativeDirectory()
70+
def reactProperties = new Properties()
71+
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
72+
73+
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
74+
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
7975

8076
def SQLITE_FLAGS = rootProject.properties['nitroSqliteFlags']
8177

78+
apply plugin: "com.android.library"
79+
apply plugin: "kotlin-android"
80+
81+
if (isNewArchitectureEnabled()) {
82+
apply plugin: "com.facebook.react"
83+
}
84+
85+
apply from: '../nitrogen/generated/android/RNNitroSQLite+autolinking.gradle'
86+
8287
android {
8388
if (supportsNamespace()) {
8489
namespace "com.margelo.rnnitrosqlite"
@@ -97,14 +102,14 @@ android {
97102
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
98103
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
99104

100-
buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", getReactNativeMinorVersion().toString()
105+
buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString()
101106
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
102107

103108
externalNativeBuild {
104109
cmake {
105110
arguments "-DANDROID_STL=c++_shared",
106111
"-DANDROID_TOOLCHAIN=clang",
107-
"-DREACT_NATIVE_MINOR_VERSION=${getReactNativeMinorVersion()}",
112+
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
108113
"-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'"
109114
abiFilters (*reactNativeArchitectures())
110115
}
@@ -114,6 +119,7 @@ android {
114119
externalNativeBuild {
115120
cmake {
116121
path "CMakeLists.txt"
122+
version = System.getenv("CMAKE_VERSION") ?: "3.22.1"
117123
}
118124
}
119125

@@ -153,6 +159,7 @@ android {
153159
}
154160

155161
packagingOptions {
162+
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
156163
excludes = [
157164
"META-INF",
158165
"META-INF/**",

0 commit comments

Comments
 (0)