Skip to content

Commit bc57422

Browse files
authored
Merge pull request #2889 from compnerd/manifest-flags
PackageLoading: introduce `-Xmanifest`
2 parents b30b5e2 + 09c4117 commit bc57422

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Sources/Commands/Options.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ struct BuildFlagsGroup: ParsableArguments {
4242
"Pass flag through to the Xcode build system invocations",
4343
shouldDisplay: false))
4444
var xcbuildFlags: [String] = []
45-
45+
46+
@Option(name: .customLong("Xmanifest", withSingleDash: true),
47+
parsing: .unconditionalSingleValue,
48+
help: ArgumentHelp("Pass flag to the manifest build invocation",
49+
shouldDisplay: false))
50+
var manifestFlags: [String] = []
51+
4652
var buildFlags: BuildFlags {
4753
BuildFlags(
4854
xcc: cCompilerFlags,
@@ -96,7 +102,11 @@ public struct SwiftToolOptions: ParsableArguments {
96102
var xcbuildFlags: [String] {
97103
buildFlagsGroup.xcbuildFlags
98104
}
99-
105+
106+
var manifestFlags: [String] {
107+
buildFlagsGroup.manifestFlags
108+
}
109+
100110
/// Build configuration.
101111
@Option(name: .shortAndLong, help: "Build with configuration")
102112
var configuration: BuildConfiguration = .debug

Sources/Commands/SwiftTool.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ public class SwiftTool {
655655
// Always use the host toolchain's resources for parsing manifest.
656656
manifestResources: self._hostToolchain.get().manifestResources,
657657
isManifestSandboxEnabled: !self.options.shouldDisableSandbox,
658-
cacheDir: self.options.shouldDisableManifestCaching ? nil : self.buildPath
658+
cacheDir: self.options.shouldDisableManifestCaching ? nil : self.buildPath,
659+
extraManifestFlags: self.options.manifestFlags
659660
)
660661
})
661662
}()

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,21 @@ public final class ManifestLoader: ManifestLoaderProtocol {
143143
let cacheDir: AbsolutePath!
144144
let delegate: ManifestLoaderDelegate?
145145
private(set) var cache: PersistentCacheProtocol?
146+
private let extraManifestFlags: [String]
146147

147148
public init(
148149
manifestResources: ManifestResourceProvider,
149150
serializedDiagnostics: Bool = false,
150151
isManifestSandboxEnabled: Bool = true,
151152
cacheDir: AbsolutePath? = nil,
152-
delegate: ManifestLoaderDelegate? = nil
153+
delegate: ManifestLoaderDelegate? = nil,
154+
extraManifestFlags: [String] = []
153155
) {
154156
self.resources = manifestResources
155157
self.serializedDiagnostics = serializedDiagnostics
156158
self.isManifestSandboxEnabled = isManifestSandboxEnabled
157159
self.delegate = delegate
160+
self.extraManifestFlags = extraManifestFlags
158161

159162
// Resolve symlinks since we can't use them in sandbox profiles.
160163
if let cacheDir = cacheDir {
@@ -690,6 +693,8 @@ public final class ManifestLoader: ManifestLoaderProtocol {
690693

691694
cmd += [manifestPath.pathString]
692695

696+
cmd += self.extraManifestFlags
697+
693698
try withTemporaryDirectory(removeTreeOnDeinit: true) { tmpDir in
694699
// Set path to compiled manifest executable.
695700
#if os(Windows)

0 commit comments

Comments
 (0)