diff --git a/.bazelrc b/.bazelrc index 4a132c30e..fe3969277 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,8 +4,8 @@ common --incompatible_allow_tags_propagation # Fail if a glob doesn't match anything (https://github.com/bazelbuild/bazel/issues/8195) build --incompatible_disallow_empty_glob -build --host_macos_minimum_os=13.0 -build --macos_minimum_os=13.0 +build --host_macos_minimum_os=15.0 +build --macos_minimum_os=15.0 # We don't need to bump some of our dependencies, just becuse our dev # dependencies cause us to use a newer version diff --git a/MODULE.bazel b/MODULE.bazel index bce62ac41..945526f70 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -33,6 +33,8 @@ use_repo( "com_github_apple_swift_nio_transport_services", "com_github_apple_swift_protobuf", "com_github_grpc_grpc_swift", + "com_github_grpc_grpc_swift_protobuf", + "com_github_grpc_grpc_swift_nio_transport", ) apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension") diff --git a/doc/proto_migration.md b/doc/proto_migration.md index f08ef0b59..76dabe472 100644 --- a/doc/proto_migration.md +++ b/doc/proto_migration.md @@ -221,18 +221,6 @@ swift_proto_library( ], protos = [":service_proto"], ) - -swift_proto_library( - name = "service_test_client_swift_proto", - additional_compiler_info = { - "ExtraModuleImports": "examples_xplatform_grpc_service_client_swift_proto", - }, - compiler_deps = [ - ":service_client_swift_proto", - ], - compilers = ["@build_bazel_rules_swift//proto/compilers:swift_test_client_proto"], - protos = [":service_proto"], -) ``` Note here that we don't need the intermediate `swift_proto_library` target, diff --git a/examples/xplatform/grpc/BUILD b/examples/xplatform/grpc/BUILD index c4752f82f..7b58aaaa1 100644 --- a/examples/xplatform/grpc/BUILD +++ b/examples/xplatform/grpc/BUILD @@ -20,6 +20,8 @@ swift_binary( srcs = ["server_main.swift"], deps = [ "//examples/xplatform/grpc/service:service_server_swift_proto", + "@com_github_apple_swift_nio//:NIO", + "@com_github_apple_swift_nio//:NIOCore", ], ) @@ -28,6 +30,9 @@ swift_binary( srcs = ["client_main.swift"], deps = [ "//examples/xplatform/grpc/service:service_client_swift_proto", + "@com_github_apple_swift_nio//:NIO", + "@com_github_apple_swift_nio//:NIOCore", + "@com_github_grpc_grpc_swift_nio_transport//:GRPCNIOTransportHTTP2", ], ) @@ -39,16 +44,7 @@ swift_test( deps = [ "//examples/xplatform/grpc/service:service_client_swift_proto", "//examples/xplatform/grpc/service:service_server_swift_proto", - ], -) - -swift_test( - name = "echo_test_client_unit_test", - srcs = [ - "test_client_unit_test.swift", - ], - deps = [ - "//examples/xplatform/grpc/service:service_client_swift_proto", - "//examples/xplatform/grpc/service:service_test_client_swift_proto", + "@com_github_apple_swift_nio//:NIO", + "@com_github_apple_swift_nio//:NIOCore", ], ) diff --git a/examples/xplatform/grpc/client_main.swift b/examples/xplatform/grpc/client_main.swift index 75bf5a5a5..f85bc7d04 100644 --- a/examples/xplatform/grpc/client_main.swift +++ b/examples/xplatform/grpc/client_main.swift @@ -14,49 +14,41 @@ import Foundation import SwiftProtobuf -import GRPC +import GRPCCore import NIOCore import NIOPosix import ServiceClient +import GRPCNIOTransportHTTP2 @main struct ClientMain { + @MainActor static func main() throws { - // Setup an `EventLoopGroup` for the connection to run on. - // - // See: https://github.com/apple/swift-nio#eventloops-and-eventloopgroups - let group = MultiThreadedEventLoopGroup(numberOfThreads: 1) - - // Make sure the group is shutdown when we're done with it. - defer { - try! group.syncShutdownGracefully() - } - - // Configure the channel, we're not using TLS so the connection is `insecure`. - let channel = try GRPCChannelPool.with( - target: .host("localhost", port: 9000), - transportSecurity: .plaintext, - eventLoopGroup: group - ) - // Initialize the client using the same address the server is started on. - let client = Service_EchoServiceNIOClient(channel: channel) - - // Construct a request to the echo service. - let request = Service_EchoRequest.with { - $0.contents = "Hello, world!" - let timestamp = Google_Protobuf_Timestamp(date: Date()) - $0.extra = try! Google_Protobuf_Any(message: timestamp) - } - - let call = client.echo(request) - - // Make the remote method call and print the response we receive. - do { - let response = try call.response.wait() - print(response.contents) - } catch { - print("Echo failed: \(error)") + try await withGRPCClient( + transport: .http2NIOPosix( + target: .host("localhost", port: 9000), + transportSecurity: .plaintext + ) + ) { client in + let echo = Service_EchoService.Client(wrapping: client) + + // Construct a request to the echo service. + let request = Service_EchoRequest.with { + $0.contents = "Hello, world!" + let timestamp = Google_Protobuf_Timestamp(date: Date()) + $0.extra = try! Google_Protobuf_Any(message: timestamp) + } + + let call = client.echo(request) + + // Make the remote method call and print the response we receive. + do { + let response = try await call.response + print(response.contents) + } catch { + print("Echo failed: \(error)") + } } } } diff --git a/examples/xplatform/grpc/client_unit_test.swift b/examples/xplatform/grpc/client_unit_test.swift index ae3c1c1fb..e6a5a726b 100644 --- a/examples/xplatform/grpc/client_unit_test.swift +++ b/examples/xplatform/grpc/client_unit_test.swift @@ -14,12 +14,12 @@ import ServiceClient import ServiceServer -import GRPC +import GRPCCore import NIOCore import NIOPosix import XCTest -public class EchoServiceProvider: Service_EchoServiceProvider { +public class EchoServiceProvider: Service_EchoService.ClientProtocol { public let interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? public init(interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? = nil) { diff --git a/examples/xplatform/grpc/server_main.swift b/examples/xplatform/grpc/server_main.swift index 298136b7b..54cc90d79 100644 --- a/examples/xplatform/grpc/server_main.swift +++ b/examples/xplatform/grpc/server_main.swift @@ -13,13 +13,13 @@ // limitations under the License. import Dispatch -import GRPC +import GRPCCore import NIOCore import NIOPosix import ServiceServer /// Concrete implementation of the `EchoService` service definition. -class EchoProvider: Service_EchoServiceProvider { +class EchoProvider: Service_EchoService.ClientProtocol { var interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? /// Called when the server receives a request for the `EchoService.Echo` method. diff --git a/examples/xplatform/grpc/service/BUILD b/examples/xplatform/grpc/service/BUILD index 3c5d43045..f8010575b 100644 --- a/examples/xplatform/grpc/service/BUILD +++ b/examples/xplatform/grpc/service/BUILD @@ -33,19 +33,3 @@ swift_proto_library( protos = [":service_proto"], visibility = ["//visibility:public"], ) - -swift_proto_library( - name = "service_test_client_swift_proto", - additional_compiler_deps = [ - "//examples/xplatform/grpc/service:service_client_swift_proto", - ], - additional_compiler_info = { - "ExtraModuleImports": "ServiceClient", - }, - compilers = [ - "//proto/compilers:swift_test_client_proto", - ], - module_name = "ServiceTestClient", - protos = [":service_proto"], - visibility = ["//visibility:public"], -) diff --git a/examples/xplatform/grpc/test_client_unit_test.swift b/examples/xplatform/grpc/test_client_unit_test.swift deleted file mode 100644 index c3a2f6e28..000000000 --- a/examples/xplatform/grpc/test_client_unit_test.swift +++ /dev/null @@ -1,50 +0,0 @@ -// 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. - -import ServiceClient -import ServiceTestClient -import GRPC -import NIOCore -import NIOPosix -import XCTest - -class UnitTest: XCTestCase { - func testGetWithFakeClient() throws { - - // Set up the fake contents: - let fakeContents = "Response" - let fakeResponse = Service_EchoResponse.with { - $0.contents = fakeContents - } - let fakeClient = Service_EchoServiceTestClient() - fakeClient.enqueueEchoResponse(fakeResponse) - let client: Service_EchoServiceClientProtocol = fakeClient - - // Make the fake request: - let completed = self.expectation(description: "'Get' completed") - let call = client.echo(.with { $0.contents = fakeContents }) - call.response.whenComplete { result in - switch result { - case let .success(response): - XCTAssertEqual(response.contents, fakeContents) - case let .failure(error): - XCTFail("Unexpected error \(error)") - } - - completed.fulfill() - } - - self.wait(for: [completed], timeout: 10.0) - } -} diff --git a/examples/xplatform/proto_library_group/BUILD b/examples/xplatform/proto_library_group/BUILD index 8440f8b85..93d8c28d3 100644 --- a/examples/xplatform/proto_library_group/BUILD +++ b/examples/xplatform/proto_library_group/BUILD @@ -6,6 +6,8 @@ swift_binary( srcs = ["server_main.swift"], deps = [ "//examples/xplatform/proto_library_group/service:service_server_swift_proto", + "@com_github_apple_swift_nio//:NIO", + "@com_github_apple_swift_nio//:NIOCore", ], ) @@ -14,6 +16,8 @@ swift_binary( srcs = ["client_main.swift"], deps = [ "//examples/xplatform/proto_library_group/service:service_client_swift_proto", + "@com_github_apple_swift_nio//:NIO", + "@com_github_apple_swift_nio//:NIOCore", ], ) @@ -25,5 +29,7 @@ swift_test( deps = [ "//examples/xplatform/proto_library_group/service:service_client_swift_proto", "//examples/xplatform/proto_library_group/service:service_server_swift_proto", + "@com_github_apple_swift_nio//:NIO", + "@com_github_apple_swift_nio//:NIOCore", ], ) diff --git a/examples/xplatform/proto_library_group/client_main.swift b/examples/xplatform/proto_library_group/client_main.swift index 7888832d2..2fb0fda95 100644 --- a/examples/xplatform/proto_library_group/client_main.swift +++ b/examples/xplatform/proto_library_group/client_main.swift @@ -14,7 +14,7 @@ import Foundation import SwiftProtobuf -import GRPC +import GRPCCore import NIOCore import NIOPosix import examples_xplatform_proto_library_group_request_request_proto diff --git a/examples/xplatform/proto_library_group/client_unit_test.swift b/examples/xplatform/proto_library_group/client_unit_test.swift index a53694ece..2d362d22e 100644 --- a/examples/xplatform/proto_library_group/client_unit_test.swift +++ b/examples/xplatform/proto_library_group/client_unit_test.swift @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import GRPC +import GRPCCore import NIOCore import NIOPosix import XCTest @@ -21,7 +21,7 @@ import examples_xplatform_proto_library_group_response_response_proto import ServiceClient import ServiceServer -public class EchoServiceProvider: Service_EchoServiceProvider { +public class EchoServiceProvider: Service_EchoService.ClientProtocol { public let interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? public init(interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? = nil) { diff --git a/examples/xplatform/proto_library_group/server_main.swift b/examples/xplatform/proto_library_group/server_main.swift index 83b078857..b1db406b3 100644 --- a/examples/xplatform/proto_library_group/server_main.swift +++ b/examples/xplatform/proto_library_group/server_main.swift @@ -13,7 +13,7 @@ // limitations under the License. import Dispatch -import GRPC +import GRPCCore import NIOCore import NIOPosix import examples_xplatform_proto_library_group_request_request_proto @@ -21,7 +21,7 @@ import examples_xplatform_proto_library_group_response_response_proto import ServiceServer /// Concrete implementation of the `EchoService` service definition. -class EchoProvider: Service_EchoServiceProvider { +class EchoProvider: Service_EchoService.ClientProtocol { var interceptors: Service_EchoServiceServerInterceptorFactoryProtocol? /// Called when the server receives a request for the `EchoService.Echo` method. diff --git a/proto/compilers/BUILD b/proto/compilers/BUILD index f824b1e08..1ac42326e 100644 --- a/proto/compilers/BUILD +++ b/proto/compilers/BUILD @@ -4,7 +4,6 @@ load( "//proto/compilers:swift_proto_compiler_macros.bzl", "GRPC_VARIANT_CLIENT", "GRPC_VARIANT_SERVER", - "GRPC_VARIANT_TEST_CLIENT", "PROTO_PLUGIN_OPTIONS", "PROTO_PLUGIN_OPTION_ALLOWLIST", "make_grpc_swift_proto_compiler", @@ -40,11 +39,6 @@ make_grpc_swift_proto_compiler( variants = [GRPC_VARIANT_CLIENT], ) -make_grpc_swift_proto_compiler( - name = "swift_test_client_proto", - variants = [GRPC_VARIANT_TEST_CLIENT], -) - bzl_library( name = "swift_proto_compiler_macros", srcs = ["swift_proto_compiler_macros.bzl"], diff --git a/proto/compilers/swift_proto_compiler_macros.bzl b/proto/compilers/swift_proto_compiler_macros.bzl index 5db4e29af..8447ab128 100644 --- a/proto/compilers/swift_proto_compiler_macros.bzl +++ b/proto/compilers/swift_proto_compiler_macros.bzl @@ -30,11 +30,9 @@ PROTO_PLUGIN_OPTIONS = { } GRPC_VARIANT_SERVER = "Server" GRPC_VARIANT_CLIENT = "Client" -GRPC_VARIANT_TEST_CLIENT = "TestClient" GRPC_VARIANTS = [ GRPC_VARIANT_SERVER, GRPC_VARIANT_CLIENT, - GRPC_VARIANT_TEST_CLIENT, ] GRPC_PLUGIN_OPTION_ALLOWLIST = PROTO_PLUGIN_OPTION_ALLOWLIST + [ "KeepMethodCasing", @@ -76,8 +74,8 @@ def make_grpc_swift_proto_compiler( plugin_options = merged_plugin_options, suffixes = [".grpc.swift"], deps = [ - "@com_github_apple_swift_protobuf//:SwiftProtobuf", - "@com_github_grpc_grpc_swift//:GRPC", + "@com_github_grpc_grpc_swift_protobuf//:GRPCProtobuf", + "@com_github_grpc_grpc_swift//:GRPCCore", ], visibility = ["//visibility:public"], ) diff --git a/swift/repositories.bzl b/swift/repositories.bzl index bcbad3974..69794e356 100644 --- a/swift/repositories.bzl +++ b/swift/repositories.bzl @@ -106,9 +106,9 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): _maybe( 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", - strip_prefix = "swift-protobuf-1.20.2/", + urls = ["https://github.com/apple/swift-protobuf/archive/1.28.1.tar.gz"], # pinned to grpc-swift version + sha256 = "9204c512ee90378f22db3255ecc35de927d672a4925d5222497c57b3f30de726", + strip_prefix = "swift-protobuf-1.28.1/", build_file = Label( "//third_party:com_github_apple_swift_protobuf/BUILD.overlay", ), @@ -117,14 +117,36 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): _maybe( 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", - strip_prefix = "grpc-swift-1.16.0/", + urls = ["https://github.com/grpc/grpc-swift/archive/2.0.0.tar.gz"], # latest at time of writing + sha256 = "f0264d6a90eef30d4189e5e8ccc39b429bcd0444c86b41d246c4b803c0676ecd", + strip_prefix = "grpc-swift-2.0.0/", build_file = Label( "//third_party:com_github_grpc_grpc_swift/BUILD.overlay", ), ) + _maybe( + http_archive, + name = "com_github_grpc_grpc_swift_nio_transport", + urls = ["https://github.com/grpc/grpc-swift-nio-transport/archive/1.0.0.tar.gz"], # latest at time of writing + sha256 = "e590f7a30961802cbdf4f8cac37ae2dbc9ab2c8f8032c2ef2f66ed2b63623185", + strip_prefix = "grpc-swift-nio-transport-1.0.0/", + build_file = Label( + "//third_party:com_github_grpc_grpc_swift_nio_transport/BUILD.overlay", + ), + ) + + _maybe( + http_archive, + name = "com_github_grpc_grpc_swift_protobuf", + urls = ["https://github.com/grpc/grpc-swift-protobuf/archive/1.0.0.tar.gz"], # latest at time of writing + sha256 = "c31969782aa710e002f9a6214a9eb1e4292800e3606c2a092b034b97fdff52ac", + strip_prefix = "grpc-swift-protobuf-1.0.0/", + build_file = Label( + "//third_party:com_github_grpc_grpc_swift_protobuf/BUILD.overlay", + ), + ) + _maybe( http_archive, name = "com_github_apple_swift_docc_symbolkit", @@ -139,9 +161,9 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): _maybe( 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", - strip_prefix = "swift-nio-2.42.0/", + urls = ["https://github.com/apple/swift-nio/archive/2.78.0.tar.gz"], # pinned to grpc swift version + sha256 = "7262fe6a134ce83fda666429ca88a511db517f36996955dafeb2068d66b7d260", + strip_prefix = "swift-nio-2.78.0/", build_file = Label( "//third_party:com_github_apple_swift_nio/BUILD.overlay", ), @@ -150,9 +172,9 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): _maybe( 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", - strip_prefix = "swift-nio-http2-1.26.0/", + urls = ["https://github.com/apple/swift-nio-http2/archive/1.35.0.tar.gz"], # pinned to grpc-swift version + sha256 = "ffc425d7e2737d17b80a0227f2b2823eb95bd76cb681906494e5b795f64f6f5c", + strip_prefix = "swift-nio-http2-1.35.0/", build_file = Label( "//third_party:com_github_apple_swift_nio_http2/BUILD.overlay", ), @@ -194,9 +216,9 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): _maybe( 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", - strip_prefix = "swift-nio-ssl-2.23.0/", + urls = ["https://github.com/apple/swift-nio-ssl/archive/2.29.0.tar.gz"], # pinned to grpc swift version + sha256 = "f35a05309d791ec5ff23e1b0cdff2962872e2388fa0e27fced57566bb0383ea4", + strip_prefix = "swift-nio-ssl-2.29.0/", build_file = Label( "//third_party:com_github_apple_swift_nio_ssl/BUILD.overlay", ), @@ -205,9 +227,9 @@ def swift_rules_dependencies(include_bzlmod_ready_dependencies = True): _maybe( 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", - strip_prefix = "swift-collections-1.0.4/", + urls = ["https://github.com/apple/swift-collections/archive/1.1.3.tar.gz"], # pinned to swift-nio @ grpc-swift version + sha256 = "7e5e48d0dc2350bed5919be5cf60c485e72a30bd1f2baf718a619317677b91db", + strip_prefix = "swift-collections-1.1.3/", build_file = Label( "//third_party:com_github_apple_swift_collections/BUILD.overlay", ), diff --git a/third_party/com_github_apple_swift_collections/BUILD.overlay b/third_party/com_github_apple_swift_collections/BUILD.overlay index 8ac6aaa71..48c21205a 100644 --- a/third_party/com_github_apple_swift_collections/BUILD.overlay +++ b/third_party/com_github_apple_swift_collections/BUILD.overlay @@ -18,6 +18,9 @@ swift_library( srcs = glob([ "Sources/DequeModule/**/*.swift", ]), + deps = [ + ":InternalCollectionsUtilities", + ], module_name = "DequeModule", visibility = ["//visibility:public"], ) @@ -27,6 +30,18 @@ swift_library( srcs = glob([ "Sources/OrderedCollections/**/*.swift", ]), + deps = [ + ":InternalCollectionsUtilities", + ], module_name = "OrderedCollections", visibility = ["//visibility:public"], ) + +swift_library( + name = "InternalCollectionsUtilities", + srcs = glob([ + "Sources/InternalCollectionsUtilities/**/*.swift", + ]), + module_name = "InternalCollectionsUtilities", + visibility = ["//visibility:public"], +) diff --git a/third_party/com_github_apple_swift_nio/BUILD.overlay b/third_party/com_github_apple_swift_nio/BUILD.overlay index 792a26701..58b5a566d 100644 --- a/third_party/com_github_apple_swift_nio/BUILD.overlay +++ b/third_party/com_github_apple_swift_nio/BUILD.overlay @@ -155,9 +155,26 @@ swift_library( ":CNIOLinux", ":CNIOWindows", ":NIOConcurrencyHelpers", + ":_NIODataStructures", + ":_NIOBase64", "@com_github_apple_swift_atomics//:Atomics", "@com_github_apple_swift_collections//:DequeModule", ], + features = [ + "swift.upcoming.StrictConcurrency", + "swift.upcoming.InferSendableFromCaptures", + ], +) + +swift_library( + name = "_NIOBase64", + srcs = glob([ + "Sources/_NIOBase64/*.swift", + ]), + copts = [], + module_name = "_NIOBase64", + visibility = ["//visibility:public"], + deps = [], ) swift_library( diff --git a/third_party/com_github_apple_swift_nio_ssl/BUILD.overlay b/third_party/com_github_apple_swift_nio_ssl/BUILD.overlay index 90dc52f7d..1fe3501f3 100644 --- a/third_party/com_github_apple_swift_nio_ssl/BUILD.overlay +++ b/third_party/com_github_apple_swift_nio_ssl/BUILD.overlay @@ -51,10 +51,14 @@ cc_library( ]), hdrs = glob([ "Sources/CNIOBoringSSL/include/**/*.h", - "Sources/CNIOBoringSSL/include/**/*.inc", + "Sources/CNIOBoringSSL/**/*.inc", ]), aspect_hints = [":CNIOBoringSSL_interop"], - copts = [], + copts = [ + "-D_GNU_SOURCE", + "-D_POSIX_C_SOURCE=200112L", + "-D_DARWIN_C_SOURCE", + ], includes = ["Sources/CNIOBoringSSL/include"], visibility = ["//visibility:public"], deps = [], diff --git a/third_party/com_github_apple_swift_nio_transport_services/BUILD.overlay b/third_party/com_github_apple_swift_nio_transport_services/BUILD.overlay index 218735f37..6c765e32d 100644 --- a/third_party/com_github_apple_swift_nio_transport_services/BUILD.overlay +++ b/third_party/com_github_apple_swift_nio_transport_services/BUILD.overlay @@ -14,4 +14,7 @@ swift_library( "@com_github_apple_swift_nio//:NIOFoundationCompat", "@com_github_apple_swift_nio//:NIOTLS", ], + features = [ + "swift.upcoming.MemberImportVisibility", + ], ) diff --git a/third_party/com_github_grpc_grpc_swift/BUILD.overlay b/third_party/com_github_grpc_grpc_swift/BUILD.overlay index 8fb8b0e2e..40694aba2 100644 --- a/third_party/com_github_grpc_grpc_swift/BUILD.overlay +++ b/third_party/com_github_grpc_grpc_swift/BUILD.overlay @@ -1,62 +1,41 @@ -load("@build_bazel_rules_swift//swift:swift_binary.bzl", "swift_binary") -load( - "@build_bazel_rules_swift//swift:swift_interop_hint.bzl", - "swift_interop_hint", -) load("@build_bazel_rules_swift//swift:swift_library.bzl", "swift_library") -cc_library( - name = "CGRPCZlib", - srcs = glob([ - "Sources/CGRPCZlib/**/*.c", - ]), - hdrs = glob([ - "Sources/CGRPCZlib/**/*.h", - ]), - aspect_hints = [":CGRPCZLIB_interop"], - includes = ["Sources/CGRPCZlib/include"], - linkopts = ["-lz"], -) - -swift_interop_hint( - name = "CGRPCZLIB_interop", - module_name = "CGRPCZlib", -) - swift_library( - name = "GRPC", + name = "GRPCCodeGen", srcs = glob([ - "Sources/GRPC/**/*.swift", + "Sources/GRPCCodeGen/**/*.swift", ]), defines = ["SWIFT_PACKAGE"], # activates CgRPC imports - module_name = "GRPC", + module_name = "GRPCCodeGen", + package_name = "GRPCCodeGen", visibility = ["//visibility:public"], - deps = [ - ":CGRPCZlib", - "@com_github_apple_swift_log//:Logging", - "@com_github_apple_swift_nio//:NIO", - "@com_github_apple_swift_nio//:NIOCore", - "@com_github_apple_swift_nio//:NIOEmbedded", - "@com_github_apple_swift_nio//:NIOFoundationCompat", - "@com_github_apple_swift_nio//:NIOHTTP1", - "@com_github_apple_swift_nio//:NIOPosix", - "@com_github_apple_swift_nio//:NIOTLS", - "@com_github_apple_swift_nio_extras//:NIOExtras", - "@com_github_apple_swift_nio_http2//:NIOHTTP2", - "@com_github_apple_swift_nio_ssl//:NIOSSL", - "@com_github_apple_swift_nio_transport_services//:NIOTransportServices", - "@com_github_apple_swift_protobuf//:SwiftProtobuf", + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", ], + deps = [], ) -swift_binary( - name = "protoc-gen-grpc-swift", +swift_library( + name = "GRPCCore", srcs = glob([ - "Sources/protoc-gen-grpc-swift/*.swift", + "Sources/GRPCCore/**/*.swift", + ], exclude = [ + "Sources/GRPCCore/Documentation.docc/**/*", ]), + defines = ["SWIFT_PACKAGE"], # activates CgRPC imports + module_name = "GRPCCore", + package_name = "GRPCCore", visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", + ], deps = [ - "@com_github_apple_swift_protobuf//:SwiftProtobuf", - "@com_github_apple_swift_protobuf//:SwiftProtobufPluginLibrary", + "@com_github_apple_swift_collections//:DequeModule", ], ) diff --git a/third_party/com_github_grpc_grpc_swift_nio_transport/BUILD.overlay b/third_party/com_github_grpc_grpc_swift_nio_transport/BUILD.overlay new file mode 100644 index 000000000..fa1767e43 --- /dev/null +++ b/third_party/com_github_grpc_grpc_swift_nio_transport/BUILD.overlay @@ -0,0 +1,111 @@ +load( + "@build_bazel_rules_swift//swift:swift_interop_hint.bzl", + "swift_interop_hint", +) +load("@build_bazel_rules_swift//swift:swift_library.bzl", "swift_library") + +cc_library( + name = "CGRPCNIOTransportZlib", + srcs = glob([ + "Sources/CGRPCNIOTransportZlib/**/*.c", + ]), + hdrs = glob([ + "Sources/CGRPCNIOTransportZlib/**/*.h", + ]), + aspect_hints = [":CGRPCZLIB_interop"], + includes = ["Sources/CGRPCNIOTransportZlib/include"], + linkopts = ["-lz"], +) + +swift_interop_hint( + name = "CGRPCZLIB_interop", + module_name = "CGRPCNIOTransportZlib", +) + +swift_library( + name = "GRPCNIOTransportHTTP2", + srcs = glob([ + "Sources/GRPCNIOTransportHTTP2/**/*.swift", + ]), + defines = ["SWIFT_PACKAGE"], + module_name = "GRPCNIOTransportHTTP2", + package_name = "GRPCNIOTransport", + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", + ], + deps = [ + ":GRPCNIOTransportHTTP2Posix", + ":GRPCNIOTransportHTTP2TransportServices", + ], +) + +swift_library( + name = "GRPCNIOTransportCore", + srcs = glob([ + "Sources/GRPCNIOTransportCore/**/*.swift", + ]), + defines = ["SWIFT_PACKAGE"], + module_name = "GRPCNIOTransportCore", + package_name = "GRPCNIOTransport", + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + ], + deps = [ + "@com_github_grpc_grpc_swift//:GRPCCore", + # "@com_github_apple_swift_nio//:NIOCore", + "@com_github_apple_swift_nio_http2//:NIOHTTP2", + "@com_github_apple_swift_nio_extras//:NIOExtras", + ":CGRPCNIOTransportZlib", + ], +) + +swift_library( + name = "GRPCNIOTransportHTTP2Posix", + srcs = glob([ + "Sources/GRPCNIOTransportHTTP2Posix/**/*.swift", + ]), + defines = ["SWIFT_PACKAGE"], + module_name = "GRPCNIOTransportHTTP2Posix", + package_name = "GRPCNIOTransport", + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + ], + deps = [ + ":GRPCNIOTransportCore", + "@com_github_grpc_grpc_swift//:GRPCCore", + "@com_github_apple_swift_nio//:NIOPosix", + "@com_github_apple_swift_nio_ssl//:NIOSSL", + ], +) + +swift_library( + name = "GRPCNIOTransportHTTP2TransportServices", + srcs = glob([ + "Sources/GRPCNIOTransportHTTP2TransportServices/**/*.swift", + ]), + defines = ["SWIFT_PACKAGE"], + module_name = "GRPCNIOTransportHTTP2TransportServices", + package_name = "GRPCNIOTransport", + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", + ], + deps = [ + ":GRPCNIOTransportCore", + "@com_github_grpc_grpc_swift//:GRPCCore", + "@com_github_apple_swift_nio_transport_services//:NIOTransportServices", + ], +) diff --git a/third_party/com_github_grpc_grpc_swift_protobuf/BUILD.overlay b/third_party/com_github_grpc_grpc_swift_protobuf/BUILD.overlay new file mode 100644 index 000000000..6f06e5224 --- /dev/null +++ b/third_party/com_github_grpc_grpc_swift_protobuf/BUILD.overlay @@ -0,0 +1,64 @@ +load("@build_bazel_rules_swift//swift:swift_binary.bzl", "swift_binary") +load("@build_bazel_rules_swift//swift:swift_library.bzl", "swift_library") + +swift_binary( + name = "protoc-gen-grpc-swift", + srcs = glob([ + "Sources/protoc-gen-grpc-swift/*.swift", + ]), + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", + ], + deps = [ + ":GRPCProtobufCodeGen", + "@com_github_grpc_grpc_swift//:GRPCCodeGen", + "@com_github_apple_swift_protobuf//:SwiftProtobuf", + "@com_github_apple_swift_protobuf//:SwiftProtobufPluginLibrary", + ], +) + +swift_library( + name = "GRPCProtobuf", + srcs = glob([ + "Sources/GRPCProtobuf/**/*.swift", + ]), + defines = ["SWIFT_PACKAGE"], # activates CgRPC imports + module_name = "GRPCProtobuf", + package_name = "GRPCProtobuf", + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", + ], + deps = [ + "@com_github_grpc_grpc_swift//:GRPCCore", + "@com_github_apple_swift_protobuf//:SwiftProtobuf", + ], +) + +swift_library( + name = "GRPCProtobufCodeGen", + srcs = glob([ + "Sources/GRPCProtobufCodeGen/**/*.swift", + ]), + defines = ["SWIFT_PACKAGE"], # activates CgRPC imports + module_name = "GRPCProtobufCodeGen", + package_name = "GRPCProtobufCodeGen", + visibility = ["//visibility:public"], + features = [ + "swift.upcoming.ExistentialAny", + "swift.upcoming.InternalImportsByDefault", + "swift.upcoming.MemberImportVisibility", + "swift.enable_v6", + ], + deps = [ + "@com_github_grpc_grpc_swift//:GRPCCodeGen", + "@com_github_apple_swift_protobuf//:SwiftProtobufPluginLibrary", + ], +) diff --git a/tools/protoc_wrapper/BUILD b/tools/protoc_wrapper/BUILD index 4c0932288..201bf329f 100644 --- a/tools/protoc_wrapper/BUILD +++ b/tools/protoc_wrapper/BUILD @@ -30,7 +30,7 @@ alias( universal_binary( name = "universal_protoc-gen-grpc-swift", - binary = "@com_github_grpc_grpc_swift//:protoc-gen-grpc-swift", + binary = "@com_github_grpc_grpc_swift_protobuf//:protoc-gen-grpc-swift", tags = ["manual"], target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"], @@ -42,7 +42,7 @@ alias( name = "protoc-gen-grpc-swift", actual = select({ "//swift:universal_tools_config": ":universal_protoc-gen-grpc-swift", - "//conditions:default": "@com_github_grpc_grpc_swift//:protoc-gen-grpc-swift", + "//conditions:default": "@com_github_grpc_grpc_swift_protobuf//:protoc-gen-grpc-swift", }), target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"],