Skip to content

Commit 215b063

Browse files
committed
chore: add clean script to ottrelite interop otel
1 parent 07f4b21 commit 215b063

File tree

3 files changed

+39
-85
lines changed

3 files changed

+39
-85
lines changed

examples/rn-app/ios/license_plist.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ manual:
14031403
14041404
version: '18.3.1'
14051405
source: https://github.com/facebook/react
1406-
file: '../../../node_modules/pretty-format/node_modules/react-is/LICENSE'
1406+
file: '../../../node_modules/react-is/LICENSE'
14071407
14081408
version: '0.83.1'
14091409
source: https://github.com/facebook/metro
@@ -1523,7 +1523,7 @@ manual:
15231523
15241524
version: '2.20.3'
15251525
source: https://github.com/tj/commander.js
1526-
file: '../../../node_modules/terser/node_modules/commander/LICENSE'
1526+
file: '../../../node_modules/commander/LICENSE'
15271527
15281528
version: '0.5.21'
15291529
source: https://github.com/evanw/node-source-map-support
@@ -1791,7 +1791,7 @@ manual:
17911791
17921792
version: '12.1.0'
17931793
source: https://github.com/tj/commander.js
1794-
file: '../../../node_modules/commander/LICENSE'
1794+
file: '../../../node_modules/react-native/node_modules/commander/LICENSE'
17951795
17961796
version: '29.7.0'
17971797
source: https://github.com/jestjs/jest
@@ -1955,7 +1955,7 @@ manual:
19551955
19561956
version: '16.13.1'
19571957
source: https://github.com/facebook/react
1958-
file: '../../../node_modules/react-is/LICENSE'
1958+
file: '../../../node_modules/hoist-non-react-statics/node_modules/react-is/LICENSE'
19591959
19601960
version: '3.2.1'
19611961
source: Qix-/color

