forked from ewconnell/swiftrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.swift
78 lines (67 loc) · 2.77 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
76
77
78
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version
// of Swift required to build this package.
import PackageDescription
import Foundation
//------------------------------------------------------------------------------
// determine platform build type
let validPlatforms = Set(arrayLiteral: "cpu", "cuda")
let environment = ProcessInfo.processInfo.environment
let platform = (environment["SWIFTRT_PLATFORM"] ?? "cpu").lowercased()
if !validPlatforms.contains(platform) {
fatalError("valid SWIFTRT_PLATFORM types: \(validPlatforms)")
}
let buildCuda = platform == "cuda"
//---------------------------------------
// the base products, dependencies, and targets
var products: [PackageDescription.Product] = [
.library(name: "SwiftRT", targets: ["SwiftRT"]),
.library(name: "SwiftRTCore", targets: ["SwiftRTCore"]),
.library(name: "SwiftRTLayers", targets: ["SwiftRTLayers"]),
]
var targets: [PackageDescription.Target] = []
var coreDependencies: [Target.Dependency] =
[.product(name: "Numerics", package: "swift-numerics")]
var testDependencies: [Target.Dependency] = ["SwiftRT"]
var exclusions: [String] = ["*.gyb"]
//==============================================================================
// Cuda platform module
if buildCuda {
//---------------------------------------
// add cuda modules
// they are currently combined into a single module to work around
// multi-module symbol conflicts
products.append(.library(name: "SwiftRTCuda", targets: ["SwiftRTCuda"]))
coreDependencies.append("SwiftRTCuda")
testDependencies.append("SwiftRTCuda")
targets.append(.systemLibrary(
name: "SwiftRTCuda",
path: "Modules/SwiftRTCuda",
pkgConfig: "cuda"))
} else {
exclusions.append("platform/cuda")
}
//==============================================================================
// Targets
targets.append(contentsOf: [
// umbrella import
.target(name: "SwiftRT", dependencies: ["SwiftRTCore", "SwiftRTLayers"]),
// neural net layers
.target(name: "SwiftRTLayers", dependencies: ["SwiftRTCore"]),
// core platform and base types
.target(name: "SwiftRTCore", dependencies: coreDependencies, exclude: exclusions),
// tests
.testTarget(name: "BenchmarkTests", dependencies: testDependencies),
.testTarget(name: "SwiftRTCoreTests", dependencies: testDependencies),
.testTarget(name: "SwiftRTLayerTests", dependencies: testDependencies),
])
//==============================================================================
// package specification
let package = Package(
name: "SwiftRT",
products: products,
dependencies: [
.package(url: "https://github.com/apple/swift-numerics", .branch("master"))
],
targets: targets
)