Update grpc-swift to 1.0.0 and manually manage dependencies

This commit is contained in:
Adam Liddell 2021-02-11 23:25:01 +00:00
parent 104c00ea4a
commit e31f58752c
13 changed files with 319 additions and 15 deletions

View File

@ -222,17 +222,61 @@ VERSIONS = {
},
# Swift
"com_github_grpc_grpc_swift_patched": {
"com_github_grpc_grpc_swift": {
"type": "github",
"org": "grpc",
"repo": "grpc-swift",
"ref": "0.11.0",
"sha256": "82e0a3d8fe2b9ee813b918e1a674f5a7c6dc024abe08109a347b686db6e57432",
"build_file": "@build_bazel_rules_swift//third_party:com_github_grpc_grpc_swift/BUILD.overlay",
"patch_cmds": [
"sed -i.bak -e 's/if fileDescriptor.services.count > 0/if true/g' Sources/protoc-gen-swiftgrpc/main.swift", # Make grpc plugin always output files
"rm Sources/protoc-gen-swiftgrpc/main.swift.bak", # Remove .bak file we had to create above due to mac OS sed weirdness
],
"ref": "1.0.0",
"sha256": "5e0258437538bdfa26ca0e023649d97baa138d91881b949b2b344ef84cc2082a",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_grpc_grpc_swift",
},
"com_github_apple_swift_log": { # Dependency of com_github_grpc_grpc_swift
"type": "github",
"org": "apple",
"repo": "swift-log",
"ref": "1.4.0",
"sha256": "057fb5fd7e7f60a368c0cd4a93cd5ecce701031d8ccafb7973b3635415d2e368",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_apple_swift_log",
},
"com_github_apple_swift_nio": { # Dependency of com_github_grpc_grpc_swift
"type": "github",
"org": "apple",
"repo": "swift-nio",
"ref": "2.25.1",
"sha256": "ddaeaba8f94d4480a4607ce8f262aa654649632bdf51d280beebf053c8f37b2c",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_apple_swift_nio",
},
"com_github_apple_swift_nio_extras": { # Dependency of com_github_grpc_grpc_swift
"type": "github",
"org": "apple",
"repo": "swift-nio-extras",
"ref": "1.7.0",
"sha256": "b718ee9fb24c1f0fa77a54747eba472e50067b90d5df6f2b67cfdea2036b0ee0",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_apple_swift_nio_extras",
},
"com_github_apple_swift_nio_http2": { # Dependency of com_github_grpc_grpc_swift
"type": "github",
"org": "apple",
"repo": "swift-nio-http2",
"ref": "1.16.2",
"sha256": "af65870424c6e0eb643365278886d0c5358f6700eae2255f11dbf5b10f90b567",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_apple_swift_nio_http2",
},
"com_github_apple_swift_nio_ssl": { # Dependency of com_github_grpc_grpc_swift
"type": "github",
"org": "apple",
"repo": "swift-nio-ssl",
"ref": "2.10.2",
"sha256": "700c69f5496ae473164a338677e07f826eb24d7d3808d6e0fdcf50f27df0614d",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_apple_swift_nio_ssl",
},
"com_github_apple_swift_nio_transport_services": { # Dependency of com_github_grpc_grpc_swift
"type": "github",
"org": "apple",
"repo": "swift-nio-transport-services",
"ref": "1.9.1",
"sha256": "2f0283647d8e17dcea6d4b6454c915d10c4c0106c7025d233aec0aaf4a3f2255",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_apple_swift_nio_transport_services",
},
}
@ -480,5 +524,23 @@ def com_github_scalapb_scalapb(**kwargs):
#
# Swift
#
def com_github_grpc_grpc_swift_patched(**kwargs):
_generic_dependency("com_github_grpc_grpc_swift_patched", **kwargs)
def com_github_grpc_grpc_swift(**kwargs):
_generic_dependency("com_github_grpc_grpc_swift", **kwargs)
def com_github_apple_swift_log(**kwargs):
_generic_dependency("com_github_apple_swift_log", **kwargs)
def com_github_apple_swift_nio(**kwargs):
_generic_dependency("com_github_apple_swift_nio", **kwargs)
def com_github_apple_swift_nio_extras(**kwargs):
_generic_dependency("com_github_apple_swift_nio_extras", **kwargs)
def com_github_apple_swift_nio_http2(**kwargs):
_generic_dependency("com_github_apple_swift_nio_http2", **kwargs)
def com_github_apple_swift_nio_ssl(**kwargs):
_generic_dependency("com_github_apple_swift_nio_ssl", **kwargs)
def com_github_apple_swift_nio_transport_services(**kwargs):
_generic_dependency("com_github_apple_swift_nio_transport_services", **kwargs)

View File

