1%YAML 1.2 2--- | 3 // swift-tools-version:5.5 4 // The swift-tools-version declares the minimum version of Swift required to build this package. 5 import PackageDescription 6 import Foundation 7 8 var basePath = FileManager.default.fileExists(atPath: "native") ? "native" : "." 9 10 let package = Package( 11 name: "gRPC", 12 products: [ 13 .library( 14 name: "gRPC-Core", 15 targets: [ 16 "gRPC-Core", 17 ] 18 ), 19 .library( 20 name: "gRPC-cpp", 21 targets: [ 22 "gRPC-cpp", 23 ] 24 ) 25 ], 26 27 dependencies: [ 28 .package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20240722.0"..<"0.20240723.0"), 29 .package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.32.0"..<"0.33.0"), 30 ], 31 32 targets: [ 33 .target( 34 name: "gRPC-Core", 35 dependencies: [ 36 .product(name:"abseil", package: "abseil-cpp-SwiftPM"), 37 .product(name:"openssl_grpc", package: "boringssl-SwiftPM"), 38 ], 39 path: basePath, 40 exclude: [ 41 "examples/", 42 "src/objective-c/", 43 ], 44 <% 45 files = [] 46 lib_maps = {lib.name: lib for lib in libs} 47 for dep in swift_package.get('deps', []): 48 lib = lib_maps[dep] 49 files.extend(lib.get('public_headers', []) + lib.headers + lib.src) 50 files = sorted(set(files)) 51 %> 52 sources: [ 53 % for file in files: 54 "${file}", 55 % endfor 56 ], 57 resources: [ 58 .copy("src/objective-c/PrivacyInfo.xcprivacy"), 59 ], 60 publicHeadersPath: "spm-core-include", 61 cSettings: [ 62 .headerSearchPath("./"), 63 .headerSearchPath("include/"), 64 .headerSearchPath("third_party/re2/"), 65 .headerSearchPath("third_party/upb/"), 66 .headerSearchPath("third_party/utf8_range/"), 67 .headerSearchPath("third_party/xxhash/"), 68 .headerSearchPath("third_party/address_sorting/include/"), 69 .headerSearchPath("src/core/ext/upb-gen/"), 70 .headerSearchPath("src/core/ext/upbdefs-gen/"), 71 .define("GRPC_ARES", to: "0"), 72 ], 73 linkerSettings: [ 74 .linkedFramework("CoreFoundation"), 75 .linkedLibrary("z"), 76 ] 77 ), 78 .target( 79 name: "gRPC-cpp", 80 dependencies: [ 81 .product(name:"abseil", package: "abseil-cpp-SwiftPM"), 82 "gRPC-Core", 83 ], 84 path: basePath, 85 exclude: [ 86 "examples/", 87 "src/cpp/client/cronet_credentials.cc", 88 "src/cpp/client/channel_test_peer.cc", 89 "src/cpp/common/alts_util.cc", 90 "src/cpp/common/alts_context.cc", 91 "src/cpp/common/insecure_create_auth_context.cc", 92 "src/cpp/server/admin/", 93 "src/cpp/server/channelz/", 94 "src/cpp/server/csds/", 95 "src/cpp/server/load_reporter/", 96 "src/cpp/ext/", 97 "src/cpp/util/core_stats.cc", 98 "src/cpp/util/core_stats.h", 99 "src/cpp/util/error_details.cc", 100 "src/objective-c/examples/", 101 "src/objective-c/manual_tests/", 102 "src/objective-c/tests/", 103 ], 104 sources: [ 105 "src/cpp/", 106 ], 107 resources: [ 108 .copy("src/objective-c/PrivacyInfo.xcprivacy"), 109 ], 110 publicHeadersPath: "spm-cpp-include", 111 cSettings: [ 112 .headerSearchPath("./"), 113 .headerSearchPath("include/"), 114 .headerSearchPath("third_party/upb/"), 115 .headerSearchPath("src/core/ext/upb-gen"), 116 ] 117 ), 118 .testTarget( 119 name: "build-test", 120 dependencies: [ 121 "gRPC-cpp", 122 ], 123 path: basePath + "/test/spm_build" 124 ), 125 ], 126 cLanguageStandard: .gnu11, 127 cxxLanguageStandard: .cxx14 128 ) 129