-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathPackage.swift
More file actions
119 lines (115 loc) · 3.82 KB
/
Copy pathPackage.swift
File metadata and controls
119 lines (115 loc) · 3.82 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
// swift-tools-version: 6.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
import class Foundation.ProcessInfo
let package = Package(
name: "swift-opa",
platforms: [
.macOS(.v15),
.iOS(.v18),
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "SwiftOPA",
targets: ["SwiftOPA"]),
.executable(
name: "swift-opa-cli",
targets: ["CLI"]
),
],
traits: [
// Enabled by default. Library-only consumers can opt out to drop optional
// features and dependencies from the build.
.default(enabledTraits: ["CLI", "YAML"]),
Trait(
name: "CLI",
description: "Builds the swift-opa-cli executable and its dependencies."
),
Trait(
name: "YAML",
description: "Builds the yaml.* builtins and their Yams dependency."
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
.package(url: "https://github.com/jpsim/Yams", from: "6.2.1"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "SwiftOPA",
dependencies: ["AST", "IR", "Bytecode", "Rego"]
),
.target(name: "AST"),
.target(
name: "IR",
dependencies: ["AST"]
),
.target(
name: "Bytecode",
dependencies: ["AST", "IR"]
),
.target(
name: "Rego",
dependencies: [
"AST",
"IR",
"Bytecode",
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux])),
.product(name: "Yams", package: "Yams", condition: .when(traits: ["YAML"])),
]
),
// Internal module tests
.testTarget(
name: "ASTTests",
dependencies: ["AST"]
),
.testTarget(
name: "IRTests",
dependencies: ["AST", "IR"],
resources: [.copy("Fixtures")]
),
.testTarget(
name: "BytecodeTests",
dependencies: ["AST", "IR", "Bytecode"]
),
.testTarget(
name: "RegoTests",
dependencies: ["Rego"],
resources: [.copy("TestData")]
),
// Public API surface tests
.testTarget(
name: "SwiftOPATests",
dependencies: ["SwiftOPA"]
),
.executableTarget(
name: "CLI",
dependencies: [
"Rego",
.product(
name: "ArgumentParser",
package: "swift-argument-parser",
condition: .when(traits: ["CLI"])
),
]
),
]
)
// If the `SWIFT_OPA_ALLOW_SWIFT_CRYPTO_BETA` environment variable is set
// swift-opa will accept swift-crypto beta releases as a dependency.
//
// Note: A beta release can only be used if other packages in the dependency tree
// that have a direct dependency on swift-crypto accept beta releases as well.
if ProcessInfo.processInfo.environment["SWIFT_OPA_ALLOW_SWIFT_CRYPTO_BETA"] == nil {
package.dependencies += [
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"5.0.0")
]
} else {
print("Accepting beta versions of swift-crypto!")
package.dependencies += [
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"5.0.0-beta.max")
]
}