-
Notifications
You must be signed in to change notification settings - Fork 3
/
Package.swift
76 lines (63 loc) · 2.02 KB
/
Package.swift
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
// swift-tools-version:5.7
import PackageDescription
import Foundation
// MARK: - Conveniences
let localDev = false
let devDir = "../"
struct Dep {
let package: PackageDescription.Package.Dependency
let targets: [Target.Dependency]
init (_ what: What, _ targets: Target.Dependency...) {
self.package = what.dependency
self.targets = targets
}
}
struct What {
let dependency: Package.Dependency
static func local(_ path: String) -> What {
.init(dependency: .package(path: "\(devDir)\(path)"))
}
static func github(_ path: String, _ from: Version) -> What {
.init(dependency: .package(url: "https://github.com/\(path)", from: from))
}
static func github(_ path: String, exact: Version) -> What {
.init(dependency: .package(url: "https://github.com/\(path)", exact: exact))
}
static func github(_ path: String, branch: String) -> What {
.init(dependency: .package(url: "https://github.com/\(path)", branch: branch))
}
}
extension Target.Dependency {
static func product(_ name: String, _ package: String? = nil) -> Target.Dependency {
.product(name: name, package: package ?? name)
}
}
// MARK: - Dependencies
var deps: [Dep] = [
.init(.github("vapor/vapor", "4.0.0"), .product("Vapor", "vapor")),
.init(.github("swifweb/console-kit", branch: "master"), .product("ConsoleKit", "console-kit")),
.init(.github("swiftwasm/WasmTransformer", "0.0.3"), .product("WasmTransformer", "WasmTransformer"))
]
if localDev {
deps.append(contentsOf: [
.init(.local("webber-tools"), .product("WebberTools", "webber-tools"))
])
} else {
deps.append(contentsOf: [
.init(.github("swifweb/webber-tools", "1.4.2"), .product("WebberTools", "webber-tools"))
])
}
// MARK: - Package
let package = Package(
name: "webber",
platforms: [
.macOS(.v10_15)
],
products: [
.executable(name: "Webber", targets: ["Webber"])
],
dependencies: deps.map { $0.package },
targets: [
.target(name: "Webber", dependencies: deps.flatMap { $0.targets })
]
)