expo-modules-core 1.0.3 → 1.1.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/CHANGELOG.md +30 -3
- package/ExpoModulesCore.podspec +38 -4
- package/android/CMakeLists.txt +21 -71
- package/android/ExpoModulesCorePlugin.gradle +200 -0
- package/android/build.gradle +42 -205
- package/android/legacy/CMakeLists.txt +194 -0
- package/android/{src → legacy}/fabric/Android-prebuilt.cmake +2 -0
- package/android/legacy/fabric/CMakeLists.txt +40 -0
- package/android/proguard-rules.pro +13 -0
- package/android/src/fabric/CMakeLists.txt +23 -16
- package/android/src/main/java/expo/modules/adapters/react/ModuleRegistryAdapter.java +0 -1
- package/android/src/main/java/expo/modules/kotlin/AppContext.kt +7 -0
- package/android/src/main/java/expo/modules/kotlin/exception/CommonExceptions.kt +5 -0
- package/android/src/main/java/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +44 -0
- package/android/src/main/java/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +9 -1
- package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinitionBuilder.kt +46 -0
- package/build/EventEmitter.d.ts +2 -2
- package/build/EventEmitter.d.ts.map +1 -1
- package/build/NativeModulesProxy.types.d.ts +1 -1
- package/build/NativeModulesProxy.types.d.ts.map +1 -1
- package/build/NativeViewManagerAdapter.native.d.ts +1 -1
- package/build/NativeViewManagerAdapter.native.d.ts.map +1 -1
- package/build/NativeViewManagerAdapter.native.js +3 -3
- package/build/NativeViewManagerAdapter.native.js.map +1 -1
- package/build/PermissionsHook.d.ts +4 -4
- package/build/PermissionsHook.d.ts.map +1 -1
- package/build/PermissionsInterface.d.ts +1 -1
- package/build/PermissionsInterface.d.ts.map +1 -1
- package/build/Platform.d.ts +2 -2
- package/build/Platform.d.ts.map +1 -1
- package/build/TypedArrays.types.d.ts +9 -0
- package/build/TypedArrays.types.d.ts.map +1 -0
- package/build/TypedArrays.types.js +2 -0
- package/build/TypedArrays.types.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/requireNativeModule.d.ts +1 -1
- package/build/requireNativeModule.d.ts.map +1 -1
- package/common/cpp/fabric/ExpoViewProps.cpp +2 -0
- package/ios/AppDelegates/EXAppDelegateWrapper.h +22 -0
- package/ios/AppDelegates/EXAppDelegateWrapper.mm +100 -0
- package/ios/JSI/EXJavaScriptRuntime.mm +5 -5
- package/ios/ReactDelegates/EXReactCompatibleHelpers.h +1 -1
- package/ios/ReactDelegates/EXReactCompatibleHelpers.m +8 -2
- package/ios/ReactDelegates/EXReactDelegateWrapper.h +5 -0
- package/ios/ReactDelegates/EXReactDelegateWrapper.m +14 -1
- package/ios/ReactDelegates/ExpoReactDelegate.swift +7 -2
- package/ios/Swift/AppContext.swift +9 -0
- package/ios/Swift/Arguments/Enumerable.swift +2 -16
- package/ios/Swift/Classes/ClassComponentElement.swift +1 -1
- package/ios/Swift/Convertibles/Either.swift +5 -14
- package/ios/Swift/DynamicTypes/DynamicEnumType.swift +1 -1
- package/ios/Swift/DynamicTypes/DynamicSharedObjectType.swift +4 -0
- package/ios/Swift/DynamicTypes/DynamicType.swift +1 -1
- package/ios/Swift/ExpoBridgeModule.swift +6 -18
- package/ios/Swift/Functions/AnyFunction.swift +18 -0
- package/ios/Swift/JavaScriptUtils.swift +25 -8
- package/ios/Swift/Objects/ObjectDefinition.swift +4 -4
- package/ios/Swift/Objects/ObjectDefinitionComponents.swift +7 -0
- package/ios/Swift/Objects/PropertyComponent.swift +138 -48
- package/ios/Swift/SharedObjects/SharedObject.swift +5 -0
- package/ios/Tests/ClassComponentSpec.swift +15 -0
- package/ios/Tests/EitherSpec.swift +28 -0
- package/ios/Tests/FunctionSpec.swift +31 -0
- package/ios/Tests/PropertyComponentSpec.swift +131 -33
- package/package.json +2 -2
- package/src/NativeViewManagerAdapter.native.tsx +4 -4
- package/src/TypedArrays.types.ts +11 -0
- package/src/index.ts +1 -0
- package/ios/AppDelegates/EXAppDelegateWrapper.m +0 -45
package/CHANGELOG.md
CHANGED
|
@@ -10,13 +10,40 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 1.0
|
|
13
|
+
## 1.1.0 — 2022-12-30
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Added TS definitions for `TypedArray` and additional union types for Int, Uint and Float TypedArrays. ([#20257](https://github.com/expo/expo/pull/20257) by [@aleqsio](https://github.com/aleqsio))
|
|
18
|
+
- Added a new `executeOnJavaScriptThread` method to `appContext` to allow for running code blocks on the JS thread. ([#20161](https://github.com/expo/expo/pull/20161) by [@aleqsio](https://github.com/aleqsio))
|
|
19
|
+
- Added the `Exceptions.MissingActivity` on Android. ([#20174](https://github.com/expo/expo/pull/20174) by [@lukmccall](https://github.com/lukmccall))
|
|
20
|
+
- Trailing optional arguments can be skipped when calling native functions from JavaScript on iOS. ([#20234](https://github.com/expo/expo/pull/20234) by [@tsapeta](https://github.com/tsapeta))
|
|
21
|
+
- `Events` component can now be initialized with an array of event names (not only variadic arguments). ([#20590](https://github.com/expo/expo/pull/20590) by [@tsapeta](https://github.com/tsapeta))
|
|
22
|
+
- `Property` component can now take the native shared object instance as the first argument. ([#20608](https://github.com/expo/expo/pull/20608) by [@tsapeta](https://github.com/tsapeta))
|
|
23
|
+
- Added support for referencing to `Property`'s owner properties using Swift key paths. ([#20610](https://github.com/expo/expo/pull/20610) by [@tsapeta](https://github.com/tsapeta))
|
|
24
|
+
|
|
25
|
+
### 🐛 Bug fixes
|
|
26
|
+
|
|
27
|
+
- Fixed build errors when testing on React Native nightly builds. ([#19805](https://github.com/expo/expo/pull/19805) by [@kudo](https://github.com/kudo))
|
|
28
|
+
- Fixed failed resolution of 'java.nio.file.Path' on Android. ([#20037](https://github.com/expo/expo/pull/20037) by [@lukmccall](https://github.com/lukmccall))
|
|
29
|
+
- Fixed libraries using the `ViewDefinitionBuilder` crashes when ProGuard or R8 is enabled on Android. ([#20197](https://github.com/expo/expo/pull/20197) by [@lukmccall](https://github.com/lukmccall))
|
|
30
|
+
- Fixed Either types not supporting non-primitive types on iOS. ([#20247](https://github.com/expo/expo/pull/20247) by [@tsapeta](https://github.com/tsapeta))
|
|
31
|
+
- Fixed Function not supporting certain arities on Android. ([#20419](https://github.com/expo/expo/pull/20419) by [@motiz88](https://github.com/motiz88))
|
|
32
|
+
- Added React Native 0.71 support. ([#20470](https://github.com/expo/expo/pull/20470) by [@kudo](https://github.com/kudo))
|
|
33
|
+
- Fixed the `SharedObject` initializer being inaccessible due to `internal` protection level. ([#20588](https://github.com/expo/expo/pull/20588) by [@tsapeta](https://github.com/tsapeta))
|
|
34
|
+
|
|
35
|
+
### 💡 Others
|
|
36
|
+
|
|
37
|
+
- [iOS] Make `Enumerable` protocol implement `CaseIterable` to get rid of operating on unsafe pointers. ([#20640](https://github.com/expo/expo/pull/20640) by [@tsapeta](https://github.com/tsapeta))
|
|
38
|
+
|
|
39
|
+
## 1.0.4 - 2022-12-21
|
|
14
40
|
|
|
15
41
|
### 🐛 Bug fixes
|
|
16
42
|
|
|
17
|
-
- Fixed
|
|
43
|
+
- Fixed views are not correctly initialized after reloading on Android. ([#20063](https://github.com/expo/expo/pull/20063) by [@lukmccall](https://github.com/lukmccall))
|
|
44
|
+
- Fixed threading crash issue when running with Hermes on iOS. ([#20506](https://github.com/expo/expo/pull/20506) by [@kudo](https://github.com/kudo))
|
|
18
45
|
|
|
19
|
-
## 1.0.2
|
|
46
|
+
## 1.0.2 - 2022-11-08
|
|
20
47
|
|
|
21
48
|
### 💡 Others
|
|
22
49
|
|
package/ExpoModulesCore.podspec
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
reactNativeVersion = '0.0.0'
|
|
6
|
+
begin
|
|
7
|
+
reactNativeVersion = `node --print "require('react-native/package.json').version"`
|
|
8
|
+
rescue
|
|
9
|
+
reactNativeVersion = '0.0.0'
|
|
10
|
+
end
|
|
11
|
+
if ENV["REACT_NATIVE_OVERRIDE_VERSION"]
|
|
12
|
+
reactNativeVersion = ENV["REACT_NATIVE_OVERRIDE_VERSION"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
REACT_NATIVE_MINOR_VERSION = reactNativeVersion.split('.')[1].to_i
|
|
16
|
+
|
|
4
17
|
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
5
|
-
fabric_compiler_flags = '-DRN_FABRIC_ENABLED'
|
|
18
|
+
fabric_compiler_flags = '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED'
|
|
6
19
|
folly_version = '2021.07.22.00'
|
|
7
20
|
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
8
21
|
|
|
@@ -20,24 +33,44 @@ Pod::Spec.new do |s|
|
|
|
20
33
|
s.static_framework = true
|
|
21
34
|
s.header_dir = 'ExpoModulesCore'
|
|
22
35
|
|
|
36
|
+
header_search_paths = [
|
|
37
|
+
# EXJavaScriptRuntime -> Hermes
|
|
38
|
+
'"$(PODS_ROOT)/boost"',
|
|
39
|
+
'"$(PODS_ROOT)/DoubleConversion"',
|
|
40
|
+
'"$(PODS_ROOT)/RCT-Folly"',
|
|
41
|
+
'"${PODS_ROOT}/Headers/Public/React-hermes"',
|
|
42
|
+
'"${PODS_ROOT}/Headers/Public/hermes-engine"',
|
|
43
|
+
|
|
44
|
+
# EXAppDelegateWrapper -> RCTAppDelegate -> RCTCxxBridgeDelegate
|
|
45
|
+
'"${PODS_ROOT}/Headers/Private/React-Core"',
|
|
46
|
+
|
|
47
|
+
# similar to https://github.com/facebook/react-native/commit/c4b51e8d7, review this when we drop SDK 47
|
|
48
|
+
'"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging"',
|
|
49
|
+
'"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"',
|
|
50
|
+
]
|
|
51
|
+
|
|
23
52
|
# Swift/Objective-C compatibility
|
|
24
53
|
s.pod_target_xcconfig = {
|
|
25
54
|
'USE_HEADERMAP' => 'YES',
|
|
26
55
|
'DEFINES_MODULE' => 'YES',
|
|
27
56
|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
|
28
57
|
'SWIFT_COMPILATION_MODE' => 'wholemodule',
|
|
29
|
-
'HEADER_SEARCH_PATHS' =>
|
|
58
|
+
'HEADER_SEARCH_PATHS' => header_search_paths.join(' '),
|
|
59
|
+
"FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
|
|
30
60
|
'OTHER_SWIFT_FLAGS' => "$(inherited) #{fabric_enabled ? fabric_compiler_flags : ''}"
|
|
31
61
|
}
|
|
32
62
|
s.user_target_xcconfig = {
|
|
33
63
|
"HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"",
|
|
34
64
|
}
|
|
35
65
|
|
|
66
|
+
compiler_flags = folly_compiler_flags + ' ' + "-DREACT_NATIVE_MINOR_VERSION=#{REACT_NATIVE_MINOR_VERSION}"
|
|
67
|
+
|
|
36
68
|
s.dependency 'React-Core'
|
|
37
69
|
s.dependency 'ReactCommon/turbomodule/core'
|
|
70
|
+
s.dependency 'React-RCTAppDelegate' if REACT_NATIVE_MINOR_VERSION >= 71
|
|
38
71
|
|
|
39
72
|
if fabric_enabled
|
|
40
|
-
|
|
73
|
+
compiler_flags << ' ' << fabric_compiler_flags
|
|
41
74
|
|
|
42
75
|
s.dependency 'React-RCTFabric'
|
|
43
76
|
s.dependency 'RCT-Folly', folly_version
|
|
@@ -55,8 +88,9 @@ Pod::Spec.new do |s|
|
|
|
55
88
|
exclude_files.append('ios/Fabric/')
|
|
56
89
|
exclude_files.append('common/cpp/fabric/')
|
|
57
90
|
end
|
|
58
|
-
s.exclude_files = exclude_files
|
|
59
91
|
|
|
92
|
+
s.exclude_files = exclude_files
|
|
93
|
+
s.compiler_flags = compiler_flags
|
|
60
94
|
s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
|
|
61
95
|
|
|
62
96
|
s.test_spec 'Tests' do |test_spec|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -6,7 +6,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
6
6
|
set(CMAKE_CXX_STANDARD 17)
|
|
7
7
|
set(PACKAGE_NAME "expo-modules-core")
|
|
8
8
|
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
|
9
|
-
set(ignoreMe "${PROJECT_BUILD_DIR} ${REACT_ANDROID_BUILD_DIR} ${REACT_ANDROID_DIR} ${HERMES_HEADER_DIR}")
|
|
9
|
+
set(ignoreMe "${PROJECT_BUILD_DIR} ${REACT_ANDROID_BUILD_DIR} ${REACT_NATIVE_TARGET_VERSION} ${REACT_ANDROID_DIR} ${HERMES_HEADER_DIR}")
|
|
10
10
|
|
|
11
11
|
if (${NATIVE_DEBUG})
|
|
12
12
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
|
|
@@ -72,8 +72,6 @@ if (NOT LIBRN_DIR)
|
|
|
72
72
|
file(GLOB LIBRN_DIR "${REACT_NATIVE_SO_DIR}")
|
|
73
73
|
endif ()
|
|
74
74
|
|
|
75
|
-
file(GLOB libfbjni_include_DIRS "${BUILD_DIR}/fbjni-*-headers.jar/")
|
|
76
|
-
|
|
77
75
|
# tests
|
|
78
76
|
|
|
79
77
|
if(${UNIT_TEST})
|
|
@@ -100,81 +98,33 @@ else()
|
|
|
100
98
|
set(JSEXECUTOR_INCLUDE "")
|
|
101
99
|
endif()
|
|
102
100
|
|
|
101
|
+
# find libraries
|
|
102
|
+
|
|
103
|
+
find_library(LOG_LIB log)
|
|
104
|
+
|
|
105
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
106
|
+
|
|
107
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
103
108
|
|
|
104
109
|
# includes
|
|
105
110
|
|
|
111
|
+
get_target_property(INCLUDE_reactnativejni
|
|
112
|
+
ReactAndroid::reactnativejni
|
|
113
|
+
INTERFACE_INCLUDE_DIRECTORIES)
|
|
106
114
|
target_include_directories(
|
|
107
115
|
${PACKAGE_NAME}
|
|
108
116
|
PRIVATE
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react"
|
|
117
|
+
${INCLUDE_reactnativejni}/react
|
|
118
|
+
|
|
119
|
+
# header only imports from turbomodule, e.g. CallInvokerHolder.h
|
|
113
120
|
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
|
|
114
|
-
|
|
115
|
-
"${REACT_NATIVE_DIR}/ReactCommon"
|
|
116
|
-
"${REACT_NATIVE_DIR}/ReactCommon/react/nativemodule/core"
|
|
117
|
-
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
|
118
|
-
"${REACT_NATIVE_DIR}/ReactCommon/jsi"
|
|
121
|
+
|
|
119
122
|
"${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}"
|
|
120
|
-
"${BUILD_DIR}/third-party-ndk/double-conversion"
|
|
121
|
-
"${BUILD_DIR}/third-party-ndk/folly"
|
|
122
|
-
"${libfbjni_include_DIRS}"
|
|
123
123
|
"${COMMON_DIR}"
|
|
124
124
|
"${JSEXECUTOR_INCLUDE}"
|
|
125
125
|
"${SRC_DIR}/fabric"
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
-
# find libraries
|
|
129
|
-
|
|
130
|
-
find_library(LOG_LIB log)
|
|
131
|
-
|
|
132
|
-
if(${REACT_NATIVE_TARGET_VERSION} LESS 69)
|
|
133
|
-
find_library(
|
|
134
|
-
FOLLY_LIB
|
|
135
|
-
folly_json
|
|
136
|
-
PATHS ${LIBRN_DIR}
|
|
137
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
138
|
-
)
|
|
139
|
-
else()
|
|
140
|
-
find_library(
|
|
141
|
-
FOLLY_LIB
|
|
142
|
-
folly_runtime
|
|
143
|
-
PATHS ${LIBRN_DIR}
|
|
144
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
145
|
-
)
|
|
146
|
-
endif()
|
|
147
|
-
|
|
148
|
-
find_library(
|
|
149
|
-
FBJNI_LIB
|
|
150
|
-
fbjni
|
|
151
|
-
PATHS ${LIBRN_DIR}
|
|
152
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
find_library(
|
|
156
|
-
JSI_LIB
|
|
157
|
-
jsi
|
|
158
|
-
PATHS ${LIBRN_DIR}
|
|
159
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
find_library(
|
|
163
|
-
REACT_NATIVE_JNI_LIB
|
|
164
|
-
reactnativejni
|
|
165
|
-
PATHS ${LIBRN_DIR}
|
|
166
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
find_library(
|
|
170
|
-
REACT_NATIVE_MODULES_CORE
|
|
171
|
-
react_nativemodule_core
|
|
172
|
-
PATHS ${LIBRN_DIR}
|
|
173
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
#reactnativejni
|
|
177
|
-
|
|
178
128
|
# linking
|
|
179
129
|
|
|
180
130
|
target_compile_options(
|
|
@@ -190,12 +140,12 @@ target_link_libraries(
|
|
|
190
140
|
${PACKAGE_NAME}
|
|
191
141
|
CommonSettings
|
|
192
142
|
${LOG_LIB}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
${REACT_NATIVE_MODULES_CORE}
|
|
143
|
+
fbjni::fbjni
|
|
144
|
+
ReactAndroid::jsi
|
|
145
|
+
ReactAndroid::reactnativejni
|
|
146
|
+
ReactAndroid::folly_runtime
|
|
147
|
+
ReactAndroid::react_nativemodule_core
|
|
199
148
|
android
|
|
149
|
+
${JSEXECUTOR_LIB}
|
|
200
150
|
${NEW_ARCHITECTURE_DEPENDENCIES}
|
|
201
151
|
)
|
|
@@ -13,3 +13,203 @@ class KotlinExpoModulesCorePlugin implements Plugin<Project> {
|
|
|
13
13
|
ext.applyKotlinExpoModulesCorePlugin = {
|
|
14
14
|
apply plugin: KotlinExpoModulesCorePlugin
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
// [BEGIN] Remove when we drop SDK 47
|
|
18
|
+
abstract class ExtractReactNativeAARTask extends DefaultTask {
|
|
19
|
+
@Input
|
|
20
|
+
abstract Property<String> getBuildType()
|
|
21
|
+
|
|
22
|
+
@Input
|
|
23
|
+
abstract Property<String> getReactNativeDir()
|
|
24
|
+
|
|
25
|
+
@TaskAction
|
|
26
|
+
def taskAction() {
|
|
27
|
+
def suffix = buildType.get() == 'Debug' ? '-debug' : '-release'
|
|
28
|
+
def rnAARs = project.fileTree("${reactNativeDir.get()}/android").matching { include "**/react-native/**/*${suffix}.aar" }
|
|
29
|
+
if (rnAARs.isEmpty()) {
|
|
30
|
+
rnAARs = project.fileTree("${reactNativeDir.get()}/android").matching { include "**/react-native/**/*.aar" }
|
|
31
|
+
}
|
|
32
|
+
if (rnAARs.any()) {
|
|
33
|
+
// node_modules/react-native has a .aar, extract headers
|
|
34
|
+
if (rnAARs.size() > 1) {
|
|
35
|
+
logger.error("More than one React Native AAR file has been found:")
|
|
36
|
+
rnAARs.each {println(it) }
|
|
37
|
+
throw new GradleException("Multiple React Native AARs found:\n${rnAARs.join("\n")}" +
|
|
38
|
+
"\nRemove the old ones and try again")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
def rnAAR = rnAARs.singleFile
|
|
42
|
+
def file = rnAAR.absoluteFile
|
|
43
|
+
def packageName = file.name.tokenize('-')[0]
|
|
44
|
+
project.copy {
|
|
45
|
+
from project.zipTree(file)
|
|
46
|
+
into "${project.buildDir}/${packageName}"
|
|
47
|
+
include "jni/**/*"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class LegacyReactNativeLibsExtractionPlugin implements Plugin<Project> {
|
|
53
|
+
void nativeBuildDependsOn(project, dependsOnTask, buildTypesIncludes) {
|
|
54
|
+
def buildTasks = project.tasks.findAll { task ->
|
|
55
|
+
def taskName = task.name
|
|
56
|
+
if (taskName.contains("Clean")) { return false }
|
|
57
|
+
if (taskName.contains("externalNative") || taskName.contains("CMake") || taskName.contains("generateJsonModel")) {
|
|
58
|
+
if (buildTypesIncludes == null) { return true }
|
|
59
|
+
for (buildType in buildTypesIncludes) {
|
|
60
|
+
if (taskName.contains(buildType)) { return true }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void apply(Project project) {
|
|
69
|
+
def REACT_NATIVE_BUILD_FROM_SOURCE = project.findProject(":ReactAndroid") != null
|
|
70
|
+
def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
|
|
71
|
+
? project.findProject(":ReactAndroid").getProjectDir().parent
|
|
72
|
+
: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, project.rootDir).text.trim()).parent
|
|
73
|
+
|
|
74
|
+
def reactProperties = new Properties()
|
|
75
|
+
new File("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
76
|
+
def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION")
|
|
77
|
+
def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION")
|
|
78
|
+
def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION")
|
|
79
|
+
def REACT_NATIVE_VERSION = System.getenv("REACT_NATIVE_OVERRIDE_VERSION") ?: reactProperties.getProperty("VERSION_NAME")
|
|
80
|
+
def REACT_NATIVE_TARGET_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
|
81
|
+
|
|
82
|
+
def isNewArchitectureEnabled = project.findProperty("newArchEnabled") == "true"
|
|
83
|
+
def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
|
|
84
|
+
def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("${project.buildDir}/downloads")
|
|
85
|
+
def thirdPartyNdkDir = new File("${project.buildDir}/third-party-ndk")
|
|
86
|
+
def reactNativeThirdParty = new File("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/third-party")
|
|
87
|
+
|
|
88
|
+
def createNativeDepsDirectories = project.tasks.findByName('createNativeDepsDirectories') ?: project.tasks.register('createNativeDepsDirectories') {
|
|
89
|
+
downloadsDir.mkdirs()
|
|
90
|
+
thirdPartyNdkDir.mkdirs()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
def extractReactNativeAARRelease = project.tasks.register('extractReactNativeAARRelease', ExtractReactNativeAARTask) {
|
|
94
|
+
reactNativeDir = REACT_NATIVE_DIR
|
|
95
|
+
buildType = 'Release'
|
|
96
|
+
}
|
|
97
|
+
def extractReactNativeAARDebug = project.tasks.register('extractReactNativeAARDebug', ExtractReactNativeAARTask) {
|
|
98
|
+
reactNativeDir = REACT_NATIVE_DIR
|
|
99
|
+
buildType = 'Debug'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
def packageReactNdkDebugLibs = project.tasks.register("packageReactNdkDebugLibs", Copy) {
|
|
103
|
+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
|
|
104
|
+
from("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/prebuilt/lib")
|
|
105
|
+
into("${project.buildDir}/react-ndk/exported")
|
|
106
|
+
}
|
|
107
|
+
def packageReactNdkReleaseLibs = project.tasks.register("packageReactNdkReleaseLibs", Copy) {
|
|
108
|
+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
|
|
109
|
+
from("$REACT_NATIVE_DIR/ReactAndroid/src/main/jni/prebuilt/lib")
|
|
110
|
+
into("${project.buildDir}/react-ndk/exported")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// [BEGIN] Extra libs
|
|
114
|
+
def downloadDoubleConversion = project.tasks.create('downloadDoubleConversion', project.Download) {
|
|
115
|
+
dependsOn(createNativeDepsDirectories)
|
|
116
|
+
src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
|
|
117
|
+
onlyIfNewer(true)
|
|
118
|
+
overwrite(false)
|
|
119
|
+
dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
def prepareDoubleConversion = project.tasks.register('prepareDoubleConversion', Copy) {
|
|
123
|
+
dependsOn(downloadDoubleConversion)
|
|
124
|
+
from(project.tarTree(downloadDoubleConversion.dest))
|
|
125
|
+
from("$reactNativeThirdParty/double-conversion/Android.mk")
|
|
126
|
+
include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
|
|
127
|
+
filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
|
|
128
|
+
includeEmptyDirs = false
|
|
129
|
+
into("$thirdPartyNdkDir/double-conversion")
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
def downloadFolly = project.tasks.create('downloadFolly', project.Download) {
|
|
133
|
+
dependsOn(createNativeDepsDirectories)
|
|
134
|
+
src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
|
|
135
|
+
onlyIfNewer(true)
|
|
136
|
+
overwrite(false)
|
|
137
|
+
dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
def prepareFolly = project.tasks.register('prepareFolly', Copy) {
|
|
141
|
+
dependsOn(downloadFolly)
|
|
142
|
+
from(project.tarTree(downloadFolly.dest))
|
|
143
|
+
from("$reactNativeThirdParty/folly/Android.mk")
|
|
144
|
+
include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
|
|
145
|
+
eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
|
|
146
|
+
// Fixes problem with Folly failing to build on certain systems. See
|
|
147
|
+
// https://github.com/software-mansion/react-native-reanimated/issues/1024
|
|
148
|
+
def follyReplaceContent = '''
|
|
149
|
+
ssize_t r;
|
|
150
|
+
do {
|
|
151
|
+
r = open(name, flags, mode);
|
|
152
|
+
} while (r == -1 && errno == EINTR);
|
|
153
|
+
return r;
|
|
154
|
+
'''
|
|
155
|
+
filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) }
|
|
156
|
+
includeEmptyDirs = false
|
|
157
|
+
into("$thirdPartyNdkDir/folly")
|
|
158
|
+
}
|
|
159
|
+
// [END] Extra libs
|
|
160
|
+
|
|
161
|
+
project.afterEvaluate {
|
|
162
|
+
if (REACT_NATIVE_BUILD_FROM_SOURCE) {
|
|
163
|
+
nativeBuildDependsOn(project, ":ReactAndroid:copyReleaseJniLibsProjectOnly", ["Release", "RelWithDebInfo"])
|
|
164
|
+
nativeBuildDependsOn(project, ":ReactAndroid:copyDebugJniLibsProjectOnly", ["Debug"])
|
|
165
|
+
} else {
|
|
166
|
+
nativeBuildDependsOn(project, extractReactNativeAARRelease, ["Release", "RelWithDebInfo"])
|
|
167
|
+
nativeBuildDependsOn(project, extractReactNativeAARDebug, ["Debug"])
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
def extraLibs = project.extensions.extraProperties.has('extraLegacyReactNativeLibs')
|
|
171
|
+
? project.extensions.extraProperties.get('extraLegacyReactNativeLibs')
|
|
172
|
+
: []
|
|
173
|
+
extraLibs.each {
|
|
174
|
+
nativeBuildDependsOn(project, project.tasks.named(it), null)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (isNewArchitectureEnabled) {
|
|
178
|
+
def preDebugBuild = project.tasks.named('preDebugBuild')
|
|
179
|
+
def preReleaseBuild = project.tasks.named('preReleaseBuild')
|
|
180
|
+
preDebugBuild.configure {
|
|
181
|
+
dependsOn(packageReactNdkDebugLibs)
|
|
182
|
+
}
|
|
183
|
+
preReleaseBuild.configure {
|
|
184
|
+
dependsOn(packageReactNdkReleaseLibs)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Due to a bug inside AGP, we have to explicitly set a dependency
|
|
188
|
+
// between configureCMake* tasks and the preBuild tasks.
|
|
189
|
+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
|
|
190
|
+
project.tasks.named('configureCMakeDebug').configure {
|
|
191
|
+
dependsOn(preDebugBuild)
|
|
192
|
+
}
|
|
193
|
+
project.tasks.named('configureCMakeRelWithDebInfo').configure {
|
|
194
|
+
dependsOn(preReleaseBuild)
|
|
195
|
+
}
|
|
196
|
+
def reactNativeArchitectures = project.getProperties().get("reactNativeArchitectures")?.split(",") ?: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
197
|
+
|
|
198
|
+
reactNativeArchitectures.each { architecture ->
|
|
199
|
+
project.tasks.named("configureCMakeDebug[${architecture}]")?.configure {
|
|
200
|
+
dependsOn("preDebugBuild")
|
|
201
|
+
}
|
|
202
|
+
project.tasks.named("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
|
|
203
|
+
dependsOn("preReleaseBuild")
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
ext.applyLegacyReactNativeLibsExtractionPlugin = {
|
|
212
|
+
apply plugin: LegacyReactNativeLibsExtractionPlugin
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// [END] Remove when we drop SDK 47
|