|
| 1 | +// swift-tools-version: 6.1 |
| 2 | +// The swift-tools-version declares the minimum version of Swift required to build this package. |
| 3 | + |
| 4 | +import PackageDescription |
| 5 | + |
| 6 | +let availabilityMacro: SwiftSetting = .enableExperimentalFeature( |
| 7 | + "AvailabilityMacro=SubprocessSpan: macOS 9999", |
| 8 | +) |
| 9 | + |
| 10 | +var dep: [Package.Dependency] = [ |
| 11 | + .package( |
| 12 | + url: "https://github.com/apple/swift-system", |
| 13 | + from: "1.0.0" |
| 14 | + ) |
| 15 | +] |
| 16 | +#if !os(Windows) |
| 17 | +dep.append( |
| 18 | + .package( |
| 19 | + url: "https://github.com/apple/swift-docc-plugin", |
| 20 | + from: "1.4.3" |
| 21 | + ), |
| 22 | +) |
| 23 | +#endif |
| 24 | + |
| 25 | +// Enable SubprocessFoundation by default |
| 26 | +var defaultTraits: Set<String> = ["SubprocessFoundation"] |
| 27 | +#if compiler(>=6.2) |
| 28 | +// Enable SubprocessSpan when Span is available |
| 29 | +defaultTraits.insert("SubprocessSpan") |
| 30 | +#endif |
| 31 | + |
| 32 | +let package = Package( |
| 33 | + name: "Subprocess", |
| 34 | + platforms: [.macOS(.v13)], |
| 35 | + products: [ |
| 36 | + .library( |
| 37 | + name: "Subprocess", |
| 38 | + targets: ["Subprocess"] |
| 39 | + ) |
| 40 | + ], |
| 41 | + traits: [ |
| 42 | + "SubprocessFoundation", |
| 43 | + "SubprocessSpan", |
| 44 | + .default( |
| 45 | + enabledTraits: defaultTraits |
| 46 | + ), |
| 47 | + ], |
| 48 | + dependencies: dep, |
| 49 | + targets: [ |
| 50 | + .target( |
| 51 | + name: "Subprocess", |
| 52 | + dependencies: [ |
| 53 | + "_SubprocessCShims", |
| 54 | + .product(name: "SystemPackage", package: "swift-system"), |
| 55 | + ], |
| 56 | + path: "Sources/Subprocess", |
| 57 | + swiftSettings: [ |
| 58 | + .enableExperimentalFeature("StrictConcurrency"), |
| 59 | + .enableExperimentalFeature("NonescapableTypes"), |
| 60 | + .enableExperimentalFeature("LifetimeDependence"), |
| 61 | + .enableExperimentalFeature("Span"), |
| 62 | + availabilityMacro, |
| 63 | + ] |
| 64 | + ), |
| 65 | + .testTarget( |
| 66 | + name: "SubprocessTests", |
| 67 | + dependencies: [ |
| 68 | + "_SubprocessCShims", |
| 69 | + "Subprocess", |
| 70 | + "TestResources", |
| 71 | + .product(name: "SystemPackage", package: "swift-system"), |
| 72 | + ], |
| 73 | + swiftSettings: [ |
| 74 | + .enableExperimentalFeature("Span"), |
| 75 | + availabilityMacro, |
| 76 | + ] |
| 77 | + ), |
| 78 | + |
| 79 | + .target( |
| 80 | + name: "TestResources", |
| 81 | + dependencies: [ |
| 82 | + .product(name: "SystemPackage", package: "swift-system") |
| 83 | + ], |
| 84 | + path: "Tests/TestResources", |
| 85 | + resources: [ |
| 86 | + .copy("Resources") |
| 87 | + ] |
| 88 | + ), |
| 89 | + |
| 90 | + .target( |
| 91 | + name: "_SubprocessCShims", |
| 92 | + path: "Sources/_SubprocessCShims" |
| 93 | + ), |
| 94 | + ] |
| 95 | +) |
0 commit comments