Skip to content

Commit 73f2ec3

Browse files
committed
Fix argument length errors by switching WriteSwiftDebugSettings to always use a param file
Signed-off-by: John Szumski <[email protected]>
1 parent 9c117ee commit 73f2ec3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

tools/generators/swift_debug_settings/src/SwiftDebugSettings.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Darwin
2+
import Foundation
23
import ToolCommon
34

45
@main
@@ -12,16 +13,32 @@ struct SwiftDebugSettings {
1213

1314
do {
1415
// First argument is executable name
15-
var rawArguments = CommandLine.arguments.dropFirst()
16+
let rawArguments = CommandLine.arguments.dropFirst()
17+
18+
// Check for a params file
19+
var arguments: ArraySlice<String>
20+
if let arg = rawArguments.first, rawArguments.count == 1,
21+
arg.starts(with: "@")
22+
{
23+
arguments = try await parseParamsFile(String(arg.dropFirst()))
24+
} else {
25+
arguments = ArraySlice(rawArguments)
26+
}
1627

17-
if try rawArguments.consumeArg("colorize", as: Bool.self) {
28+
if try arguments.consumeArg("colorize", as: Bool.self) {
1829
logger.enableColors()
1930
}
2031

21-
try await Generator().generate(rawArguments: rawArguments)
32+
try await Generator().generate(rawArguments: arguments)
2233
} catch {
2334
logger.logError(error.localizedDescription)
2435
Darwin.exit(1)
2536
}
2637
}
38+
39+
private static func parseParamsFile(
40+
_ path: String
41+
) async throws -> ArraySlice<String> {
42+
return try await ArraySlice(URL(fileURLWithPath: path).allLines.collect())
43+
}
2744
}

xcodeproj/internal/pbxproj_partials.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,8 @@ def _write_swift_debug_settings(
10491049
)
10501050

10511051
args = actions.args()
1052+
args.use_param_file("@%s")
1053+
args.set_param_file_format(format = "multiline")
10521054

10531055
# colorize
10541056
args.add(TRUE_ARG if colorize else FALSE_ARG)

0 commit comments

Comments
 (0)