[ObjC] generate Package.swift from template (#33505)

This is to help simplify the grpc iOS release flow.

Package.swift was manually written and out of sync for a long time in
this repo.
They are currently being updated updated for releases in
[grpc-ios](https://github.com/grpc/grpc-ios) repo, which includes a lot
of manual work to include new files and exclude tests.

This diff generate Package.swift from a template like other languages to
avoid the tedious work. Currently only gRPC-Core is generated form the
template, gRPC-cpp remains the same for now as they don't change often.

CC @sampajano
pull/33513/head
Hannah Shi 1 year ago committed by GitHub
parent a194f145e4
commit 12e0e60242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1974
      Package.swift
  2. 7
      build_handwritten.yaml
  3. 121
      templates/Package.swift.template

File diff suppressed because it is too large Load Diff

@ -202,3 +202,10 @@ ruby_gem:
- boringssl
- re2
- z
swift_package:
deps:
- grpc
- grpc_authorization_provider
- gpr
- upb
- re2

@ -0,0 +1,121 @@
%YAML 1.2
--- |
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
import Foundation
var basePath = FileManager.default.fileExists(atPath: "native") ? "native" : "."
let package = Package(
name: "gRPC",
products: [
.library(
name: "gRPC-Core",
targets: [
"gRPC-Core",
]
),
.library(
name: "gRPC-cpp",
targets: [
"gRPC-cpp",
]
)
],
dependencies: [
.package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20220623.0"..<"0.20220624.0"),
.package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.9.0"..<"0.10.0"),
],
targets: [
.target(
name: "gRPC-Core",
dependencies: [
.product(name:"abseil", package: "abseil-cpp-SwiftPM"),
.product(name:"openssl_grpc", package: "boringssl-SwiftPM"),
],
path: basePath,
exclude: [
"examples/",
"src/objective-c/",
],
<%
files = []
lib_maps = {lib.name: lib for lib in libs}
for dep in swift_package.get('deps', []):
lib = lib_maps[dep]
files.extend(lib.get('public_headers', []) + lib.headers + lib.src)
files = sorted(set(files))
%>
sources: [
% for file in files:
"${file}",
% endfor
],
publicHeadersPath: "spm-core-include",
cSettings: [
.headerSearchPath("./"),
.headerSearchPath("include/"),
.headerSearchPath("third_party/re2/"),
.headerSearchPath("third_party/upb/"),
.headerSearchPath("third_party/utf8_range/"),
.headerSearchPath("third_party/xxhash/"),
.headerSearchPath("src/core/ext/upb-generated/"),
.headerSearchPath("src/core/ext/upbdefs-generated/"),
.define("GRPC_ARES", to: "0"),
],
linkerSettings: [
.linkedFramework("CoreFoundation"),
.linkedLibrary("z"),
]
),
.target(
name: "gRPC-cpp",
dependencies: [
.product(name:"abseil", package: "abseil-cpp-SwiftPM"),
"gRPC-Core",
],
path: basePath,
exclude: [
"examples/",
"src/cpp/client/cronet_credentials.cc",
"src/cpp/client/channel_test_peer.cc",
"src/cpp/common/alts_util.cc",
"src/cpp/common/alts_context.cc",
"src/cpp/common/insecure_create_auth_context.cc",
"src/cpp/server/admin/",
"src/cpp/server/channelz/",
"src/cpp/server/csds/",
"src/cpp/server/load_reporter/",
"src/cpp/ext/",
"src/cpp/util/core_stats.cc",
"src/cpp/util/core_stats.h",
"src/cpp/util/error_details.cc",
"src/objective-c/examples/",
"src/objective-c/manual_tests/",
"src/objective-c/tests/",
],
sources: [
"src/cpp/",
],
publicHeadersPath: "spm-cpp-include",
cSettings: [
.headerSearchPath("./"),
.headerSearchPath("include/"),
.headerSearchPath("third_party/upb/"),
.headerSearchPath("src/core/ext/upb-generated"),
]
),
.testTarget(
name: "build-test",
dependencies: [
"gRPC-cpp",
],
path: basePath + "/test/spm_build"
),
],
cLanguageStandard: .gnu11,
cxxLanguageStandard: .cxx14
)
Loading…
Cancel
Save