Skip to content

Add -PHAVE_CS4 Gradle property for Android CS4 builds (follow-up to #1476)#1477

Closed
bmehta001 wants to merge 2 commits into
microsoft:mainfrom
bmehta001:bhamehta/android-cs4-gradle-prop
Closed

Add -PHAVE_CS4 Gradle property for Android CS4 builds (follow-up to #1476)#1477
bmehta001 wants to merge 2 commits into
microsoft:mainfrom
bmehta001:bhamehta/android-cs4-gradle-prop

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

Follow-up to #1476. Adds a discoverable, dedicated Gradle property for enabling Common Schema 4.0 on Android, instead of stuffing a raw -DHAVE_CS4=1 into CXXFLAGS.

Change

lib/android_build/maesdk/build.gradle maps:

  • -PHAVE_CS4=1 (or the HAVE_CS4 env var) → -DMATSDK_HAVE_CS4=ON
  • -PHAVE_CS4_FULL=1 (or HAVE_CS4_FULL env) → -DMATSDK_HAVE_CS4_FULL=ON

This mirrors the existing USE_ROOM dedicated-parameter pattern, and uses the CMake option from #1476 — so HAVE_CS4 is applied as a PUBLIC compile definition and propagates to consumers (the raw-CXXFLAGS path does not). gradle.properties is updated to document the property.

./gradlew <task> -PHAVE_CS4=1

The existing CXXFLAGS path is unchanged, and with no property set the build is byte-for-byte the same — so this is inert until the property is used.

Depends on #1476

This maps to the MATSDK_HAVE_CS4 CMake option added in #1476. Until that merges, -DMATSDK_HAVE_CS4=ON is a no-op; please merge #1476 first.

Deferred: vcpkg cs4 feature

The third CS4 follow-up — a cs4 feature on the cpp-client-telemetry vcpkg port — is intentionally not included. Both the official port (microsoft/vcpkg#52316) and the in-repo overlay build from the v3.10.161.1 release tag, which does not contain MATSDK_HAVE_CS4 (it's #1476). A feature there would pass -DMATSDK_HAVE_CS4=ON to a source that ignores it — silently doing nothing. It should be added when the port bumps to a release that includes #1476 (e.g. via the vcpkg-release-bump workflow in #1475).

Map the -PHAVE_CS4 / -PHAVE_CS4_FULL Gradle properties (and the HAVE_CS4 /
HAVE_CS4_FULL environment variables) to the MATSDK_HAVE_CS4 / MATSDK_HAVE_CS4_FULL
CMake options, mirroring the existing USE_ROOM dedicated parameter. This is the
discoverable, propagating way to enable Common Schema 4.0 on Android instead of
stuffing a raw -DHAVE_CS4=1 into CXXFLAGS.

Depends on microsoft#1476 (adds the MATSDK_HAVE_CS4 option); inert until that lands.

- maesdk/build.gradle: -PHAVE_CS4[_FULL] -> -DMATSDK_HAVE_CS4[_FULL]=ON
- gradle.properties: document the dedicated property

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 requested a review from a team as a code owner June 11, 2026 04:09
@bmehta001 bmehta001 requested a review from Copilot June 11, 2026 04:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds dedicated, discoverable Gradle properties for Android builds to enable Common Schema 4.0 (CS4) by mapping -PHAVE_CS4=1 / -PHAVE_CS4_FULL=1 (or corresponding env vars) into CMake options, avoiding the need to inject raw -DHAVE_CS4=1 via CXXFLAGS and aligning with the propagating CMake option introduced in PR #1476.

Changes:

  • Add Gradle property/env var handling in the Android build to pass -DMATSDK_HAVE_CS4=ON / -DMATSDK_HAVE_CS4_FULL=ON to CMake.
  • Document the new Gradle properties in lib/android_build/gradle.properties.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/android_build/maesdk/build.gradle Reads HAVE_CS4 / HAVE_CS4_FULL from Gradle properties or environment and maps them to CMake options.
lib/android_build/gradle.properties Documents the new -PHAVE_CS4=1 / -PHAVE_CS4_FULL=1 build-time properties and keeps the CXXFLAGS escape hatch documented.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +41
String haveCs4 = project.findProperty("HAVE_CS4") ?: System.getenv("HAVE_CS4") ?: ""
if (haveCs4.equalsIgnoreCase("1") || haveCs4.equalsIgnoreCase("true") || haveCs4.equalsIgnoreCase("on")) {
args.add("-DMATSDK_HAVE_CS4=ON")
}
String haveCs4Full = project.findProperty("HAVE_CS4_FULL") ?: System.getenv("HAVE_CS4_FULL") ?: ""
if (haveCs4Full.equalsIgnoreCase("1") || haveCs4Full.equalsIgnoreCase("true") || haveCs4Full.equalsIgnoreCase("on")) {
args.add("-DMATSDK_HAVE_CS4_FULL=ON")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b4fd4fe. When -PHAVE_CS4_FULL (or the env var) is set, the mapping now also adds -DMATSDK_HAVE_CS4=ON (cs4 = cs4Full || cs4), so it does not rely on the CMake-side implication.

build.gradle: when -PHAVE_CS4_FULL (or env) is set, also add -DMATSDK_HAVE_CS4=ON
so the Gradle mapping does not rely on the CMake-side implication
(cs4 = cs4Full || cs4).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@bmehta001 bmehta001 closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants