Reduce xcodebuild noise #2 (#14622)

* Revert "Revert "Reduce noise in xcodebuild stdout (#14586)" (#14605)"

This reverts commit 8e2278bd8d.

* Specify the build config when cleaning
This commit is contained in:
xster 2018-02-11 05:54:14 -08:00 committed by GitHub
parent 4e106d7e47
commit 33ea7f84a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 13 deletions

View file

@ -4,7 +4,9 @@
# found in the LICENSE file.
RunCommand() {
echo "$*"
if [[ -n "$VERBOSE_SCRIPT_LOGGING" ]]; then
echo "$*"
fi
"$@"
return $?
}

View file

@ -277,16 +277,41 @@ Future<XcodeBuildResult> buildXcodeProject({
);
}
final Status cleanStatus =
logger.startProgress('Running Xcode clean...', expectSlowOperation: true);
final RunResult cleanResult = await runAsync(
<String>[
'/usr/bin/env',
'xcrun',
'xcodebuild',
'clean',
'-configuration', configuration,
],
workingDirectory: app.appDirectory,
);
cleanStatus.stop();
if (cleanResult.exitCode != 0) {
throwToolExit('Xcode failed to clean\n${cleanResult.stderr}');
}
final List<String> commands = <String>[
'/usr/bin/env',
'xcrun',
'xcodebuild',
'clean',
'build',
'-configuration', configuration,
'ONLY_ACTIVE_ARCH=YES',
];
if (logger.isVerbose) {
// An environment variable to be passed to xcode_backend.sh determining
// whether to echo back executed commands.
commands.add('VERBOSE_SCRIPT_LOGGING=YES');
} else {
// This will print warnings and errors only.
commands.add('-quiet');
}
if (developmentTeam != null)
commands.add('DEVELOPMENT_TEAM=$developmentTeam');
@ -318,27 +343,28 @@ Future<XcodeBuildResult> buildXcodeProject({
);
}
final Status status = logger.startProgress('Running Xcode build...', expectSlowOperation: true);
final RunResult result = await runAsync(
final Status buildStatus =
logger.startProgress('Running Xcode build...', expectSlowOperation: true);
final RunResult buildResult = await runAsync(
commands,
workingDirectory: app.appDirectory,
allowReentrantFlutter: true
);
status.stop();
if (result.exitCode != 0) {
buildStatus.stop();
if (buildResult.exitCode != 0) {
printStatus('Failed to build iOS app');
if (result.stderr.isNotEmpty) {
if (buildResult.stderr.isNotEmpty) {
printStatus('Error output from Xcode build:\n');
printStatus(result.stderr, indent: 4);
printStatus(buildResult.stderr, indent: 4);
}
if (result.stdout.isNotEmpty) {
if (buildResult.stdout.isNotEmpty) {
printStatus('Xcode\'s output:\n');
printStatus(result.stdout, indent: 4);
printStatus(buildResult.stdout, indent: 4);
}
return new XcodeBuildResult(
success: false,
stdout: result.stdout,
stderr: result.stderr,
stdout: buildResult.stdout,
stderr: buildResult.stderr,
xcodeBuildExecution: new XcodeBuildExecution(
commands,
app.appDirectory,
@ -348,7 +374,7 @@ Future<XcodeBuildResult> buildXcodeProject({
} else {
// Look for 'clean build/<configuration>-<sdk>/Runner.app'.
final RegExp regexp = new RegExp(r' clean (.*\.app)$', multiLine: true);
final Match match = regexp.firstMatch(result.stdout);
final Match match = regexp.firstMatch(buildResult.stdout);
String outputDir;
if (match != null) {
final String actualOutputDir = match.group(1).replaceAll('\\ ', ' ');