@@ -207,92 +207,94 @@ tasks.register("buildAndInstallOpenSSL") {
207207
208208 def openSSLTarFile = file(" ${ temporaryDir} /${ opensslTarName} " )
209209
210- reactNativeArchitectures(). each { abi ->
211- def cmakeInstallDir = getCmakeInstallDir(abi)
212- if (new File (cmakeInstallDir, " lib/libssl.a" ). exists()) {
213- println (" [@ottrelite/interop-otel] OpenSSL already built for ABI $abi , skipping build." )
214- } else {
215- println (" [@ottrelite/interop-otel] Building OpenSSL using openssl_for_android for ABI $abi from ${ openSSLForAndroidSourceDir} and writing to source dir..." )
216-
217- // 1. Clean Git repo
218- exec {
219- workingDir openSSLForAndroidSourceDir
220- commandLine " git" , " reset" , " --hard" , " HEAD"
221- }
222- exec {
223- workingDir openSSLForAndroidSourceDir
224- commandLine " git" , " clean" , " -fd"
225- }
210+ doLast {
211+ reactNativeArchitectures(). each { abi ->
212+ def cmakeInstallDir = getCmakeInstallDir(abi)
213+ if (new File (cmakeInstallDir, " lib/libssl.a" ). exists()) {
214+ println (" [@ottrelite/interop-otel] OpenSSL already built, skipping build." )
215+ } else {
216+ println (" [@ottrelite/interop-otel] Building OpenSSL using openssl_for_android for ABI $abi from ${ openSSLForAndroidSourceDir} and writing to source dir..." )
226217
227- // 2. Download & extract OpenSSL
228- def openSSLForAndroidSourceDirFile = file(openSSLForAndroidSourceDir)
229- if (! openSSLForAndroidSourceDirFile. exists()) {
230- println (" [@ottrelite/interop-otel] Cloning openssl_for_android to ${ openSSLForAndroidSourceDir} ..." )
218+ // 1. Clean Git repo
219+ exec {
220+ workingDir openSSLForAndroidSourceDir
221+ commandLine " git" , " reset" , " --hard" , " HEAD"
222+ }
223+ exec {
224+ workingDir openSSLForAndroidSourceDir
225+ commandLine " git" , " clean" , " -fd"
226+ }
231227
228+ // 2. Download & extract OpenSSL
229+ def openSSLForAndroidSourceDirFile = file(openSSLForAndroidSourceDir)
232230 if (! openSSLForAndroidSourceDirFile. exists()) {
233- openSSLForAndroidSourceDirFile. mkdirs()
231+ println (" [@ottrelite/interop-otel] Cloning openssl_for_android to ${ openSSLForAndroidSourceDir} ..." )
232+
233+ if (! openSSLForAndroidSourceDirFile. exists()) {
234+ openSSLForAndroidSourceDirFile. mkdirs()
234235
235- exec {
236- commandLine " git" , " clone" , " --depth" , " 1" , " https://github.com/217heidai/openssl_for_android.git" , openSSLForAndroidSourceDir
236+ exec {
237+ commandLine " git" , " clone" , " --depth" , " 1" , " https://github.com/217heidai/openssl_for_android.git" , openSSLForAndroidSourceDir
238+ }
239+ } else {
240+ println (" [@ottrelite/interop-otel] openssl_for_android already cloned in ${ openSSLForAndroidSourceDir} " )
237241 }
238- } else {
239- println (" [@ottrelite/interop-otel] openssl_for_android already cloned in ${ openSSLForAndroidSourceDir} " )
240242 }
241- }
242243
243- if (! openSSLSourceDirFile. exists()) {
244- openSSLSourceDirFile. mkdirs()
244+ if (! openSSLSourceDirFile. exists()) {
245+ openSSLSourceDirFile. mkdirs()
245246
246- if (openSSLTarFile. exists()) {
247- println (" [@ottrelite/interop-otel] OpenSSL tarball already downloaded to ${ openSSLTarFile.path} , skipping download." )
248- }else {
249- println (" [@ottrelite/interop-otel] Downloading OpenSSL ${ opensslVersion} to ${ openSSLTarFile.path} ..." )
250- new URL (opensslUrl). withInputStream { i ->
251- openSSLTarFile. withOutputStream { it << i }
247+ if (openSSLTarFile. exists()) {
248+ println (" [@ottrelite/interop-otel] OpenSSL tarball already downloaded to ${ openSSLTarFile.path} , skipping download." )
249+ }else {
250+ println (" [@ottrelite/interop-otel] Downloading OpenSSL ${ opensslVersion} to ${ openSSLTarFile.path} ..." )
251+ new URL (opensslUrl). withInputStream { i ->
252+ openSSLTarFile. withOutputStream { it << i }
253+ }
252254 }
253- }
254255
255- println (" [@ottrelite/interop-otel] Extracting OpenSSL from ${ openSSLTarFile.path} to ${ openSSLSourceDir} ..." )
256+ println (" [@ottrelite/interop-otel] Extracting OpenSSL from ${ openSSLTarFile.path} to ${ openSSLSourceDir} ..." )
256257
257- copy {
258- from tarTree(openSSLTarFile. path)
258+ copy {
259+ from tarTree(openSSLTarFile. path)
259260
260- // below: actually, the script appends the openssl-${opensslVersion} directory by itself
261- into openSSLSourceDirFile. parent
261+ // below: actually, the script appends the openssl-${opensslVersion} directory by itself
262+ into openSSLSourceDirFile. parent
263+ }
264+ } else {
265+ println (" [@ottrelite/interop-otel] OpenSSL already extracted to ${ openSSLSourceDir} " )
262266 }
263- } else {
264- println (" [@ottrelite/interop-otel] OpenSSL already extracted to ${ openSSLSourceDir} " )
265- }
266267
267- def symlinkTarget = new File (openSSLSourceDirFile. parent, " android-ndk-${ android.ndkVersion} " )
268- if (! symlinkTarget. exists()) {
269- println (" [@ottrelite/interop-otel] Symlinking the Android NDK for openssl_for_android to ${ openSSLSourceDirFile.parent} ..." )
270- Files . createSymbolicLink(symlinkTarget. toPath(), android. ndkDirectory. toPath())
271- } else {
272- println (" [@ottrelite/interop-otel] Symlink target ${ symlinkTarget} already exists." )
273- }
268+ def symlinkTarget = new File (openSSLSourceDirFile. parent, " android-ndk-${ android.ndkVersion} " )
269+ if (! symlinkTarget. exists()) {
270+ println (" [@ottrelite/interop-otel] Symlinking the Android NDK for openssl_for_android to ${ openSSLSourceDirFile.parent} ..." )
271+ Files . createSymbolicLink(symlinkTarget. toPath(), android. ndkDirectory. toPath())
272+ } else {
273+ println (" [@ottrelite/interop-otel] Symlink target ${ symlinkTarget} already exists." )
274+ }
274275
275- // 3. Build OpenSSL
276- exec {
277- commandLine " bash" , new File (openSSLForAndroidSourceDir, " openssl_build_new.sh" ). path,
278- " ${ android.defaultConfig.minSdkVersion.apiLevel} " ,
279- " $abi " ,
280- " $opensslVersion " ,
281- " $android . ndkVersion "
282- }
276+ // 3. Build OpenSSL
277+ exec {
278+ commandLine " bash" , new File (openSSLForAndroidSourceDir, " openssl_build_new.sh" ). path,
279+ " ${ android.defaultConfig.minSdkVersion.apiLevel} " ,
280+ " $abi " ,
281+ " $opensslVersion " ,
282+ " $android . ndkVersion "
283+ }
283284
284- // 4. Copy built files to cmake install dir
285- def openSSLForAndroidBuildDir = getOpenSSLForAndroidBuildDir(abi)
285+ // 4. Copy built files to cmake install dir
286+ def openSSLForAndroidBuildDir = getOpenSSLForAndroidBuildDir(abi)
286287
287- println (" [@ottrelite/interop-otel] Copying OpenSSL build artifacts for ABI $abi from ${ openSSLForAndroidBuildDir} to ${ cmakeInstallDir} ..." )
288+ println (" [@ottrelite/interop-otel] Copying OpenSSL build artifacts for ABI $abi from ${ openSSLForAndroidBuildDir} to ${ cmakeInstallDir} ..." )
288289
289- copy {
290- from fileTree(openSSLForAndroidBuildDir) {
291- include " include/**"
292- include " lib/**"
293- }
290+ copy {
291+ from fileTree(openSSLForAndroidBuildDir) {
292+ include " include/**"
293+ include " lib/**"
294+ }
294295
295- into cmakeInstallDir
296+ into cmakeInstallDir
297+ }
296298 }
297299 }
298300 }
@@ -534,6 +536,11 @@ tasks.register("buildAndInstallCppWrapper") {
534536 def wrapperBuildDir = getWrapperBuildDir(abi)
535537 def cmakeInstallDir = getCmakeInstallDir(abi)
536538
539+ if (new File (cmakeInstallDir, " lib/libopentelemetry_common.a" ). exists()) {
540+ println (" [@ottrelite/interop-otel] C++ OTEL wrapper already built and installed to ${ getCmakeInstallDir(abi)} , skipping build." )
541+ return
542+ }
543+
537544 println (" [@ottrelite/interop-otel] Building & installing artifacts for ABI $abi , this may take a while..." )
538545
539546 if (! new File (wrapperBuildDir). exists()) {
0 commit comments