-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPackage.swift
More file actions
170 lines (156 loc) · 6.1 KB
/
Package.swift
File metadata and controls
170 lines (156 loc) · 6.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
// Package.swift
// UntoldEngine
//
// Copyright (C) Untold Engine Studios
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
import Foundation
// swift-tools-version: 6.0
import PackageDescription
let engineResources: [Resource] = {
var resources: [Resource] = [
.copy("UntoldEngineKernels/UntoldEngineKernels.metallib"), // macOS
.copy("UntoldEngineKernels/UntoldEngineKernels-ios.metallib"), // iOS (device)
.copy("UntoldEngineKernels/UntoldEngineKernels-iossim.metallib"), // iOS (simulator)
.copy("UntoldEngineKernels/UntoldEngineKernels-tvos.metallib"), // tvOS (device)
.copy("UntoldEngineKernels/UntoldEngineKernels-tvossim.metallib"), // tvOS (simulator)
.copy("UntoldEngineKernels/UntoldEngineKernels-xros.metallib"), // visionOS (device)
.copy("UntoldEngineKernels/UntoldEngineKernels-xrossim.metallib"), // visionOS (simulator)
]
// Keep model resources optional so package builds still succeed when that folder is absent.
if FileManager.default.fileExists(atPath: "Sources/UntoldEngine/Resources/Models") {
resources.append(.process("Resources/Models"))
}
resources.append(contentsOf: [
.process("Resources/HDR"),
.process("Resources/textures"),
])
return resources
}()
let package = Package(
name: "UntoldEngine",
platforms: [
.macOS(.v14),
.iOS(.v17),
.visionOS(.v2),
],
products: [
// Library product for the engine
.library(
name: "UntoldEngine",
targets: ["UntoldEngine"]
),
.library(name: "UntoldEngineXR", targets: ["UntoldEngineXR"]),
.library(name: "UntoldEngineAR", targets: ["UntoldEngineAR"]),
// Executable for the demo game
.executable(
name: "DemoGame",
targets: ["DemoGame"]
),
],
dependencies: [],
targets: [
.target(
name: "CShaderTypes",
path: "Sources/CShaderTypes",
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("."),
]
),
.target(
name: "UntoldEngine",
dependencies: ["CShaderTypes"],
path: "Sources/UntoldEngine",
exclude: ["Shaders"],
// 📦 Ship prebuilt metallibs for each platform; pick at runtime.
resources: engineResources,
swiftSettings: [
// Compile engine stats collection only in debug by default.
// Release builds can still opt in explicitly with -DENGINE_STATS_ENABLED.
.define("ENGINE_STATS_ENABLED", .when(configuration: .debug)),
.swiftLanguageMode(.v6),
],
linkerSettings: [
// Common
.linkedFramework("Metal"),
.linkedFramework("QuartzCore", .when(platforms: [.macOS, .iOS /* , .visionOS */ ])),
// macOS UI stack
.linkedFramework("AppKit", .when(platforms: [.macOS])),
// iOS UI stack (only if some targets import UIKit)
.linkedFramework("UIKit", .when(platforms: [.iOS])),
]
),
// Vision OS target
.target(
name: "UntoldEngineXR",
dependencies: [
"UntoldEngine",
],
path: "Sources/UntoldEngineXR",
swiftSettings: [
// CompositorServices and ARKit only exist on visionOS
.define("VISIONOS_AVAILABLE", .when(platforms: [.visionOS])),
// Must mirror the engine flag so #if ENGINE_STATS_ENABLED blocks in this
// target are active; without it, xrFrameStartTime is never declared and
// finalizeXRStatsAndMonitors receives 0.0, producing garbage frameTotalMs.
.define("ENGINE_STATS_ENABLED", .when(configuration: .debug)),
.swiftLanguageMode(.v6),
],
linkerSettings: [
.linkedFramework("Metal", .when(platforms: [.visionOS])),
.linkedFramework("CompositorServices", .when(platforms: [.visionOS])),
.linkedFramework("ARKit", .when(platforms: [.visionOS])),
]
),
// iOS AR target
.target(
name: "UntoldEngineAR",
dependencies: ["UntoldEngine"],
path: "Sources/UntoldEngineAR",
swiftSettings: [
.define("AR_AVAILABLE", .when(platforms: [.iOS])),
.swiftLanguageMode(.v6),
],
linkerSettings: [
.linkedFramework("Metal", .when(platforms: [.iOS])),
.linkedFramework("MetalKit", .when(platforms: [.iOS])),
.linkedFramework("ARKit", .when(platforms: [.iOS])),
]
),
// These executables are macOS-only
.executableTarget(
name: "DemoGame",
dependencies: ["UntoldEngine"],
path: "Sources/DemoGame",
swiftSettings: [.swiftLanguageMode(.v6)],
linkerSettings: [
.linkedFramework("Metal"),
.linkedFramework("QuartzCore", .when(platforms: [.macOS, .iOS])),
.linkedFramework("AppKit", .when(platforms: [.macOS])),
]
),
// Test target for unit tests
.testTarget(
name: "UntoldEngineTests",
dependencies: ["UntoldEngine"],
path: "Tests/UntoldEngineTests",
swiftSettings: [.swiftLanguageMode(.v6)]
),
// Render-specific test target
.testTarget(
name: "UntoldEngineRenderTests",
dependencies: ["UntoldEngine"],
path: "Tests/UntoldEngineRenderTests",
exclude: ["Resources/compare_psnr.py"],
resources: [
.copy("Resources/compare_psnr.py"),
.process("Resources"),
],
swiftSettings: [.swiftLanguageMode(.v6)]
),
]
)