forked from niochat/MatrixSDK
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-package.swift
41 lines (32 loc) · 1.03 KB
/
generate-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
import Foundation
func packageString(url: String, checksum: String) -> String {
"""
// swift-tools-version:5.6
import PackageDescription
let package = Package(
name: "MatrixSDK",
products: [
.library(name: "MatrixSDK", targets: ["MatrixSDK"])
],
targets: [
.binaryTarget(name: "MatrixSDK", url: "\(url)", checksum: "\(checksum)")
]
)
"""
}
guard CommandLine.arguments.count == 3 else {
print("Usage: swiftc generate-package.swift url checksum")
exit(-1)
}
print("Generating binary package")
print("• URL: \(CommandLine.arguments[1])")
print("• Checksum: \(CommandLine.arguments[2]) \n")
guard let data = packageString(url: CommandLine.arguments[1], checksum: CommandLine.arguments[2]).data(using: .utf8) else {
fatalError("Error creating data.")
}
do {
try data.write(to: URL(fileURLWithPath: "./Package.swift"))
} catch {
fatalError("Error writing package manifest to disk.")
}
print("Package manifest succesfully written to disk.")