diff --git a/examples/example_infos.bzl b/examples/example_infos.bzl index 9931517d6..4325e5a5b 100644 --- a/examples/example_infos.bzl +++ b/examples/example_infos.bzl @@ -146,6 +146,7 @@ _macos_single_bazel_version_test_examples = [ "shake_ios_example", "snapkit_example", "stripe_example", + "swift_protobuf_example", "xcmetrics_example", "tca_example", "symlink_example", diff --git a/examples/swift_protobuf_example/.bazelrc b/examples/swift_protobuf_example/.bazelrc index e69de29bb..b5fc1b379 100644 --- a/examples/swift_protobuf_example/.bazelrc +++ b/examples/swift_protobuf_example/.bazelrc @@ -0,0 +1,9 @@ + +# Import Shared settings +import %workspace%/../../shared.bazelrc + +# Import CI settings. +import %workspace%/../../ci.bazelrc + +# Try to import a local.rc file; typically, written by CI +try-import %workspace%/../../local.bazelrc \ No newline at end of file diff --git a/examples/swift_protobuf_example/BUILD.bazel b/examples/swift_protobuf_example/BUILD.bazel index e69de29bb..54ccdfb9e 100644 --- a/examples/swift_protobuf_example/BUILD.bazel +++ b/examples/swift_protobuf_example/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_swift//swift:swift.bzl", "swift_library") + +swift_library( + name = "swift_protobuf_test", + srcs = ["Sources/SwiftProtobufTest.swift"], + module_name = "SwiftProtobufTest", + visibility = ["//visibility:public"], + deps = [ + "@swiftpkg_swift_protobuf//:SwiftProtobuf", + ], +) diff --git a/examples/swift_protobuf_example/MODULE.bazel b/examples/swift_protobuf_example/MODULE.bazel index 3a159e7ab..a3c1f7e53 100644 --- a/examples/swift_protobuf_example/MODULE.bazel +++ b/examples/swift_protobuf_example/MODULE.bazel @@ -2,13 +2,14 @@ Example module for grpc + proto target generation. """ +# cgrindel_bazel_starlib + +bazel_dep(name = "cgrindel_bazel_starlib", version = "0.21.0") + # rules_go bazel_dep(name = "rules_go", version = "0.50.1") -go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") -go_sdk.host() - # gazelle bazel_dep(name = "gazelle", version = "0.40.0") @@ -40,7 +41,6 @@ local_path_override( path = "../..", ) -# swift_deps START swift_deps = use_extension( "@rules_swift_package_manager//:extensions.bzl", "swift_deps", @@ -56,12 +56,3 @@ use_repo( "swift_package", "swiftpkg_swift_protobuf", ) -# swift_deps END - -# rules_apple - -bazel_dep(name = "rules_apple", version = "3.16.1") - -# rules_xcodeproj - -bazel_dep(name = "rules_xcodeproj", version = "2.10.0") diff --git a/examples/swift_protobuf_example/Package.swift b/examples/swift_protobuf_example/Package.swift index 6b1ba5f2f..93fcd57b9 100644 --- a/examples/swift_protobuf_example/Package.swift +++ b/examples/swift_protobuf_example/Package.swift @@ -6,10 +6,6 @@ let package = Package( name: "swift_protobuf_example", dependencies: [ // These are the versions used by rules_swift - // .package(url: "https://github.com/grpc/grpc-swift-extras", exact: "1.0.0-beta.2"), - // .package(url: "https://github.com/grpc/grpc-swift.git", exact: "2.0.0-beta.2"), // Required by grpc-swift-extras @ 1.0.0-beta.2 - // .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", exact: "1.0.0-beta.2"), // Required by grpc-swift @ 2.0.0-beta.2 - // .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", exact: "1.0.0-beta.2"), // Required by grpc-swift @ 2.0.0-beta.2 .package(url: "https://github.com/apple/swift-protobuf.git", exact: "1.28.1"), ] ) diff --git a/examples/swift_protobuf_example/Sources/SwiftProtobufTest.swift b/examples/swift_protobuf_example/Sources/SwiftProtobufTest.swift new file mode 100644 index 000000000..99b381c5b --- /dev/null +++ b/examples/swift_protobuf_example/Sources/SwiftProtobufTest.swift @@ -0,0 +1 @@ +import SwiftProtobuf \ No newline at end of file diff --git a/examples/swift_protobuf_example/do_test b/examples/swift_protobuf_example/do_test index 809bb324c..93f62acd1 100755 --- a/examples/swift_protobuf_example/do_test +++ b/examples/swift_protobuf_example/do_test @@ -6,11 +6,6 @@ set -o errexit -o nounset -o pipefail # to bazel. bazel="${BIT_BAZEL_BINARY:-bazel}" -# Generate Swift external deps and update build files -"${bazel}" run //:tidy +# Ensure that it builds +"${bazel}" build //... -# Ensure that it builds and tests pass -"${bazel}" test //... - -# Ensure that Gazelle doesn't make any changes -"${bazel}" run //:update_build_files -- --mode=diff diff --git a/swiftpkg/tests/swiftpkg_build_files_tests.bzl b/swiftpkg/tests/swiftpkg_build_files_tests.bzl index de7c889b7..822c150e8 100644 --- a/swiftpkg/tests/swiftpkg_build_files_tests.bzl +++ b/swiftpkg/tests/swiftpkg_build_files_tests.bzl @@ -156,10 +156,18 @@ _pkg_info = pkginfos.new( ], ), ), + pkginfos.new_build_setting( + kind = build_setting_kinds.language_modes, + values = ["6"], + ), pkginfos.new_build_setting( kind = build_setting_kinds.experimental_features, values = ["BuiltinModule"], ), + pkginfos.new_build_setting( + kind = build_setting_kinds.upcoming_features, + values = ["ExistentialAny"], + ), pkginfos.new_build_setting( kind = build_setting_kinds.unsafe_flags, values = ["-cross-module-optimization"], @@ -552,11 +560,7 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary") swift_binary( name = "SwiftExecutableTarget.rspm", - copts = [ - "-DSWIFT_PACKAGE", - "-enable-experimental-feature", - "BuiltinModule", - ] + select({ + copts = ["-DSWIFT_PACKAGE"] + select({ "@rules_swift_package_manager//config_settings/spm/platform:ios": ["-DFOOBAR"], "//conditions:default": [], }) + select({ @@ -566,6 +570,11 @@ swift_binary( "@rules_swift_package_manager//config_settings/spm/configuration:release": ["-cross-module-optimization"], "//conditions:default": [], }), + features = [ + "swift.enable_v6", + "swift.experimental.BuiltinModule", + "swift.upcoming.ExistentialAny", + ], module_name = "SwiftExecutableTarget", package_name = "MyPackage", srcs = ["Source/SwiftExecutableTarget/main.swift"],