
This attempts to re-land #22656. There are two changes from the original: I turned off wrapping completely when not sending output to a terminal. Previously I had defaulted to wrapping at and arbitrary 100 chars in that case, just to keep long messages from being too long, but that turns out the be a bad idea because there are tests that are relying on the specific form of the output. It's also pretty arbitrary, and mostly people sending output to a non-terminal will want unwrapped text. I found a better way to terminate ANSI color/bold sequences, so that they can be embedded within each other without needed quite as complex a dance with removing redundant sequences. As part of these changes, I removed the Logger.supportsColor setter so that the one source of truth for color support is in AnsiTerminal.supportsColor. * Turn on line wrapping again in usage and status messages, adds ANSI color to doctor and analysis messages. (#22656) This turns on text wrapping for usage messages and status messages. When on a terminal, wraps to the width of the terminal. When writing to a non-terminal, wrap lines at a default column width (currently defined to be 100 chars). If --no-wrap is specified, then no wrapping occurs. If --wrap-column is specified, wraps to that column (if --wrap is on). Adds ANSI color to the doctor and analysis output on terminals. This is in this PR with the wrapping, since wrapping needs to know how to count visible characters in the presence of ANSI sequences. (This is just one more step towards re-implementing all of Curses for Flutter. :-)) Will not print ANSI sequences when sent to a non-terminal, or of --no-color is specified. Fixes ANSI color and bold sequences so that they can be combined (bold, colored text), and a small bug in indentation calculation for wrapping. Since wrapping is now turned on, also removed many redundant '\n's in the code.
112 lines
4.5 KiB
Dart
112 lines
4.5 KiB
Dart
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:async';
|
|
|
|
import '../base/common.dart';
|
|
import '../build_info.dart';
|
|
import '../bundle.dart';
|
|
import '../runner/flutter_command.dart' show FlutterOptions, FlutterCommandResult;
|
|
import 'build.dart';
|
|
|
|
class BuildBundleCommand extends BuildSubCommand {
|
|
BuildBundleCommand({bool verboseHelp = false}) {
|
|
usesTargetOption();
|
|
usesFilesystemOptions(hide: !verboseHelp);
|
|
addBuildModeFlags();
|
|
argParser
|
|
..addFlag('precompiled', negatable: false)
|
|
// This option is still referenced by the iOS build scripts. We should
|
|
// remove it once we've updated those build scripts.
|
|
..addOption('asset-base', help: 'Ignored. Will be removed.', hide: !verboseHelp)
|
|
..addOption('manifest', defaultsTo: defaultManifestPath)
|
|
..addOption('private-key', defaultsTo: defaultPrivateKeyPath)
|
|
..addOption('depfile', defaultsTo: defaultDepfilePath)
|
|
..addOption('kernel-file', defaultsTo: defaultApplicationKernelPath)
|
|
..addOption('target-platform',
|
|
defaultsTo: 'android-arm',
|
|
allowed: <String>['android-arm', 'android-arm64', 'ios']
|
|
)
|
|
..addFlag('track-widget-creation',
|
|
hide: !verboseHelp,
|
|
help: 'Track widget creation locations. Requires Dart 2.0 functionality.',
|
|
)
|
|
..addOption('precompile',
|
|
hide: !verboseHelp,
|
|
help: 'Precompile functions specified in input file. This flag is only '
|
|
'allowed when using --dynamic. It takes a Dart compilation trace '
|
|
'file produced by the training run of the application. With this '
|
|
'flag, instead of using default Dart VM snapshot provided by the '
|
|
'engine, the application will use its own snapshot that includes '
|
|
'additional compiled functions.'
|
|
)
|
|
..addFlag('hotupdate',
|
|
hide: !verboseHelp,
|
|
help: 'Build differential snapshot based on the last state of the build '
|
|
'tree and any changes to the application source code since then. '
|
|
'This flag is only allowed when using --dynamic. With this flag, '
|
|
'a partial VM snapshot is generated that is loaded on top of the '
|
|
'original VM snapshot that contains precompiled code.'
|
|
)
|
|
..addMultiOption(FlutterOptions.kExtraFrontEndOptions,
|
|
splitCommas: true,
|
|
hide: true,
|
|
)
|
|
..addMultiOption(FlutterOptions.kExtraGenSnapshotOptions,
|
|
splitCommas: true,
|
|
hide: true,
|
|
)
|
|
..addOption('asset-dir', defaultsTo: getAssetBuildDirectory())
|
|
..addFlag('report-licensed-packages',
|
|
help: 'Whether to report the names of all the packages that are included '
|
|
'in the application\'s LICENSE file.',
|
|
defaultsTo: false);
|
|
usesPubOption();
|
|
}
|
|
|
|
@override
|
|
final String name = 'bundle';
|
|
|
|
@override
|
|
final String description = 'Build the Flutter assets directory from your app.';
|
|
|
|
@override
|
|
final String usageFooter = 'The Flutter assets directory contains your '
|
|
'application code and resources; they are used by some Flutter Android and'
|
|
' iOS runtimes.';
|
|
|
|
@override
|
|
Future<FlutterCommandResult> runCommand() async {
|
|
await super.runCommand();
|
|
|
|
final String targetPlatform = argResults['target-platform'];
|
|
final TargetPlatform platform = getTargetPlatformForName(targetPlatform);
|
|
if (platform == null)
|
|
throwToolExit('Unknown platform: $targetPlatform');
|
|
|
|
final BuildMode buildMode = getBuildMode();
|
|
|
|
await build(
|
|
platform: platform,
|
|
buildMode: buildMode,
|
|
mainPath: targetFile,
|
|
manifestPath: argResults['manifest'],
|
|
applicationKernelFilePath: argResults['kernel-file'],
|
|
depfilePath: argResults['depfile'],
|
|
privateKeyPath: argResults['private-key'],
|
|
assetDirPath: argResults['asset-dir'],
|
|
precompiledSnapshot: argResults['precompiled'],
|
|
reportLicensedPackages: argResults['report-licensed-packages'],
|
|
trackWidgetCreation: argResults['track-widget-creation'],
|
|
compilationTraceFilePath: argResults['precompile'],
|
|
buildHotUpdate: argResults['hotupdate'],
|
|
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
|
|
extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions],
|
|
fileSystemScheme: argResults['filesystem-scheme'],
|
|
fileSystemRoots: argResults['filesystem-root'],
|
|
);
|
|
return null;
|
|
}
|
|
}
|