react-native-mmkv 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MMKV/Core/MMKV.cpp +13 -0
- package/MMKV/Core/MMKVPredef.h +1 -1
- package/MMKV/Core/MMKV_IO.cpp +2 -0
- package/MMKV/Core/MMKV_OSX.cpp +7 -1
- package/README.md +1 -1
- package/android/CMakeLists.txt +14 -44
- package/android/build.gradle +61 -317
- package/android/gradle.properties +5 -3
- package/android/src/main/cpp/MmkvHostObject.cpp +1 -0
- package/ios/MmkvHostObject.mm +3 -2
- package/lib/commonjs/MMKV.js +5 -34
- package/lib/commonjs/MMKV.js.map +1 -1
- package/lib/commonjs/PlatformChecker.js +0 -2
- package/lib/commonjs/PlatformChecker.js.map +1 -1
- package/lib/commonjs/createMMKV.js +8 -19
- package/lib/commonjs/createMMKV.js.map +1 -1
- package/lib/commonjs/createMMKV.mock.js +0 -2
- package/lib/commonjs/createMMKV.mock.js.map +1 -1
- package/lib/commonjs/createMMKV.web.js +3 -20
- package/lib/commonjs/createMMKV.web.js.map +1 -1
- package/lib/commonjs/createTextEncoder.js +0 -1
- package/lib/commonjs/createTextEncoder.js.map +1 -1
- package/lib/commonjs/hooks.js +26 -28
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +0 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/MMKV.js +5 -29
- package/lib/module/MMKV.js.map +1 -1
- package/lib/module/PlatformChecker.js +0 -1
- package/lib/module/PlatformChecker.js.map +1 -1
- package/lib/module/createMMKV.js +8 -15
- package/lib/module/createMMKV.js.map +1 -1
- package/lib/module/createMMKV.mock.js.map +1 -1
- package/lib/module/createMMKV.web.js +4 -16
- package/lib/module/createMMKV.web.js.map +1 -1
- package/lib/module/createTextEncoder.js.map +1 -1
- package/lib/module/hooks.js +23 -22
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/MMKV.d.ts +2 -1
- package/lib/typescript/MMKV.d.ts.map +1 -0
- package/lib/typescript/PlatformChecker.d.ts +1 -0
- package/lib/typescript/PlatformChecker.d.ts.map +1 -0
- package/lib/typescript/createMMKV.d.ts +1 -0
- package/lib/typescript/createMMKV.d.ts.map +1 -0
- package/lib/typescript/createMMKV.mock.d.ts +1 -0
- package/lib/typescript/createMMKV.mock.d.ts.map +1 -0
- package/lib/typescript/createMMKV.web.d.ts +1 -0
- package/lib/typescript/createMMKV.web.d.ts.map +1 -0
- package/lib/typescript/createTextEncoder.d.ts +1 -0
- package/lib/typescript/createTextEncoder.d.ts.map +1 -0
- package/lib/typescript/hooks.d.ts +15 -3
- package/lib/typescript/hooks.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +15 -14
- package/MMKV/CHANGELOG.md +0 -553
- package/MMKV/LICENSE.TXT +0 -193
- package/MMKV/README.md +0 -288
package/MMKV/Core/MMKV.cpp
CHANGED
|
@@ -540,6 +540,7 @@ bool MMKV::getString(MMKVKey_t key, string &result) {
|
|
|
540
540
|
return false;
|
|
541
541
|
}
|
|
542
542
|
SCOPED_LOCK(m_lock);
|
|
543
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
543
544
|
auto data = getDataForKey(key);
|
|
544
545
|
if (data.length() > 0) {
|
|
545
546
|
try {
|
|
@@ -558,6 +559,7 @@ bool MMKV::getBytes(MMKVKey_t key, mmkv::MMBuffer &result) {
|
|
|
558
559
|
return false;
|
|
559
560
|
}
|
|
560
561
|
SCOPED_LOCK(m_lock);
|
|
562
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
561
563
|
auto data = getDataForKey(key);
|
|
562
564
|
if (data.length() > 0) {
|
|
563
565
|
try {
|
|
@@ -576,6 +578,7 @@ MMBuffer MMKV::getBytes(MMKVKey_t key) {
|
|
|
576
578
|
return MMBuffer();
|
|
577
579
|
}
|
|
578
580
|
SCOPED_LOCK(m_lock);
|
|
581
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
579
582
|
auto data = getDataForKey(key);
|
|
580
583
|
if (data.length() > 0) {
|
|
581
584
|
try {
|
|
@@ -593,6 +596,7 @@ bool MMKV::getVector(MMKVKey_t key, vector<string> &result) {
|
|
|
593
596
|
return false;
|
|
594
597
|
}
|
|
595
598
|
SCOPED_LOCK(m_lock);
|
|
599
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
596
600
|
auto data = getDataForKey(key);
|
|
597
601
|
if (data.length() > 0) {
|
|
598
602
|
try {
|
|
@@ -615,6 +619,7 @@ bool MMKV::getBool(MMKVKey_t key, bool defaultValue, bool *hasValue) {
|
|
|
615
619
|
return defaultValue;
|
|
616
620
|
}
|
|
617
621
|
SCOPED_LOCK(m_lock);
|
|
622
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
618
623
|
auto data = getDataForKey(key);
|
|
619
624
|
if (data.length() > 0) {
|
|
620
625
|
try {
|
|
@@ -641,6 +646,7 @@ int32_t MMKV::getInt32(MMKVKey_t key, int32_t defaultValue, bool *hasValue) {
|
|
|
641
646
|
return defaultValue;
|
|
642
647
|
}
|
|
643
648
|
SCOPED_LOCK(m_lock);
|
|
649
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
644
650
|
auto data = getDataForKey(key);
|
|
645
651
|
if (data.length() > 0) {
|
|
646
652
|
try {
|
|
@@ -667,6 +673,7 @@ uint32_t MMKV::getUInt32(MMKVKey_t key, uint32_t defaultValue, bool *hasValue) {
|
|
|
667
673
|
return defaultValue;
|
|
668
674
|
}
|
|
669
675
|
SCOPED_LOCK(m_lock);
|
|
676
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
670
677
|
auto data = getDataForKey(key);
|
|
671
678
|
if (data.length() > 0) {
|
|
672
679
|
try {
|
|
@@ -693,6 +700,7 @@ int64_t MMKV::getInt64(MMKVKey_t key, int64_t defaultValue, bool *hasValue) {
|
|
|
693
700
|
return defaultValue;
|
|
694
701
|
}
|
|
695
702
|
SCOPED_LOCK(m_lock);
|
|
703
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
696
704
|
auto data = getDataForKey(key);
|
|
697
705
|
if (data.length() > 0) {
|
|
698
706
|
try {
|
|
@@ -719,6 +727,7 @@ uint64_t MMKV::getUInt64(MMKVKey_t key, uint64_t defaultValue, bool *hasValue) {
|
|
|
719
727
|
return defaultValue;
|
|
720
728
|
}
|
|
721
729
|
SCOPED_LOCK(m_lock);
|
|
730
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
722
731
|
auto data = getDataForKey(key);
|
|
723
732
|
if (data.length() > 0) {
|
|
724
733
|
try {
|
|
@@ -745,6 +754,7 @@ float MMKV::getFloat(MMKVKey_t key, float defaultValue, bool *hasValue) {
|
|
|
745
754
|
return defaultValue;
|
|
746
755
|
}
|
|
747
756
|
SCOPED_LOCK(m_lock);
|
|
757
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
748
758
|
auto data = getDataForKey(key);
|
|
749
759
|
if (data.length() > 0) {
|
|
750
760
|
try {
|
|
@@ -771,6 +781,7 @@ double MMKV::getDouble(MMKVKey_t key, double defaultValue, bool *hasValue) {
|
|
|
771
781
|
return defaultValue;
|
|
772
782
|
}
|
|
773
783
|
SCOPED_LOCK(m_lock);
|
|
784
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
774
785
|
auto data = getDataForKey(key);
|
|
775
786
|
if (data.length() > 0) {
|
|
776
787
|
try {
|
|
@@ -794,6 +805,7 @@ size_t MMKV::getValueSize(MMKVKey_t key, bool actualSize) {
|
|
|
794
805
|
return 0;
|
|
795
806
|
}
|
|
796
807
|
SCOPED_LOCK(m_lock);
|
|
808
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
797
809
|
auto data = getDataForKey(key);
|
|
798
810
|
if (actualSize) {
|
|
799
811
|
try {
|
|
@@ -819,6 +831,7 @@ int32_t MMKV::writeValueToBuffer(MMKVKey_t key, void *ptr, int32_t size) {
|
|
|
819
831
|
auto s_size = static_cast<size_t>(size);
|
|
820
832
|
|
|
821
833
|
SCOPED_LOCK(m_lock);
|
|
834
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
822
835
|
auto data = getDataForKey(key);
|
|
823
836
|
try {
|
|
824
837
|
CodedInputData input(data.getPtr(), data.length());
|
package/MMKV/Core/MMKVPredef.h
CHANGED
package/MMKV/Core/MMKV_IO.cpp
CHANGED
|
@@ -447,6 +447,8 @@ bool MMKV::writeActualSize(size_t size, uint32_t crcDigest, const void *iv, bool
|
|
|
447
447
|
m_metaInfo->m_version = MMKVVersionActualSize;
|
|
448
448
|
}
|
|
449
449
|
needsFullWrite = true;
|
|
450
|
+
MMKVInfo("[%s] increase sequence to %u, crc %u, actualSize %u", m_mmapID.c_str(), m_metaInfo->m_sequence,
|
|
451
|
+
m_metaInfo->m_crcDigest, m_metaInfo->m_actualSize);
|
|
450
452
|
}
|
|
451
453
|
#ifdef MMKV_IOS
|
|
452
454
|
auto ret = guardForBackgroundWriting(m_metaFile->getMemory(), sizeof(MMKVMetaInfo));
|
package/MMKV/Core/MMKV_OSX.cpp
CHANGED
|
@@ -173,6 +173,7 @@ NSObject *MMKV::getObject(MMKVKey_t key, Class cls) {
|
|
|
173
173
|
return nil;
|
|
174
174
|
}
|
|
175
175
|
SCOPED_LOCK(m_lock);
|
|
176
|
+
SCOPED_LOCK(m_sharedProcessLock);
|
|
176
177
|
auto data = getDataForKey(key);
|
|
177
178
|
if (data.length() > 0) {
|
|
178
179
|
if (MiniPBCoder::isCompatibleClass(cls)) {
|
|
@@ -185,7 +186,12 @@ NSObject *MMKV::getObject(MMKVKey_t key, Class cls) {
|
|
|
185
186
|
} else {
|
|
186
187
|
if ([cls conformsToProtocol:@protocol(NSCoding)]) {
|
|
187
188
|
auto tmp = [NSData dataWithBytesNoCopy:data.getPtr() length:data.length() freeWhenDone:NO];
|
|
188
|
-
|
|
189
|
+
try {
|
|
190
|
+
id result = [NSKeyedUnarchiver unarchiveObjectWithData:tmp];
|
|
191
|
+
return result;
|
|
192
|
+
} catch (NSException *exception) {
|
|
193
|
+
MMKVError("%s", exception.reason);
|
|
194
|
+
}
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
197
|
}
|
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ This creates a new storage instance using a custom MMKV storage ID. By using a c
|
|
|
112
112
|
|
|
113
113
|
The following values can be configured:
|
|
114
114
|
|
|
115
|
-
* `id`: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can
|
|
115
|
+
* `id`: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can separate the global app's storage and a logged-in user's storage. (required if `path` or `encryptionKey` fields are specified, otherwise defaults to: `'mmkv.default'`)
|
|
116
116
|
* `path`: The MMKV instance's root path. By default, MMKV stores file inside `$(Documents)/mmkv/`. You can customize MMKV's root directory on MMKV initialization (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#customize-location) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#customize-location))
|
|
117
117
|
* `encryptionKey`: The MMKV instance's encryption/decryption key. By default, MMKV stores all key-values in plain text on file, relying on iOS's/Android's sandbox to make sure the file is encrypted. Should you worry about information leaking, you can choose to encrypt MMKV. (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#encryption) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#encryption))
|
|
118
118
|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -1,34 +1,27 @@
|
|
|
1
|
+
project(ReactNativeMMKV)
|
|
1
2
|
cmake_minimum_required(VERSION 3.9.0)
|
|
2
3
|
|
|
3
4
|
set (PACKAGE_NAME "react-native-mmkv")
|
|
4
5
|
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
|
6
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
7
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
# Add headers search paths
|
|
8
10
|
include_directories(
|
|
9
11
|
../MMKV/Core
|
|
10
12
|
../cpp
|
|
11
|
-
"${NODE_MODULES_DIR}/react-native/React"
|
|
12
|
-
"${NODE_MODULES_DIR}/react-native/React/Base"
|
|
13
|
-
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
|
|
14
13
|
)
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
|
|
20
|
-
INCLUDE_JSI_CPP
|
|
21
|
-
)
|
|
22
|
-
endif()
|
|
23
|
-
|
|
15
|
+
# Add MMKV core sources
|
|
16
|
+
add_subdirectory(../MMKV/Core core)
|
|
17
|
+
# Add react-native-mmkv sources
|
|
24
18
|
add_library(reactnativemmkv # <-- Library name
|
|
25
19
|
SHARED
|
|
26
20
|
src/main/cpp/cpp-adapter.cpp
|
|
27
21
|
src/main/cpp/MmkvHostObject.cpp
|
|
28
22
|
../cpp/TypedArray.cpp
|
|
29
|
-
${INCLUDE_JSI_CPP} # only on older RN versions
|
|
30
23
|
)
|
|
31
|
-
|
|
24
|
+
# Configure C++ 17
|
|
32
25
|
set_target_properties(
|
|
33
26
|
reactnativemmkv PROPERTIES
|
|
34
27
|
CXX_STANDARD 17
|
|
@@ -36,36 +29,13 @@ set_target_properties(
|
|
|
36
29
|
POSITION_INDEPENDENT_CODE ON
|
|
37
30
|
)
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
find_library(
|
|
42
|
-
log-lib
|
|
43
|
-
log
|
|
44
|
-
)
|
|
45
|
-
find_library(
|
|
46
|
-
REACT_NATIVE_JNI_LIB
|
|
47
|
-
reactnativejni
|
|
48
|
-
PATHS ${LIBRN_DIR}
|
|
49
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
50
|
-
)
|
|
51
|
-
if(${REACT_NATIVE_VERSION} LESS 66)
|
|
52
|
-
# JSI lib didn't exist on RN 0.65 and before. Simply omit it.
|
|
53
|
-
set (JSI_LIB "")
|
|
54
|
-
else()
|
|
55
|
-
# RN 0.66 distributes libjsi.so, can be used instead of compiling jsi.cpp manually.
|
|
56
|
-
find_library(
|
|
57
|
-
JSI_LIB
|
|
58
|
-
jsi
|
|
59
|
-
PATHS ${LIBRN_DIR}
|
|
60
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
61
|
-
)
|
|
62
|
-
endif()
|
|
32
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
33
|
+
find_library(log-lib log)
|
|
63
34
|
|
|
64
35
|
target_link_libraries(
|
|
65
36
|
reactnativemmkv
|
|
66
|
-
core
|
|
67
|
-
${log-lib}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
android
|
|
37
|
+
core # <-- MMKV core
|
|
38
|
+
${log-lib} # <-- Logcat logger
|
|
39
|
+
ReactAndroid::jsi # <-- JSI
|
|
40
|
+
android # <-- Android JNI core
|
|
71
41
|
)
|
package/android/build.gradle
CHANGED
|
@@ -1,114 +1,82 @@
|
|
|
1
|
-
import groovy.json.JsonSlurper
|
|
2
|
-
import org.apache.tools.ant.filters.ReplaceTokens
|
|
3
|
-
import java.nio.file.Paths
|
|
4
|
-
|
|
5
|
-
static def findNodeModules(baseDir) {
|
|
6
|
-
def basePath = baseDir.toPath().normalize()
|
|
7
|
-
// Node's module resolution algorithm searches up to the root directory,
|
|
8
|
-
// after which the base path will be null
|
|
9
|
-
while (basePath) {
|
|
10
|
-
def nodeModulesPath = Paths.get(basePath.toString(), "node_modules")
|
|
11
|
-
def reactNativePath = Paths.get(nodeModulesPath.toString(), "react-native")
|
|
12
|
-
if (nodeModulesPath.toFile().exists() && reactNativePath.toFile().exists()) {
|
|
13
|
-
return nodeModulesPath.toString()
|
|
14
|
-
}
|
|
15
|
-
basePath = basePath.getParent()
|
|
16
|
-
}
|
|
17
|
-
throw new GradleException("MMKV: Failed to find node_modules/ path!")
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
def nodeModules = findNodeModules(projectDir)
|
|
21
|
-
logger.warn("MMKV: node_modules/ found at: ${nodeModules}")
|
|
22
|
-
|
|
23
1
|
buildscript {
|
|
24
2
|
repositories {
|
|
25
|
-
google()
|
|
26
|
-
jcenter()
|
|
27
3
|
maven {
|
|
28
4
|
url "https://plugins.gradle.org/m2/"
|
|
29
5
|
}
|
|
6
|
+
mavenCentral()
|
|
7
|
+
google()
|
|
30
8
|
}
|
|
31
9
|
|
|
32
10
|
dependencies {
|
|
33
|
-
classpath
|
|
34
|
-
classpath 'de.undercouch:gradle-download-task:4.1.2'
|
|
11
|
+
classpath("com.android.tools.build:gradle:7.2.2")
|
|
35
12
|
}
|
|
36
13
|
}
|
|
37
14
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def getExtOrDefault(name) {
|
|
42
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Mmkv_' + name]
|
|
43
|
-
}
|
|
15
|
+
def resolveBuildType() {
|
|
16
|
+
Gradle gradle = getGradle()
|
|
17
|
+
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['Mmkv_' + name]).toInteger()
|
|
19
|
+
return tskReqStr.contains('Release') ? 'release' : 'debug'
|
|
47
20
|
}
|
|
48
21
|
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
22
|
+
def isNewArchitectureEnabled() {
|
|
23
|
+
// To opt-in for the New Architecture, you can either:
|
|
24
|
+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
25
|
+
// - Invoke gradle with `-newArchEnabled=true`
|
|
26
|
+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
27
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
52
28
|
}
|
|
53
29
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def androidSourcesDir = null
|
|
57
|
-
def androidSourcesName = 'React Native sources'
|
|
30
|
+
apply plugin: 'com.facebook.react'
|
|
31
|
+
apply plugin: 'com.android.library'
|
|
58
32
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
androidSourcesDir = defaultDir.parentFile.toString()
|
|
62
|
-
} else if (findProject(':ReactAndroid') != null) {
|
|
63
|
-
sourceBuild = true
|
|
64
|
-
defaultDir = project(':ReactAndroid').projectDir
|
|
65
|
-
androidSourcesDir = defaultDir.parentFile.toString()
|
|
66
|
-
} else {
|
|
67
|
-
defaultDir = file("$nodeModules/react-native/android")
|
|
68
|
-
androidSourcesDir = defaultDir.parentFile.toString()
|
|
33
|
+
def safeExtGet(prop, fallback) {
|
|
34
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
69
35
|
}
|
|
70
36
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
37
|
+
def reactNativeArchitectures() {
|
|
38
|
+
def value = project.getProperties().get("reactNativeArchitectures")
|
|
39
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
75
40
|
}
|
|
76
41
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
42
|
+
repositories {
|
|
43
|
+
mavenCentral()
|
|
44
|
+
}
|
|
80
45
|
|
|
46
|
+
android {
|
|
47
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 28)
|
|
81
48
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
49
|
+
// Used to override the NDK path/version on internal CI or by allowing
|
|
50
|
+
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
|
51
|
+
if (rootProject.hasProperty("ndkPath")) {
|
|
52
|
+
ndkPath rootProject.ext.ndkPath
|
|
53
|
+
}
|
|
54
|
+
if (rootProject.hasProperty("ndkVersion")) {
|
|
55
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
56
|
+
}
|
|
85
57
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
ndkVersion getExtOrDefault('ndkVersion')
|
|
58
|
+
buildFeatures {
|
|
59
|
+
prefab true
|
|
60
|
+
}
|
|
90
61
|
|
|
91
62
|
defaultConfig {
|
|
92
|
-
minSdkVersion
|
|
93
|
-
targetSdkVersion
|
|
63
|
+
minSdkVersion safeExtGet('minSdkVersion', 16)
|
|
64
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 28)
|
|
94
65
|
versionCode 1
|
|
95
66
|
versionName "1.0"
|
|
67
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
96
68
|
externalNativeBuild {
|
|
97
69
|
cmake {
|
|
98
|
-
cppFlags "-
|
|
99
|
-
arguments
|
|
100
|
-
|
|
101
|
-
"-DNODE_MODULES_DIR=${nodeModules}",
|
|
102
|
-
"-DPREBUILT_DIR=${prebuiltDir}"
|
|
70
|
+
cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all"
|
|
71
|
+
arguments "-DANDROID_STL=c++_shared"
|
|
72
|
+
abiFilters (*reactNativeArchitectures())
|
|
103
73
|
}
|
|
104
74
|
}
|
|
105
|
-
ndk {
|
|
106
|
-
abiFilters (*reactNativeArchitectures())
|
|
107
|
-
}
|
|
108
75
|
}
|
|
109
76
|
|
|
110
|
-
|
|
111
|
-
|
|
77
|
+
compileOptions {
|
|
78
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
79
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
112
80
|
}
|
|
113
81
|
|
|
114
82
|
externalNativeBuild {
|
|
@@ -116,256 +84,32 @@ android {
|
|
|
116
84
|
path "CMakeLists.txt"
|
|
117
85
|
}
|
|
118
86
|
}
|
|
119
|
-
|
|
120
87
|
packagingOptions {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
lintOptions {
|
|
130
|
-
disable 'GradleCompatible'
|
|
131
|
-
}
|
|
132
|
-
compileOptions {
|
|
133
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
134
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
configurations {
|
|
138
|
-
extractHeaders
|
|
139
|
-
extractJNI
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
repositories {
|
|
144
|
-
mavenCentral()
|
|
145
|
-
google()
|
|
146
|
-
|
|
147
|
-
maven {
|
|
148
|
-
url defaultDir.toString()
|
|
149
|
-
name androidSourcesName
|
|
88
|
+
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
|
|
89
|
+
excludes = [
|
|
90
|
+
"META-INF",
|
|
91
|
+
"META-INF/**",
|
|
92
|
+
"**/libjsi.so",
|
|
93
|
+
]
|
|
150
94
|
}
|
|
151
95
|
}
|
|
152
96
|
|
|
153
97
|
dependencies {
|
|
154
|
-
// noinspection GradleDynamicVersion
|
|
155
|
-
implementation 'com.facebook.react:react-native:+'
|
|
156
|
-
|
|
157
|
-
//noinspection GradleDynamicVersion
|
|
158
|
-
extractHeaders("com.facebook.fbjni:fbjni:+:headers")
|
|
159
98
|
//noinspection GradleDynamicVersion
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (!sourceBuild) {
|
|
163
|
-
def buildType = "debug"
|
|
164
|
-
tasks.all({ task ->
|
|
165
|
-
if (task.name == "buildCMakeRelease") {
|
|
166
|
-
buildType = "release"
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
|
|
170
|
-
if (REACT_NATIVE_VERSION < 69) {
|
|
171
|
-
rnAarMatcher = "**/**/*.aar"
|
|
172
|
-
}
|
|
173
|
-
def rnAAR = fileTree("${defaultDir.toString()}").matching({ it.include rnAarMatcher }).singleFile
|
|
174
|
-
extractJNI(files(rnAAR))
|
|
175
|
-
}
|
|
99
|
+
implementation 'com.facebook.react:react-android:+'
|
|
176
100
|
}
|
|
177
101
|
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads")
|
|
184
|
-
def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
|
|
185
|
-
def thirdPartyVersionsFile = new File("${androidSourcesDir.toString()}/ReactAndroid/gradle.properties")
|
|
186
|
-
def thirdPartyVersions = new Properties()
|
|
187
|
-
thirdPartyVersions.load(new FileInputStream(thirdPartyVersionsFile))
|
|
188
|
-
|
|
189
|
-
def BOOST_VERSION = thirdPartyVersions["BOOST_VERSION"]
|
|
190
|
-
def boost_file = new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz")
|
|
191
|
-
def DOUBLE_CONVERSION_VERSION = thirdPartyVersions["DOUBLE_CONVERSION_VERSION"]
|
|
192
|
-
def double_conversion_file = new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz")
|
|
193
|
-
def FOLLY_VERSION = thirdPartyVersions["FOLLY_VERSION"]
|
|
194
|
-
def folly_file = new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz")
|
|
195
|
-
def GLOG_VERSION = thirdPartyVersions["GLOG_VERSION"]
|
|
196
|
-
def glog_file = new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz")
|
|
197
|
-
|
|
198
|
-
task createNativeDepsDirectories {
|
|
199
|
-
doLast {
|
|
200
|
-
downloadsDir.mkdirs()
|
|
201
|
-
thirdPartyNdkDir.mkdirs()
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
206
|
-
def transformedVersion = BOOST_VERSION.replace("_", ".")
|
|
207
|
-
def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
|
|
208
|
-
if (REACT_NATIVE_VERSION < 69) {
|
|
209
|
-
srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
|
|
210
|
-
}
|
|
211
|
-
src(srcUrl)
|
|
212
|
-
onlyIfNewer(true)
|
|
213
|
-
overwrite(false)
|
|
214
|
-
dest(boost_file)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
task prepareBoost(dependsOn: downloadBoost, type: Copy) {
|
|
218
|
-
from(tarTree(resources.gzip(downloadBoost.dest)))
|
|
219
|
-
from("src/main/jni/third-party/boost/Android.mk")
|
|
220
|
-
include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
|
|
221
|
-
includeEmptyDirs = false
|
|
222
|
-
into("$thirdPartyNdkDir") // /boost_X_XX_X
|
|
223
|
-
doLast {
|
|
224
|
-
file("$thirdPartyNdkDir/boost_${BOOST_VERSION}").renameTo("$thirdPartyNdkDir/boost")
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
229
|
-
src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
|
|
230
|
-
onlyIfNewer(true)
|
|
231
|
-
overwrite(false)
|
|
232
|
-
dest(double_conversion_file)
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
task prepareDoubleConversion(dependsOn: downloadDoubleConversion, type: Copy) {
|
|
236
|
-
from(tarTree(downloadDoubleConversion.dest))
|
|
237
|
-
from("src/main/jni/third-party/double-conversion/Android.mk")
|
|
238
|
-
include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
|
|
239
|
-
filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
|
|
240
|
-
includeEmptyDirs = false
|
|
241
|
-
into("$thirdPartyNdkDir/double-conversion")
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
245
|
-
src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
|
|
246
|
-
onlyIfNewer(true)
|
|
247
|
-
overwrite(false)
|
|
248
|
-
dest(folly_file)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
task prepareFolly(dependsOn: downloadFolly, type: Copy) {
|
|
252
|
-
from(tarTree(downloadFolly.dest))
|
|
253
|
-
from("src/main/jni/third-party/folly/Android.mk")
|
|
254
|
-
include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
|
|
255
|
-
eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
|
|
256
|
-
includeEmptyDirs = false
|
|
257
|
-
into("$thirdPartyNdkDir/folly")
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
261
|
-
src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
|
|
262
|
-
onlyIfNewer(true)
|
|
263
|
-
overwrite(false)
|
|
264
|
-
dest(glog_file)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
task prepareGlog(dependsOn: downloadGlog, type: Copy) {
|
|
268
|
-
from(tarTree(downloadGlog.dest))
|
|
269
|
-
from("src/main/jni/third-party/glog/")
|
|
270
|
-
include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
|
|
271
|
-
includeEmptyDirs = false
|
|
272
|
-
filesMatching("**/*.h.in") {
|
|
273
|
-
filter(ReplaceTokens, tokens: [
|
|
274
|
-
ac_cv_have_unistd_h : "1",
|
|
275
|
-
ac_cv_have_stdint_h : "1",
|
|
276
|
-
ac_cv_have_systypes_h : "1",
|
|
277
|
-
ac_cv_have_inttypes_h : "1",
|
|
278
|
-
ac_cv_have_libgflags : "0",
|
|
279
|
-
ac_google_start_namespace : "namespace google {",
|
|
280
|
-
ac_cv_have_uint16_t : "1",
|
|
281
|
-
ac_cv_have_u_int16_t : "1",
|
|
282
|
-
ac_cv_have___uint16 : "0",
|
|
283
|
-
ac_google_end_namespace : "}",
|
|
284
|
-
ac_cv_have___builtin_expect : "1",
|
|
285
|
-
ac_google_namespace : "google",
|
|
286
|
-
ac_cv___attribute___noinline : "__attribute__ ((noinline))",
|
|
287
|
-
ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
|
|
288
|
-
ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
|
|
289
|
-
])
|
|
290
|
-
it.path = (it.name - ".in")
|
|
291
|
-
}
|
|
292
|
-
into("$thirdPartyNdkDir/glog")
|
|
293
|
-
|
|
294
|
-
doLast {
|
|
295
|
-
copy {
|
|
296
|
-
from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
|
|
297
|
-
includeEmptyDirs = false
|
|
298
|
-
into("$thirdPartyNdkDir/glog/exported/glog")
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
task prepareThirdPartyNdkHeaders {
|
|
304
|
-
if (!boost_file.exists()) {
|
|
305
|
-
dependsOn(prepareBoost)
|
|
306
|
-
}
|
|
307
|
-
if (!double_conversion_file.exists()) {
|
|
308
|
-
dependsOn(prepareDoubleConversion)
|
|
309
|
-
}
|
|
310
|
-
if (!folly_file.exists()) {
|
|
311
|
-
dependsOn(prepareFolly)
|
|
312
|
-
}
|
|
313
|
-
if (!glog_file.exists()) {
|
|
314
|
-
dependsOn(prepareGlog)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
prepareThirdPartyNdkHeaders.mustRunAfter createNativeDepsDirectories
|
|
319
|
-
|
|
320
|
-
task extractAARHeaders {
|
|
321
|
-
doLast {
|
|
322
|
-
configurations.extractHeaders.files.each {
|
|
323
|
-
def file = it.absoluteFile
|
|
324
|
-
copy {
|
|
325
|
-
from zipTree(file)
|
|
326
|
-
into "$buildDir/$file.name"
|
|
327
|
-
include "**/*.h"
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
extractAARHeaders.mustRunAfter prepareThirdPartyNdkHeaders
|
|
333
|
-
|
|
334
|
-
task extractJNIFiles {
|
|
335
|
-
doLast {
|
|
336
|
-
configurations.extractJNI.files.each {
|
|
337
|
-
def file = it.absoluteFile
|
|
338
|
-
|
|
339
|
-
copy {
|
|
340
|
-
from zipTree(file)
|
|
341
|
-
into "$buildDir/$file.name"
|
|
342
|
-
include "jni/**/*"
|
|
343
|
-
}
|
|
102
|
+
// Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
|
|
103
|
+
tasks.whenTaskAdded { task ->
|
|
104
|
+
if (task.name.contains("configureCMakeDebug")) {
|
|
105
|
+
rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
|
|
106
|
+
task.dependsOn(it)
|
|
344
107
|
}
|
|
345
108
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
def buildTasks = tasks.findAll({ task ->
|
|
351
|
-
!task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) })
|
|
352
|
-
if (variant != null) {
|
|
353
|
-
buildTasks = buildTasks.findAll({ task -> task.name.contains(variant) })
|
|
354
|
-
}
|
|
355
|
-
buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
afterEvaluate {
|
|
359
|
-
if (sourceBuild) {
|
|
360
|
-
if (REACT_NATIVE_VERSION < 68) {
|
|
361
|
-
nativeBuildDependsOn(":ReactAndroid:packageReactNdkLibsForBuck", null)
|
|
362
|
-
} else {
|
|
363
|
-
nativeBuildDependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck", "Debug")
|
|
364
|
-
nativeBuildDependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck", "Rel")
|
|
109
|
+
// We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
|
|
110
|
+
if (task.name.contains("configureCMakeRel")) {
|
|
111
|
+
rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach {
|
|
112
|
+
task.dependsOn(it)
|
|
365
113
|
}
|
|
366
|
-
} else {
|
|
367
|
-
nativeBuildDependsOn(extractAARHeaders, null)
|
|
368
|
-
nativeBuildDependsOn(extractJNIFiles, null)
|
|
369
|
-
nativeBuildDependsOn(prepareThirdPartyNdkHeaders, null)
|
|
370
114
|
}
|
|
371
115
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
Mmkv_compileSdkVersion=
|
|
2
|
-
Mmkv_buildToolsVersion=
|
|
3
|
-
Mmkv_targetSdkVersion=
|
|
1
|
+
Mmkv_compileSdkVersion=31
|
|
2
|
+
Mmkv_buildToolsVersion=31.0.0
|
|
3
|
+
Mmkv_targetSdkVersion=31
|
|
4
4
|
android.useAndroidX=true
|
|
5
|
+
|
|
6
|
+
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|