@ -13,7 +13,8 @@ proto_plugin(
proto_plugin(
name = "grpc_swift_plugin",
outputs = ["{protopath}.grpc.swift"],
tool = "@com_github_grpc_grpc_swift_patched//:protoc-gen-swiftgrpc",
tool = "@com_github_grpc_grpc_swift//:protoc-gen-grpc-swift",
empty_template = "empty.template",
exclusions = [
"google/protobuf",
],

1
swift/empty.template Normal file
View File

@ -0,0 +1 @@
// Written by rules_proto_grpc fixer due to missing plugin output file

View File

@ -1,11 +1,23 @@
load(
"//:repositories.bzl",
"build_bazel_rules_swift",
"com_github_grpc_grpc_swift_patched",
"com_github_apple_swift_log",
"com_github_apple_swift_nio",
"com_github_apple_swift_nio_extras",
"com_github_apple_swift_nio_http2",
"com_github_apple_swift_nio_ssl",
"com_github_apple_swift_nio_transport_services",
"com_github_grpc_grpc_swift",
"rules_proto_grpc_repos",
)
def swift_repos(**kwargs):
rules_proto_grpc_repos(**kwargs)
build_bazel_rules_swift(**kwargs)
com_github_grpc_grpc_swift_patched(**kwargs)
com_github_grpc_grpc_swift(**kwargs)
com_github_apple_swift_log(**kwargs)
com_github_apple_swift_nio(**kwargs)
com_github_apple_swift_nio_extras(**kwargs)
com_github_apple_swift_nio_http2(**kwargs)
com_github_apple_swift_nio_ssl(**kwargs)
com_github_apple_swift_nio_transport_services(**kwargs)

View File

@ -20,5 +20,5 @@ def swift_grpc_library(**kwargs):
GRPC_DEPS = [
"@com_github_apple_swift_protobuf//:SwiftProtobuf",
"@com_github_grpc_grpc_swift//:SwiftGRPC",
"@com_github_grpc_grpc_swift//:GRPC",
]

View File

@ -0,0 +1,8 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "Logging",
srcs = glob(["Sources/Logging/**/*.swift"]),
module_name = "Logging",
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,90 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
# C libraries
cc_library(
name = "CNIOAtomics",
srcs = glob(["Sources/CNIOAtomics/**/*.c", "Sources/CNIOAtomics/**/*.h"]),
hdrs = glob(["Sources/CNIOAtomics/include/**/*.h"]),
includes = ["Sources/CNIOAtomics/include"],
tags = ["swift_module=CNIOAtomics"],
)
cc_library(
name = "CNIODarwin",
srcs = glob(["Sources/CNIODarwin/**/*.c", "Sources/CNIODarwin/**/*.h"]),
hdrs = glob(["Sources/CNIODarwin/include/**/*.h"]),
includes = ["Sources/CNIODarwin/include"],
tags = ["swift_module=CNIODarwin"],
)
cc_library(
name = "CNIOHTTPParser",
srcs = glob(["Sources/CNIOHTTPParser/**/*.c", "Sources/CNIOHTTPParser/**/*.h"]),
hdrs = glob(["Sources/CNIOHTTPParser/include/**/*.h"]),
includes = ["Sources/CNIOHTTPParser/include"],
tags = ["swift_module=CNIOHTTPParser"],
)
cc_library(
name = "CNIOLinux",
srcs = glob(["Sources/CNIOLinux/**/*.c", "Sources/CNIOLinux/**/*.h"]),
hdrs = glob(["Sources/CNIOLinux/include/**/*.h"]),
includes = ["Sources/CNIOLinux/include"],
tags = ["swift_module=CNIOLinux"],
)
cc_library(
name = "CNIOWindows",
srcs = glob(["Sources/CNIOWindows/**/*.c", "Sources/CNIOWindows/**/*.h"]),
hdrs = glob(["Sources/CNIOWindows/include/**/*.h"]),
includes = ["Sources/CNIOWindows/include"],
tags = ["swift_module=CNIOWindows"],
)
# Swift libraries
swift_library(
name = "NIOConcurrencyHelpers",
srcs = glob(["Sources/NIOConcurrencyHelpers/**/*.swift"]),
module_name = "NIOConcurrencyHelpers",
visibility = ["//visibility:public"],
deps = [":CNIOAtomics"],
)
swift_library(
name = "NIOFoundationCompat",
srcs = glob(["Sources/NIOFoundationCompat/**/*.swift"]),
module_name = "NIOFoundationCompat",
visibility = ["//visibility:public"],
deps = [":NIO"],
)
swift_library(
name = "NIOHTTP1",
srcs = glob(["Sources/NIOHTTP1/**/*.swift"]),
module_name = "NIOHTTP1",
visibility = ["//visibility:public"],
deps = [":NIO", ":CNIOHTTPParser", ":NIOConcurrencyHelpers"],
)
swift_library(
name = "NIOTLS",
srcs = glob(["Sources/NIOTLS/**/*.swift"]),
module_name = "NIOTLS",
visibility = ["//visibility:public"],
deps = [":NIO"],
)
swift_library(
name = "NIO",
srcs = glob(["Sources/NIO/**/*.swift"]),
module_name = "NIO",
visibility = ["//visibility:public"],
deps = [
":CNIOLinux",
":CNIODarwin",
":CNIOWindows",
":NIOConcurrencyHelpers",
],
)

View File

@ -0,0 +1,11 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "NIOExtras",
srcs = glob(["Sources/NIOExtras/**/*.swift"]),
module_name = "NIOExtras",
visibility = ["//visibility:public"],
deps = [
"@com_github_apple_swift_nio//:NIO",
],
)

View File

@ -0,0 +1,27 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "NIOHTTP2",
srcs = glob(["Sources/NIOHTTP2/**/*.swift"]),
module_name = "NIOHTTP2",
visibility = ["//visibility:public"],
deps = [
":NIOHPACK",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOHTTP1",
"@com_github_apple_swift_nio//:NIOConcurrencyHelpers",
"@com_github_apple_swift_nio//:NIOTLS",
],
)
swift_library(
name = "NIOHPACK",
srcs = glob(["Sources/NIOHPACK/**/*.swift"]),
module_name = "NIOHPACK",
visibility = ["//visibility:public"],
deps = [
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOHTTP1",
"@com_github_apple_swift_nio//:NIOConcurrencyHelpers",
],
)

