diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index f3811b0ee..ee53f1c6b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -40,10 +40,25 @@ x_defaults: - "-//test:output_file_map_default" windows_common: &windows_common platform: windows + environment: + SWIFT_VERSION: 6.1.0 + PATH: "%LOCALAPPDATA%\\Programs\\Swift\\Toolchains\\%SWIFT_VERSION%+Asserts\\usr\\bin;%LOCALAPPDATA%\\Programs\\Swift\\Runtimes\\%SWIFT_VERSION%\\usr\\bin;%Path%" + SDKROOT: "%LOCALAPPDATA%\\Programs\\Swift\\Platforms\\%SWIFT_VERSION%\\Windows.platform\\Developer\\SDKs\\Windows.sdk" + batch_commands: + - echo --- Installing Windows SDK + - curl.exe -L https://go.microsoft.com/fwlink/?linkid=2342616 -o %TEMP%\winsdkinstaller.exe + - PowerShell Start-Process -FilePath ${env:TEMP}\winsdkinstaller.exe -ArgumentList(\"/quiet\", \"/norestart\") -Wait -PassThru -Verb RunAs + - PowerShell Start-Process -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" -ArgumentList(\"/amd64\") -Wait -PassThru -Verb RunAs + - echo --- Downloading and installing Swift %SWIFT_VERSION% + - curl.exe -L https://download.swift.org/swift-6.1-release/windows10/swift-6.1-RELEASE/swift-6.1-RELEASE-windows10.exe -o %TEMP%\installer.exe + - PowerShell Start-Process -FilePath ${env:TEMP}\installer.exe -ArgumentList(\"/install\", \"/passive\", \"/norestart\", \"/log log.txt\") -Wait -PassThru -Verb RunAs build_flags: # Override 'sandboxed' strategy set in .bazelrc because it's not # available on Windows - "--strategy=SwiftCompile=" + - "--repo_env=CC=clang-cl" + - "--repo_env=SDKROOT=%LOCALAPPDATA%\\Programs\\Swift\\Platforms\\%SWIFT_VERSION%\\Windows.platform\\Developer\\SDKs\\Windows.sdk" + - "--repo_env=Path=%LOCALAPPDATA%\\Programs\\Swift\\Toolchains\\%SWIFT_VERSION%+Asserts\\usr\\bin;%LOCALAPPDATA%\\Programs\\Swift\\Runtimes\\%SWIFT_VERSION%\\usr\\bin;%Path%" build_targets: - "//tools/..." @@ -131,11 +146,10 @@ tasks: - .bazelci/update_workspace_to_deps_heads.sh <<: *linux_common - # TODO: re-enable when Windows in Bazel CI is properly configured for Swift. - # windows_last_green: - # name: "Last Green Bazel" - # bazel: last_green - # <<: *windows_common + windows_last_green: + name: "Latest Bazel" + bazel: latest + <<: *windows_common doc_tests: name: "Doc tests" diff --git a/swift/internal/swift_autoconfiguration.bzl b/swift/internal/swift_autoconfiguration.bzl index 46f1f3746..b1dfbc820 100644 --- a/swift/internal/swift_autoconfiguration.bzl +++ b/swift/internal/swift_autoconfiguration.bzl @@ -315,10 +315,10 @@ def _create_windows_toolchain(*, repository_ctx): """ path_to_swiftc = repository_ctx.which("swiftc.exe") if not path_to_swiftc: - return """\ + fail("""\ # No 'swiftc.exe' executable found in $PATH. Not auto-generating a Windows \ Swift toolchain. -""" +""") root = path_to_swiftc.dirname.dirname enabled_features = [ @@ -341,7 +341,7 @@ Swift toolchain. env = { "Path": repository_ctx.os.environ["Path"] if "Path" in repository_ctx.os.environ else repository_ctx.os.environ["PATH"], - "ProgramData": repository_ctx.os.environ["ProgramData"], + # "ProgramData": repository_ctx.os.environ["ProgramData"], } return """\ @@ -364,7 +364,10 @@ toolchain( "@platforms//os:windows", "@platforms//cpu:x86_64", ], - target_compatible_with = APPLE_PLATFORMS_CONSTRAINTS[arch], + target_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], toolchain = ":windows-toolchain", toolchain_type = "{toolchain_type}", visibility = ["//visibility:public"],