Skip to content

Commit 33ea7f8

Browse files
authored
Reduce xcodebuild noise #2 (flutter#14622)
* Revert "Revert "Reduce noise in xcodebuild stdout (flutter#14586)" (flutter#14605)" This reverts commit 8e2278b. * Specify the build config when cleaning
1 parent 4e106d7 commit 33ea7f8

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

packages/flutter_tools/bin/xcode_backend.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# found in the LICENSE file.
55

66
RunCommand() {
7-
echo "$*"
7+
if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then
8+
echo "$*"
9+
fi
810
"$@"
911
return $?
1012
}

packages/flutter_tools/lib/src/ios/mac.dart

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,41 @@ Future<XcodeBuildResult> buildXcodeProject({
277277
);
278278
}
279279

280+
final Status cleanStatus =
281+
logger.startProgress('Running Xcode clean...', expectSlowOperation: true);
282+
final RunResult cleanResult = await runAsync(
283+
<String>[
284+
'/usr/bin/env',
285+
'xcrun',
286+
'xcodebuild',
287+
'clean',
288+
'-configuration', configuration,
289+
],
290+
workingDirectory: app.appDirectory,
291+
);
292+
cleanStatus.stop();
293+
if (cleanResult.exitCode != 0) {
294+
throwToolExit('Xcode failed to clean\n${cleanResult.stderr}');
295+
}
296+
280297
final List<String> commands = <String>[
281298
'/usr/bin/env',
282299
'xcrun',
283300
'xcodebuild',
284-
'clean',
285301
'build',
286302
'-configuration', configuration,
287303
'ONLY_ACTIVE_ARCH=YES',
288304
];
289305

306+
if (logger.isVerbose) {
307+
// An environment variable to be passed to xcode_backend.sh determining
308+
// whether to echo back executed commands.
309+
commands.add('VERBOSE_SCRIPT_LOGGING=YES');
310+
} else {
311+
// This will print warnings and errors only.
312+
commands.add('-quiet');
313+
}
314+
290315
if (developmentTeam != null)
291316
commands.add('DEVELOPMENT_TEAM=$developmentTeam');
292317

@@ -318,27 +343,28 @@ Future<XcodeBuildResult> buildXcodeProject({
318343
);
319344
}
320345

321-
final Status status = logger.startProgress('Running Xcode build...', expectSlowOperation: true);
322-
final RunResult result = await runAsync(
346+
final Status buildStatus =
347+
logger.startProgress('Running Xcode build...', expectSlowOperation: true);
348+
final RunResult buildResult = await runAsync(
323349
commands,
324350
workingDirectory: app.appDirectory,
325351
allowReentrantFlutter: true
326352
);
327-
status.stop();
328-
if (result.exitCode != 0) {
353+
buildStatus.stop();
354+
if (buildResult.exitCode != 0) {
329355
printStatus('Failed to build iOS app');
330-
if (result.stderr.isNotEmpty) {
356+
if (buildResult.stderr.isNotEmpty) {
331357
printStatus('Error output from Xcode build:\n↳');
332-
printStatus(result.stderr, indent: 4);
358+
printStatus(buildResult.stderr, indent: 4);
333359
}
334-
if (result.stdout.isNotEmpty) {
360+
if (buildResult.stdout.isNotEmpty) {
335361
printStatus('Xcode\'s output:\n↳');
336-
printStatus(result.stdout, indent: 4);
362+
printStatus(buildResult.stdout, indent: 4);
337363
}
338364
return new XcodeBuildResult(
339365
success: false,
340-
stdout: result.stdout,
341-
stderr: result.stderr,
366+
stdout: buildResult.stdout,
367+
stderr: buildResult.stderr,
342368
xcodeBuildExecution: new XcodeBuildExecution(
343369
commands,
344370
app.appDirectory,
@@ -348,7 +374,7 @@ Future<XcodeBuildResult> buildXcodeProject({
348374
} else {
349375
// Look for 'clean build/<configuration>-<sdk>/Runner.app'.
350376
final RegExp regexp = new RegExp(r' clean (.*\.app)$', multiLine: true);
351-
final Match match = regexp.firstMatch(result.stdout);
377+
final Match match = regexp.firstMatch(buildResult.stdout);
352378
String outputDir;
353379
if (match != null) {
354380
final String actualOutputDir = match.group(1).replaceAll('\\ ', ' ');

0 commit comments

Comments
 (0)