diff --git a/.bazelrc b/.bazelrc index b1416d4e5..a7a13a65b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,7 +1,7 @@ # To update these lines, execute # `bazel run @rules_bazel_integration_test//tools:update_deleted_packages` -build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/interesting_deps/ios,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example -query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/interesting_deps/ios,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example +build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/interesting_deps/ios,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/swift_protobuf_example,examples/swift_protobuf_example/Sources,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example +query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/interesting_deps/ios,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/swift_protobuf_example,examples/swift_protobuf_example/Sources,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example # Import Shared settings import %workspace%/shared.bazelrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3c0958d8..22806632b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,8 @@ jobs: runner: macos-13 - test: '@@//examples:stripe_example_test_bazel_.bazelversion' runner: macos-13 + - test: '@@//examples:swift_protobuf_example_test_bazel_.bazelversion' + runner: macos-13 - test: '@@//examples:symlink_example_test_bazel_.bazelversion' runner: macos-13 - test: '@@//examples:tca_example_test_bazel_.bazelversion' diff --git a/examples/swift_protobuf_example/BUILD.bazel b/examples/swift_protobuf_example/BUILD.bazel index 8cef6ccda..2eb696535 100644 --- a/examples/swift_protobuf_example/BUILD.bazel +++ b/examples/swift_protobuf_example/BUILD.bazel @@ -1,11 +1,33 @@ -load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") +load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") +load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy") -swift_library( - name = "swift_protobuf_test", - srcs = ["Sources/SwiftProtobufTest.swift"], - module_name = "SwiftProtobufTest", - visibility = ["//visibility:public"], - deps = [ - "@swiftpkg_swift_protobuf//:SwiftProtobuf", +tidy( + name = "tidy", + targets = [ + ":update_build_files", ], ) + +# MARK: - Gazelle + +# Ignore the Swift build folder +# gazelle:exclude .build + +gazelle_binary( + name = "gazelle_bin", + languages = [ + "@bazel_skylib_gazelle_plugin//bzl", + "@rules_swift_package_manager//gazelle", + ], +) + +gazelle( + name = "update_build_files", + data = [ + "@swift_deps_info//:swift_deps_index", + ], + extra_args = [ + "-swift_dependency_index=$(location @swift_deps_info//:swift_deps_index)", + ], + gazelle = ":gazelle_bin", +) diff --git a/examples/swift_protobuf_example/MODULE.bazel b/examples/swift_protobuf_example/MODULE.bazel index bb5fe1343..8610fe38a 100644 --- a/examples/swift_protobuf_example/MODULE.bazel +++ b/examples/swift_protobuf_example/MODULE.bazel @@ -1,9 +1,3 @@ -""" -Example module for grpc + proto target generation. -""" - -# rules_swift_package_manager - bazel_dep( name = "rules_swift_package_manager", version = "0.0.0", @@ -13,14 +7,15 @@ local_path_override( path = "../..", ) -# core deps - bazel_dep(name = "cgrindel_bazel_starlib", version = "0.21.0") bazel_dep(name = "bazel_skylib", version = "1.7.1") -bazel_dep(name = "apple_support", version = "1.17.1") +bazel_dep( + name = "apple_support", + version = "1.17.1", +) bazel_dep( name = "rules_swift", - version = "2.2.2", + version = "2.3.1", repo_name = "build_bazel_rules_swift", ) bazel_dep( @@ -29,7 +24,17 @@ bazel_dep( repo_name = "build_bazel_rules_apple", ) -# apple_cc_configure +bazel_dep( + name = "bazel_skylib_gazelle_plugin", + version = "1.7.1", + dev_dependency = True, +) +bazel_dep( + name = "gazelle", + version = "0.40.0", + dev_dependency = True, + repo_name = "bazel_gazelle", +) apple_cc_configure = use_extension( "@apple_support//crosstool:setup.bzl", @@ -37,8 +42,6 @@ apple_cc_configure = use_extension( ) use_repo(apple_cc_configure, "local_config_apple_cc") -# swift_deps - swift_deps = use_extension( "@rules_swift_package_manager//:extensions.bzl", "swift_deps", diff --git a/examples/swift_protobuf_example/Sources/BUILD.bazel b/examples/swift_protobuf_example/Sources/BUILD.bazel new file mode 100644 index 000000000..ad394704f --- /dev/null +++ b/examples/swift_protobuf_example/Sources/BUILD.bazel @@ -0,0 +1,8 @@ +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_test") + +swift_test( + name = "Sources", + srcs = ["SwiftProtobufTest.swift"], + module_name = "Sources", + deps = ["@swiftpkg_swift_protobuf//:SwiftProtobuf"], +) diff --git a/examples/swift_protobuf_example/WORKSPACE b/examples/swift_protobuf_example/WORKSPACE new file mode 100644 index 000000000..d251ab7ba --- /dev/null +++ b/examples/swift_protobuf_example/WORKSPACE @@ -0,0 +1 @@ +# Intentionally blank: Using bzlmod diff --git a/examples/swift_protobuf_example/WORKSPACE.bzlmod b/examples/swift_protobuf_example/WORKSPACE.bzlmod new file mode 100644 index 000000000..8cf89c330 --- /dev/null +++ b/examples/swift_protobuf_example/WORKSPACE.bzlmod @@ -0,0 +1,2 @@ +# Intentionally blank +# This exists to force Bazel in bzlmod mode to be strict. diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index a754ad094..af97bf495 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -139,7 +139,7 @@ def _swift_target_build_file(pkg_ctx, target): new_language_mode = bzl_selects.new( value = "swift.enable_v" + language_mode.value, kind = language_mode.kind, - condition = language_mode.condition + condition = language_mode.condition, ) features.append(new_language_mode) for bs in target.swift_settings.experimental_features: @@ -147,7 +147,7 @@ def _swift_target_build_file(pkg_ctx, target): new_experimental_feature = bzl_selects.new( value = "swift.experimental." + experimental_feature.value, kind = experimental_feature.kind, - condition = experimental_feature.condition + condition = experimental_feature.condition, ) features.append(new_experimental_feature) for bs in target.swift_settings.upcoming_features: @@ -155,7 +155,7 @@ def _swift_target_build_file(pkg_ctx, target): new_upcoming_feature = bzl_selects.new( value = "swift.upcoming." + upcoming_feature.value, kind = upcoming_feature.kind, - condition = upcoming_feature.condition + condition = upcoming_feature.condition, ) features.append(new_upcoming_feature) if len(features) > 0: