Remove Toolchain and extend ToolConfiguration to locate host tools such as sky_snapshot (#3870)
Host tools can be found in the artifact cache directory for the host platform. If a developer wants to use a local engine build instead, then provide an --engine-build flag that selects the specific engine build variant.
This commit is contained in:
parent
45db865079
commit
0f53f7966b
@ -15,7 +15,6 @@ import '../device.dart';
|
|||||||
import '../flx.dart' as flx;
|
import '../flx.dart' as flx;
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../service_protocol.dart';
|
import '../service_protocol.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
import 'adb.dart';
|
import 'adb.dart';
|
||||||
import 'android.dart';
|
import 'android.dart';
|
||||||
|
|
||||||
@ -322,8 +321,7 @@ class AndroidDevice extends Device {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LaunchResult> startApp(
|
Future<LaunchResult> startApp(
|
||||||
ApplicationPackage package,
|
ApplicationPackage package, {
|
||||||
Toolchain toolchain, {
|
|
||||||
String mainPath,
|
String mainPath,
|
||||||
String route,
|
String route,
|
||||||
DebuggingOptions debuggingOptions,
|
DebuggingOptions debuggingOptions,
|
||||||
@ -333,7 +331,6 @@ class AndroidDevice extends Device {
|
|||||||
return new LaunchResult.failed();
|
return new LaunchResult.failed();
|
||||||
|
|
||||||
String localBundlePath = await flx.buildFlx(
|
String localBundlePath = await flx.buildFlx(
|
||||||
toolchain,
|
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
includeRobotoFonts: false
|
includeRobotoFonts: false
|
||||||
);
|
);
|
||||||
|
@ -17,7 +17,6 @@ import '../flx.dart' as flx;
|
|||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
import '../services.dart';
|
import '../services.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
import 'build_aot.dart';
|
import 'build_aot.dart';
|
||||||
import 'run.dart';
|
import 'run.dart';
|
||||||
|
|
||||||
@ -242,7 +241,6 @@ class BuildApkCommand extends FlutterCommand {
|
|||||||
return await buildAndroid(
|
return await buildAndroid(
|
||||||
TargetPlatform.android_arm,
|
TargetPlatform.android_arm,
|
||||||
mode,
|
mode,
|
||||||
toolchain: toolchain,
|
|
||||||
force: true,
|
force: true,
|
||||||
manifest: argResults['manifest'],
|
manifest: argResults['manifest'],
|
||||||
resources: argResults['resources'],
|
resources: argResults['resources'],
|
||||||
@ -457,7 +455,6 @@ bool _needsRebuild(String apkPath, String manifest) {
|
|||||||
Future<int> buildAndroid(
|
Future<int> buildAndroid(
|
||||||
TargetPlatform platform,
|
TargetPlatform platform,
|
||||||
BuildMode buildMode, {
|
BuildMode buildMode, {
|
||||||
Toolchain toolchain,
|
|
||||||
bool force: false,
|
bool force: false,
|
||||||
String manifest: _kDefaultAndroidManifestPath,
|
String manifest: _kDefaultAndroidManifestPath,
|
||||||
String resources,
|
String resources,
|
||||||
@ -515,7 +512,6 @@ Future<int> buildAndroid(
|
|||||||
} else {
|
} else {
|
||||||
// Build the FLX.
|
// Build the FLX.
|
||||||
flxPath = await flx.buildFlx(
|
flxPath = await flx.buildFlx(
|
||||||
toolchain,
|
|
||||||
mainPath: findMainDartFile(target),
|
mainPath: findMainDartFile(target),
|
||||||
precompiledSnapshot: isAotBuildMode(buildMode),
|
precompiledSnapshot: isAotBuildMode(buildMode),
|
||||||
includeRobotoFonts: false);
|
includeRobotoFonts: false);
|
||||||
@ -556,8 +552,7 @@ Future<int> buildAndroid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> buildApk(
|
Future<int> buildApk(
|
||||||
TargetPlatform platform,
|
TargetPlatform platform, {
|
||||||
Toolchain toolchain, {
|
|
||||||
String target,
|
String target,
|
||||||
BuildMode buildMode: BuildMode.debug
|
BuildMode buildMode: BuildMode.debug
|
||||||
}) async {
|
}) async {
|
||||||
@ -569,7 +564,6 @@ Future<int> buildApk(
|
|||||||
int result = await buildAndroid(
|
int result = await buildAndroid(
|
||||||
platform,
|
platform,
|
||||||
buildMode,
|
buildMode,
|
||||||
toolchain: toolchain,
|
|
||||||
force: false,
|
force: false,
|
||||||
target: target
|
target: target
|
||||||
);
|
);
|
||||||
|
@ -7,7 +7,6 @@ import 'dart:async';
|
|||||||
import '../flx.dart';
|
import '../flx.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
|
|
||||||
class BuildFlxCommand extends FlutterCommand {
|
class BuildFlxCommand extends FlutterCommand {
|
||||||
BuildFlxCommand() {
|
BuildFlxCommand() {
|
||||||
@ -16,7 +15,6 @@ class BuildFlxCommand extends FlutterCommand {
|
|||||||
// This option is still referenced by the iOS build scripts. We should
|
// This option is still referenced by the iOS build scripts. We should
|
||||||
// remove it once we've updated those build scripts.
|
// remove it once we've updated those build scripts.
|
||||||
argParser.addOption('asset-base', help: 'Ignored. Will be removed.', hide: true);
|
argParser.addOption('asset-base', help: 'Ignored. Will be removed.', hide: true);
|
||||||
argParser.addOption('compiler');
|
|
||||||
argParser.addOption('manifest', defaultsTo: defaultManifestPath);
|
argParser.addOption('manifest', defaultsTo: defaultManifestPath);
|
||||||
argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
|
argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
|
||||||
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
|
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
|
||||||
@ -39,14 +37,9 @@ class BuildFlxCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
String compilerPath = argResults['compiler'];
|
|
||||||
if (compilerPath != null)
|
|
||||||
toolchain = new Toolchain(compiler: new SnapshotCompiler(compilerPath));
|
|
||||||
|
|
||||||
String outputPath = argResults['output-file'];
|
String outputPath = argResults['output-file'];
|
||||||
|
|
||||||
return await build(
|
return await build(
|
||||||
toolchain,
|
|
||||||
mainPath: argResults['target'],
|
mainPath: argResults['target'],
|
||||||
manifestPath: argResults['manifest'],
|
manifestPath: argResults['manifest'],
|
||||||
outputPath: outputPath,
|
outputPath: outputPath,
|
||||||
|
@ -264,7 +264,6 @@ class AppDomain extends Domain {
|
|||||||
try {
|
try {
|
||||||
int result = await startApp(
|
int result = await startApp(
|
||||||
device,
|
device,
|
||||||
command.toolchain,
|
|
||||||
stop: true,
|
stop: true,
|
||||||
target: args['target'],
|
target: args['target'],
|
||||||
route: args['route']
|
route: args['route']
|
||||||
|
@ -248,7 +248,6 @@ Future<int> startApp(DriveCommand command, BuildMode buildMode) async {
|
|||||||
printTrace('Building an APK.');
|
printTrace('Building an APK.');
|
||||||
int result = await build_apk.buildApk(
|
int result = await build_apk.buildApk(
|
||||||
command.device.platform,
|
command.device.platform,
|
||||||
command.toolchain,
|
|
||||||
target: command.target
|
target: command.target
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -267,7 +266,6 @@ Future<int> startApp(DriveCommand command, BuildMode buildMode) async {
|
|||||||
printTrace('Starting application.');
|
printTrace('Starting application.');
|
||||||
LaunchResult result = await command.device.startApp(
|
LaunchResult result = await command.device.startApp(
|
||||||
package,
|
package,
|
||||||
command.toolchain,
|
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
route: command.route,
|
route: command.route,
|
||||||
debuggingOptions: new DebuggingOptions.enabled(
|
debuggingOptions: new DebuggingOptions.enabled(
|
||||||
|
@ -60,7 +60,6 @@ class ListenCommand extends RunCommandBase {
|
|||||||
|
|
||||||
result = await startApp(
|
result = await startApp(
|
||||||
deviceForCommand,
|
deviceForCommand,
|
||||||
toolchain,
|
|
||||||
target: target,
|
target: target,
|
||||||
install: firstTime,
|
install: firstTime,
|
||||||
stop: true,
|
stop: true,
|
||||||
|
@ -9,6 +9,7 @@ import 'package:path/path.dart' as path;
|
|||||||
|
|
||||||
import '../android/android_device.dart';
|
import '../android/android_device.dart';
|
||||||
import '../application_package.dart';
|
import '../application_package.dart';
|
||||||
|
import '../flx.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ class RefreshCommand extends FlutterCommand {
|
|||||||
try {
|
try {
|
||||||
String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin');
|
String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin');
|
||||||
|
|
||||||
int result = await toolchain.compiler.createSnapshot(
|
int result = await createSnapshot(
|
||||||
mainPath: argResults['target'],
|
mainPath: argResults['target'],
|
||||||
snapshotPath: snapshotPath
|
snapshotPath: snapshotPath
|
||||||
);
|
);
|
||||||
|
@ -15,7 +15,6 @@ import '../build_configuration.dart';
|
|||||||
import '../device.dart';
|
import '../device.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
import 'build_apk.dart';
|
import 'build_apk.dart';
|
||||||
import 'install.dart';
|
import 'install.dart';
|
||||||
|
|
||||||
@ -118,7 +117,6 @@ class RunCommand extends RunCommandBase {
|
|||||||
if (argResults['resident']) {
|
if (argResults['resident']) {
|
||||||
_RunAndStayResident runner = new _RunAndStayResident(
|
_RunAndStayResident runner = new _RunAndStayResident(
|
||||||
deviceForCommand,
|
deviceForCommand,
|
||||||
toolchain,
|
|
||||||
target: target,
|
target: target,
|
||||||
debuggingOptions: options,
|
debuggingOptions: options,
|
||||||
traceStartup: traceStartup,
|
traceStartup: traceStartup,
|
||||||
@ -129,7 +127,6 @@ class RunCommand extends RunCommandBase {
|
|||||||
} else {
|
} else {
|
||||||
return startApp(
|
return startApp(
|
||||||
deviceForCommand,
|
deviceForCommand,
|
||||||
toolchain,
|
|
||||||
target: target,
|
target: target,
|
||||||
stop: argResults['full-restart'],
|
stop: argResults['full-restart'],
|
||||||
install: true,
|
install: true,
|
||||||
@ -143,8 +140,7 @@ class RunCommand extends RunCommandBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<int> startApp(
|
Future<int> startApp(
|
||||||
Device device,
|
Device device, {
|
||||||
Toolchain toolchain, {
|
|
||||||
String target,
|
String target,
|
||||||
bool stop: true,
|
bool stop: true,
|
||||||
bool install: true,
|
bool install: true,
|
||||||
@ -179,7 +175,6 @@ Future<int> startApp(
|
|||||||
|
|
||||||
int result = await buildApk(
|
int result = await buildApk(
|
||||||
device.platform,
|
device.platform,
|
||||||
toolchain,
|
|
||||||
target: target,
|
target: target,
|
||||||
buildMode: buildMode
|
buildMode: buildMode
|
||||||
);
|
);
|
||||||
@ -220,7 +215,6 @@ Future<int> startApp(
|
|||||||
|
|
||||||
LaunchResult result = await device.startApp(
|
LaunchResult result = await device.startApp(
|
||||||
package,
|
package,
|
||||||
toolchain,
|
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
route: route,
|
route: route,
|
||||||
debuggingOptions: debuggingOptions,
|
debuggingOptions: debuggingOptions,
|
||||||
@ -349,8 +343,7 @@ String _getDisplayPath(String fullPath) {
|
|||||||
|
|
||||||
class _RunAndStayResident {
|
class _RunAndStayResident {
|
||||||
_RunAndStayResident(
|
_RunAndStayResident(
|
||||||
this.device,
|
this.device, {
|
||||||
this.toolchain, {
|
|
||||||
this.target,
|
this.target,
|
||||||
this.debuggingOptions,
|
this.debuggingOptions,
|
||||||
this.traceStartup : false,
|
this.traceStartup : false,
|
||||||
@ -358,7 +351,6 @@ class _RunAndStayResident {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final Device device;
|
final Device device;
|
||||||
final Toolchain toolchain;
|
|
||||||
final String target;
|
final String target;
|
||||||
final DebuggingOptions debuggingOptions;
|
final DebuggingOptions debuggingOptions;
|
||||||
final bool traceStartup;
|
final bool traceStartup;
|
||||||
@ -399,7 +391,6 @@ class _RunAndStayResident {
|
|||||||
|
|
||||||
int result = await buildApk(
|
int result = await buildApk(
|
||||||
device.platform,
|
device.platform,
|
||||||
toolchain,
|
|
||||||
target: target,
|
target: target,
|
||||||
buildMode: buildMode
|
buildMode: buildMode
|
||||||
);
|
);
|
||||||
@ -438,7 +429,6 @@ class _RunAndStayResident {
|
|||||||
|
|
||||||
LaunchResult result = await device.startApp(
|
LaunchResult result = await device.startApp(
|
||||||
package,
|
package,
|
||||||
toolchain,
|
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
debuggingOptions: debuggingOptions,
|
debuggingOptions: debuggingOptions,
|
||||||
platformArgs: platformArgs
|
platformArgs: platformArgs
|
||||||
|
@ -167,7 +167,6 @@ class RunMojoCommand extends FlutterCommand {
|
|||||||
String mainPath = findMainDartFile(argResults['target']);
|
String mainPath = findMainDartFile(argResults['target']);
|
||||||
|
|
||||||
int result = await flx.build(
|
int result = await flx.build(
|
||||||
toolchain,
|
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
outputPath: targetApp
|
outputPath: targetApp
|
||||||
);
|
);
|
||||||
|
@ -18,7 +18,6 @@ import 'build_configuration.dart';
|
|||||||
import 'globals.dart';
|
import 'globals.dart';
|
||||||
import 'ios/devices.dart';
|
import 'ios/devices.dart';
|
||||||
import 'ios/simulators.dart';
|
import 'ios/simulators.dart';
|
||||||
import 'toolchain.dart';
|
|
||||||
|
|
||||||
/// A class to get all available devices.
|
/// A class to get all available devices.
|
||||||
class DeviceManager {
|
class DeviceManager {
|
||||||
@ -181,8 +180,7 @@ abstract class Device {
|
|||||||
/// [platformArgs] allows callers to pass platform-specific arguments to the
|
/// [platformArgs] allows callers to pass platform-specific arguments to the
|
||||||
/// start call.
|
/// start call.
|
||||||
Future<LaunchResult> startApp(
|
Future<LaunchResult> startApp(
|
||||||
ApplicationPackage package,
|
ApplicationPackage package, {
|
||||||
Toolchain toolchain, {
|
|
||||||
String mainPath,
|
String mainPath,
|
||||||
String route,
|
String route,
|
||||||
DebuggingOptions debuggingOptions,
|
DebuggingOptions debuggingOptions,
|
||||||
|
@ -14,6 +14,7 @@ import 'package:yaml/yaml.dart';
|
|||||||
|
|
||||||
import 'artifacts.dart';
|
import 'artifacts.dart';
|
||||||
import 'base/file_system.dart' show ensureDirectoryExists;
|
import 'base/file_system.dart' show ensureDirectoryExists;
|
||||||
|
import 'base/process.dart';
|
||||||
import 'globals.dart';
|
import 'globals.dart';
|
||||||
import 'package_map.dart';
|
import 'package_map.dart';
|
||||||
import 'toolchain.dart';
|
import 'toolchain.dart';
|
||||||
@ -33,6 +34,28 @@ const String _kSnapshotKey = 'snapshot_blob.bin';
|
|||||||
const String _kFontSetMaterial = 'material';
|
const String _kFontSetMaterial = 'material';
|
||||||
const String _kFontSetRoboto = 'roboto';
|
const String _kFontSetRoboto = 'roboto';
|
||||||
|
|
||||||
|
Future<int> createSnapshot({
|
||||||
|
String mainPath,
|
||||||
|
String snapshotPath,
|
||||||
|
String depfilePath,
|
||||||
|
String buildOutputPath
|
||||||
|
}) {
|
||||||
|
assert(mainPath != null);
|
||||||
|
assert(snapshotPath != null);
|
||||||
|
|
||||||
|
final List<String> args = <String>[
|
||||||
|
tools.getHostToolPath(HostTool.SkySnapshot),
|
||||||
|
mainPath,
|
||||||
|
'--packages=${PackageMap.instance.packagesPath}',
|
||||||
|
'--snapshot=$snapshotPath'
|
||||||
|
];
|
||||||
|
if (depfilePath != null)
|
||||||
|
args.add('--depfile=$depfilePath');
|
||||||
|
if (buildOutputPath != null)
|
||||||
|
args.add('--build-output=$buildOutputPath');
|
||||||
|
return runCommandAndStreamOutput(args);
|
||||||
|
}
|
||||||
|
|
||||||
class _Asset {
|
class _Asset {
|
||||||
_Asset({ this.base, String assetEntry, this.relativePath, this.source }) {
|
_Asset({ this.base, String assetEntry, this.relativePath, this.source }) {
|
||||||
this._assetEntry = assetEntry;
|
this._assetEntry = assetEntry;
|
||||||
@ -259,8 +282,7 @@ ZipEntry _createFontManifest(Map<String, dynamic> manifestDescriptor,
|
|||||||
/// Build the flx in the build/ directory and return `localBundlePath` on success.
|
/// Build the flx in the build/ directory and return `localBundlePath` on success.
|
||||||
///
|
///
|
||||||
/// Return `null` on failure.
|
/// Return `null` on failure.
|
||||||
Future<String> buildFlx(
|
Future<String> buildFlx({
|
||||||
Toolchain toolchain, {
|
|
||||||
String mainPath: defaultMainPath,
|
String mainPath: defaultMainPath,
|
||||||
bool precompiledSnapshot: false,
|
bool precompiledSnapshot: false,
|
||||||
bool includeRobotoFonts: true
|
bool includeRobotoFonts: true
|
||||||
@ -269,7 +291,6 @@ Future<String> buildFlx(
|
|||||||
String localBundlePath = path.join('build', 'app.flx');
|
String localBundlePath = path.join('build', 'app.flx');
|
||||||
String localSnapshotPath = path.join('build', 'snapshot_blob.bin');
|
String localSnapshotPath = path.join('build', 'snapshot_blob.bin');
|
||||||
result = await build(
|
result = await build(
|
||||||
toolchain,
|
|
||||||
snapshotPath: localSnapshotPath,
|
snapshotPath: localSnapshotPath,
|
||||||
outputPath: localBundlePath,
|
outputPath: localBundlePath,
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
@ -292,8 +313,7 @@ class DirectoryResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> build(
|
Future<int> build({
|
||||||
Toolchain toolchain, {
|
|
||||||
String mainPath: defaultMainPath,
|
String mainPath: defaultMainPath,
|
||||||
String manifestPath: defaultManifestPath,
|
String manifestPath: defaultManifestPath,
|
||||||
String outputPath: defaultFlxOutputPath,
|
String outputPath: defaultFlxOutputPath,
|
||||||
@ -321,7 +341,7 @@ Future<int> build(
|
|||||||
|
|
||||||
// In a precompiled snapshot, the instruction buffer contains script
|
// In a precompiled snapshot, the instruction buffer contains script
|
||||||
// content equivalents
|
// content equivalents
|
||||||
int result = await toolchain.compiler.createSnapshot(
|
int result = await createSnapshot(
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
snapshotPath: snapshotPath,
|
snapshotPath: snapshotPath,
|
||||||
depfilePath: depfilePath
|
depfilePath: depfilePath
|
||||||
|
@ -14,7 +14,6 @@ import '../base/process.dart';
|
|||||||
import '../build_configuration.dart';
|
import '../build_configuration.dart';
|
||||||
import '../device.dart';
|
import '../device.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
import 'mac.dart';
|
import 'mac.dart';
|
||||||
|
|
||||||
const String _ideviceinstallerInstructions =
|
const String _ideviceinstallerInstructions =
|
||||||
@ -154,8 +153,7 @@ class IOSDevice extends Device {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LaunchResult> startApp(
|
Future<LaunchResult> startApp(
|
||||||
ApplicationPackage app,
|
ApplicationPackage app, {
|
||||||
Toolchain toolchain, {
|
|
||||||
String mainPath,
|
String mainPath,
|
||||||
String route,
|
String route,
|
||||||
DebuggingOptions debuggingOptions,
|
DebuggingOptions debuggingOptions,
|
||||||
|
@ -16,7 +16,6 @@ import '../device.dart';
|
|||||||
import '../flx.dart' as flx;
|
import '../flx.dart' as flx;
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../service_protocol.dart';
|
import '../service_protocol.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
import 'mac.dart';
|
import 'mac.dart';
|
||||||
|
|
||||||
const String _xcrunPath = '/usr/bin/xcrun';
|
const String _xcrunPath = '/usr/bin/xcrun';
|
||||||
@ -437,8 +436,7 @@ class IOSSimulator extends Device {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LaunchResult> startApp(
|
Future<LaunchResult> startApp(
|
||||||
ApplicationPackage app,
|
ApplicationPackage app, {
|
||||||
Toolchain toolchain, {
|
|
||||||
String mainPath,
|
String mainPath,
|
||||||
String route,
|
String route,
|
||||||
DebuggingOptions debuggingOptions,
|
DebuggingOptions debuggingOptions,
|
||||||
@ -446,7 +444,7 @@ class IOSSimulator extends Device {
|
|||||||
}) async {
|
}) async {
|
||||||
printTrace('Building ${app.name} for $id.');
|
printTrace('Building ${app.name} for $id.');
|
||||||
|
|
||||||
if (!(await _setupUpdatedApplicationBundle(app, toolchain)))
|
if (!(await _setupUpdatedApplicationBundle(app)))
|
||||||
return new LaunchResult.failed();
|
return new LaunchResult.failed();
|
||||||
|
|
||||||
ServiceProtocolDiscovery observatoryDiscovery;
|
ServiceProtocolDiscovery observatoryDiscovery;
|
||||||
@ -524,8 +522,8 @@ class IOSSimulator extends Device {
|
|||||||
return isInstalled && isRunning;
|
return isInstalled && isRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _setupUpdatedApplicationBundle(ApplicationPackage app, Toolchain toolchain) async {
|
Future<bool> _setupUpdatedApplicationBundle(ApplicationPackage app) async {
|
||||||
bool sideloadResult = await _sideloadUpdatedAssetsForInstalledApplicationBundle(app, toolchain);
|
bool sideloadResult = await _sideloadUpdatedAssetsForInstalledApplicationBundle(app);
|
||||||
|
|
||||||
if (!sideloadResult)
|
if (!sideloadResult)
|
||||||
return false;
|
return false;
|
||||||
@ -558,8 +556,8 @@ class IOSSimulator extends Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _sideloadUpdatedAssetsForInstalledApplicationBundle(
|
Future<bool> _sideloadUpdatedAssetsForInstalledApplicationBundle(
|
||||||
ApplicationPackage app, Toolchain toolchain) async {
|
ApplicationPackage app) async {
|
||||||
return (await flx.build(toolchain, precompiledSnapshot: true)) == 0;
|
return (await flx.build(precompiledSnapshot: true)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -14,7 +14,6 @@ import '../device.dart';
|
|||||||
import '../flx.dart' as flx;
|
import '../flx.dart' as flx;
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../package_map.dart';
|
import '../package_map.dart';
|
||||||
import '../toolchain.dart';
|
|
||||||
import '../usage.dart';
|
import '../usage.dart';
|
||||||
import 'flutter_command_runner.dart';
|
import 'flutter_command_runner.dart';
|
||||||
|
|
||||||
@ -86,10 +85,6 @@ abstract class FlutterCommand extends Command {
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setupToolchain() {
|
|
||||||
toolchain ??= Toolchain.forConfigs(buildConfigurations);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _setupApplicationPackages() {
|
void _setupApplicationPackages() {
|
||||||
applicationPackages ??= new ApplicationPackageStore();
|
applicationPackages ??= new ApplicationPackageStore();
|
||||||
}
|
}
|
||||||
@ -166,7 +161,6 @@ abstract class FlutterCommand extends Command {
|
|||||||
if (flutterUsage.isFirstRun)
|
if (flutterUsage.isFirstRun)
|
||||||
flutterUsage.printUsage();
|
flutterUsage.printUsage();
|
||||||
|
|
||||||
_setupToolchain();
|
|
||||||
_setupApplicationPackages();
|
_setupApplicationPackages();
|
||||||
|
|
||||||
String commandPath = usagePath;
|
String commandPath = usagePath;
|
||||||
@ -215,5 +209,4 @@ abstract class FlutterCommand extends Command {
|
|||||||
Device get deviceForCommand => _deviceForCommand;
|
Device get deviceForCommand => _deviceForCommand;
|
||||||
|
|
||||||
ApplicationPackageStore applicationPackages;
|
ApplicationPackageStore applicationPackages;
|
||||||
Toolchain toolchain;
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ class FlutterCommandRunner extends CommandRunner {
|
|||||||
help:
|
help:
|
||||||
'Set this if you are building Flutter locally and want to use the release build products.\n'
|
'Set this if you are building Flutter locally and want to use the release build products.\n'
|
||||||
'The --engine-release option is not compatible with the listen command on iOS devices and simulators.');
|
'The --engine-release option is not compatible with the listen command on iOS devices and simulators.');
|
||||||
|
|
||||||
argParser.addOption('engine-src-path',
|
argParser.addOption('engine-src-path',
|
||||||
hide: !verboseHelp,
|
hide: !verboseHelp,
|
||||||
help:
|
help:
|
||||||
@ -81,6 +82,13 @@ class FlutterCommandRunner extends CommandRunner {
|
|||||||
'dependency_overrides for $kFlutterEnginePackageName, if any, or, failing that, tries to guess at the location\n'
|
'dependency_overrides for $kFlutterEnginePackageName, if any, or, failing that, tries to guess at the location\n'
|
||||||
'based on the value of the --flutter-root option.');
|
'based on the value of the --flutter-root option.');
|
||||||
|
|
||||||
|
argParser.addOption('local-engine',
|
||||||
|
hide: !verboseHelp,
|
||||||
|
help:
|
||||||
|
'Name of a build output within the engine out directory, if you are building Flutter locally.\n'
|
||||||
|
'Use this to select a specific version of the engine if you have built multiple engine targets.\n'
|
||||||
|
'This path is relative to --engine-src-path/out.');
|
||||||
|
|
||||||
argParser.addOption('host-debug-build-path',
|
argParser.addOption('host-debug-build-path',
|
||||||
hide: !verboseHelp,
|
hide: !verboseHelp,
|
||||||
help:
|
help:
|
||||||
@ -220,6 +228,7 @@ class FlutterCommandRunner extends CommandRunner {
|
|||||||
// Set up the tooling configuration.
|
// Set up the tooling configuration.
|
||||||
if (enginePath != null) {
|
if (enginePath != null) {
|
||||||
ToolConfiguration.instance.engineSrcPath = enginePath;
|
ToolConfiguration.instance.engineSrcPath = enginePath;
|
||||||
|
ToolConfiguration.instance.engineBuildPath = _findEngineBuildPath(globalResults, enginePath);
|
||||||
|
|
||||||
if (globalResults.wasParsed('engine-release'))
|
if (globalResults.wasParsed('engine-release'))
|
||||||
ToolConfiguration.instance.engineRelease = globalResults['engine-release'];
|
ToolConfiguration.instance.engineRelease = globalResults['engine-release'];
|
||||||
@ -287,6 +296,35 @@ class FlutterCommandRunner extends CommandRunner {
|
|||||||
return engineSourcePath;
|
return engineSourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _findEngineBuildPath(ArgResults globalResults, String enginePath) {
|
||||||
|
String localEngine;
|
||||||
|
if (globalResults['local-engine'] != null) {
|
||||||
|
localEngine = globalResults['local-engine'];
|
||||||
|
} else {
|
||||||
|
// This is a temporary hack to find an engine build in the same way that we found the toolchain.
|
||||||
|
// TODO(jsimmons): delete this and make --local-engine mandatory when BuildConfigurations are removed.
|
||||||
|
for (BuildConfiguration config in buildConfigurations) {
|
||||||
|
if (FileSystemEntity.isDirectorySync(config.buildDir)) {
|
||||||
|
localEngine = path.basename(config.buildDir);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localEngine == null) {
|
||||||
|
printError('You must specify --local-engine if you are using a locally built engine.');
|
||||||
|
throw new ProcessExit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String engineBuildPath = path.join(enginePath, 'out', localEngine);
|
||||||
|
if (!FileSystemEntity.isDirectorySync(engineBuildPath)) {
|
||||||
|
printError('No Flutter engine build found at $engineBuildPath.');
|
||||||
|
throw new ProcessExit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return engineBuildPath;
|
||||||
|
}
|
||||||
|
|
||||||
List<BuildConfiguration> _createBuildConfigurations(ArgResults globalResults) {
|
List<BuildConfiguration> _createBuildConfigurations(ArgResults globalResults) {
|
||||||
bool isDebug = globalResults['engine-debug'];
|
bool isDebug = globalResults['engine-debug'];
|
||||||
bool isRelease = globalResults['engine-release'];
|
bool isRelease = globalResults['engine-release'];
|
||||||
|
@ -2,77 +2,17 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import 'artifacts.dart';
|
|
||||||
import 'base/context.dart';
|
import 'base/context.dart';
|
||||||
import 'base/process.dart';
|
|
||||||
import 'build_configuration.dart';
|
import 'build_configuration.dart';
|
||||||
import 'cache.dart';
|
import 'cache.dart';
|
||||||
import 'globals.dart';
|
import 'globals.dart';
|
||||||
import 'package_map.dart';
|
|
||||||
|
|
||||||
class SnapshotCompiler {
|
enum HostTool {
|
||||||
SnapshotCompiler(this._path);
|
SkySnapshot,
|
||||||
|
|
||||||
final String _path;
|
|
||||||
|
|
||||||
Future<int> createSnapshot({
|
|
||||||
String mainPath,
|
|
||||||
String snapshotPath,
|
|
||||||
String depfilePath,
|
|
||||||
String buildOutputPath
|
|
||||||
}) {
|
|
||||||
assert(mainPath != null);
|
|
||||||
assert(snapshotPath != null);
|
|
||||||
|
|
||||||
final List<String> args = <String>[
|
|
||||||
_path,
|
|
||||||
mainPath,
|
|
||||||
'--packages=${PackageMap.instance.packagesPath}',
|
|
||||||
'--snapshot=$snapshotPath'
|
|
||||||
];
|
|
||||||
if (depfilePath != null)
|
|
||||||
args.add('--depfile=$depfilePath');
|
|
||||||
if (buildOutputPath != null)
|
|
||||||
args.add('--build-output=$buildOutputPath');
|
|
||||||
return runCommandAndStreamOutput(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(devoncarew): This should instead take a host platform and target platform.
|
|
||||||
|
|
||||||
String _getCompilerPath(BuildConfiguration config) {
|
|
||||||
if (config.type != BuildType.prebuilt) {
|
|
||||||
String compilerPath = path.join(config.buildDir, 'clang_x64', 'sky_snapshot');
|
|
||||||
if (FileSystemEntity.isFileSync(compilerPath))
|
|
||||||
return compilerPath;
|
|
||||||
compilerPath = path.join(config.buildDir, 'sky_snapshot');
|
|
||||||
if (FileSystemEntity.isFileSync(compilerPath))
|
|
||||||
return compilerPath;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Artifact artifact = ArtifactStore.getArtifact(
|
|
||||||
type: ArtifactType.snapshot, hostPlatform: config.hostPlatform);
|
|
||||||
return ArtifactStore.getPath(artifact);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Toolchain {
|
|
||||||
Toolchain({ this.compiler });
|
|
||||||
|
|
||||||
final SnapshotCompiler compiler;
|
|
||||||
|
|
||||||
static Toolchain forConfigs(List<BuildConfiguration> configs) {
|
|
||||||
for (BuildConfiguration config in configs) {
|
|
||||||
String compilerPath = _getCompilerPath(config);
|
|
||||||
if (compilerPath != null)
|
|
||||||
return new Toolchain(compiler: new SnapshotCompiler(compilerPath));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A ToolConfiguration can return the tools directory for the current host platform
|
/// A ToolConfiguration can return the tools directory for the current host platform
|
||||||
@ -95,6 +35,9 @@ class ToolConfiguration {
|
|||||||
/// Override using the artifacts from the cache directory (--engine-src-path).
|
/// Override using the artifacts from the cache directory (--engine-src-path).
|
||||||
String engineSrcPath;
|
String engineSrcPath;
|
||||||
|
|
||||||
|
/// Path to a local engine build acting as a source for artifacts (--local-engine).
|
||||||
|
String engineBuildPath;
|
||||||
|
|
||||||
/// The engine mode to use (only relevent when [engineSrcPath] is set).
|
/// The engine mode to use (only relevent when [engineSrcPath] is set).
|
||||||
bool engineRelease;
|
bool engineRelease;
|
||||||
|
|
||||||
@ -159,4 +102,17 @@ class ToolConfiguration {
|
|||||||
return new Directory(path.join(engineDir.path, dirName));
|
return new Directory(path.join(engineDir.path, dirName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getHostToolPath(HostTool tool) {
|
||||||
|
if (tool != HostTool.SkySnapshot)
|
||||||
|
throw new Exception('Unexpected host tool: $tool');
|
||||||
|
|
||||||
|
if (isLocalEngine) {
|
||||||
|
return path.join(engineBuildPath, 'clang_x64', 'sky_snapshot');
|
||||||
|
} else {
|
||||||
|
return path.join(_cache.getArtifactDirectory('engine').path,
|
||||||
|
getNameForHostPlatform(getCurrentHostPlatform()),
|
||||||
|
'sky_snapshot');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import 'package:flutter_tools/src/device.dart';
|
|||||||
import 'package:flutter_tools/src/ios/devices.dart';
|
import 'package:flutter_tools/src/ios/devices.dart';
|
||||||
import 'package:flutter_tools/src/ios/simulators.dart';
|
import 'package:flutter_tools/src/ios/simulators.dart';
|
||||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||||
import 'package:flutter_tools/src/toolchain.dart';
|
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
|
|
||||||
class MockApplicationPackageStore extends ApplicationPackageStore {
|
class MockApplicationPackageStore extends ApplicationPackageStore {
|
||||||
@ -28,13 +27,6 @@ class MockApplicationPackageStore extends ApplicationPackageStore {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockSnapshotCompiler extends Mock implements SnapshotCompiler {
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockToolchain extends Toolchain {
|
|
||||||
MockToolchain() : super(compiler: new MockSnapshotCompiler());
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockAndroidDevice extends Mock implements AndroidDevice {
|
class MockAndroidDevice extends Mock implements AndroidDevice {
|
||||||
@override
|
@override
|
||||||
TargetPlatform get platform => TargetPlatform.android_arm;
|
TargetPlatform get platform => TargetPlatform.android_arm;
|
||||||
@ -74,6 +66,5 @@ class MockDeviceLogReader extends DeviceLogReader {
|
|||||||
void applyMocksToCommand(FlutterCommand command) {
|
void applyMocksToCommand(FlutterCommand command) {
|
||||||
command
|
command
|
||||||
..applicationPackages = new MockApplicationPackageStore()
|
..applicationPackages = new MockApplicationPackageStore()
|
||||||
..toolchain = new MockToolchain()
|
|
||||||
..commandValidator = () => true;
|
..commandValidator = () => true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user