Skip to content

Add reusable action for MSVC + Win SDK overrides #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Steelskin
Copy link
Collaborator

@Steelskin Steelskin commented May 20, 2025

This introduces a new reusable action, setup-build, which will eventually replace all of the custom installation steps in the swift-build jobs. Currently it only supports providing explicit versions for MSVC and the Windows SDK.

This also adds tests for the setup-build action, with a configurable runner, ensuring we can catch issues early as runner images get updated.

Bug: #821

This introduces a new reusable action, `setup-build`, which will
eventually replace all of the custom installation steps in the
swift-build jobs. Currently it only supports providing explicit versions
for MSVC and the Windows SDK.

This also adds tests for the `setup-build` action, with a configurable
runner, ensuring we can catch issues early as runner images get updated.
@Steelskin Steelskin requested a review from compnerd May 20, 2025 18:32
description: Sets up the build environment for the current job

inputs:
windows-sdk-version:
Copy link
Owner

Choose a reason for hiding this comment

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

Any reason to prefix the options with windows-?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is going to be expanded to also add sccache and cmake, which are cross-platforms. I intend to reduce the number of if: in the swift workflow.
However, I did rename the msvc-version input, since Windows is implied there.

description: The Windows MSVC version to use, e.g. "14.42"
required: false
type: string
setup-vs-dev-env:
Copy link
Owner

Choose a reason for hiding this comment

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

Especially since this is also Windows specific

id: verify-input
shell: pwsh
run: |
if ($IsWindows) {
Copy link
Owner

Choose a reason for hiding this comment

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

Where is $IsWindows defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's an automatic variable set up by pwsh. I was looking for something better to use to differentiate between Windows/macOS/Other. Unfortunately, the only other option I found is [environment]::OSVersion.Platform, which is set to Unix on MacOS.

$MajorVersion = $WinMsvcVersion.Major
$MinorVersion = $WinMsvcVersion.Minor
$BuildVersion = 17
$RevisionVersion = $MinorVersion - 30
Copy link
Owner

Choose a reason for hiding this comment

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

What is this based on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

14.29.16.11 was the last VS16 toolchain version.
14.30.17.0 was the first VS17 toolchain version.
14.31.17.1 was the second VS17 toolchain version.
Etc.

Basically, the first toolchain that shipped with VS17 was 14.30 and the revision number is based on that. I added a comment to explain that.

You can find the package names here. Note that counterintuitively, while the build tools version is 14.42, the compiler itself has version 19.42.
Point is, we can't have nice things.

$WinMsvcVersion = [System.Version]::Parse($WinMsvcVersionString)
$MajorVersion = $WinMsvcVersion.Major
$MinorVersion = $WinMsvcVersion.Minor
$BuildVersion = 17
Copy link
Owner

Choose a reason for hiding this comment

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

Why hardcoded to VS17? (2022)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am trying to avoid having to specify 2 versions: the MSVC build tools version and the package version, so I am computing the package version from the major.minor build tools version.
To simplify things, I am only supporting VS17 here. I do not expect that we also want to support VS16 toolchains, but this will require updating once Microsoft releases VS18.

@Steelskin Steelskin requested a review from compnerd May 21, 2025 00:25
@Steelskin
Copy link
Collaborator Author

FYI, I am removing the ::info:: annotations in favor of a ℹ️ emoji. The correct annotation would be ::notice:: but it adds a log in the main action page, which gets quite spammy.

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