Skip to content

Commit 8fac6d1

Browse files
authored
Fix argument length error for WriteSwiftDebugSettings (#3173)
Fix argument length errors by switching WriteSwiftDebugSettings to use a param file when needed. Previously when generating a very large project with 7000+ targets: ``` ERROR: /private/var/tmp/_bazel_jszumski/399f2da8a1f92cab020446a488e7bec6/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj_generated/generator/tools/rules/xcodeproj/bazel-project/BUILD:12:10: Generating bazel-project.xcodeproj Debug-swift_debug_settings.py failed: (Exit -1): universal_swift_debug_settings failed: error executing WriteSwiftDebugSettings command (from target @@rules_xcodeproj_generated//generator/tools/rules/xcodeproj/bazel-project:bazel-project) (cd /private/var/tmp/_bazel_jszumski/399f2da8a1f92cab020446a488e7bec6/rules_xcodeproj.noindex/build_output_base/execroot/register && \ exec env - \ bazel-out/darwin_x86_64-opt-exec-macos-x86_64-min13.0-applebin_macos-ST-5b758c1c0c80/bin/external/rules_xcodeproj/tools/generators/swift_debug_settings/universal_swift_debug_settings 1 {...lots of pairs here...} # Configuration: 794c86670c8dbf3648f6dfd018247dc9402b8c0a923a1790920ea9bf34028e6a # Execution platform: @@internal_platforms_do_not_use//host:host Action failed to execute: java.io.IOException: Cannot run program "/var/tmp/_bazel_jszumski/install/fd0e803cd377e5d6c999b9f309de8848/process-wrapper" (in directory "/private/var/tmp/_bazel_jszumski/399f2da8a1f92cab020446a488e7bec6/rules_xcodeproj.noindex/build_output_base/execroot/register"): error=7, Argument list too long ``` Signed-off-by: John Szumski <[email protected]>
1 parent 78856c9 commit 8fac6d1

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)