View File

@ -0,0 +1,35 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
# C libraries
cc_library(
name = "CNIOBoringSSL",
srcs = glob(["Sources/CNIOBoringSSL/**/*.c", "Sources/CNIOBoringSSL/**/*.h"]),
hdrs = glob(["Sources/CNIOBoringSSL/include/**/*.h"]),
includes = ["Sources/CNIOBoringSSL/include"],
tags = ["swift_module=CNIOBoringSSL"],
)
cc_library(
name = "CNIOBoringSSLShims",
srcs = glob(["Sources/CNIOBoringSSLShims/**/*.c", "Sources/CNIOBoringSSLShims/**/*.h"]),
hdrs = glob(["Sources/CNIOBoringSSLShims/include/**/*.h"]),
includes = ["Sources/CNIOBoringSSLShims/include"],
tags = ["swift_module=CNIOBoringSSLShims"],
deps = [":CNIOBoringSSL"]
)
# Swift libraries
swift_library(
name = "NIOSSL",
srcs = glob(["Sources/NIOSSL/**/*.swift"]),
module_name = "NIOSSL",
visibility = ["//visibility:public"],
deps = [
":CNIOBoringSSL",
":CNIOBoringSSLShims",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOConcurrencyHelpers",
"@com_github_apple_swift_nio//:NIOTLS",
],
)

View File

@ -0,0 +1,14 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "NIOTransportServices",
srcs = glob(["Sources/NIOTransportServices/**/*.swift"]),
module_name = "NIOTransportServices",
visibility = ["//visibility:public"],
deps = [
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOFoundationCompat",
"@com_github_apple_swift_nio//:NIOConcurrencyHelpers",
"@com_github_apple_swift_nio//:NIOTLS",
],
)

View File

@ -0,0 +1,43 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary", "swift_library")
# C libraries
cc_library(
name = "CGRPCZlib",
srcs = glob(["Sources/CGRPCZlib/**/*.c", "Sources/CGRPCZlib/**/*.h"]),
hdrs = glob(["Sources/CGRPCZlib/include/**/*.h"]),
includes = ["Sources/CGRPCZlib/include"],
tags = ["swift_module=CGRPCZlib"],
deps = ["@zlib"],
)
# Swift libraries
swift_library(
name = "GRPC",
srcs = glob(["Sources/GRPC/**/*.swift"]),
module_name = "GRPC",
visibility = ["//visibility:public"],
deps = [
":CGRPCZlib",
"@com_github_apple_swift_log//:Logging",
"@com_github_apple_swift_nio//:NIO",
"@com_github_apple_swift_nio//:NIOHTTP1",
"@com_github_apple_swift_nio//:NIOFoundationCompat",
"@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",
],
)
swift_binary(
name = "protoc-gen-grpc-swift",
srcs = glob(["Sources/protoc-gen-grpc-swift/*.swift"]),
visibility = ["//visibility:public"],
deps = [
"@com_github_apple_swift_protobuf//:SwiftProtobuf",
"@com_github_apple_swift_protobuf//:SwiftProtobufPluginLibrary",
],
)

View File

@ -57,7 +57,7 @@ def {{ .Rule.Name }}(**kwargs):
GRPC_DEPS = [
"@com_github_apple_swift_protobuf//:SwiftProtobuf",
"@com_github_grpc_grpc_swift//:SwiftGRPC",
"@com_github_grpc_grpc_swift//:GRPC",
]`)
func makeSwift() *Language {