@@ -13,10 +13,7 @@ import de.undercouch.gradle.tasks.download.Download
13
13
import org.apache.tools.ant.taskdefs.condition.Os
14
14
import org.apache.tools.ant.filters.ReplaceTokens
15
15
16
- // In FB react-native, we are downloading all third dependencies source code during build time and then build and consume it.
17
- // We got rid of this due to anti-compliance and other requirements like building on other environment like clang.
18
- // Now we have all third party dependencies as separate git repo which are then sub modules of react-native.
19
- // For boost, we are getting source though nuget. After this we are following the same approach.
16
+ // We download various C++ open-source dependencies into downloads.
20
17
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
21
18
// After that we build native code from src/main/jni with module path pointing at third-party-ndk.
22
19
@@ -35,19 +32,15 @@ def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
35
32
// The Boost library is a very large download (>100MB).
36
33
// If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable
37
34
// and the build will use that.
38
- def boostPath = dependenciesPath ?: System . getenv(" REACT_NATIVE_BOOST_PATH" ) ?: ' packages/boost.1.68.0.0/lib/native/include '
35
+ def boostPath = dependenciesPath ?: System . getenv(" REACT_NATIVE_BOOST_PATH" )
39
36
40
- def DoubleConversionPath = ' ../double-conversion'
41
- def FollyPath = ' ..'
42
- def GlogPath = ' ..'
43
37
def V8Path = ' packages/ReactNative.V8.Android.7.0.276.32-v1'
44
38
45
39
task createNativeDepsDirectories {
46
40
downloadsDir. mkdirs()
47
41
thirdPartyNdkDir. mkdirs()
48
42
}
49
43
50
- // For GitHub CI - we use this task
51
44
task downloadBoost (dependsOn : createNativeDepsDirectories, type : Download ) {
52
45
src(" https://github.com/react-native-community/boost-for-react-native/releases/download/v${ BOOST_VERSION.replace("_", ".")} -0/boost_${ BOOST_VERSION} .tar.gz" )
53
46
onlyIfNewer(true )
@@ -68,27 +61,48 @@ task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
68
61
// }
69
62
}
70
63
71
- task prepareDoubleConversion (dependsOn : createNativeDepsDirectories, type : Copy ) {
72
- from(DoubleConversionPath )
64
+ task downloadDoubleConversion (dependsOn : createNativeDepsDirectories, type : Download ) {
65
+ src(" https://github.com/google/double-conversion/archive/v${ DOUBLE_CONVERSION_VERSION} .tar.gz" )
66
+ onlyIfNewer(true )
67
+ overwrite(false )
68
+ dest(new File (downloadsDir, " double-conversion-${ DOUBLE_CONVERSION_VERSION} .tar.gz" ))
69
+ }
70
+
71
+ task prepareDoubleConversion (dependsOn : dependenciesPath ? [] : [downloadDoubleConversion], type: Copy ) {
72
+ from(dependenciesPath ?: tarTree(downloadDoubleConversion. dest))
73
73
from(" src/main/jni/third-party/double-conversion/Android.mk" )
74
74
include ' double-conversion/**/*' , ' Android.mk'
75
75
includeEmptyDirs = false
76
76
into(" $thirdPartyNdkDir /double-conversion" )
77
77
}
78
78
79
- task prepareFolly (dependsOn : createNativeDepsDirectories, type : Copy ) {
80
- from(FollyPath )
79
+ task downloadFolly (dependsOn : createNativeDepsDirectories, type : Download ) {
80
+ src(" https://github.com/facebook/folly/archive/v${ FOLLY_VERSION} .tar.gz" )
81
+ onlyIfNewer(true )
82
+ overwrite(false )
83
+ dest(new File (downloadsDir, " folly-${ FOLLY_VERSION} .tar.gz" ))
84
+ }
85
+
86
+ task prepareFolly (dependsOn : dependenciesPath ? [] : [downloadFolly], type: Copy ) {
87
+ from(dependenciesPath ?: tarTree(downloadFolly. dest))
81
88
from(" src/main/jni/third-party/folly/Android.mk" )
82
89
include(" Folly/folly/**/*" , " Android.mk" )
83
90
eachFile {fname -> fname. path = (fname. path - " Folly/" )}
84
91
includeEmptyDirs = false
85
92
into(" $thirdPartyNdkDir /folly" )
86
93
}
87
94
95
+ task downloadGlog (dependsOn : createNativeDepsDirectories, type : Download ) {
96
+ src(" https://github.com/google/glog/archive/v${ GLOG_VERSION} .tar.gz" )
97
+ onlyIfNewer(true )
98
+ overwrite(false )
99
+ dest(new File (downloadsDir, " glog-${ GLOG_VERSION} .tar.gz" ))
100
+ }
101
+
88
102
// Prepare glog sources to be compiled, this task will perform steps that normally should've been
89
103
// executed by automake. This way we can avoid dependencies on make/automake
90
- task prepareGlog (dependsOn : createNativeDepsDirectories , type : Copy ) {
91
- from(GlogPath )
104
+ task prepareGlog (dependsOn : dependenciesPath ? [] : [downloadGlog] , type: Copy ) {
105
+ from(dependenciesPath ?: tarTree(downloadGlog . dest) )
92
106
from(" src/main/jni/third-party/glog/" )
93
107
include(" glog/src/**/*" , " Android.mk" , " config.h" )
94
108
includeEmptyDirs = false
@@ -153,6 +167,9 @@ task downloadNdkBuildDependencies {
153
167
if (! boostPath) {
154
168
dependsOn(downloadBoost)
155
169
}
170
+ dependsOn(downloadDoubleConversion)
171
+ dependsOn(downloadFolly)
172
+ dependsOn(downloadGlog)
156
173
}
157
174
158
175
def getNdkBuildName () {
@@ -216,7 +233,7 @@ def getNdkBuildFullPath() {
216
233
return ndkBuildFullPath
217
234
}
218
235
219
- task buildReactNdkLib (dependsOn : [prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type : Exec ) {
236
+ task buildReactNdkLib (dependsOn : [prepareJSC, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type : Exec ) {
220
237
inputs. dir(" $projectDir /../ReactCommon" )
221
238
inputs. dir(" src/main/jni" )
222
239
outputs. dir(" $buildDir /react-ndk/all" )
0 commit comments