-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPackage.swift
More file actions
132 lines (119 loc) · 5.14 KB
/
Package.swift
File metadata and controls
132 lines (119 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// swift-tools-version: 6.2
import PackageDescription
// MARK: - String Extensions
extension String {
static var htmlToPdfTypes: Self { "HtmlToPdfTypes" }
static var htmlToPdfLive: Self { "HtmlToPdfLive" }
static var htmlToPdf: Self { "HtmlToPdf" }
static var pdfTestSupport: Self { "PDFTestSupport" }
static var dependencies: Self { "Dependencies" }
static var dependenciesMacros: Self { "DependenciesMacros" }
static var dependenciesTestSupport: Self { "DependenciesTestSupport" }
static var loggingExtras: Self { "LoggingExtras" }
static var metrics: Self { "Metrics" }
static var html: Self { "HTML" }
static var resourcePool: Self { "ResourcePool" }
}
// MARK: - Target Dependency Extensions
extension Target.Dependency {
static var htmlToPdfTypes: Self { .target(name: .htmlToPdfTypes) }
static var htmlToPdfLive: Self { .target(name: .htmlToPdfLive) }
static var htmlToPdf: Self { .target(name: .htmlToPdf) }
static var pdfTestSupport: Self { .target(name: .pdfTestSupport) }
}
extension Target.Dependency {
static var dependencies: Self { .product(name: .dependencies, package: "swift-dependencies") }
static var dependenciesMacros: Self {
.product(name: .dependenciesMacros, package: "swift-dependencies")
}
static var dependenciesTestSupport: Self {
.product(name: .dependenciesTestSupport, package: "swift-dependencies")
}
static var loggingExtras: Self {
.product(name: .loggingExtras, package: "swift-logging-extras")
}
static var metrics: Self { .product(name: .metrics, package: "swift-metrics") }
static var resourcePool: Self { .product(name: .resourcePool, package: "swift-resource-pool") }
static var html: Self { .product(name: .html, package: "swift-html") }
}
// MARK: - Package Dependencies (to help compiler with traits complexity)
extension Package.Dependency {
static var swiftDependencies: Package.Dependency {
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.8.0")
}
static var swiftLoggingExtras: Package.Dependency {
.package(url: "https://github.com/coenttb/swift-logging-extras", from: "0.1.1")
}
static var swiftMetrics: Package.Dependency {
.package(url: "https://github.com/apple/swift-metrics", from: "2.4.0")
}
static var swiftResourcePool: Package.Dependency {
.package(url: "https://github.com/coenttb/swift-resource-pool", from: "0.1.3")
}
static var swiftHtml: Package.Dependency {
.package(url: "https://github.com/coenttb/swift-html", from: "0.11.1")
}
}
let package = Package(
name: "swift-html-to-pdf",
platforms: [.macOS(.v13), .iOS(.v16)],
products: [
.library(name: .htmlToPdfTypes, targets: [.htmlToPdfTypes]),
.library(name: .htmlToPdfLive, targets: [.htmlToPdfLive]),
.library(name: .htmlToPdf, targets: [.htmlToPdf]),
.library(name: .pdfTestSupport, targets: [.pdfTestSupport]),
],
traits: [
.trait(
name: "HTML",
description: "Include HTML integration (swift-html with PointFreeHTML)"
) // .default(enabledTraits: ["HTML"])
],
dependencies: [
.swiftDependencies, .swiftLoggingExtras, .swiftMetrics, .swiftResourcePool, .swiftHtml,
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
// Types target - NO PointFreeHTML dependency
.target(name: .htmlToPdfTypes, dependencies: [.dependencies, .dependenciesMacros]),
// Live target - NO PointFreeHTML dependency
.target(
name: .htmlToPdfLive,
dependencies: [
.htmlToPdfTypes, .dependencies, .dependenciesMacros, .loggingExtras, .metrics,
.resourcePool,
],
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency")
]
),
// Umbrella + Integration target - ADDS swift-html (conditionally)
.target(
name: .htmlToPdf,
dependencies: [
.htmlToPdfLive,
.product(name: .html, package: "swift-html", condition: .when(traits: ["HTML"])),
],
swiftSettings: [.define("HTML", .when(traits: ["HTML"]))]
),
.target(name: .pdfTestSupport, dependencies: [.htmlToPdfTypes, .dependencies, .metrics]),
.testTarget(
name: .htmlToPdfTypes.tests,
dependencies: [.htmlToPdfTypes, .dependenciesTestSupport],
exclude: ["HtmlToPdfTypes.xctestplan"],
),
.testTarget(
name: .htmlToPdfLive.tests,
dependencies: [.htmlToPdfLive, .pdfTestSupport, .dependenciesTestSupport],
exclude: ["HtmlToPdfLive.xctestplan", "StressTestLogs"],
resources: [.process("Resources")]
),
.testTarget(
name: .htmlToPdf.tests,
dependencies: [.htmlToPdf, .pdfTestSupport, .dependenciesTestSupport],
exclude: ["HtmlToPdf.xctestplan"],
swiftSettings: [.define("HTML", .when(traits: ["HTML"]))]
),
]
)
extension String { var tests: Self { self + "Tests" } }