From 2f74c13fcd1e00d4164aab51d7ffb7c4dcb940e5 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Wed, 22 Jul 2026 03:03:51 -0500 Subject: [PATCH 1/4] Add Android HTTP transport selection for vcpkg Decouple Android HTTP transport choice from MATSDK_USE_VCPKG_DEPS so consumers can use vcpkg-provided native dependencies while still packaging the Java/JNI transport. Files changed: - CMakeLists.txt, lib/CMakeLists.txt, cmake/MSTelemetryConfig.cmake.in: add MATSDK_ANDROID_HTTP_CLIENT and export Android Java source metadata. - tools/ports/cpp-client-telemetry/*, docs/building-with-vcpkg.md: add android-java-http feature, source guard, and consumer documentation. - lib/pal/posix/*_Android.cpp: align initializer order for current NDK Clang builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41 --- CMakeLists.txt | 35 ++++++++++++- cmake/MSTelemetryConfig.cmake.in | 4 ++ docs/building-with-vcpkg.md | 50 +++++++++++++++++-- lib/CMakeLists.txt | 10 +++- .../posix/DeviceInformationImpl_Android.cpp | 5 +- .../posix/NetworkInformationImpl_Android.cpp | 3 +- .../posix/SystemInformationImpl_Android.cpp | 5 +- .../ports/cpp-client-telemetry/portfile.cmake | 21 +++++++- tools/ports/cpp-client-telemetry/vcpkg.json | 36 +++++++------ 9 files changed, 138 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b2321e3c..5b6935d5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -362,6 +362,39 @@ option(BUILD_SIGNALS "Build Signals" YES) option(BUILD_SANITIZER "Build Sanitizer" YES) option(LINK_STATIC_DEPENDS "Link dependencies for static build" YES) +set(MATSDK_ANDROID_HTTP_CLIENT "AUTO" CACHE STRING "Android HTTP client: AUTO, JAVA, or CURL") +set_property(CACHE MATSDK_ANDROID_HTTP_CLIENT PROPERTY STRINGS AUTO JAVA CURL) +string(TOUPPER "${MATSDK_ANDROID_HTTP_CLIENT}" MATSDK_ANDROID_HTTP_CLIENT_UPPER) +if(NOT MATSDK_ANDROID_HTTP_CLIENT_UPPER STREQUAL "AUTO" + AND NOT MATSDK_ANDROID_HTTP_CLIENT_UPPER STREQUAL "JAVA" + AND NOT MATSDK_ANDROID_HTTP_CLIENT_UPPER STREQUAL "CURL") + message(FATAL_ERROR + "MATSDK_ANDROID_HTTP_CLIENT must be AUTO, JAVA, or CURL; got " + "'${MATSDK_ANDROID_HTTP_CLIENT}'.") +endif() + +set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "") +set(MATSDK_ANDROID_USES_CURL OFF) +set(MATSDK_ANDROID_USES_JAVA_HTTP OFF) +if(CMAKE_SYSTEM_NAME STREQUAL "Android") + if(MATSDK_ANDROID_HTTP_CLIENT_UPPER STREQUAL "AUTO") + if(MATSDK_USE_VCPKG_DEPS) + set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "CURL") + else() + set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "JAVA") + endif() + else() + set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "${MATSDK_ANDROID_HTTP_CLIENT_UPPER}") + endif() + + if(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED STREQUAL "CURL") + set(MATSDK_ANDROID_USES_CURL ON) + elseif(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED STREQUAL "JAVA") + set(MATSDK_ANDROID_USES_JAVA_HTTP ON) + endif() + message(STATUS "MATSDK_ANDROID_HTTP_CLIENT: ${MATSDK_ANDROID_HTTP_CLIENT} -> ${MATSDK_ANDROID_HTTP_CLIENT_RESOLVED}") +endif() + # Enable Azure Monitor / Application Insights end-point support option(BUILD_AZMON "Build for Azure Monitor" YES) @@ -381,7 +414,7 @@ endif() set(MATSDK_NEEDS_CURL OFF) if(PAL_IMPLEMENTATION STREQUAL "CPP11" AND NOT BUILD_IOS - AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Android" OR MATSDK_USE_VCPKG_DEPS) + AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Android" OR MATSDK_ANDROID_USES_CURL) AND NOT BUILD_APPLE_HTTP) set(MATSDK_NEEDS_CURL ON) add_definitions(-DHAVE_MAT_CURL_HTTP_CLIENT) diff --git a/cmake/MSTelemetryConfig.cmake.in b/cmake/MSTelemetryConfig.cmake.in index af3838d65..dc163e933 100644 --- a/cmake/MSTelemetryConfig.cmake.in +++ b/cmake/MSTelemetryConfig.cmake.in @@ -27,6 +27,10 @@ if(@MATSDK_NEEDS_CURL@) find_dependency(CURL CONFIG) endif() +set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@") +set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR + "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java") + # Pthreads are needed on Linux and Android (POSIX threading) if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") find_dependency(Threads) diff --git a/docs/building-with-vcpkg.md b/docs/building-with-vcpkg.md index 315fa8662..d74d761f3 100644 --- a/docs/building-with-vcpkg.md +++ b/docs/building-with-vcpkg.md @@ -139,6 +139,47 @@ scaffolding and not part of the published package.) Supported triplets: `arm64-android`, `arm-neon-android`, `x64-android`, `x86-android`. +#### Android HTTP transport + +The CMake option `MATSDK_ANDROID_HTTP_CLIENT` selects the Android HTTP transport: + +| Value | Behavior | +| ----- | -------- | +| `AUTO` | Default. Uses `CURL` in vcpkg dependency mode and `JAVA` in the legacy Android Gradle/AAR build. | +| `CURL` | Builds the native libcurl transport. This is the vcpkg default and requires one curl TLS feature. | +| `JAVA` | Builds `HttpClient_Android`, which calls the Android Java bridge via JNI. | + +For vcpkg, select Java transport with the Android-only `android-java-http` +feature. Use the `[core,...]` form if you also want to avoid pulling the default +curl dependency: + +```json +{ + "dependencies": [ + { + "name": "cpp-client-telemetry", + "default-features": false, + "features": ["android-java-http", "system-sqlite"] + } + ] +} +``` + +When Java transport is selected, the package installs the bridge sources under: + +```text +share/cpp-client-telemetry/android/java/com/microsoft/applications/events/ +``` + +The installed bridge contains `HttpClient.java` and `HttpClientRequest.java`. +Consumers are responsible for compiling those Java sources into their Android +application/AAR and constructing `com.microsoft.applications.events.HttpClient` +so it initializes the native `HttpClient_Android` singleton before telemetry is +uploaded. The bridge imports AndroidX annotations (`@Keep`, `@NonNull`, +`@Nullable`, `@RequiresApi`), so ensure `androidx.annotation:annotation` is on +the Java compile classpath, for example as a Gradle `compileOnly` or +`implementation` dependency. + ## Dependencies The vcpkg port automatically resolves the following dependencies: @@ -165,9 +206,9 @@ the mbedTLS backend — see [Choose the HTTP client / TLS backend](#choose-the-http-client--tls-backend-largest-lever-on-linux). Windows and macOS/iOS use platform-native HTTP clients (WinInet and -NSURLSession respectively). Android vcpkg consumers use native libcurl because -the Java-backed `HttpClient_Android` singleton is initialized by the repo's -Android Gradle/AAR flow, not by standalone native vcpkg consumers. +NSURLSession respectively). Android defaults to native libcurl in vcpkg mode for +backward compatibility, but consumers that package the SDK with the Android Java +bridge can select the Java/JNI transport with the `android-java-http` feature. > **Note (Windows):** The port targets the MSVC/`WIN32` PAL on Windows, which > uses WinInet, so `curl` is declared for `linux | android` only. A MinGW / @@ -382,7 +423,8 @@ unchanged against the minimal build. When the SDK detects it is being built via vcpkg (by checking for `VCPKG_TOOLCHAIN` or `VCPKG_TARGET_TRIPLET`), it automatically sets `MATSDK_USE_VCPKG_DEPS=ON`. This switches dependency resolution from -vendored sources to vcpkg-provided packages via `find_package()`. +vendored sources to vcpkg-provided packages via `find_package()`. Android HTTP +transport selection is controlled separately by `MATSDK_ANDROID_HTTP_CLIENT`. You can also set this explicitly for custom CMake workflows: diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 97428a101..13b4d46d4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -197,7 +197,7 @@ if(PAL_IMPLEMENTATION STREQUAL "CPP11") list(APPEND SRCS pal/posix/NetworkInformationImpl_Android.cpp ) - if(MATSDK_USE_VCPKG_DEPS) + if(MATSDK_ANDROID_USES_CURL) list(APPEND SRCS http/HttpClient_Curl.cpp http/HttpClient_Curl.hpp @@ -680,6 +680,14 @@ if(MATSDK_USE_VCPKG_DEPS) "${CMAKE_CURRENT_BINARY_DIR}/MSTelemetryConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MSTelemetry ) + + if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND MATSDK_ANDROID_USES_JAVA_HTTP) + install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/android_build/maesdk/src/main/java/com/microsoft/applications/events/HttpClient.java" + "${CMAKE_CURRENT_SOURCE_DIR}/android_build/maesdk/src/main/java/com/microsoft/applications/events/HttpClientRequest.java" + DESTINATION "${CMAKE_INSTALL_DATADIR}/cpp-client-telemetry/android/java/com/microsoft/applications/events" + ) + endif() else() # Legacy install: just put the library and headers in standard locations install(TARGETS mat diff --git a/lib/pal/posix/DeviceInformationImpl_Android.cpp b/lib/pal/posix/DeviceInformationImpl_Android.cpp index 61746d664..53b101583 100644 --- a/lib/pal/posix/DeviceInformationImpl_Android.cpp +++ b/lib/pal/posix/DeviceInformationImpl_Android.cpp @@ -52,8 +52,8 @@ namespace PAL_NS_BEGIN { ///// IDeviceInformation API DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) : - m_info_helper(), - m_powerSource(PowerSource_Battery) + m_powerSource(PowerSource_Battery), + m_info_helper() {} std::string DeviceInformationImpl::GetDeviceTicket() const @@ -260,4 +260,3 @@ Java_com_microsoft_applications_events_HttpClient_onPowerChange(JNIEnv* env, PAL::AndroidDeviceInformationConnector::setModel(std::string(start, end)); env->ReleaseStringUTFChars(model, start); } - diff --git a/lib/pal/posix/NetworkInformationImpl_Android.cpp b/lib/pal/posix/NetworkInformationImpl_Android.cpp index 0c12464b4..f12498d92 100644 --- a/lib/pal/posix/NetworkInformationImpl_Android.cpp +++ b/lib/pal/posix/NetworkInformationImpl_Android.cpp @@ -42,8 +42,8 @@ namespace PAL_NS_BEGIN { NetworkCost AndroidNetcostConnector::s_cost = NetworkCost_Unknown; NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) : - m_info_helper(), m_cost(NetworkCost_Unknown), + m_info_helper(), m_isNetDetectEnabled(configuration[CFG_BOOL_ENABLE_NET_DETECT]){}; NetworkInformationImpl::~NetworkInformationImpl() {}; @@ -156,4 +156,3 @@ Java_com_microsoft_applications_events_HttpClient_onCostChange(JNIEnv* env, { PAL::AndroidNetcostConnector::UpdateCost(isMetered ? NetworkCost_Metered : NetworkCost_Unmetered); } - diff --git a/lib/pal/posix/SystemInformationImpl_Android.cpp b/lib/pal/posix/SystemInformationImpl_Android.cpp index 15e0bb9b1..b1911f8ae 100644 --- a/lib/pal/posix/SystemInformationImpl_Android.cpp +++ b/lib/pal/posix/SystemInformationImpl_Android.cpp @@ -163,8 +163,8 @@ namespace PAL_NS_BEGIN { std::string AndroidSystemInformationConnector::s_device_class; SystemInformationImpl::SystemInformationImpl(IRuntimeConfig& configuration) : - m_info_helper(), - m_os_name("Android") + m_os_name("Android"), + m_info_helper() { if (configuration.HasConfig(CFG_PTR_ANDROID_JVM) && configuration.HasConfig(CFG_JOBJECT_ANDROID_ACTIVITY)) { @@ -245,4 +245,3 @@ extern "C" JNIEXPORT void JNICALL Java_com_microsoft_applications_events_HttpCli PAL::AndroidSystemInformationConnector::s_device_class, deviceClass); } - diff --git a/tools/ports/cpp-client-telemetry/portfile.cmake b/tools/ports/cpp-client-telemetry/portfile.cmake index c9ce3168c..09de925e0 100644 --- a/tools/ports/cpp-client-telemetry/portfile.cmake +++ b/tools/ports/cpp-client-telemetry/portfile.cmake @@ -35,6 +35,19 @@ if(VCPKG_TARGET_IS_IOS) set(MATSDK_BUILD_IOS ON) endif() +set(MATSDK_ANDROID_HTTP_CLIENT AUTO) +if(VCPKG_TARGET_IS_ANDROID AND "android-java-http" IN_LIST FEATURES) + set(MATSDK_ANDROID_HTTP_CLIENT JAVA) + file(READ "${SOURCE_PATH}/CMakeLists.txt" _matsdk_root_cmake) + if(NOT _matsdk_root_cmake MATCHES "MATSDK_ANDROID_HTTP_CLIENT") + message(FATAL_ERROR + "The android-java-http feature requires a cpp-client-telemetry source " + "revision that supports MATSDK_ANDROID_HTTP_CLIENT. Update this port's " + "REF/SHA512 to a newer SDK release, or set MATSDK_VCPKG_SOURCE_DIR to a " + "local checkout that contains the Android Java transport selector.") + endif() +endif() + # curl-openssl (default) and curl-mbedtls choose the TLS backend for the built-in # HTTP client and are mutually exclusive. They only matter on Linux/Android: the # curl dependency is platform-filtered to those triplets, so on Windows/macOS/iOS @@ -49,7 +62,7 @@ foreach(_matsdk_http_feature curl-openssl curl-mbedtls) endif() endforeach() list(LENGTH _matsdk_http_features _matsdk_http_feature_count) -if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_ANDROID) +if(VCPKG_TARGET_IS_LINUX OR (VCPKG_TARGET_IS_ANDROID AND NOT MATSDK_ANDROID_HTTP_CLIENT STREQUAL "JAVA")) if(_matsdk_http_feature_count GREATER 1) message(FATAL_ERROR "curl-openssl (default) and curl-mbedtls are mutually exclusive but both were " @@ -69,6 +82,11 @@ if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_ANDROID) "SQLite backend, e.g. cpp-client-telemetry[core,curl-openssl,system-sqlite] " "(or curl-mbedtls / minimal-sqlite in place of those).") endif() +elseif(VCPKG_TARGET_IS_ANDROID AND _matsdk_http_feature_count GREATER 0) + message(STATUS + "cpp-client-telemetry: android-java-http selected; curl backend features are " + "not used by the SDK build. Use the [core,android-java-http,...] form if you " + "also want to avoid installing curl dependencies.") endif() # minimal-sqlite -> -DMATSDK_MINIMAL_SQLITE=ON (private feature-stripped SQLite). @@ -83,6 +101,7 @@ vcpkg_cmake_configure( OPTIONS ${FEATURE_OPTIONS} -DMATSDK_USE_VCPKG_DEPS=ON + -DMATSDK_ANDROID_HTTP_CLIENT=${MATSDK_ANDROID_HTTP_CLIENT} -DBUILD_HEADERS=ON -DBUILD_LIBRARY=ON -DBUILD_TEST_TOOL=OFF diff --git a/tools/ports/cpp-client-telemetry/vcpkg.json b/tools/ports/cpp-client-telemetry/vcpkg.json index e8a9eb5a5..9e1770d36 100644 --- a/tools/ports/cpp-client-telemetry/vcpkg.json +++ b/tools/ports/cpp-client-telemetry/vcpkg.json @@ -21,23 +21,27 @@ } ], "default-features": [ - "system-sqlite", - "curl-openssl" + "curl-openssl", + "system-sqlite" ], "features": { - "system-sqlite": { - "description": "Link the external vcpkg sqlite3 package for the offline storage cache (default). On macOS/iOS the SDK links the system libsqlite3 instead, so this dependency is not pulled there.", + "android-java-http": { + "description": "On Android, build the SDK native library against the Java/JNI HttpClient_Android bridge instead of libcurl. Use the [core,android-java-http,system-sqlite] or [core,android-java-http,minimal-sqlite] form to avoid pulling the default curl feature.", + "supports": "android" + }, + "curl-mbedtls": { + "description": "Built-in libcurl HTTP client with the mbedTLS backend instead of OpenSSL (smaller footprint). Affects Linux/Android only. Use [core,curl-mbedtls,system-sqlite] to drop the default OpenSSL curl; the [core,...] form drops all defaults (including system-sqlite), so also re-select system-sqlite or minimal-sqlite.", "dependencies": [ { - "name": "sqlite3", + "name": "curl", "default-features": false, - "platform": "!osx & !ios" + "features": [ + "mbedtls" + ], + "platform": "linux | android" } ] }, - "minimal-sqlite": { - "description": "Build a private, feature-stripped SQLite compiled from the SDK's vendored amalgamation instead of linking the external sqlite3 package. Smaller footprint; combine with [core,minimal-sqlite] to also drop the sqlite3 dependency." - }, "curl-openssl": { "description": "Built-in libcurl HTTP client with the OpenSSL TLS backend (default). Affects Linux/Android only; Windows uses WinInet and Apple uses NSURLSession regardless.", "dependencies": [ @@ -51,16 +55,16 @@ } ] }, - "curl-mbedtls": { - "description": "Built-in libcurl HTTP client with the mbedTLS backend instead of OpenSSL (smaller footprint). Affects Linux/Android only. Use [core,curl-mbedtls,system-sqlite] to drop the default OpenSSL curl; the [core,...] form drops all defaults (including system-sqlite), so also re-select system-sqlite or minimal-sqlite.", + "minimal-sqlite": { + "description": "Build a private, feature-stripped SQLite compiled from the SDK's vendored amalgamation instead of linking the external sqlite3 package. Smaller footprint; combine with [core,minimal-sqlite] to also drop the sqlite3 dependency." + }, + "system-sqlite": { + "description": "Link the external vcpkg sqlite3 package for the offline storage cache (default). On macOS/iOS the SDK links the system libsqlite3 instead, so this dependency is not pulled there.", "dependencies": [ { - "name": "curl", + "name": "sqlite3", "default-features": false, - "features": [ - "mbedtls" - ], - "platform": "linux | android" + "platform": "!osx & !ios" } ] } From 9997e156729297747e428a34f05aaab1cc0be32f Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Wed, 22 Jul 2026 11:22:53 -0500 Subject: [PATCH 2/4] Default Android vcpkg builds to Java HTTP Make Android AUTO select the Java/JNI HTTP transport regardless of dependency sourcing, and require explicit android-curl-* features for native curl. Files changed: - CMakeLists.txt: resolve Android AUTO to JAVA. - tools/ports/cpp-client-telemetry/portfile.cmake: use the in-repo checkout for overlay builds and add explicit Android curl feature handling. - tools/ports/cpp-client-telemetry/vcpkg.json: move Android curl to explicit android-curl-openssl/android-curl-mbedtls features. - docs/building-with-vcpkg.md: document Java default and curl escape hatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41 --- CMakeLists.txt | 6 +- docs/building-with-vcpkg.md | 79 +++++++++++------- .../ports/cpp-client-telemetry/portfile.cmake | 80 ++++++++++--------- tools/ports/cpp-client-telemetry/vcpkg.json | 38 +++++++-- 4 files changed, 125 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b6935d5b..cc36e9da3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -378,11 +378,7 @@ set(MATSDK_ANDROID_USES_CURL OFF) set(MATSDK_ANDROID_USES_JAVA_HTTP OFF) if(CMAKE_SYSTEM_NAME STREQUAL "Android") if(MATSDK_ANDROID_HTTP_CLIENT_UPPER STREQUAL "AUTO") - if(MATSDK_USE_VCPKG_DEPS) - set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "CURL") - else() - set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "JAVA") - endif() + set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "JAVA") else() set(MATSDK_ANDROID_HTTP_CLIENT_RESOLVED "${MATSDK_ANDROID_HTTP_CLIENT_UPPER}") endif() diff --git a/docs/building-with-vcpkg.md b/docs/building-with-vcpkg.md index d74d761f3..fed2dbdcf 100644 --- a/docs/building-with-vcpkg.md +++ b/docs/building-with-vcpkg.md @@ -145,13 +145,11 @@ The CMake option `MATSDK_ANDROID_HTTP_CLIENT` selects the Android HTTP transport | Value | Behavior | | ----- | -------- | -| `AUTO` | Default. Uses `CURL` in vcpkg dependency mode and `JAVA` in the legacy Android Gradle/AAR build. | -| `CURL` | Builds the native libcurl transport. This is the vcpkg default and requires one curl TLS feature. | +| `AUTO` | Default. Uses the Android Java/JNI transport. | +| `CURL` | Builds the native libcurl transport. This is an explicit escape hatch and requires one Android curl backend feature. | | `JAVA` | Builds `HttpClient_Android`, which calls the Android Java bridge via JNI. | -For vcpkg, select Java transport with the Android-only `android-java-http` -feature. Use the `[core,...]` form if you also want to avoid pulling the default -curl dependency: +For vcpkg, Android uses Java transport by default: ```json { @@ -159,12 +157,29 @@ curl dependency: { "name": "cpp-client-telemetry", "default-features": false, - "features": ["android-java-http", "system-sqlite"] + "features": ["system-sqlite"] } ] } ``` +To opt into native curl on Android, select exactly one Android curl backend: + +```json +{ + "dependencies": [ + { + "name": "cpp-client-telemetry", + "default-features": false, + "features": ["android-curl-openssl", "system-sqlite"] + } + ] +} +``` + +Use `android-curl-mbedtls` in place of `android-curl-openssl` for the mbedTLS +backend. + When Java transport is selected, the package installs the bridge sources under: ```text @@ -189,7 +204,7 @@ The vcpkg port automatically resolves the following dependencies: | SQLite3 | `sqlite3` | `unofficial::sqlite3::sqlite3` | Non-Apple (default; see `minimal-sqlite`). **macOS/iOS link the system `libsqlite3`** (`SQLite::SQLite3`) | | zlib | `zlib` | `ZLIB::ZLIB` | Non-Apple. **macOS/iOS link the system `libz`** | | nlohmann JSON | `nlohmann-json` | `nlohmann_json::nlohmann_json` | All | -| libcurl | `curl[openssl]` or `curl[mbedtls]` | `CURL::libcurl` | Non-Windows, non-Apple (required; TLS backend selectable: OpenSSL default or mbedTLS) | +| libcurl | `curl[openssl]` or `curl[mbedtls]` | `CURL::libcurl` | Linux by default; Android only when `android-curl-openssl` or `android-curl-mbedtls` is selected | On **macOS/iOS** the SDK links the OS-provided `libsqlite3` and `libz` (the same system libraries the SDK's Swift Package links), so the vcpkg `sqlite3` and `zlib` @@ -201,17 +216,17 @@ feature. The `minimal-sqlite` feature replaces it with a private, feature-stripp SQLite built from the SDK's vendored amalgamation — see [Build a private minimal SQLite](#build-a-private-minimal-sqlite-minimal-sqlite-feature). -libcurl is provided by the default `curl-openssl` feature; `curl-mbedtls` swaps in -the mbedTLS backend — see -[Choose the HTTP client / TLS backend](#choose-the-http-client--tls-backend-largest-lever-on-linux). +On Linux, libcurl is provided by the default `curl-openssl` feature; +`curl-mbedtls` swaps in the mbedTLS backend — see +[Choose the Linux HTTP client / TLS backend](#choose-the-linux-http-client--tls-backend-largest-lever-on-linux). Windows and macOS/iOS use platform-native HTTP clients (WinInet and -NSURLSession respectively). Android defaults to native libcurl in vcpkg mode for -backward compatibility, but consumers that package the SDK with the Android Java -bridge can select the Java/JNI transport with the `android-java-http` feature. +NSURLSession respectively). Android defaults to the platform Java/JNI HTTP +bridge; native curl is available only through explicit `android-curl-*` features. > **Note (Windows):** The port targets the MSVC/`WIN32` PAL on Windows, which -> uses WinInet, so `curl` is declared for `linux | android` only. A MinGW / +> uses WinInet, so the default `curl` dependency is declared for Linux only +> (Android has separate explicit `android-curl-*` features). A MinGW / > non-MSVC Windows triplet — or forcing `-DPAL_IMPLEMENTATION=CPP11` on Windows — > selects the curl HTTP client, which the port does not provision on Windows > (broadening `curl` to `windows` would pull an unused curl into every MSVC @@ -285,13 +300,13 @@ the stripping happens at your link. Keep the SDK a static dependency linked *into* your binary: if you re-export its API across your own DLL boundary, the export table pins its symbols and defeats `/OPT:REF`. -### Choose the HTTP client / TLS backend (largest lever on Linux) +### Choose the Linux HTTP client / TLS backend (largest lever on Linux) -On Linux/Android the built-in HTTP client is libcurl, and curl's TLS backend -dominates the SDK's footprint. (Windows uses WinInet and Apple uses NSURLSession, -so this section does not apply there.) The port exposes the TLS backend as two -mutually-exclusive features; pick the one that matches what your application -already has: +On Linux the built-in HTTP client is libcurl, and curl's TLS backend dominates +the SDK's footprint. (Windows uses WinInet, Apple uses NSURLSession, and Android +uses the Java/JNI bridge by default, so this section does not apply there.) The +port exposes the Linux TLS backend as two mutually-exclusive features; pick the +one that matches what your application already has: | Feature | Transport | Approx. stripped size¹ | Use when | | ------- | --------- | ---------------------- | -------- | @@ -302,7 +317,8 @@ already has: (worst case); enabling `-Wl,--gc-sections` at your link reduces them. Your numbers depend on triplet, dead-stripping, and what else shares those libraries. -To select **mbedTLS**, two things are required in *your top-level* manifest: +To select **mbedTLS on Linux**, two things are required in *your top-level* +manifest: ```json { @@ -331,7 +347,9 @@ To select **mbedTLS**, two things are required in *your top-level* manifest: verified with `vcpkg install --dry-run`. The default install (no features specified) keeps `curl-openssl` and works out of -the box. +the box on Linux. Android uses the Java/JNI HTTP bridge by default; use +`android-curl-openssl` or `android-curl-mbedtls` only when you explicitly want +the native curl Android escape hatch. ### Drop unused SQLite features (json1) @@ -388,12 +406,14 @@ Enable it through the vcpkg feature: Use the `[core,minimal-sqlite]` form (here, `"default-features": false` is the `[core]` part) so the default `system-sqlite` feature — and its `sqlite3` -dependency — is dropped. Because `[core]` drops **all** defaults, the example -also re-selects `curl-openssl`: on Linux/Android the built-in curl client -requires a TLS backend, so omitting it would fail to configure (swap in -`curl-mbedtls` for the smaller mbedTLS backend). Requesting `minimal-sqlite` -*without* `[core]` still pulls in the default `system-sqlite`; that is harmless -(the external `sqlite3` is installed but unused) but does not save the dependency. +dependency — is dropped. Because `[core]` drops **all** defaults, Linux examples +also re-select `curl-openssl`; on Linux the built-in curl client requires a TLS +backend, so omitting it would fail to configure (swap in `curl-mbedtls` for the +smaller mbedTLS backend). Android does not need a curl feature unless you +explicitly opt into `android-curl-openssl` or `android-curl-mbedtls`. +Requesting `minimal-sqlite` *without* `[core]` still pulls in the default +`system-sqlite`; that is harmless (the external `sqlite3` is installed but +unused) but does not save the dependency. For a plain (non-vcpkg) CMake build, pass the option directly: @@ -424,7 +444,8 @@ When the SDK detects it is being built via vcpkg (by checking for `VCPKG_TOOLCHAIN` or `VCPKG_TARGET_TRIPLET`), it automatically sets `MATSDK_USE_VCPKG_DEPS=ON`. This switches dependency resolution from vendored sources to vcpkg-provided packages via `find_package()`. Android HTTP -transport selection is controlled separately by `MATSDK_ANDROID_HTTP_CLIENT`. +transport selection is controlled separately by `MATSDK_ANDROID_HTTP_CLIENT`, +which defaults to `JAVA` on Android. You can also set this explicitly for custom CMake workflows: diff --git a/tools/ports/cpp-client-telemetry/portfile.cmake b/tools/ports/cpp-client-telemetry/portfile.cmake index 09de925e0..59444cd50 100644 --- a/tools/ports/cpp-client-telemetry/portfile.cmake +++ b/tools/ports/cpp-client-telemetry/portfile.cmake @@ -1,8 +1,7 @@ -# In-repo port validation (tests/vcpkg/*) sets MATSDK_VCPKG_SOURCE_DIR so the port -# builds the working tree under review instead of a pinned release -- this is what -# lets the port tests actually exercise the SDK source + manifest together. When -# the variable is unset (production installs), the pinned release is downloaded as -# usual, so the published port behavior is unchanged. +# In-repo overlay-port use should build the working tree under review instead of +# a pinned release -- this is what lets local port installs and tests exercise +# the SDK source + manifest together. The registry copy of this port is not under +# the SDK checkout, so it falls back to the pinned release below. if(DEFINED ENV{MATSDK_VCPKG_SOURCE_DIR}) set(SOURCE_PATH "$ENV{MATSDK_VCPKG_SOURCE_DIR}") if(NOT EXISTS "${SOURCE_PATH}/CMakeLists.txt") @@ -11,6 +10,9 @@ if(DEFINED ENV{MATSDK_VCPKG_SOURCE_DIR}) "was found there. It must point to a cpp_client_telemetry source checkout.") endif() message(STATUS "cpp-client-telemetry: building local source $ENV{MATSDK_VCPKG_SOURCE_DIR} (MATSDK_VCPKG_SOURCE_DIR is set)") +elseif(EXISTS "${CURRENT_PORT_DIR}/../../../CMakeLists.txt") + get_filename_component(SOURCE_PATH "${CURRENT_PORT_DIR}/../../.." ABSOLUTE) + message(STATUS "cpp-client-telemetry: building in-repo overlay source ${SOURCE_PATH}") else() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH @@ -36,57 +38,61 @@ if(VCPKG_TARGET_IS_IOS) endif() set(MATSDK_ANDROID_HTTP_CLIENT AUTO) -if(VCPKG_TARGET_IS_ANDROID AND "android-java-http" IN_LIST FEATURES) - set(MATSDK_ANDROID_HTTP_CLIENT JAVA) +if(VCPKG_TARGET_IS_ANDROID) file(READ "${SOURCE_PATH}/CMakeLists.txt" _matsdk_root_cmake) if(NOT _matsdk_root_cmake MATCHES "MATSDK_ANDROID_HTTP_CLIENT") message(FATAL_ERROR - "The android-java-http feature requires a cpp-client-telemetry source " - "revision that supports MATSDK_ANDROID_HTTP_CLIENT. Update this port's " - "REF/SHA512 to a newer SDK release, or set MATSDK_VCPKG_SOURCE_DIR to a " - "local checkout that contains the Android Java transport selector.") + "Android vcpkg builds require a cpp-client-telemetry source revision that " + "supports MATSDK_ANDROID_HTTP_CLIENT. Update this port's REF/SHA512 to a " + "newer SDK release, or set MATSDK_VCPKG_SOURCE_DIR to a local checkout " + "that contains the Android Java transport selector.") + endif() + if("android-curl-openssl" IN_LIST FEATURES OR "android-curl-mbedtls" IN_LIST FEATURES) + set(MATSDK_ANDROID_HTTP_CLIENT CURL) endif() endif() -# curl-openssl (default) and curl-mbedtls choose the TLS backend for the built-in -# HTTP client and are mutually exclusive. They only matter on Linux/Android: the -# curl dependency is platform-filtered to those triplets, so on Windows/macOS/iOS -# both features may be present (curl-openssl is a default) yet pull no curl, and -# the SDK uses WinInet / Apple HTTP there. vcpkg cannot express mutual exclusivity -# or "exactly one of", so validate it here -- but only where curl is actually used, -# to avoid failing legitimate cross-platform manifests on Windows/Apple. +# curl-openssl/curl-mbedtls choose the Linux TLS backend. Android defaults to +# Java/JNI HTTP and uses separate explicit android-curl-* features for its curl +# escape hatch. vcpkg cannot express mutual exclusivity or "exactly one of", so +# validate it here -- but only where curl is actually used, to avoid failing +# legitimate cross-platform manifests on Windows/Apple. set(_matsdk_http_features "") -foreach(_matsdk_http_feature curl-openssl curl-mbedtls) +if(VCPKG_TARGET_IS_ANDROID) + set(_matsdk_http_feature_candidates android-curl-openssl android-curl-mbedtls) +else() + set(_matsdk_http_feature_candidates curl-openssl curl-mbedtls) +endif() +foreach(_matsdk_http_feature ${_matsdk_http_feature_candidates}) if(_matsdk_http_feature IN_LIST FEATURES) list(APPEND _matsdk_http_features ${_matsdk_http_feature}) endif() endforeach() list(LENGTH _matsdk_http_features _matsdk_http_feature_count) -if(VCPKG_TARGET_IS_LINUX OR (VCPKG_TARGET_IS_ANDROID AND NOT MATSDK_ANDROID_HTTP_CLIENT STREQUAL "JAVA")) +if(VCPKG_TARGET_IS_LINUX OR MATSDK_ANDROID_HTTP_CLIENT STREQUAL "CURL") if(_matsdk_http_feature_count GREATER 1) message(FATAL_ERROR - "curl-openssl (default) and curl-mbedtls are mutually exclusive but both were " - "selected. To use mbedTLS, drop the defaults with the [core,...] form and " - "re-select a SQLite backend (the [core,...] form also drops the default " - "system-sqlite feature), e.g. " - "cpp-client-telemetry[core,curl-mbedtls,system-sqlite] " - "(or minimal-sqlite in place of system-sqlite).") - elseif(_matsdk_http_feature_count EQUAL 0) + "The curl HTTP backend features are mutually exclusive but multiple were " + "selected. On Linux, use exactly one of curl-openssl/curl-mbedtls. On " + "Android, use exactly one of android-curl-openssl/android-curl-mbedtls.") + elseif(_matsdk_http_feature_count EQUAL 0 AND VCPKG_TARGET_IS_LINUX) # The built-in curl HTTP client requires exactly one TLS backend. The [core,...] # form drops the default curl-openssl, so fail fast (with a complete example) # rather than letting the SDK CMake fail later on a missing libcurl. message(FATAL_ERROR - "On Linux/Android the built-in curl HTTP client requires exactly one TLS " - "backend feature, but none was selected. The [core,...] form drops the " - "default curl-openssl feature, so re-add a curl backend together with a " - "SQLite backend, e.g. cpp-client-telemetry[core,curl-openssl,system-sqlite] " - "(or curl-mbedtls / minimal-sqlite in place of those).") + "On Linux the built-in curl HTTP client requires exactly one TLS backend " + "feature, but none was selected. The [core,...] form drops the default " + "curl-openssl feature, so re-add a curl backend together with a SQLite " + "backend, e.g. " + "cpp-client-telemetry[core,curl-mbedtls,system-sqlite] " + "(or minimal-sqlite in place of system-sqlite).") + elseif(_matsdk_http_feature_count EQUAL 0) + message(FATAL_ERROR + "On Android, MATSDK_ANDROID_HTTP_CLIENT=CURL requires exactly one explicit " + "Android curl backend feature. Use android-curl-openssl or " + "android-curl-mbedtls together with a SQLite backend, e.g. " + "cpp-client-telemetry[core,android-curl-openssl,system-sqlite].") endif() -elseif(VCPKG_TARGET_IS_ANDROID AND _matsdk_http_feature_count GREATER 0) - message(STATUS - "cpp-client-telemetry: android-java-http selected; curl backend features are " - "not used by the SDK build. Use the [core,android-java-http,...] form if you " - "also want to avoid installing curl dependencies.") endif() # minimal-sqlite -> -DMATSDK_MINIMAL_SQLITE=ON (private feature-stripped SQLite). diff --git a/tools/ports/cpp-client-telemetry/vcpkg.json b/tools/ports/cpp-client-telemetry/vcpkg.json index 9e1770d36..d183bf6ca 100644 --- a/tools/ports/cpp-client-telemetry/vcpkg.json +++ b/tools/ports/cpp-client-telemetry/vcpkg.json @@ -25,12 +25,36 @@ "system-sqlite" ], "features": { - "android-java-http": { - "description": "On Android, build the SDK native library against the Java/JNI HttpClient_Android bridge instead of libcurl. Use the [core,android-java-http,system-sqlite] or [core,android-java-http,minimal-sqlite] form to avoid pulling the default curl feature.", - "supports": "android" + "android-curl-mbedtls": { + "description": "On Android, explicitly build the native libcurl HTTP client with the mbedTLS backend instead of the default Java/JNI HttpClient_Android bridge.", + "supports": "android", + "dependencies": [ + { + "name": "curl", + "default-features": false, + "features": [ + "mbedtls" + ], + "platform": "android" + } + ] + }, + "android-curl-openssl": { + "description": "On Android, explicitly build the native libcurl HTTP client with the OpenSSL backend instead of the default Java/JNI HttpClient_Android bridge.", + "supports": "android", + "dependencies": [ + { + "name": "curl", + "default-features": false, + "features": [ + "openssl" + ], + "platform": "android" + } + ] }, "curl-mbedtls": { - "description": "Built-in libcurl HTTP client with the mbedTLS backend instead of OpenSSL (smaller footprint). Affects Linux/Android only. Use [core,curl-mbedtls,system-sqlite] to drop the default OpenSSL curl; the [core,...] form drops all defaults (including system-sqlite), so also re-select system-sqlite or minimal-sqlite.", + "description": "Built-in libcurl HTTP client with the mbedTLS backend instead of OpenSSL (smaller footprint). Affects Linux only. Use [core,curl-mbedtls,system-sqlite] to drop the default OpenSSL curl; the [core,...] form drops all defaults (including system-sqlite), so also re-select system-sqlite or minimal-sqlite.", "dependencies": [ { "name": "curl", @@ -38,12 +62,12 @@ "features": [ "mbedtls" ], - "platform": "linux | android" + "platform": "linux" } ] }, "curl-openssl": { - "description": "Built-in libcurl HTTP client with the OpenSSL TLS backend (default). Affects Linux/Android only; Windows uses WinInet and Apple uses NSURLSession regardless.", + "description": "Built-in libcurl HTTP client with the OpenSSL TLS backend (default). Affects Linux only; Android uses the Java/JNI bridge unless an android-curl-* feature is selected, Windows uses WinInet, and Apple uses NSURLSession.", "dependencies": [ { "name": "curl", @@ -51,7 +75,7 @@ "features": [ "openssl" ], - "platform": "linux | android" + "platform": "linux" } ] }, From 4e6db99f0fe38d9168956b04e31dd6c57b203ade Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Wed, 22 Jul 2026 19:32:51 -0500 Subject: [PATCH 3/4] Address Copilot review for Android transport PR NetworkInformationImpl_Android.cpp: initialize m_registeredCount so callback registration bookkeeping does not read an indeterminate value. Verified m_registeredCount is incremented/decremented in lib/pal/NetworkInformationImpl.hpp. DeviceInformationImpl_Android.cpp: initialize m_registeredCount for the same callback bookkeeping path. Verified m_registeredCount is incremented/decremented in lib/pal/DeviceInformationImpl.hpp. MSTelemetryConfig.cmake.in: update the curl dependency comment to reflect Linux, explicit Android curl builds, and macOS-without-Apple-HTTP only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41 --- cmake/MSTelemetryConfig.cmake.in | 5 +++-- lib/pal/posix/DeviceInformationImpl_Android.cpp | 3 ++- lib/pal/posix/NetworkInformationImpl_Android.cpp | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/MSTelemetryConfig.cmake.in b/cmake/MSTelemetryConfig.cmake.in index dc163e933..a4ab9d45b 100644 --- a/cmake/MSTelemetryConfig.cmake.in +++ b/cmake/MSTelemetryConfig.cmake.in @@ -14,8 +14,9 @@ find_dependency(ZLIB) find_dependency(nlohmann_json CONFIG) # Curl is re-found only when the SDK was built with the curl HTTP client -# (Linux, Android via vcpkg, and macOS built without Apple HTTP). -# Windows (WinInet), iOS, and macOS-with-Apple-HTTP do not link curl. +# (Linux, explicit Android curl builds, and macOS built without Apple HTTP). +# Windows (WinInet), default Android Java/JNI HTTP, iOS, and +# macOS-with-Apple-HTTP do not link curl. # We bake the build-time decision into a boolean rather than re-deriving it, # because the macOS BUILD_APPLE_HTTP choice can't be inferred from # CMAKE_SYSTEM_NAME alone. diff --git a/lib/pal/posix/DeviceInformationImpl_Android.cpp b/lib/pal/posix/DeviceInformationImpl_Android.cpp index 53b101583..fb21537a8 100644 --- a/lib/pal/posix/DeviceInformationImpl_Android.cpp +++ b/lib/pal/posix/DeviceInformationImpl_Android.cpp @@ -53,7 +53,8 @@ namespace PAL_NS_BEGIN { ///// IDeviceInformation API DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) : m_powerSource(PowerSource_Battery), - m_info_helper() + m_info_helper(), + m_registeredCount(0) {} std::string DeviceInformationImpl::GetDeviceTicket() const diff --git a/lib/pal/posix/NetworkInformationImpl_Android.cpp b/lib/pal/posix/NetworkInformationImpl_Android.cpp index f12498d92..10e9bda2f 100644 --- a/lib/pal/posix/NetworkInformationImpl_Android.cpp +++ b/lib/pal/posix/NetworkInformationImpl_Android.cpp @@ -44,6 +44,7 @@ namespace PAL_NS_BEGIN { NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) : m_cost(NetworkCost_Unknown), m_info_helper(), + m_registeredCount(0), m_isNetDetectEnabled(configuration[CFG_BOOL_ENABLE_NET_DETECT]){}; NetworkInformationImpl::~NetworkInformationImpl() {}; From 59825201b7bfd67ece0c0f67455ef1409ec9f3aa Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Wed, 22 Jul 2026 19:39:49 -0500 Subject: [PATCH 4/4] Address Copilot follow-up review for Android transport portfile.cmake: make in-repo overlay source detection require SDK-specific paths so registry/vcpkg checkouts cannot be mistaken for cpp_client_telemetry. MSTelemetryConfig.cmake.in: set MSTelemetry_ANDROID_JAVA_SOURCE_DIR only for Java-transport packages; set it empty otherwise. Android PAL: initialize m_type and m_os_architecture alongside the callback counters so inline getters never read indeterminate values. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b12c5862-01e3-45e4-bf91-6389c20cae41 --- cmake/MSTelemetryConfig.cmake.in | 8 ++++++-- lib/pal/posix/DeviceInformationImpl_Android.cpp | 1 + lib/pal/posix/NetworkInformationImpl_Android.cpp | 1 + tools/ports/cpp-client-telemetry/portfile.cmake | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cmake/MSTelemetryConfig.cmake.in b/cmake/MSTelemetryConfig.cmake.in index a4ab9d45b..3dde138d7 100644 --- a/cmake/MSTelemetryConfig.cmake.in +++ b/cmake/MSTelemetryConfig.cmake.in @@ -29,8 +29,12 @@ if(@MATSDK_NEEDS_CURL@) endif() set(MSTelemetry_ANDROID_HTTP_CLIENT "@MATSDK_ANDROID_HTTP_CLIENT_RESOLVED@") -set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR - "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java") +if(MSTelemetry_ANDROID_HTTP_CLIENT STREQUAL "JAVA") + set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR + "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_DATADIR@/cpp-client-telemetry/android/java") +else() + set(MSTelemetry_ANDROID_JAVA_SOURCE_DIR "") +endif() # Pthreads are needed on Linux and Android (POSIX threading) if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") diff --git a/lib/pal/posix/DeviceInformationImpl_Android.cpp b/lib/pal/posix/DeviceInformationImpl_Android.cpp index fb21537a8..fc132629d 100644 --- a/lib/pal/posix/DeviceInformationImpl_Android.cpp +++ b/lib/pal/posix/DeviceInformationImpl_Android.cpp @@ -52,6 +52,7 @@ namespace PAL_NS_BEGIN { ///// IDeviceInformation API DeviceInformationImpl::DeviceInformationImpl(IRuntimeConfig& configuration) : + m_os_architecture(OsArchitectureType_Unknown), m_powerSource(PowerSource_Battery), m_info_helper(), m_registeredCount(0) diff --git a/lib/pal/posix/NetworkInformationImpl_Android.cpp b/lib/pal/posix/NetworkInformationImpl_Android.cpp index 10e9bda2f..04f1960f5 100644 --- a/lib/pal/posix/NetworkInformationImpl_Android.cpp +++ b/lib/pal/posix/NetworkInformationImpl_Android.cpp @@ -42,6 +42,7 @@ namespace PAL_NS_BEGIN { NetworkCost AndroidNetcostConnector::s_cost = NetworkCost_Unknown; NetworkInformationImpl::NetworkInformationImpl(IRuntimeConfig& configuration) : + m_type(NetworkType_Unknown), m_cost(NetworkCost_Unknown), m_info_helper(), m_registeredCount(0), diff --git a/tools/ports/cpp-client-telemetry/portfile.cmake b/tools/ports/cpp-client-telemetry/portfile.cmake index 59444cd50..1bc8d07c4 100644 --- a/tools/ports/cpp-client-telemetry/portfile.cmake +++ b/tools/ports/cpp-client-telemetry/portfile.cmake @@ -10,10 +10,19 @@ if(DEFINED ENV{MATSDK_VCPKG_SOURCE_DIR}) "was found there. It must point to a cpp_client_telemetry source checkout.") endif() message(STATUS "cpp-client-telemetry: building local source $ENV{MATSDK_VCPKG_SOURCE_DIR} (MATSDK_VCPKG_SOURCE_DIR is set)") -elseif(EXISTS "${CURRENT_PORT_DIR}/../../../CMakeLists.txt") - get_filename_component(SOURCE_PATH "${CURRENT_PORT_DIR}/../../.." ABSOLUTE) - message(STATUS "cpp-client-telemetry: building in-repo overlay source ${SOURCE_PATH}") else() + get_filename_component(_matsdk_overlay_source "${CURRENT_PORT_DIR}/../../.." ABSOLUTE) +endif() + +if(NOT DEFINED SOURCE_PATH + AND EXISTS "${_matsdk_overlay_source}/CMakeLists.txt" + AND EXISTS "${_matsdk_overlay_source}/lib/CMakeLists.txt" + AND EXISTS "${_matsdk_overlay_source}/tools/ports/cpp-client-telemetry/portfile.cmake") + set(SOURCE_PATH "${_matsdk_overlay_source}") + message(STATUS "cpp-client-telemetry: building in-repo overlay source ${SOURCE_PATH}") +endif() + +if(NOT DEFINED SOURCE_PATH) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO microsoft/cpp_client_telemetry