From 74a1b9b33ed2c76f9808eeb70feec17aefedff97 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 9 Apr 2020 09:00:44 -0700 Subject: [PATCH] [flutter_tools] make verbose macOS builds actually verbose (#54320) --- .../lib/src/commands/build_macos.dart | 1 + .../lib/src/macos/build_macos.dart | 5 +++++ .../lib/src/macos/macos_device.dart | 1 + .../hermetic/build_macos_test.dart | 21 ++++++++++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/commands/build_macos.dart b/packages/flutter_tools/lib/src/commands/build_macos.dart index 8830260e75..f6aaf9c269 100644 --- a/packages/flutter_tools/lib/src/commands/build_macos.dart +++ b/packages/flutter_tools/lib/src/commands/build_macos.dart @@ -54,6 +54,7 @@ class BuildMacosCommand extends BuildSubCommand { flutterProject: flutterProject, buildInfo: buildInfo, targetOverride: targetFile, + verboseLogging: globals.logger.isVerbose, ); return FlutterCommandResult.success(); } diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index 6f7cb3e566..83c98497ac 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:meta/meta.dart'; + import '../base/common.dart'; import '../base/file_system.dart'; import '../base/logger.dart'; @@ -18,6 +20,7 @@ Future buildMacOS({ FlutterProject flutterProject, BuildInfo buildInfo, String targetOverride, + @required bool verboseLogging, }) async { if (!flutterProject.macos.xcodeWorkspace.existsSync()) { throwToolExit('No macOS desktop project configured. ' @@ -83,6 +86,8 @@ Future buildMacOS({ '-derivedDataPath', flutterBuildDir.absolute.path, 'OBJROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}', 'SYMROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}', + if (verboseLogging) + 'VERBOSE_SCRIPT_LOGGING=YES', 'COMPILER_INDEX_STORE_ENABLE=NO', ...environmentVariablesAsXcodeBuildSettings(globals.platform) ], trace: true); diff --git a/packages/flutter_tools/lib/src/macos/macos_device.dart b/packages/flutter_tools/lib/src/macos/macos_device.dart index 8f790812b2..ac22442141 100644 --- a/packages/flutter_tools/lib/src/macos/macos_device.dart +++ b/packages/flutter_tools/lib/src/macos/macos_device.dart @@ -44,6 +44,7 @@ class MacOSDevice extends DesktopDevice { flutterProject: FlutterProject.current(), buildInfo: buildInfo, targetOverride: mainPath, + verboseLogging: globals.logger.isVerbose, ); } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart index 26c763da9f..86b3de2977 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart @@ -69,7 +69,7 @@ void main() { // Creates a FakeCommand for the xcodebuild call to build the app // in the given configuration. - FakeCommand setUpMockXcodeBuildHandler(String configuration) { + FakeCommand setUpMockXcodeBuildHandler(String configuration, { bool verbose = false }) { final FlutterProject flutterProject = FlutterProject.fromDirectory(fileSystem.currentDirectory); final Directory flutterBuildDir = fileSystem.directory(getMacOSBuildDirectory()); return FakeCommand( @@ -83,6 +83,8 @@ void main() { '-derivedDataPath', flutterBuildDir.absolute.path, 'OBJROOT=${fileSystem.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}', 'SYMROOT=${fileSystem.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}', + if (verbose) + 'VERBOSE_SCRIPT_LOGGING=YES', 'COMPILER_INDEX_STORE_ENABLE=NO', ], stdout: 'STDOUT STUFF', @@ -159,6 +161,23 @@ void main() { FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true), }); + testUsingContext('macOS build invokes xcode build (debug) with verbosity', () async { + final BuildCommand command = BuildCommand(); + createMinimalMockProjectFiles(); + + await createTestCommandRunner(command).run( + const ['build', 'macos', '--debug', '-v'] + ); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => FakeProcessManager.list([ + setUpMockXcodeBuildHandler('Debug', verbose: true) + ]), + Platform: () => macosPlatform, + FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true), + }); + + testUsingContext('macOS build invokes xcode build (profile)', () async { final BuildCommand command = BuildCommand(); createMinimalMockProjectFiles();