From 7402901529cc3c29d844f2af2ef27490278861f7 Mon Sep 17 00:00:00 2001 From: Aaron Sky Date: Fri, 14 Nov 2025 08:37:15 -0500 Subject: [PATCH] remove WORKSPACE support --- .bazelci/presubmit.yml | 43 +----- .bazelci/update_workspace_to_deps_heads.sh | 45 ------ .github/generate-notes.sh | 29 ---- BUILD | 1 - README.md | 3 +- WORKSPACE | 95 ------------ WORKSPACE.bzlmod | 0 doc/BUILD | 23 +-- doc/README.md | 1 - doc/setup.md | 25 ---- swift/BUILD | 9 -- swift/extensions.bzl | 4 +- swift/extras.bzl | 33 ----- swift/{ => internal}/repositories.bzl | 164 ++------------------- 14 files changed, 22 insertions(+), 453 deletions(-) delete mode 100755 .bazelci/update_workspace_to_deps_heads.sh delete mode 100644 WORKSPACE delete mode 100644 WORKSPACE.bzlmod delete mode 100644 doc/setup.md delete mode 100644 swift/extras.bzl rename swift/{ => internal}/repositories.bzl (54%) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index f3811b0ee..edfd801da 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -48,14 +48,6 @@ x_defaults: - "//tools/..." tasks: - macos_7: - name: "Previous LTS with no bzlmod" - bazel: 7.x - build_flags: - - "--noenable_bzlmod" - - "--enable_workspace" - <<: *mac_common - macos_latest: name: "Current LTS" bazel: latest @@ -71,27 +63,6 @@ tasks: bazel: last_green <<: *mac_common - macos_latest_head_deps: - name: "Current LTS with Head Deps" - bazel: latest - shell_commands: - # Update the WORKSPACE to use head versions of some deps to ensure nothing - # has landed on them breaking this project. - - .bazelci/update_workspace_to_deps_heads.sh - <<: *mac_common - - ubuntu2204_7: - name: "Previous LTS with no bzlmod" - bazel: 7.x - shell_commands: - - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - - "mkdir $SWIFT_HOME" - - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" - build_flags: - - "--noenable_bzlmod" - - "--enable_workspace" - <<: *linux_common - ubuntu2204_latest: name: "Current LTS" bazel: latest @@ -119,18 +90,6 @@ tasks: - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" <<: *linux_common - ubuntu2204_latest_head_deps: - name: "Current LTS with Head Deps" - bazel: latest - shell_commands: - - "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME" - - "mkdir $SWIFT_HOME" - - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" - # Update the WORKSPACE to use head versions of some deps to ensure nothing - # has landed on them breaking this project. - - .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" @@ -146,6 +105,6 @@ tasks: - "mkdir $SWIFT_HOME" - "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME" test_targets: - - "doc/..." + - "doc/..." buildifier: 8.2.1 diff --git a/.bazelci/update_workspace_to_deps_heads.sh b/.bazelci/update_workspace_to_deps_heads.sh deleted file mode 100755 index 45681551b..000000000 --- a/.bazelci/update_workspace_to_deps_heads.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Copyright 2019 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu - -if [[ "$(uname -s)" == "Darwin" ]] ; then - INPLACE=("-i" "") -else - INPLACE=("-i") -fi - -# Modify the WORKSPACE to pull in the master branches of some deps. -sed \ - "${INPLACE[@]}" \ - -e \ - '/^workspace.*/a \ -\ -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")\ -\ -git_repository(\ -\ name = "bazel_skylib",\ -\ remote = "https://github.com/bazelbuild/bazel-skylib.git",\ -\ branch = "main",\ -)\ -\ -git_repository(\ -\ name = "build_bazel_apple_support",\ -\ remote = "https://github.com/bazelbuild/apple_support.git",\ -\ branch = "master",\ -)\ -' \ - WORKSPACE diff --git a/.github/generate-notes.sh b/.github/generate-notes.sh index ec4cd7d0c..15c48a59f 100755 --- a/.github/generate-notes.sh +++ b/.github/generate-notes.sh @@ -3,9 +3,6 @@ set -euo pipefail readonly new_version=$1 -readonly release_archive="rules_swift.$new_version.tar.gz" - -sha=$(shasum -a 256 "$release_archive" | cut -d " " -f1) cat <", - "# Workspace Setup", - ], -) - [ stardoc( name = file + "_doc", @@ -116,14 +107,6 @@ write_file( ] in _DOC_SRCS.items() ] -stardoc( - name = "setup_doc", - out = "setup.md_", - header_template = "setup_header.vm", - input = "//swift:repositories.bzl", - deps = ["//swift:repositories"], -) - # To make these tests pass, run # bazel run //doc:update [ @@ -132,7 +115,7 @@ stardoc( file1 = file + ".md_", file2 = file + ".md", ) - for file in _DOC_SRCS.keys() + ["setup"] + for file in _DOC_SRCS.keys() ] write_file( @@ -145,14 +128,14 @@ write_file( "cp -fv bazel-bin/doc/{0}.md_ doc/{0}.md".format( file, ) - for file in _DOC_SRCS.keys() + ["setup"] + for file in _DOC_SRCS.keys() ], ) sh_binary( name = "update", srcs = ["update.sh"], - data = [file + ".md_" for file in _DOC_SRCS.keys() + ["setup"]], + data = [file + ".md_" for file in _DOC_SRCS.keys()], ) gazelle( diff --git a/doc/README.md b/doc/README.md index f3cc3c768..320f44756 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,6 +1,5 @@ # Documentation -* [WORKSPACE setup](setup.md#swift_rules_dependencies) * [Rules](rules.md) * [Providers](providers.md) * [API](api.md) diff --git a/doc/setup.md b/doc/setup.md deleted file mode 100644 index 933e79208..000000000 --- a/doc/setup.md +++ /dev/null @@ -1,25 +0,0 @@ - -# Workspace Setup - - -## swift_rules_dependencies - -
-swift_rules_dependencies(include_bzlmod_ready_dependencies)
-
- -Fetches repositories that are dependencies of `rules_swift`. - -Users should call this macro in their `WORKSPACE` to ensure that all of the -dependencies of the Swift rules are downloaded and that they are isolated -from changes to those dependencies. - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| include_bzlmod_ready_dependencies | Whether or not bzlmod-ready dependencies should be included. | `True` | - - diff --git a/swift/BUILD b/swift/BUILD index 5ae197f2e..d948eb72f 100644 --- a/swift/BUILD +++ b/swift/BUILD @@ -18,15 +18,6 @@ bzl_library( deps = [":repositories"], ) -bzl_library( - name = "extras", - srcs = ["extras.bzl"], - deps = [ - "@bazel_features//:deps", - "@build_bazel_apple_support//lib:repositories", - ], -) - bzl_library( name = "repositories", srcs = ["repositories.bzl"], diff --git a/swift/extensions.bzl b/swift/extensions.bzl index 8986e8dcf..ce7f12635 100644 --- a/swift/extensions.bzl +++ b/swift/extensions.bzl @@ -15,10 +15,10 @@ """Definitions for bzlmod module extensions.""" load("@bazel_features//:features.bzl", "bazel_features") -load("//swift:repositories.bzl", "swift_rules_dependencies") +load("//swift/internal:repositories.bzl", "swift_rules_dependencies") def _non_module_deps_impl(module_ctx): - swift_rules_dependencies(include_bzlmod_ready_dependencies = False) + swift_rules_dependencies() metadata_kwargs = {} if bazel_features.external_deps.extension_metadata_has_reproducible: diff --git a/swift/extras.bzl b/swift/extras.bzl deleted file mode 100644 index f10746eba..000000000 --- a/swift/extras.bzl +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2018 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Definitions for handling Bazel transitive repositories used by the -dependencies of the Swift rules. -""" - -load("@bazel_features//:deps.bzl", "bazel_features_deps") -load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") - -def swift_rules_extra_dependencies(): - """Fetches transitive repositories of the dependencies of `rules_swift`. - - Users should call this macro in their `WORKSPACE` following the use of - `swift_rules_dependencies` to ensure that all of the dependencies of - the Swift rules are downloaded and that they are isolated from changes - to those dependencies. - """ - - apple_support_dependencies() - - bazel_features_deps() diff --git a/swift/repositories.bzl b/swift/internal/repositories.bzl similarity index 54% rename from swift/repositories.bzl rename to swift/internal/repositories.bzl index 679c9bc2b..5c33faf5f 100644 --- a/swift/repositories.bzl +++ b/swift/internal/repositories.bzl @@ -20,125 +20,12 @@ load( "swift_autoconfiguration", ) -def _maybe(repo_rule, name, **kwargs): - """Executes the given repository rule if it hasn't been executed already. - - Args: - repo_rule: The repository rule to be executed (e.g., `http_archive`.) - name: The name of the repository to be defined by the rule. - **kwargs: Additional arguments passed directly to the repository rule. - """ - if not native.existing_rule(name): - repo_rule(name = name, **kwargs) - # buildifier: disable=unnamed-macro -def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): +def swift_rules_dependencies(): """Fetches repositories that are dependencies of `rules_swift`. - - Users should call this macro in their `WORKSPACE` to ensure that all of the - dependencies of the Swift rules are downloaded and that they are isolated - from changes to those dependencies. - - Args: - include_bzlmod_ready_dependencies: Whether or not bzlmod-ready - dependencies should be included. """ - if include_bzlmod_ready_dependencies: - _maybe( - http_archive, - name = "bazel_skylib", - urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", - ], - sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", - ) - - _maybe( - http_archive, - name = "build_bazel_apple_support", - url = "https://github.com/bazelbuild/apple_support/releases/download/1.23.1/apple_support.1.23.1.tar.gz", - sha256 = "ee20cc5c0bab47065473c8033d462374dd38d172406ecc8de5c8f08487943f2f", - ) - - _maybe( - http_archive, - name = "rules_cc", - sha256 = "a2fdfde2ab9b2176bd6a33afca14458039023edb1dd2e73e6823810809df4027", - strip_prefix = "rules_cc-0.2.14", - url = "https://github.com/bazelbuild/rules_cc/releases/download/0.2.14/rules_cc-0.2.14.tar.gz", - ) - - _maybe( - http_archive, - name = "com_google_protobuf", - urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v29.0/protobuf-29.0.tar.gz"], - sha256 = "10a0d58f39a1a909e95e00e8ba0b5b1dc64d02997f741151953a2b3659f6e78c", - strip_prefix = "protobuf-29.0", - ) - # NOTE: this is required since `com_google_protobuf` depends on a bad 7.x version - # and WORKSAPCE mode does not upgrade the dependency correctly. - # This version matches that of the resolved rules_java version in `bazel mod graph`. - _maybe( - http_archive, - name = "rules_java", - url = "https://github.com/bazelbuild/rules_java/releases/download/8.14.0/rules_java-8.14.0.tar.gz", - sha256 = "bbe7d94360cc9ed4607ec5fd94995fd1ec41e84257020b6f09e64055281ecb12", - ) - - _maybe( - http_archive, - name = "com_github_nlohmann_json", - urls = [ - "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip", - ], - sha256 = "69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf", - type = "zip", - build_file = Label( - "//third_party:com_github_nlohmann_json/BUILD.overlay", - ), - ) - - _maybe( - http_archive, - name = "bazel_features", - sha256 = "a660027f5a87f13224ab54b8dc6e191693c554f2692fcca46e8e29ee7dabc43b", - strip_prefix = "bazel_features-1.30.0", - url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.30.0/bazel_features-v1.30.0.tar.gz", - ) - - _maybe( - http_archive, - name = "com_github_apple_swift_argument_parser", - urls = ["https://github.com/apple/swift-argument-parser/archive/refs/tags/1.3.1.tar.gz"], - sha256 = "4d964f874b251abc280ee28f0f187de3c13a6122a9561524f66a10768ca2d837", - strip_prefix = "swift-argument-parser-1.3.1", - build_file = Label( - "//third_party:com_github_apple_swift_argument_parser/BUILD.overlay", - ), - ) - - _maybe( - http_archive, - name = "rules_shell", - sha256 = "d8cd4a3a91fc1dc68d4c7d6b655f09def109f7186437e3f50a9b60ab436a0c53", - strip_prefix = "rules_shell-0.3.0", - url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.3.0/rules_shell-v0.3.0.tar.gz", - ) - - _maybe( - http_archive, - name = "platforms", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", - ], - sha256 = "29742e87275809b5e598dc2f04d86960cc7a55b3067d97221c9abbc9926bff0f", - ) - - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_protobuf", urls = ["https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz"], # pinned to grpc-swift version sha256 = "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb", @@ -148,8 +35,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_grpc_grpc_swift", urls = ["https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz"], # latest at time of writing sha256 = "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5", @@ -159,8 +45,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_docc_symbolkit", urls = ["https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz"], sha256 = "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97", @@ -170,8 +55,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_nio", urls = ["https://github.com/apple/swift-nio/archive/2.42.0.tar.gz"], # pinned to grpc swift version sha256 = "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0", @@ -181,8 +65,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_nio_http2", urls = ["https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz"], # pinned to grpc-swift version sha256 = "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25", @@ -192,8 +75,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_nio_transport_services", urls = ["https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz"], # pinned to grpc-swift version sha256 = "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262", @@ -203,8 +85,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_nio_extras", urls = ["https://github.com/apple/swift-nio-extras/archive/1.4.0.tar.gz"], # pinned to grpc-swift version sha256 = "4684b52951d9d9937bb3e8ccd6b5daedd777021ef2519ea2f18c4c922843b52b", @@ -214,8 +95,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_log", urls = ["https://github.com/apple/swift-log/archive/1.4.4.tar.gz"], # pinned to grpc-swift version sha256 = "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0", @@ -225,8 +105,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_nio_ssl", urls = ["https://github.com/apple/swift-nio-ssl/archive/2.23.0.tar.gz"], # pinned to grpc swift version sha256 = "4787c63f61dd04d99e498adc3d1a628193387e41efddf8de19b8db04544d016d", @@ -236,8 +115,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_collections", urls = ["https://github.com/apple/swift-collections/archive/1.0.4.tar.gz"], # pinned to swift-nio @ grpc-swift version sha256 = "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096", @@ -247,8 +125,7 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): ), ) - _maybe( - http_archive, + http_archive( name = "com_github_apple_swift_atomics", urls = ["https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz"], # pinned to swift-nio @ grpc-swift version sha256 = "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb", @@ -263,16 +140,14 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): # TODO: we must depend on two versions of index-import to support backwards # compatibility between Xcode 16.3+ and older versions, we can remove the older # version once we drop support for Xcode 16.x. - _maybe( - http_archive, + http_archive( name = "build_bazel_rules_swift_index_import_5_8", build_file = Label("//third_party:build_bazel_rules_swift_index_import/BUILD.overlay"), canonical_id = "index-import-5.8", urls = ["https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz"], sha256 = "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15", ) - _maybe( - http_archive, + http_archive( name = "build_bazel_rules_swift_index_import_6_1", build_file = Label("//third_party:build_bazel_rules_swift_index_import/BUILD.overlay"), canonical_id = "index-import-6.1", @@ -280,13 +155,4 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): sha256 = "9a54fc1674af6031125a9884480a1e31e1bcf48b8f558b3e8bcc6b6fcd6e8b61", ) - _maybe( - swift_autoconfiguration, - name = "build_bazel_rules_swift_local_config", - ) - - if include_bzlmod_ready_dependencies: - native.register_toolchains( - # Use register_toolchain's target pattern expansion to register all toolchains in the package. - "@build_bazel_rules_swift_local_config//:all", - ) + swift_autoconfiguration(name = "build_bazel_rules_swift_local_config")