diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c53188f65..3e813fb62 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -38,12 +38,30 @@ x_defaults: - "-//test:output_file_map_default" windows_common: &windows_common platform: windows + environment: + SWIFT_VERSION: 0.0.0 + CC: "clang-cl" + 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" + BAZEL_LLVM: "%LOCALAPPDATA%\\Programs\\Swift\\Toolchains\\%SWIFT_VERSION%+Asserts\\usr" build_flags: # Override 'sandboxed' strategy set in .bazelrc because it's not # available on Windows - "--strategy=SwiftCompile=" + - "--compiler=clang-cl" + # TODO: Use the new way of setting toolchains. + - "--noincompatible_enable_cc_toolchain_resolution" build_targets: - "//tools/..." + test_flags: + - "--compiler=clang-cl" + # TODO: Use the new way of setting toolchains. + - "--noincompatible_enable_cc_toolchain_resolution" + test_targets: + - "//examples/..." + - "-//examples/apple/..." + # TODO: Fix gRPC on Windows + - "-//examples/xplatform/grpc/..." tasks: macos_6: @@ -120,11 +138,14 @@ 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: "Last Green Bazel" + bazel: last_green + batch_commands: + - echo --- Downloading and installing Swift %SWIFT_VERSION% + - curl.exe -L https://download.swift.org/swift-5.10-branch/windows10/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-01-18-a/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-01-18-a-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 + <<: *windows_common doc_tests: name: "Doc tests" diff --git a/swift/internal/swift_autoconfiguration.bzl b/swift/internal/swift_autoconfiguration.bzl index 6ec8ced15..6c301dd01 100644 --- a/swift/internal/swift_autoconfiguration.bzl +++ b/swift/internal/swift_autoconfiguration.bzl @@ -368,7 +368,7 @@ def _create_windows_toolchain(repository_ctx): 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"] if "ProgramData" in repository_ctx.os.environ else repository_ctx.os.environ["PROGRAMDATA"], } repository_ctx.file( diff --git a/swift/toolchains/swift_toolchain.bzl b/swift/toolchains/swift_toolchain.bzl index 64a8e2bbb..d5adee666 100644 --- a/swift/toolchains/swift_toolchain.bzl +++ b/swift/toolchains/swift_toolchain.bzl @@ -421,7 +421,8 @@ def _swift_toolchain_impl(ctx): if "clang" not in cc_toolchain.compiler: fail("Swift requires the configured CC toolchain to be LLVM (clang). " + "Either use the locally installed LLVM by setting `CC=clang` in your environment " + - "before invoking Bazel, or configure a Bazel LLVM CC toolchain.") + "before invoking Bazel, or configure a Bazel LLVM CC toolchain. " + + "Found compiler is %s." % cc_toolchain.compiler) if ctx.attr.os == "windows": swift_linkopts_cc_info = _swift_windows_linkopts_cc_info( @@ -505,7 +506,7 @@ def _swift_toolchain_impl(ctx): xctest = paths.normalize(paths.join(ctx.attr.sdkroot, "..", "..", "Library", "XCTest-{}".format(ctx.attr.xctest_version), "usr", bindir)) env = dicts.add( ctx.attr.env, - {"Path": xctest + ";" + ctx.attr.env["Path"]}, + {"Path": xctest + ";" + ctx.attr.env["PATH"]}, ) else: env = ctx.attr.env