packages/interop-otel/android/build.gradle

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,23 @@ dependencies {
170170
def isReleaseBuild = project.hasProperty("buildType") && project.buildType == "release"
171171
def cxxBuildVariantDirName = isReleaseBuild ? "Release" : "Debug"
172172
def thirdPartySourceDir = file("${project.projectDir}/../third_party").absolutePath
173-
def otelSourceDir = "$thirdPartySourceDir/opentelemetry-cpp"
174173
def protobufSourceDir = "$thirdPartySourceDir/protobuf"
175174
def openSSLForAndroidSourceDir = "$thirdPartySourceDir/openssl_for_android"
176175
def brotliSourceDir = "$thirdPartySourceDir/brotli"
177176
def zlibSourceDir = "$thirdPartySourceDir/zlib"
178177
def curlSourceDir = "$thirdPartySourceDir/curl"
179178
def wrapperRootDir = "$thirdPartySourceDir/wrapper"
180-
def getWrapperBuildDir = { String abi -> "$wrapperRootDir/android/$cxxBuildVariantDirName/$abi" }
181-
def getGeneric3PBuildDir = { String libName, String abi -> "$wrapperRootDir/android/$cxxBuildVariantDirName/$abi/$libName" }
179+
def wrapperBuildDir = "$wrapperRootDir/android"
180+
def getCmakeInstallDir = { String abi -> "$wrapperBuildDir/install/$abi" }
181+
def getGeneric3PBuildDir = { String libName, String abi -> "$wrapperBuildDir/$cxxBuildVariantDirName/$abi/$libName" }
182182
def getProtobufBuildDir = { String abi -> getGeneric3PBuildDir("protobuf", abi) }
183183
def getOpenSSLForAndroidBuildDir = { String abi -> new File(openSSLForAndroidSourceDir, "openssl_${opensslVersion}_${abi}").path }
184184
def getBrotliBuildDir = { String abi -> getGeneric3PBuildDir("brotli", abi) }
185185
def getZlibBuildDir = { String abi -> getGeneric3PBuildDir("zlib", abi) }
186186
def getCurlBuildDir = { String abi -> getGeneric3PBuildDir("curl", abi) }
187-
def getCmakeInstallDir = { String abi -> "$wrapperRootDir/android/install/$abi" }
188187

189188
def prepareOttreliteInteropHeadersTask = tasks.register('prepareOttreliteInteropHeadersTask', Copy) {
189+
println("Preparing Ottrelite Interop OTEL headers...")
190190
from files(
191191
fileTree('../cpp/include/public/'),
192192
fileTree('../nitrogen/generated/shared/c++/')
@@ -237,7 +237,7 @@ tasks.register("buildOpenSSL") {
237237
copy {
238238
from tarTree(tarFile.path)
239239

240-
// below: actually, the script creates the openssl-${opensslVersion} directory by itself
240+
// below: actually, the script appends the openssl-${opensslVersion} directory by itself
241241
into openSSLSourceDirFile.parent
242242
}
243243
} else {
@@ -571,81 +571,35 @@ tasks.register("buildAndInstallProtobuf") {
571571
}
572572
}
573573

574-
//// CPP wrapper + OTEL CPP SDK
575-
//tasks.register("buildAndInstallCppWrapper") {
576-
// doFirst {
577-
// if (!new File(otelSourceDir, "CMakeLists.txt").exists()) {
578-
// println("[@ottrelite/interop-otel] Cloning OpenTelemetry C++ SDK to ${otelSourceDir}...")
579-
//
580-
// if (!file(otelSourceDir).exists()) {
581-
// file(otelSourceDir).mkdirs()
582-
// exec {
583-
// commandLine "git", "clone", "--depth", "1", "--branch", "v1.23.0", "https://github.com/open-telemetry/opentelemetry-cpp.git", otelSourceDir
584-
// }
585-
// }
586-
// } else {
587-
// println("[@ottrelite/interop-otel] OpenTelemetry C++ SDK already cloned in ${otelSourceDir}")
588-
// }
589-
// }
590-
//
591-
// doLast {
592-
// reactNativeArchitectures().each { abi ->
593-
// def wrapperBuildDir = getWrapperBuildDir(abi)
594-
// def cmakeInstallDir = getCmakeInstallDir(abi)
595-
//
596-
// println("[@ottrelite/interop-otel] Building & installing artifacts for ABI $abi, this may take a while...")
597-
//
598-
// if (!new File(wrapperBuildDir).exists()) {
599-
// file(wrapperBuildDir).mkdirs()
600-
// }
601-
//
602-
// exec {
603-
// println("[@ottrelite/interop-otel] Configuring for ABI $abi from ${thirdPartySourceDir} and writing to ${wrapperBuildDir}...")
604-
//
605-
// commandLine "cmake", "-S", thirdPartySourceDir, "-B", wrapperBuildDir,
606-
// "-DANDROID_ABI=$abi",
607-
// "-DANDROID_PLATFORM=${android.defaultConfig.minSdkVersion.apiLevel}",
608-
// "-DCMAKE_TOOLCHAIN_FILE=${android.ndkDirectory}/build/cmake/android.toolchain.cmake",
609-
// "-DCMAKE_BUILD_TYPE=${cxxBuildVariantDirName}",
610-
// "-DCMAKE_CXX_FLAGS_DEBUG=-g",
611-
// "-DProtobuf_DIR=$cmakeInstallDir/lib/cmake/protobuf",
612-
// "-Dabsl_DIR=$cmakeInstallDir/lib/cmake/absl",
613-
// "-Dutf8_range_DIR=$cmakeInstallDir/lib/cmake/utf8_range",
614-
// "-DCURL_DIR=$cmakeInstallDir/lib/cmake/CURL",
615-
// "-DOPENSSL_ROOT_DIR=${cmakeInstallDir}",
616-
// "-DOPENSSL_SSL_LIBRARY=${cmakeInstallDir}/lib/libssl.a",
617-
// "-DOPENSSL_CRYPTO_LIBRARY=${cmakeInstallDir}/lib/libcrypto.a",
618-
// "-DOPENSSL_INCLUDE_DIR=${cmakeInstallDir}/include"
619-
// }
620-
//
621-
// println("[@ottrelite/interop-otel] Building for ABI $abi ${wrapperBuildDir}...")
622-
//
623-
// exec {
624-
// commandLine "cmake", "--build", wrapperBuildDir, "-j8"
625-
// }
626-
//
627-
// println("[@ottrelite/interop-otel] Installing build artifacts for ABI $abi to ${cmakeInstallDir}...")
628-
//
629-
// exec {
630-
// commandLine "cmake", "--install", wrapperBuildDir, "--prefix", cmakeInstallDir
631-
// }
632-
//
633-
// println("[@ottrelite/interop-otel] Build & install finished for ABI $abi")
634-
// }
635-
// }
636-
//}
637-
//
638-
//buildAndInstallCppWrapper.dependsOn(copyOpenSSL)
639-
//buildAndInstallCppWrapper.dependsOn(buildAndInstallProtobuf)
640-
//buildAndInstallCppWrapper.dependsOn(buildAndInstallBrotli)
641-
//buildAndInstallCppWrapper.dependsOn(buildAndInstallZlib)
642-
//buildAndInstallCppWrapper.dependsOn(buildAndInstallCURL)
643-
644-
//tasks.matching { it.name.startsWith("buildCMake") }.all { task ->
645574
preBuild.dependsOn(copyOpenSSL)
646575
preBuild.dependsOn(buildAndInstallProtobuf)
647576
preBuild.dependsOn(buildAndInstallBrotli)
648577
preBuild.dependsOn(buildAndInstallZlib)
649578
preBuild.dependsOn(buildAndInstallCURL)
650-
//}
651579

580+
tasks.named('clean') {
581+
doLast {
582+
reactNativeArchitectures().each { abi ->
583+
def wrapperBuildDirFile = new File(wrapperBuildDir)
584+
585+
if (wrapperBuildDirFile.exists()) {
586+
println "Deleting wrapper build directory: ${wrapperBuildDirFile.path}"
587+
delete(wrapperBuildDirFile)
588+
}
589+
590+
def openSSLBuildDirFile = new File(getOpenSSLForAndroidBuildDir(abi))
591+
592+
if (openSSLBuildDirFile.exists()) {
593+
println "Deleting OpenSSL build directory: ${openSSLBuildDirFile.path}"
594+
delete(openSSLBuildDirFile)
595+
}
596+
597+
def cmakeInstallDirFile = getCmakeInstallDir(abi)
598+
599+
if (cmakeInstallDirFile.exists()) {
600+
println "Deleting dependencies install directory: ${cmakeInstallDirFile.path}"
601+
delete(cmakeInstallDirFile)
602+
}
603+
}
604+
}
605+
}

packages/interop-otel/cpp/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ target_include_directories(
4343
)
4444

4545
# Find RN Ottrelite Core package
46-
find_package(ottrelite_core REQUIRED)
46+
find_package(ottrelite_core)
4747

4848
# Find Protobuf C++ package
4949
set(Protobuf_DIR "${DEPS_INSTALL_DIR}/lib/cmake/protobuf/")
50-
find_package(Protobuf CONFIG REQUIRED)
50+
find_package(Protobuf CONFIG)
5151

5252
# Find OpenSSL package
5353
set(OpenSSLArtifactsDir "${CMAKE_CURRENT_LIST_DIR}/../third_party/openssl_for_android/openssl_${OTTRELITE_OPENSSL_VERSION}_${ANDROID_ABI}")
@@ -70,11 +70,11 @@ set_target_properties(OpenSSL::Crypto PROPERTIES
7070

7171
# Find CURL C++ package
7272
set(CURL_DIR "${DEPS_INSTALL_DIR}/lib/cmake/CURL/")
73-
find_package(CURL CONFIG REQUIRED)
73+
find_package(CURL CONFIG)
7474

7575
# Find OpenTelemetry C++ package
7676
set(opentelemetry-cpp_DIR "${DEPS_INSTALL_DIR}/lib/cmake/opentelemetry-cpp/")
77-
find_package(opentelemetry-cpp CONFIG REQUIRED)
77+
find_package(opentelemetry-cpp CONFIG)
7878

7979
target_link_libraries(
8080
${PACKAGE_NAME}

0 commit comments

Comments
 (0)