Skip to content

[build-windows-toolchain.bat] Add AndroidSDKArgs parameters to cross-compile Android SDKs#87867

Open
finagolfin wants to merge 1 commit into
swiftlang:mainfrom
finagolfin:windroid
Open

[build-windows-toolchain.bat] Add AndroidSDKArgs parameters to cross-compile Android SDKs#87867
finagolfin wants to merge 1 commit into
swiftlang:mainfrom
finagolfin:windroid

Conversation

@finagolfin
Copy link
Copy Markdown
Member

@finagolfin finagolfin commented Mar 14, 2026

The @swiftlang/android-workgroup has been discussing adding Android SDK builds to the pre-commit Windows PR CI, so this is a new interface to add that Windows CI config.

@finagolfin finagolfin requested a review from compnerd as a code owner March 14, 2026 04:14
@finagolfin finagolfin marked this pull request as draft March 14, 2026 04:14
@finagolfin
Copy link
Copy Markdown
Member Author

@swift-ci smoke test windows

1 similar comment
@finagolfin
Copy link
Copy Markdown
Member Author

@swift-ci smoke test windows

@finagolfin
Copy link
Copy Markdown
Member Author

@swift-ci smoke test windows

Comment thread utils/build.ps1 Outdated
Comment thread utils/build-windows-toolchain.bat Outdated
if not "%WINDOWS_SDKS%"=="" set "WindowsSDKArgs=%WindowsSDKArgs% -WindowsSDKArchitectures %WINDOWS_SDKS%"

:: Build the arguments related to Android SDK cross-compilation
set "AndroidSDKArgs=-Android -AndroidSDKVersions Android -AndroidSDKArchitectures armv7"
Copy link
Copy Markdown
Member

@compnerd compnerd Mar 15, 2026

Choose a reason for hiding this comment

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

Suggested change
set "AndroidSDKArgs=-Android -AndroidSDKVersions Android -AndroidSDKArchitectures armv7"
set "AndroidSDKArgs=-Android -AndroidSDKVersions Android -AndroidSDKArchitectures armv7 -AndroidSDKVersions AndroidExperimental -AndroidSDKLinkModes dynamic"

This should cut the cost as we wouldn't build the static runtime.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Currently, I am not building the "Experimental" SDKs at all in this pull, only the original Build-SDK for 32-bit Android armv7, which finishes in 16 mins as we discussed. Are you saying that you'd now like to add the dynamic "Experimental" Android runtime also to the Windows smoke test CI, despite that taking longer?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, the dynamic experimental SDK builds should be preferred. I don't think that they take longer (do you have numbers for the builds that show that? The summary can be misleading as the experimental SDK is both static and dynamic, so you need to halve the number).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let me paste what you wrote earlier off github:

"I was thinking that we enable just shared armv7 for pre-commit CI, leave the other builds to nightly. That minimises the cost (~15m) but gives us some Android coverage."

I didn't know what you meant by shared armv7, but figured you were talking about the Build-SDK action I configured here, since I knew that only took around 15 mins. Did you mean the dynamic experimental runtime in the above message too?

I don't think that they take longer

I simply meant that building both Build-SDK and the dynamic experimental runtime takes longer than the former alone.

However, there is a problem with just trying to build the experimental SDK alone, as Testing only builds if the Build-SDK step is enabled (see the linked CI log from there when I tried to only build Experimental Android SDKs).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I meant the experimental SDK builds (we are trying to remove the old SDK builds). The testing dependency sounds new and a regression that we should try to fix.

@finagolfin
Copy link
Copy Markdown
Member Author

@swift-ci smoke test windows

Comment thread utils/build.ps1
# Copy static dependencies
foreach ($Build in $AndroidSDKBuilds) {
if (-not $Build.LinkModes.Contains("static")) { continue }
if (-not $Build.LinkModes.Contains("static") -or -not $AndroidSDKVersions.Contains("AndroidExperimental")) { continue }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this change, why is this needed now but wasn't previously?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Previously I simply disabled this block entirely, whereas now I added this proper check if the Experimental SDKs are being built, and only disable it if they aren't.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That doesn't entirely make sense - I don't think that we would be generating the static content in the old runtimes build (and if we are we should just disable that).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, if you mean why this check is needed at all, the logic below only installs static libraries into the Experimental SDK. This always happened as long as both the regular and Experimental SDKs were being built on the trunk snapshot toolchain CI, but once I tried to only invoke Build-SDK in this pull, with no Experimental Android SDK, the below logic broke.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That doesn't entirely make sense - I don't think that we would be generating the static content in the old runtimes build (and if we are we should just disable that).

Look at the below install logic: it only copies static libraries to the Experimental SDKs. Do the original SDKs need them too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The point is that -AndroidSDKLinkModes being dynamic would already skip this appropriately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, but I'm trying to fix this generally so it is possible to not build the experimental SDK, only the original Build-SDK. If you don't care about that config because you plan to remove the original SDK config anyway on Windows soon, I can remove this fix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I don't think that we care about that config - the sooner that we can remove the legacy SDK the better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@finagolfin
Copy link
Copy Markdown
Member Author

@compnerd, let me know what you think of the new Android interface I've added for this batch file, ignoring the top three config lines I added in this pull purely for testing this on CI now.

@swift-ci smoke test windows

@finagolfin finagolfin changed the title [build-windows-toolchain.bat] Add AndroidSDKArgs parameter to cross-compile Android SDKs [build-windows-toolchain.bat] Add AndroidSDKArgs parameters to cross-compile Android SDKs Mar 17, 2026
@finagolfin
Copy link
Copy Markdown
Member Author

@swift-ci smoke test windows

…s-compile Android SDKs

Also, fix build.ps1 for when the "Experimental" Android SDKs with static libraries aren't built.
@finagolfin finagolfin marked this pull request as ready for review March 18, 2026 01:53
@finagolfin
Copy link
Copy Markdown
Member Author

finagolfin commented Mar 18, 2026

@shahmishal and @compnerd, got this new Android interface for the Windows CI working, so need review on what you think its final shape should be.

Once this is in, we would like the CI team to add armv7 alone to the Windows smoke test PR CI, with ANDROID_SDKS=armv7 ANDROID_LINK_MODES=dynamic, and two arches to the Windows PR toolchain CI, ie ANDROID_SDKS=aarch64,armv7. According to the build times I posted elsewhere, this will add half an hour to the Windows smoke tests and 1 hour 45 mins to the PR toolchain CI.

This will allow us to test out Android changes on the pre-commit Windows PR CI before merging.

set "AndroidSDKArgs="
if not "%ANDROID_SDKS%"=="" goto Android
if not "%ANDROID_SDK_VERSIONS%"=="" goto Android
if not "%ANDROID_LINK_MODES%"=="" goto Android
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If any or all of these three Android parameters are passed in, build the Android SDKs with those flags. Otherwise, building the Android SDKs is disabled by default, as it always has been.

@finagolfin
Copy link
Copy Markdown
Member Author

Let's see if adding cross-repo pulls for the Android PR CI works yet, completely unrelated to this pull.

swiftlang/swift-docker#528

@swift-ci test android

@finagolfin
Copy link
Copy Markdown
Member Author

Another cross-repo testing check, again completely unrelated to this pull

swiftlang/swift-docker#536

@swift-ci test android

Copy link
Copy Markdown

@albertoblue87-netizen albertoblue87-netizen left a comment

Choose a reason for hiding this comment

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

Done

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.

3 participants