[flutter_tools] Ensure that global variables are easily identifiable (#47398)
diff --git a/packages/flutter_tools/BUILD.gn b/packages/flutter_tools/BUILD.gn
index 51b1a4f..cdfafe1 100644
--- a/packages/flutter_tools/BUILD.gn
+++ b/packages/flutter_tools/BUILD.gn
@@ -95,9 +95,7 @@
"src/base/logger.dart",
"src/base/net.dart",
"src/base/os.dart",
- "src/base/platform.dart",
"src/base/process.dart",
- "src/base/process_manager.dart",
"src/base/terminal.dart",
"src/base/utils.dart",
"src/base/version.dart",
@@ -183,9 +181,7 @@
"src/base/logger.dart",
"src/base/net.dart",
"src/base/os.dart",
- "src/base/platform.dart",
"src/base/process.dart",
- "src/base/process_manager.dart",
"src/base/terminal.dart",
"src/base/utils.dart",
"src/base/version.dart",
diff --git a/packages/flutter_tools/bin/fuchsia_asset_builder.dart b/packages/flutter_tools/bin/fuchsia_asset_builder.dart
index 5e75e0c..5e980aa 100644
--- a/packages/flutter_tools/bin/fuchsia_asset_builder.dart
+++ b/packages/flutter_tools/bin/fuchsia_asset_builder.dart
@@ -9,12 +9,11 @@
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart' as libfs;
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/bundle.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/reporting/reporting.dart';
const String _kOptionPackages = 'packages';
@@ -52,10 +51,10 @@
final ArgResults argResults = parser.parse(args);
if (_kRequiredOptions
.any((String option) => !argResults.options.contains(option))) {
- printError('Missing option! All options must be specified.');
+ globals.printError('Missing option! All options must be specified.');
exit(1);
}
- Cache.flutterRoot = platform.environment['FLUTTER_ROOT'];
+ Cache.flutterRoot = globals.platform.environment['FLUTTER_ROOT'];
final String assetDir = argResults[_kOptionAsset] as String;
final AssetBundle assets = await buildAssets(
@@ -72,7 +71,7 @@
final List<Future<void>> calls = <Future<void>>[];
assets.entries.forEach((String fileName, DevFSContent content) {
- final libfs.File outputFile = libfs.fs.file(libfs.fs.path.join(assetDir, fileName));
+ final libfs.File outputFile = globals.fs.file(globals.fs.path.join(assetDir, fileName));
calls.add(writeFile(outputFile, content));
});
await Future.wait<void>(calls);
@@ -83,7 +82,7 @@
Future<void> writeFuchsiaManifest(AssetBundle assets, String outputBase, String fileDest, String componentName) async {
- final libfs.File destFile = libfs.fs.file(fileDest);
+ final libfs.File destFile = globals.fs.file(fileDest);
await destFile.create(recursive: true);
final libfs.IOSink outFile = destFile.openWrite();
diff --git a/packages/flutter_tools/bin/fuchsia_attach.dart b/packages/flutter_tools/bin/fuchsia_attach.dart
index ae2452a..5c94ef3 100644
--- a/packages/flutter_tools/bin/fuchsia_attach.dart
+++ b/packages/flutter_tools/bin/fuchsia_attach.dart
@@ -17,6 +17,7 @@
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_device.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
@@ -40,20 +41,20 @@
final List<String> targetParts = _extractPathAndName(target);
final String path = targetParts[0];
final String name = targetParts[1];
- final File dartSdk = fs.file(argResults['dart-sdk']);
+ final File dartSdk = globals.fs.file(argResults['dart-sdk']);
final String buildDirectory = argResults['build-dir'] as String;
- final File frontendServer = fs.file('$buildDirectory/host_x64/gen/third_party/flutter/frontend_server/frontend_server_tool.snapshot');
- final File sshConfig = fs.file('$buildDirectory/ssh-keys/ssh_config');
- final File devFinder = fs.file(argResults['dev-finder']);
- final File platformKernelDill = fs.file('$buildDirectory/flutter_runner_patched_sdk/platform_strong.dill');
- final File flutterPatchedSdk = fs.file('$buildDirectory/flutter_runner_patched_sdk');
+ final File frontendServer = globals.fs.file('$buildDirectory/host_x64/gen/third_party/flutter/frontend_server/frontend_server_tool.snapshot');
+ final File sshConfig = globals.fs.file('$buildDirectory/ssh-keys/ssh_config');
+ final File devFinder = globals.fs.file(argResults['dev-finder']);
+ final File platformKernelDill = globals.fs.file('$buildDirectory/flutter_runner_patched_sdk/platform_strong.dill');
+ final File flutterPatchedSdk = globals.fs.file('$buildDirectory/flutter_runner_patched_sdk');
final String packages = '$buildDirectory/dartlang/gen/$path/${name}_dart_library.packages';
final String outputDill = '$buildDirectory/${name}_tmp.dill';
// TODO(jonahwilliams): running from fuchsia root hangs hot reload for some reason.
// switch to the project root directory and run from there.
- originalWorkingDirectory = fs.currentDirectory.path;
- fs.currentDirectory = path;
+ originalWorkingDirectory = globals.fs.currentDirectory.path;
+ globals.fs.currentDirectory = path;
if (!devFinder.existsSync()) {
print('Error: dev_finder not found at ${devFinder.path}.');
@@ -71,7 +72,7 @@
// Check for a package with a lib directory.
final String entrypoint = argResults['entrypoint'] as String;
String targetFile = 'lib/$entrypoint';
- if (!fs.file(targetFile).existsSync()) {
+ if (!globals.fs.file(targetFile).existsSync()) {
// Otherwise assume the package is flat.
targetFile = entrypoint;
}
diff --git a/packages/flutter_tools/bin/fuchsia_tester.dart b/packages/flutter_tools/bin/fuchsia_tester.dart
index 04bf548..b23d980 100644
--- a/packages/flutter_tools/bin/fuchsia_tester.dart
+++ b/packages/flutter_tools/bin/fuchsia_tester.dart
@@ -11,13 +11,13 @@
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/artifacts.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/test/coverage_collector.dart';
@@ -73,46 +73,46 @@
throwToolExit('Missing option! All options must be specified.');
}
final Directory tempDir =
- fs.systemTempDirectory.createTempSync('flutter_fuchsia_tester.');
+ globals.fs.systemTempDirectory.createTempSync('flutter_fuchsia_tester.');
try {
Cache.flutterRoot = tempDir.path;
- final String shellPath = fs.file(argResults[_kOptionShell]).resolveSymbolicLinksSync();
- if (!fs.isFileSync(shellPath)) {
+ final String shellPath = globals.fs.file(argResults[_kOptionShell]).resolveSymbolicLinksSync();
+ if (!globals.fs.isFileSync(shellPath)) {
throwToolExit('Cannot find Flutter shell at $shellPath');
}
- final Directory sdkRootSrc = fs.directory(argResults[_kOptionSdkRoot]);
- if (!fs.isDirectorySync(sdkRootSrc.path)) {
+ final Directory sdkRootSrc = globals.fs.directory(argResults[_kOptionSdkRoot]);
+ if (!globals.fs.isDirectorySync(sdkRootSrc.path)) {
throwToolExit('Cannot find SDK files at ${sdkRootSrc.path}');
}
Directory coverageDirectory;
final String coverageDirectoryPath = argResults[_kOptionCoverageDirectory] as String;
if (coverageDirectoryPath != null) {
- if (!fs.isDirectorySync(coverageDirectoryPath)) {
+ if (!globals.fs.isDirectorySync(coverageDirectoryPath)) {
throwToolExit('Cannot find coverage directory at $coverageDirectoryPath');
}
- coverageDirectory = fs.directory(coverageDirectoryPath);
+ coverageDirectory = globals.fs.directory(coverageDirectoryPath);
}
// Put the tester shell where runTests expects it.
// TODO(garymm): Switch to a Fuchsia-specific Artifacts impl.
final Link testerDestLink =
- fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
+ globals.fs.link(globals.artifacts.getArtifactPath(Artifact.flutterTester));
testerDestLink.parent.createSync(recursive: true);
- testerDestLink.createSync(fs.path.absolute(shellPath));
+ testerDestLink.createSync(globals.fs.path.absolute(shellPath));
final Directory sdkRootDest =
- fs.directory(artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
+ globals.fs.directory(globals.artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
sdkRootDest.createSync(recursive: true);
for (FileSystemEntity artifact in sdkRootSrc.listSync()) {
- fs.link(sdkRootDest.childFile(artifact.basename).path).createSync(artifact.path);
+ globals.fs.link(sdkRootDest.childFile(artifact.basename).path).createSync(artifact.path);
}
// TODO(tvolkert): Remove once flutter_tester no longer looks for this.
- fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill');
+ globals.fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill');
PackageMap.globalPackagesPath =
- fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages] as String));
+ globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String));
Directory testDirectory;
CoverageCollector collector;
@@ -129,16 +129,16 @@
if (!argResults.options.contains(_kOptionTestDirectory)) {
throwToolExit('Use of --coverage requires setting --test-directory');
}
- testDirectory = fs.directory(argResults[_kOptionTestDirectory]);
+ testDirectory = globals.fs.directory(argResults[_kOptionTestDirectory]);
}
final Map<String, String> tests = <String, String>{};
final List<Map<String, dynamic>> jsonList = List<Map<String, dynamic>>.from(
- (json.decode(fs.file(argResults[_kOptionTests]).readAsStringSync()) as List<dynamic>).cast<Map<String, dynamic>>());
+ (json.decode(globals.fs.file(argResults[_kOptionTests]).readAsStringSync()) as List<dynamic>).cast<Map<String, dynamic>>());
for (Map<String, dynamic> map in jsonList) {
- final String source = fs.file(map['source']).resolveSymbolicLinksSync();
- final String dill = fs.file(map['dill']).resolveSymbolicLinksSync();
+ final String source = globals.fs.file(map['source']).resolveSymbolicLinksSync();
+ final String dill = globals.fs.file(map['dill']).resolveSymbolicLinksSync();
tests[source] = dill;
}
@@ -151,8 +151,8 @@
enableObservatory: collector != null,
buildMode: BuildMode.debug,
precompiledDillFiles: tests,
- concurrency: math.max(1, platform.numberOfProcessors - 2),
- icudtlPath: fs.path.absolute(argResults[_kOptionIcudtl] as String),
+ concurrency: math.max(1, globals.platform.numberOfProcessors - 2),
+ icudtlPath: globals.fs.path.absolute(argResults[_kOptionIcudtl] as String),
coverageDirectory: coverageDirectory,
);
@@ -161,9 +161,9 @@
// package (i.e. contains lib/ and test/ sub-dirs). In some cases,
// test files may appear to be in the root directory.
if (coverageDirectory == null) {
- fs.currentDirectory = testDirectory.parent;
+ globals.fs.currentDirectory = testDirectory.parent;
} else {
- fs.currentDirectory = testDirectory;
+ globals.fs.currentDirectory = testDirectory;
}
if (!await collector.collectCoverageData(argResults[_kOptionCoveragePath] as String, coverageDirectory: coverageDirectory)) {
throwToolExit('Failed to collect coverage data');
diff --git a/packages/flutter_tools/lib/src/android/android_builder.dart b/packages/flutter_tools/lib/src/android/android_builder.dart
index ec21efa..17b5d5d 100644
--- a/packages/flutter_tools/lib/src/android/android_builder.dart
+++ b/packages/flutter_tools/lib/src/android/android_builder.dart
@@ -10,6 +10,7 @@
import '../base/context.dart';
import '../base/file_system.dart';
import '../build_info.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import 'android_sdk.dart';
import 'gradle.dart';
@@ -62,7 +63,7 @@
}) async {
try {
Directory outputDirectory =
- fs.directory(outputDirectoryPath ?? project.android.buildDirectory);
+ globals.fs.directory(outputDirectoryPath ?? project.android.buildDirectory);
if (project.isModule) {
// Module projects artifacts are located in `build/host`.
outputDirectory = outputDirectory.childDirectory('host');
diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart
index 5a523f6..3b8d6b5 100644
--- a/packages/flutter_tools/lib/src/android/android_device.dart
+++ b/packages/flutter_tools/lib/src/android/android_device.dart
@@ -14,13 +14,11 @@
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../build_info.dart';
import '../convert.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../protocol_discovery.dart';
@@ -49,7 +47,7 @@
// In platform tools 29.0.0 adb.exe seems to be ending with this heap
// corruption error code on seemingly successful termination.
// So we ignore this error on Windows.
- return exitCode == -1073740940 && platform.isWindows;
+ return exitCode == -1073740940 && globals.platform.isWindows;
}
class AndroidDevices extends PollingDeviceDiscovery {
@@ -94,12 +92,12 @@
_properties = <String, String>{};
final List<String> propCommand = adbCommandForDevice(<String>['shell', 'getprop']);
- printTrace(propCommand.join(' '));
+ globals.printTrace(propCommand.join(' '));
try {
// We pass an encoding of latin1 so that we don't try and interpret the
// `adb shell getprop` result as UTF8.
- final ProcessResult result = await processManager.run(
+ final ProcessResult result = await globals.processManager.run(
propCommand,
stdoutEncoding: latin1,
stderrEncoding: latin1,
@@ -107,11 +105,11 @@
if (result.exitCode == 0 || allowHeapCorruptionOnWindows(result.exitCode)) {
_properties = parseAdbDeviceProperties(result.stdout as String);
} else {
- printError('Error ${result.exitCode} retrieving device properties for $name:');
- printError(result.stderr as String);
+ globals.printError('Error ${result.exitCode} retrieving device properties for $name:');
+ globals.printError(result.stderr as String);
}
} on ProcessException catch (error) {
- printError('Error retrieving device properties for $name: $error');
+ globals.printError('Error retrieving device properties for $name: $error');
}
}
@@ -122,14 +120,14 @@
Future<bool> get isLocalEmulator async {
if (_isLocalEmulator == null) {
final String hardware = await _getProperty('ro.hardware');
- printTrace('ro.hardware = $hardware');
+ globals.printTrace('ro.hardware = $hardware');
if (_kKnownHardware.containsKey(hardware)) {
// Look for known hardware models.
_isLocalEmulator = _kKnownHardware[hardware] == _HardwareType.emulator;
} else {
// Fall back to a best-effort heuristic-based approach.
final String characteristics = await _getProperty('ro.build.characteristics');
- printTrace('ro.build.characteristics = $characteristics');
+ globals.printTrace('ro.build.characteristics = $characteristics');
_isLocalEmulator = characteristics != null && characteristics.contains('emulator');
}
}
@@ -159,7 +157,7 @@
const String host = 'localhost';
final int port = int.parse(portMatch.group(1));
- printTrace('Fetching avd name for $name via Android console on $host:$port');
+ globals.printTrace('Fetching avd name for $name via Android console on $host:$port');
try {
final Socket socket = await androidConsoleSocketFactory(host, port);
@@ -179,7 +177,7 @@
console.destroy();
}
} catch (e) {
- printTrace('Failed to fetch avd name for emulator at $host:$port: $e');
+ globals.printTrace('Failed to fetch avd name for emulator at $host:$port: $e');
// If we fail to connect to the device, we should not fail so just return
// an empty name. This data is best-effort.
return null;
@@ -281,7 +279,7 @@
}
return false;
}
- printError(
+ globals.printError(
'Unrecognized adb version string $adbVersion. Skipping version check.');
return true;
}
@@ -299,9 +297,9 @@
if (_isValidAdbVersion(adbVersion.stdout)) {
return true;
}
- printError('The ADB at "${getAdbPath(androidSdk)}" is too old; please install version 1.0.39 or later.');
+ globals.printError('The ADB at "${getAdbPath(androidSdk)}" is too old; please install version 1.0.39 or later.');
} catch (error, trace) {
- printError('Error running ADB: $error', stackTrace: trace);
+ globals.printError('Error running ADB: $error', stackTrace: trace);
}
return false;
@@ -324,12 +322,12 @@
final int sdkVersionParsed = int.tryParse(sdkVersion);
if (sdkVersionParsed == null) {
- printError('Unexpected response from getprop: "$sdkVersion"');
+ globals.printError('Unexpected response from getprop: "$sdkVersion"');
return false;
}
if (sdkVersionParsed < minApiLevel) {
- printError(
+ globals.printError(
'The Android version ($sdkVersion) on the target device is too old. Please '
'use a $minVersionName (version $minApiLevel / $minVersionText) device or later.');
return false;
@@ -337,8 +335,8 @@
return true;
} catch (e, stacktrace) {
- printError('Unexpected failure from adb: $e');
- printError('Stacktrace: $stacktrace');
+ globals.printError('Unexpected failure from adb: $e');
+ globals.printError('Stacktrace: $stacktrace');
return false;
}
}
@@ -354,7 +352,7 @@
}
String _getSourceSha1(AndroidApk apk) {
- final File shaFile = fs.file('${apk.file.path}.sha1');
+ final File shaFile = globals.fs.file('${apk.file.path}.sha1');
return shaFile.existsSync() ? shaFile.readAsStringSync() : '';
}
@@ -368,7 +366,7 @@
final RunResult listOut = await runAdbCheckedAsync(<String>['shell', 'pm', 'list', 'packages', app.id]);
return LineSplitter.split(listOut.stdout).contains('package:${app.id}');
} catch (error) {
- printTrace('$error');
+ globals.printTrace('$error');
return false;
}
}
@@ -382,7 +380,7 @@
@override
Future<bool> installApp(AndroidApk app) async {
if (!app.file.existsSync()) {
- printError('"${fs.path.relative(app.file.path)}" does not exist.');
+ globals.printError('"${globals.fs.path.relative(app.file.path)}" does not exist.');
return false;
}
@@ -391,7 +389,7 @@
return false;
}
- final Status status = logger.startProgress('Installing ${fs.path.relative(app.file.path)}...', timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress('Installing ${globals.fs.path.relative(app.file.path)}...', timeout: timeoutConfiguration.slowOperation);
final RunResult installResult = await processUtils.run(
adbCommandForDevice(<String>['install', '-t', '-r', app.file.path]));
status.stop();
@@ -400,12 +398,12 @@
final RegExp failureExp = RegExp(r'^Failure.*$', multiLine: true);
final String failure = failureExp.stringMatch(installResult.stdout);
if (failure != null) {
- printError('Package install error: $failure');
+ globals.printError('Package install error: $failure');
return false;
}
if (installResult.exitCode != 0) {
- printError('Error: ADB exited with exit code ${installResult.exitCode}');
- printError('$installResult');
+ globals.printError('Error: ADB exited with exit code ${installResult.exitCode}');
+ globals.printError('$installResult');
return false;
}
try {
@@ -413,7 +411,7 @@
'shell', 'echo', '-n', _getSourceSha1(app), '>', _getDeviceSha1Path(app),
]);
} on ProcessException catch (error) {
- printError('adb shell failed to write the SHA hash: $error.');
+ globals.printError('adb shell failed to write the SHA hash: $error.');
return false;
}
return true;
@@ -434,13 +432,13 @@
);
uninstallOut = uninstallResult.stdout;
} catch (error) {
- printError('adb uninstall failed: $error');
+ globals.printError('adb uninstall failed: $error');
return false;
}
final RegExp failureExp = RegExp(r'^Failure.*$', multiLine: true);
final String failure = failureExp.stringMatch(uninstallOut);
if (failure != null) {
- printError('Package uninstall error: $failure');
+ globals.printError('Package uninstall error: $failure');
return false;
}
@@ -451,21 +449,21 @@
final bool wasInstalled = await isAppInstalled(package);
if (wasInstalled) {
if (await isLatestBuildInstalled(package)) {
- printTrace('Latest build already installed.');
+ globals.printTrace('Latest build already installed.');
return true;
}
}
- printTrace('Installing APK.');
+ globals.printTrace('Installing APK.');
if (!await installApp(package)) {
- printTrace('Warning: Failed to install APK.');
+ globals.printTrace('Warning: Failed to install APK.');
if (wasInstalled) {
- printStatus('Uninstalling old version...');
+ globals.printStatus('Uninstalling old version...');
if (!await uninstallApp(package)) {
- printError('Error: Uninstalling old version failed.');
+ globals.printError('Error: Uninstalling old version failed.');
return false;
}
if (!await installApp(package)) {
- printError('Error: Failed to install APK again.');
+ globals.printError('Error: Failed to install APK again.');
return false;
}
return true;
@@ -495,7 +493,7 @@
final TargetPlatform devicePlatform = await targetPlatform;
if (devicePlatform == TargetPlatform.android_x86 &&
!debuggingOptions.buildInfo.isDebug) {
- printError('Profile and release builds are only supported on ARM/x64 targets.');
+ globals.printError('Profile and release builds are only supported on ARM/x64 targets.');
return LaunchResult.failed();
}
@@ -514,12 +512,12 @@
androidArch = AndroidArch.x86;
break;
default:
- printError('Android platforms are only supported.');
+ globals.printError('Android platforms are only supported.');
return LaunchResult.failed();
}
if (!prebuiltApplication || androidSdk.licensesAvailable && androidSdk.latestVersion == null) {
- printTrace('Building APK');
+ globals.printTrace('Building APK');
final FlutterProject project = FlutterProject.current();
await androidBuilder.buildApk(
project: project,
@@ -539,7 +537,7 @@
throwToolExit('Problem building Android application: see above error(s).');
}
- printTrace("Stopping app '${package.name}' on $name.");
+ globals.printTrace("Stopping app '${package.name}' on $name.");
await stopApp(package);
if (!await _installLatestApp(package)) {
@@ -547,7 +545,7 @@
}
final bool traceStartup = platformArgs['trace-startup'] as bool ?? false;
- printTrace('$this startApp');
+ globals.printTrace('$this startApp');
ProtocolDiscovery observatoryDiscovery;
@@ -608,7 +606,7 @@
final String result = (await runAdbCheckedAsync(cmd)).stdout;
// This invocation returns 0 even when it fails.
if (result.contains('Error: ')) {
- printError(result.trim(), wrap: false);
+ globals.printError(result.trim(), wrap: false);
return LaunchResult.failed();
}
@@ -619,7 +617,7 @@
// Wait for the service protocol port here. This will complete once the
// device has printed "Observatory is listening on...".
- printTrace('Waiting for observatory port to be available...');
+ globals.printTrace('Waiting for observatory port to be available...');
// TODO(danrubel): Waiting for observatory services can be made common across all devices.
try {
@@ -631,7 +629,7 @@
return LaunchResult.succeeded(observatoryUri: observatoryUri);
} catch (error) {
- printError('Error waiting for a debug connection: $error');
+ globals.printError('Error waiting for a debug connection: $error');
return LaunchResult.failed();
} finally {
await observatoryDiscovery.cancel();
@@ -695,7 +693,7 @@
'shell', '-x', 'logcat', '-v', 'time', '-t', '1'
]);
} catch (error) {
- printError('Failed to extract the most recent timestamp from the Android log: $error.');
+ globals.printError('Failed to extract the most recent timestamp from the Android log: $error.');
return null;
}
final Match timeMatch = _timeRegExp.firstMatch(output);
@@ -1162,7 +1160,7 @@
throwOnError: true,
).stdout.trim();
} on ProcessException catch (error) {
- printError('Failed to list forwarded ports: $error.');
+ globals.printError('Failed to list forwarded ports: $error.');
return ports;
}
diff --git a/packages/flutter_tools/lib/src/android/android_emulator.dart b/packages/flutter_tools/lib/src/android/android_emulator.dart
index 659cd99..5a7a04e 100644
--- a/packages/flutter_tools/lib/src/android/android_emulator.dart
+++ b/packages/flutter_tools/lib/src/android/android_emulator.dart
@@ -12,6 +12,7 @@
import '../base/process.dart';
import '../device.dart';
import '../emulator.dart';
+import '../globals.dart' as globals;
import 'android_sdk.dart';
class AndroidEmulators extends EmulatorDiscovery {
@@ -93,12 +94,12 @@
id = id.trim();
final String avdPath = getAvdPath();
if (avdPath != null) {
- final File iniFile = fs.file(fs.path.join(avdPath, '$id.ini'));
+ final File iniFile = globals.fs.file(globals.fs.path.join(avdPath, '$id.ini'));
if (iniFile.existsSync()) {
final Map<String, String> ini = parseIniLines(iniFile.readAsLinesSync());
if (ini['path'] != null) {
final File configFile =
- fs.file(fs.path.join(ini['path'], 'config.ini'));
+ globals.fs.file(globals.fs.path.join(ini['path'], 'config.ini'));
if (configFile.existsSync()) {
final Map<String, String> properties =
parseIniLines(configFile.readAsLinesSync());
diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart
index 7adc6c7..7c4ab74 100644
--- a/packages/flutter_tools/lib/src/android/android_sdk.dart
+++ b/packages/flutter_tools/lib/src/android/android_sdk.dart
@@ -8,12 +8,10 @@
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/version.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'android_studio.dart' as android_studio;
AndroidSdk get androidSdk => context.get<AndroidSdk>();
@@ -72,26 +70,26 @@
String getAvdPath() {
final List<String> searchPaths = <String>[
- platform.environment['ANDROID_AVD_HOME'],
- if (platform.environment['HOME'] != null)
- fs.path.join(platform.environment['HOME'], '.android', 'avd'),
+ globals.platform.environment['ANDROID_AVD_HOME'],
+ if (globals.platform.environment['HOME'] != null)
+ globals.fs.path.join(globals.platform.environment['HOME'], '.android', 'avd'),
];
- if (platform.isWindows) {
- final String homeDrive = platform.environment['HOMEDRIVE'];
- final String homePath = platform.environment['HOMEPATH'];
+ if (globals.platform.isWindows) {
+ final String homeDrive = globals.platform.environment['HOMEDRIVE'];
+ final String homePath = globals.platform.environment['HOMEPATH'];
if (homeDrive != null && homePath != null) {
// Can't use path.join for HOMEDRIVE/HOMEPATH
// https://github.com/dart-lang/path/issues/37
final String home = homeDrive + homePath;
- searchPaths.add(fs.path.join(home, '.android', 'avd'));
+ searchPaths.add(globals.fs.path.join(home, '.android', 'avd'));
}
}
return searchPaths.where((String p) => p != null).firstWhere(
- (String p) => fs.directory(p).existsSync(),
+ (String p) => globals.fs.directory(p).existsSync(),
orElse: () => null,
);
}
@@ -131,8 +129,8 @@
}
String findBundle(String androidHomeDir) {
- final String ndkDirectory = fs.path.join(androidHomeDir, 'ndk-bundle');
- if (!fs.isDirectorySync(ndkDirectory)) {
+ final String ndkDirectory = globals.fs.path.join(androidHomeDir, 'ndk-bundle');
+ if (!globals.fs.isDirectorySync(ndkDirectory)) {
throw AndroidNdkSearchError('Can not locate ndk-bundle, tried: $ndkDirectory');
}
return ndkDirectory;
@@ -141,20 +139,20 @@
// Returns list that contains toolchain bin folder and compiler binary name.
List<String> findToolchainAndCompiler(String ndkDirectory) {
String directory;
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
directory = 'linux-x86_64';
- } else if (platform.isMacOS) {
+ } else if (globals.platform.isMacOS) {
directory = 'darwin-x86_64';
} else {
throw AndroidNdkSearchError('Only Linux and macOS are supported');
}
- final String toolchainBin = fs.path.join(ndkDirectory,
+ final String toolchainBin = globals.fs.path.join(ndkDirectory,
'toolchains', 'arm-linux-androideabi-4.9', 'prebuilt', directory,
'bin');
- final String ndkCompiler = fs.path.join(toolchainBin,
+ final String ndkCompiler = globals.fs.path.join(toolchainBin,
'arm-linux-androideabi-gcc');
- if (!fs.isFileSync(ndkCompiler)) {
+ if (!globals.fs.isFileSync(ndkCompiler)) {
throw AndroidNdkSearchError('Can not locate GCC binary, tried $ndkCompiler');
}
@@ -170,11 +168,11 @@
return null;
}
- if (!fs.isDirectorySync(fs.path.join(entry.path, 'arch-arm'))) {
+ if (!globals.fs.isDirectorySync(globals.fs.path.join(entry.path, 'arch-arm'))) {
return null;
}
- final String name = fs.path.basename(entry.path);
+ final String name = globals.fs.path.basename(entry.path);
const String platformPrefix = 'android-';
if (!name.startsWith(platformPrefix)) {
@@ -184,8 +182,8 @@
return int.tryParse(name.substring(platformPrefix.length));
}
- final String platformsDir = fs.path.join(ndkDirectory, 'platforms');
- final List<int> versions = fs
+ final String platformsDir = globals.fs.path.join(ndkDirectory, 'platforms');
+ final List<int> versions = globals.fs
.directory(platformsDir)
.listSync()
.map(toPlatformVersion)
@@ -199,19 +197,19 @@
throw AndroidNdkSearchError('Can not locate a suitable platform ARM sysroot (need android-9 or newer), tried to look in $platformsDir');
}
- final String armPlatform = fs.path.join(ndkDirectory, 'platforms',
+ final String armPlatform = globals.fs.path.join(ndkDirectory, 'platforms',
'android-$suitableVersion', 'arch-arm');
return <String>['--sysroot', armPlatform];
}
int findNdkMajorVersion(String ndkDirectory) {
- final String propertiesFile = fs.path.join(ndkDirectory, 'source.properties');
- if (!fs.isFileSync(propertiesFile)) {
+ final String propertiesFile = globals.fs.path.join(ndkDirectory, 'source.properties');
+ if (!globals.fs.isFileSync(propertiesFile)) {
throw AndroidNdkSearchError('Can not establish ndk-bundle version: $propertiesFile not found');
}
// Parse source.properties: each line has Key = Value format.
- final Iterable<String> propertiesFileLines = fs.file(propertiesFile)
+ final Iterable<String> propertiesFileLines = globals.fs.file(propertiesFile)
.readAsStringSync()
.split('\n')
.map<String>((String line) => line.trim())
@@ -222,7 +220,7 @@
if (parts.length == 2) {
properties[parts[0]] = parts[1];
} else {
- printError('Malformed line in ndk source.properties: "$line".');
+ globals.printError('Malformed line in ndk source.properties: "$line".');
}
}
@@ -245,8 +243,8 @@
// system linker instead of using toolchain linker. Force clang to
// use appropriate linker by passing -fuse-ld=<path-to-ld> command line
// flag.
- final String ndkLinker = fs.path.join(ndkToolchain, 'arm-linux-androideabi-ld');
- if (!fs.isFileSync(ndkLinker)) {
+ final String ndkLinker = globals.fs.path.join(ndkToolchain, 'arm-linux-androideabi-ld');
+ if (!globals.fs.isFileSync(ndkLinker)) {
throw AndroidNdkSearchError('Can not locate linker binary, tried $ndkLinker');
}
ndkCompilerArgs.add('-fuse-ld=$ndkLinker');
@@ -289,7 +287,7 @@
/// the expectation that it will be downloaded later, e.g. by gradle or the
/// sdkmanager. The [licensesAvailable] property should be used to determine
/// whether the licenses are at least possibly accepted.
- bool get platformToolsAvailable => fs.directory(fs.path.join(directory, 'platform-tools')).existsSync();
+ bool get platformToolsAvailable => globals.fs.directory(globals.fs.path.join(directory, 'platform-tools')).existsSync();
/// Whether the `licenses` directory exists in the Android SDK.
///
@@ -298,28 +296,28 @@
/// from another workstation such as in CI scenarios. If these files are valid
/// gradle or the sdkmanager will be able to download and use other parts of
/// the SDK on demand.
- bool get licensesAvailable => fs.directory(fs.path.join(directory, 'licenses')).existsSync();
+ bool get licensesAvailable => globals.fs.directory(globals.fs.path.join(directory, 'licenses')).existsSync();
static AndroidSdk locateAndroidSdk() {
String findAndroidHomeDir() {
String androidHomeDir;
- if (config.containsKey('android-sdk')) {
- androidHomeDir = config.getValue('android-sdk') as String;
- } else if (platform.environment.containsKey(kAndroidHome)) {
- androidHomeDir = platform.environment[kAndroidHome];
- } else if (platform.environment.containsKey(kAndroidSdkRoot)) {
- androidHomeDir = platform.environment[kAndroidSdkRoot];
- } else if (platform.isLinux) {
+ if (globals.config.containsKey('android-sdk')) {
+ androidHomeDir = globals.config.getValue('android-sdk') as String;
+ } else if (globals.platform.environment.containsKey(kAndroidHome)) {
+ androidHomeDir = globals.platform.environment[kAndroidHome];
+ } else if (globals.platform.environment.containsKey(kAndroidSdkRoot)) {
+ androidHomeDir = globals.platform.environment[kAndroidSdkRoot];
+ } else if (globals.platform.isLinux) {
if (homeDirPath != null) {
- androidHomeDir = fs.path.join(homeDirPath, 'Android', 'Sdk');
+ androidHomeDir = globals.fs.path.join(homeDirPath, 'Android', 'Sdk');
}
- } else if (platform.isMacOS) {
+ } else if (globals.platform.isMacOS) {
if (homeDirPath != null) {
- androidHomeDir = fs.path.join(homeDirPath, 'Library', 'Android', 'sdk');
+ androidHomeDir = globals.fs.path.join(homeDirPath, 'Library', 'Android', 'sdk');
}
- } else if (platform.isWindows) {
+ } else if (globals.platform.isWindows) {
if (homeDirPath != null) {
- androidHomeDir = fs.path.join(homeDirPath, 'AppData', 'Local', 'Android', 'sdk');
+ androidHomeDir = globals.fs.path.join(homeDirPath, 'AppData', 'Local', 'Android', 'sdk');
}
}
@@ -327,8 +325,8 @@
if (validSdkDirectory(androidHomeDir)) {
return androidHomeDir;
}
- if (validSdkDirectory(fs.path.join(androidHomeDir, 'sdk'))) {
- return fs.path.join(androidHomeDir, 'sdk');
+ if (validSdkDirectory(globals.fs.path.join(androidHomeDir, 'sdk'))) {
+ return globals.fs.path.join(androidHomeDir, 'sdk');
}
}
@@ -336,7 +334,7 @@
final List<File> aaptBins = os.whichAll('aapt');
for (File aaptBin in aaptBins) {
// Make sure we're using the aapt from the SDK.
- aaptBin = fs.file(aaptBin.resolveSymbolicLinksSync());
+ aaptBin = globals.fs.file(aaptBin.resolveSymbolicLinksSync());
final String dir = aaptBin.parent.parent.parent.path;
if (validSdkDirectory(dir)) {
return dir;
@@ -347,7 +345,7 @@
final List<File> adbBins = os.whichAll('adb');
for (File adbBin in adbBins) {
// Make sure we're using the adb from the SDK.
- adbBin = fs.file(adbBin.resolveSymbolicLinksSync());
+ adbBin = globals.fs.file(adbBin.resolveSymbolicLinksSync());
final String dir = adbBin.parent.parent.path;
if (validSdkDirectory(dir)) {
return dir;
@@ -360,7 +358,7 @@
final String androidHomeDir = findAndroidHomeDir();
if (androidHomeDir == null) {
// No dice.
- printTrace('Unable to locate an Android SDK.');
+ globals.printTrace('Unable to locate an Android SDK.');
return null;
}
@@ -381,24 +379,24 @@
}
static bool sdkDirectoryHasPlatformTools(String dir) {
- return fs.isDirectorySync(fs.path.join(dir, 'platform-tools'));
+ return globals.fs.isDirectorySync(globals.fs.path.join(dir, 'platform-tools'));
}
static bool sdkDirectoryHasLicenses(String dir) {
- return fs.isDirectorySync(fs.path.join(dir, 'licenses'));
+ return globals.fs.isDirectorySync(globals.fs.path.join(dir, 'licenses'));
}
List<AndroidSdkVersion> get sdkVersions => _sdkVersions;
AndroidSdkVersion get latestVersion => _latestVersion;
- String get adbPath => getPlatformToolsPath(platform.isWindows ? 'adb.exe' : 'adb');
+ String get adbPath => getPlatformToolsPath(globals.platform.isWindows ? 'adb.exe' : 'adb');
String get emulatorPath => getEmulatorPath();
String get avdManagerPath => getAvdManagerPath();
- Directory get _platformsDir => fs.directory(fs.path.join(directory, 'platforms'));
+ Directory get _platformsDir => globals.fs.directory(globals.fs.path.join(directory, 'platforms'));
Iterable<Directory> get _platforms {
Iterable<Directory> platforms = <Directory>[];
@@ -413,7 +411,7 @@
/// Validate the Android SDK. This returns an empty list if there are no
/// issues; otherwise, it returns a list of issues found.
List<String> validateSdkWellFormed() {
- if (adbPath == null || !processManager.canRun(adbPath)) {
+ if (adbPath == null || !globals.processManager.canRun(adbPath)) {
return <String>['Android SDK file not found: ${adbPath ?? 'adb'}.'];
}
@@ -434,21 +432,21 @@
}
String getPlatformToolsPath(String binaryName) {
- final String path = fs.path.join(directory, 'platform-tools', binaryName);
- if (fs.file(path).existsSync()) {
+ final String path = globals.fs.path.join(directory, 'platform-tools', binaryName);
+ if (globals.fs.file(path).existsSync()) {
return path;
}
return null;
}
String getEmulatorPath() {
- final String binaryName = platform.isWindows ? 'emulator.exe' : 'emulator';
+ final String binaryName = globals.platform.isWindows ? 'emulator.exe' : 'emulator';
// Emulator now lives inside "emulator" but used to live inside "tools" so
// try both.
final List<String> searchFolders = <String>['emulator', 'tools'];
for (final String folder in searchFolders) {
- final String path = fs.path.join(directory, folder, binaryName);
- if (fs.file(path).existsSync()) {
+ final String path = globals.fs.path.join(directory, folder, binaryName);
+ if (globals.fs.file(path).existsSync()) {
return path;
}
}
@@ -456,9 +454,9 @@
}
String getAvdManagerPath() {
- final String binaryName = platform.isWindows ? 'avdmanager.bat' : 'avdmanager';
- final String path = fs.path.join(directory, 'tools', 'bin', binaryName);
- if (fs.file(path).existsSync()) {
+ final String binaryName = globals.platform.isWindows ? 'avdmanager.bat' : 'avdmanager';
+ final String path = globals.fs.path.join(directory, 'tools', 'bin', binaryName);
+ if (globals.fs.file(path).existsSync()) {
return path;
}
return null;
@@ -471,7 +469,7 @@
void reinitialize() {
List<Version> buildTools = <Version>[]; // 19.1.0, 22.0.1, ...
- final Directory buildToolsDir = fs.directory(fs.path.join(directory, 'build-tools'));
+ final Directory buildToolsDir = globals.fs.directory(globals.fs.path.join(directory, 'build-tools'));
if (buildToolsDir.existsSync()) {
buildTools = buildToolsDir
.listSync()
@@ -533,24 +531,24 @@
/// Returns the filesystem path of the Android SDK manager tool or null if not found.
String get sdkManagerPath {
- return fs.path.join(directory, 'tools', 'bin', 'sdkmanager');
+ return globals.fs.path.join(directory, 'tools', 'bin', 'sdkmanager');
}
/// First try Java bundled with Android Studio, then sniff JAVA_HOME, then fallback to PATH.
static String findJavaBinary() {
if (android_studio.javaPath != null) {
- return fs.path.join(android_studio.javaPath, 'bin', 'java');
+ return globals.fs.path.join(android_studio.javaPath, 'bin', 'java');
}
- final String javaHomeEnv = platform.environment[_javaHomeEnvironmentVariable];
+ final String javaHomeEnv = globals.platform.environment[_javaHomeEnvironmentVariable];
if (javaHomeEnv != null) {
// Trust JAVA_HOME.
- return fs.path.join(javaHomeEnv, 'bin', 'java');
+ return globals.fs.path.join(javaHomeEnv, 'bin', 'java');
}
// MacOS specific logic to avoid popping up a dialog window.
// See: http://stackoverflow.com/questions/14292698/how-do-i-check-if-the-java-jdk-is-installed-on-mac.
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
try {
final String javaHomeOutput = processUtils.runSync(
<String>['/usr/libexec/java_home'],
@@ -561,7 +559,7 @@
final List<String> javaHomeOutputSplit = javaHomeOutput.split('\n');
if ((javaHomeOutputSplit != null) && (javaHomeOutputSplit.isNotEmpty)) {
final String javaHome = javaHomeOutputSplit[0].trim();
- return fs.path.join(javaHome, 'bin', 'java');
+ return globals.fs.path.join(javaHome, 'bin', 'java');
}
}
} catch (_) { /* ignore */ }
@@ -581,7 +579,7 @@
final String javaBinary = findJavaBinary();
if (javaBinary != null) {
_sdkManagerEnv['PATH'] =
- fs.path.dirname(javaBinary) + os.pathVarSeparator + platform.environment['PATH'];
+ globals.fs.path.dirname(javaBinary) + os.pathVarSeparator + globals.platform.environment['PATH'];
}
}
return _sdkManagerEnv;
@@ -589,7 +587,7 @@
/// Returns the version of the Android SDK manager tool or null if not found.
String get sdkManagerVersion {
- if (!processManager.canRun(sdkManagerPath)) {
+ if (!globals.processManager.canRun(sdkManagerPath)) {
throwToolExit('Android sdkmanager not found. Update to the latest Android SDK to resolve this.');
}
final RunResult result = processUtils.runSync(
@@ -597,7 +595,7 @@
environment: sdkManagerEnv,
);
if (result.exitCode != 0) {
- printTrace('sdkmanager --version failed: exitCode: ${result.exitCode} stdout: ${result.stdout} stderr: ${result.stderr}');
+ globals.printTrace('sdkmanager --version failed: exitCode: ${result.exitCode} stdout: ${result.stdout} stderr: ${result.stderr}');
return null;
}
return result.stdout.trim();
@@ -641,11 +639,11 @@
}
String getPlatformsPath(String itemName) {
- return fs.path.join(sdk.directory, 'platforms', platformName, itemName);
+ return globals.fs.path.join(sdk.directory, 'platforms', platformName, itemName);
}
String getBuildToolsPath(String binaryName) {
- return fs.path.join(sdk.directory, 'build-tools', buildToolsVersionName, binaryName);
+ return globals.fs.path.join(sdk.directory, 'build-tools', buildToolsVersionName, binaryName);
}
@override
@@ -655,14 +653,14 @@
String toString() => '[${sdk.directory}, SDK version $sdkLevel, build-tools $buildToolsVersionName]';
String _exists(String path) {
- if (!fs.isFileSync(path)) {
+ if (!globals.fs.isFileSync(path)) {
return 'Android SDK file not found: $path.';
}
return null;
}
String _canRun(String path) {
- if (!processManager.canRun(path)) {
+ if (!globals.processManager.canRun(path)) {
return 'Android SDK file not found: $path.';
}
return null;
diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart
index bbcad33..32014e2 100644
--- a/packages/flutter_tools/lib/src/android/android_studio.dart
+++ b/packages/flutter_tools/lib/src/android/android_studio.dart
@@ -5,12 +5,10 @@
import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/utils.dart';
import '../base/version.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/plist_parser.dart';
AndroidStudio get androidStudio => context.get<AndroidStudio>();
@@ -41,15 +39,15 @@
}
factory AndroidStudio.fromMacOSBundle(String bundlePath) {
- String studioPath = fs.path.join(bundlePath, 'Contents');
- String plistFile = fs.path.join(studioPath, 'Info.plist');
+ String studioPath = globals.fs.path.join(bundlePath, 'Contents');
+ String plistFile = globals.fs.path.join(studioPath, 'Info.plist');
Map<String, dynamic> plistValues = PlistParser.instance.parseFile(plistFile);
// As AndroidStudio managed by JetBrainsToolbox could have a wrapper pointing to the real Android Studio.
// Check if we've found a JetBrainsToolbox wrapper and deal with it properly.
final String jetBrainsToolboxAppBundlePath = plistValues['JetBrainsToolboxApp'] as String;
if (jetBrainsToolboxAppBundlePath != null) {
- studioPath = fs.path.join(jetBrainsToolboxAppBundlePath, 'Contents');
- plistFile = fs.path.join(studioPath, 'Info.plist');
+ studioPath = globals.fs.path.join(jetBrainsToolboxAppBundlePath, 'Contents');
+ plistFile = globals.fs.path.join(studioPath, 'Info.plist');
plistValues = PlistParser.instance.parseFile(plistFile);
}
@@ -70,7 +68,7 @@
}
final String presetPluginsPath = pathsSelectorValue == null
? null
- : fs.path.join(homeDirPath, 'Library', 'Application Support', '$pathsSelectorValue');
+ : globals.fs.path.join(homeDirPath, 'Library', 'Application Support', '$pathsSelectorValue');
return AndroidStudio(studioPath, version: version, presetPluginsPath: presetPluginsPath);
}
@@ -87,13 +85,13 @@
}
String installPath;
try {
- installPath = fs
- .file(fs.path.join(homeDotDir.path, 'system', '.home'))
+ installPath = globals.fs
+ .file(globals.fs.path.join(homeDotDir.path, 'system', '.home'))
.readAsStringSync();
} catch (e) {
// ignored, installPath will be null, which is handled below
}
- if (installPath != null && fs.isDirectorySync(installPath)) {
+ if (installPath != null && globals.fs.isDirectorySync(installPath)) {
return AndroidStudio(
installPath,
version: version,
@@ -123,14 +121,14 @@
}
final int major = version?.major;
final int minor = version?.minor;
- if (platform.isMacOS) {
- return fs.path.join(
+ if (globals.platform.isMacOS) {
+ return globals.fs.path.join(
homeDirPath,
'Library',
'Application Support',
'AndroidStudio$major.$minor');
} else {
- return fs.path.join(homeDirPath,
+ return globals.fs.path.join(homeDirPath,
'.$studioAppName$major.$minor',
'config',
'plugins');
@@ -150,11 +148,11 @@
/// Locates the newest, valid version of Android Studio.
static AndroidStudio latestValid() {
- final String configuredStudio = config.getValue('android-studio-dir') as String;
+ final String configuredStudio = globals.config.getValue('android-studio-dir') as String;
if (configuredStudio != null) {
String configuredStudioPath = configuredStudio;
- if (platform.isMacOS && !configuredStudioPath.endsWith('Contents')) {
- configuredStudioPath = fs.path.join(configuredStudioPath, 'Contents');
+ if (globals.platform.isMacOS && !configuredStudioPath.endsWith('Contents')) {
+ configuredStudioPath = globals.fs.path.join(configuredStudioPath, 'Contents');
}
return AndroidStudio(configuredStudioPath,
configured: configuredStudio);
@@ -171,17 +169,17 @@
}
static List<AndroidStudio> allInstalled() =>
- platform.isMacOS ? _allMacOS() : _allLinuxOrWindows();
+ globals.platform.isMacOS ? _allMacOS() : _allLinuxOrWindows();
static List<AndroidStudio> _allMacOS() {
final List<FileSystemEntity> candidatePaths = <FileSystemEntity>[];
void _checkForStudio(String path) {
- if (!fs.isDirectorySync(path)) {
+ if (!globals.fs.isDirectorySync(path)) {
return;
}
try {
- final Iterable<Directory> directories = fs
+ final Iterable<Directory> directories = globals.fs
.directory(path)
.listSync(followLinks: false)
.whereType<Directory>();
@@ -195,16 +193,16 @@
}
}
} catch (e) {
- printTrace('Exception while looking for Android Studio: $e');
+ globals.printTrace('Exception while looking for Android Studio: $e');
}
}
_checkForStudio('/Applications');
- _checkForStudio(fs.path.join(homeDirPath, 'Applications'));
+ _checkForStudio(globals.fs.path.join(homeDirPath, 'Applications'));
- final String configuredStudioDir = config.getValue('android-studio-dir') as String;
+ final String configuredStudioDir = globals.config.getValue('android-studio-dir') as String;
if (configuredStudioDir != null) {
- FileSystemEntity configuredStudio = fs.file(configuredStudioDir);
+ FileSystemEntity configuredStudio = globals.fs.file(configuredStudioDir);
if (configuredStudio.basename == 'Contents') {
configuredStudio = configuredStudio.parent;
}
@@ -237,8 +235,8 @@
// Read all $HOME/.AndroidStudio*/system/.home files. There may be several
// pointing to the same installation, so we grab only the latest one.
- if (homeDirPath != null && fs.directory(homeDirPath).existsSync()) {
- for (FileSystemEntity entity in fs.directory(homeDirPath).listSync(followLinks: false)) {
+ if (homeDirPath != null && globals.fs.directory(homeDirPath).existsSync()) {
+ for (FileSystemEntity entity in globals.fs.directory(homeDirPath).listSync(followLinks: false)) {
if (entity is Directory && entity.basename.startsWith('.AndroidStudio')) {
final AndroidStudio studio = AndroidStudio.fromHomeDot(entity);
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) {
@@ -249,15 +247,15 @@
}
}
- final String configuredStudioDir = config.getValue('android-studio-dir') as String;
+ final String configuredStudioDir = globals.config.getValue('android-studio-dir') as String;
if (configuredStudioDir != null && !_hasStudioAt(configuredStudioDir)) {
studios.add(AndroidStudio(configuredStudioDir,
configured: configuredStudioDir));
}
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
void _checkWellKnownPath(String path) {
- if (fs.isDirectorySync(path) && !_hasStudioAt(path)) {
+ if (globals.fs.isDirectorySync(path) && !_hasStudioAt(path)) {
studios.add(AndroidStudio(path));
}
}
@@ -284,16 +282,16 @@
_validationMessages.add('android-studio-dir = $configured');
}
- if (!fs.isDirectorySync(directory)) {
+ if (!globals.fs.isDirectorySync(directory)) {
_validationMessages.add('Android Studio not found at $directory');
return;
}
- final String javaPath = platform.isMacOS ?
- fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home') :
- fs.path.join(directory, 'jre');
- final String javaExecutable = fs.path.join(javaPath, 'bin', 'java');
- if (!processManager.canRun(javaExecutable)) {
+ final String javaPath = globals.platform.isMacOS ?
+ globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home') :
+ globals.fs.path.join(directory, 'jre');
+ final String javaExecutable = globals.fs.path.join(javaPath, 'bin', 'java');
+ if (!globals.processManager.canRun(javaExecutable)) {
_validationMessages.add('Unable to find bundled Java version.');
} else {
final RunResult result = processUtils.runSync(<String>[javaExecutable, '-version']);
diff --git a/packages/flutter_tools/lib/src/android/android_studio_validator.dart b/packages/flutter_tools/lib/src/android/android_studio_validator.dart
index d4c6ecc..3055870 100644
--- a/packages/flutter_tools/lib/src/android/android_studio_validator.dart
+++ b/packages/flutter_tools/lib/src/android/android_studio_validator.dart
@@ -7,7 +7,7 @@
import '../base/user_messages.dart';
import '../base/version.dart';
import '../doctor.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../intellij/intellij.dart';
import 'android_studio.dart';
@@ -71,7 +71,7 @@
Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[];
- final String cfgAndroidStudio = config.getValue('android-studio-dir') as String;
+ final String cfgAndroidStudio = globals.config.getValue('android-studio-dir') as String;
if (cfgAndroidStudio != null) {
messages.add(ValidationMessage.error(userMessages.androidStudioMissing(cfgAndroidStudio)));
}
diff --git a/packages/flutter_tools/lib/src/android/android_workflow.dart b/packages/flutter_tools/lib/src/android/android_workflow.dart
index c9c0a05..f8e437a 100644
--- a/packages/flutter_tools/lib/src/android/android_workflow.dart
+++ b/packages/flutter_tools/lib/src/android/android_workflow.dart
@@ -7,15 +7,13 @@
import '../base/common.dart';
import '../base/context.dart';
import '../base/io.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/user_messages.dart';
import '../base/utils.dart';
import '../base/version.dart';
import '../convert.dart';
import '../doctor.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'android_sdk.dart';
const int kAndroidSdkMinVersion = 28;
@@ -74,20 +72,20 @@
Future<bool> _checkJavaVersion(String javaBinary, List<ValidationMessage> messages) async {
_task = 'Checking Java status';
try {
- if (!processManager.canRun(javaBinary)) {
+ if (!globals.processManager.canRun(javaBinary)) {
messages.add(ValidationMessage.error(userMessages.androidCantRunJavaBinary(javaBinary)));
return false;
}
String javaVersionText;
try {
- printTrace('java -version');
- final ProcessResult result = await processManager.run(<String>[javaBinary, '-version']);
+ globals.printTrace('java -version');
+ final ProcessResult result = await globals.processManager.run(<String>[javaBinary, '-version']);
if (result.exitCode == 0) {
final List<String> versionLines = (result.stderr as String).split('\n');
javaVersionText = versionLines.length >= 2 ? versionLines[1] : versionLines[0];
}
} catch (error) {
- printTrace(error.toString());
+ globals.printTrace(error.toString());
}
if (javaVersionText == null || javaVersionText.isEmpty) {
// Could not determine the java version.
@@ -112,8 +110,8 @@
if (androidSdk == null) {
// No Android SDK found.
- if (platform.environment.containsKey(kAndroidHome)) {
- final String androidHomeDir = platform.environment[kAndroidHome];
+ if (globals.platform.environment.containsKey(kAndroidHome)) {
+ final String androidHomeDir = globals.platform.environment[kAndroidHome];
messages.add(ValidationMessage.error(userMessages.androidBadSdkDir(kAndroidHome, androidHomeDir)));
} else {
messages.add(ValidationMessage.error(userMessages.androidMissingSdkInstructions(kAndroidHome)));
@@ -149,12 +147,12 @@
messages.add(ValidationMessage.error(userMessages.androidMissingSdkInstructions(kAndroidHome)));
}
- if (platform.environment.containsKey(kAndroidHome)) {
- final String androidHomeDir = platform.environment[kAndroidHome];
+ if (globals.platform.environment.containsKey(kAndroidHome)) {
+ final String androidHomeDir = globals.platform.environment[kAndroidHome];
messages.add(ValidationMessage('$kAndroidHome = $androidHomeDir'));
}
- if (platform.environment.containsKey(kAndroidSdkRoot)) {
- final String androidSdkRoot = platform.environment[kAndroidSdkRoot];
+ if (globals.platform.environment.containsKey(kAndroidSdkRoot)) {
+ final String androidSdkRoot = globals.platform.environment[kAndroidSdkRoot];
messages.add(ValidationMessage('$kAndroidSdkRoot = $androidSdkRoot'));
}
@@ -229,18 +227,18 @@
if (javaBinary == null) {
return false;
}
- if (!processManager.canRun(javaBinary)) {
+ if (!globals.processManager.canRun(javaBinary)) {
return false;
}
String javaVersion;
try {
- final ProcessResult result = await processManager.run(<String>[javaBinary, '-version']);
+ final ProcessResult result = await globals.processManager.run(<String>[javaBinary, '-version']);
if (result.exitCode == 0) {
final List<String> versionLines = (result.stderr as String).split('\n');
javaVersion = versionLines.length >= 2 ? versionLines[1] : versionLines[0];
}
} catch (error) {
- printTrace(error.toString());
+ globals.printTrace(error.toString());
}
if (javaVersion == null) {
// Could not determine the java version.
@@ -295,7 +293,7 @@
await Future.wait<void>(<Future<void>>[output, errors]);
return status ?? LicensesAccepted.unknown;
} on ProcessException catch (e) {
- printTrace('Failed to run Android sdk manager: $e');
+ globals.printTrace('Failed to run Android sdk manager: $e');
return LicensesAccepted.unknown;
}
}
@@ -303,7 +301,7 @@
/// Run the Android SDK manager tool in order to accept SDK licenses.
static Future<bool> runLicenseManager() async {
if (androidSdk == null) {
- printStatus(userMessages.androidSdkShort);
+ globals.printStatus(userMessages.androidSdkShort);
return false;
}
@@ -345,6 +343,6 @@
static bool _canRunSdkManager() {
assert(androidSdk != null);
final String sdkManagerPath = androidSdk.sdkManagerPath;
- return processManager.canRun(sdkManagerPath);
+ return globals.processManager.canRun(sdkManagerPath);
}
}
diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart
index 23a1c47..676599a 100644
--- a/packages/flutter_tools/lib/src/android/gradle.dart
+++ b/packages/flutter_tools/lib/src/android/gradle.dart
@@ -20,7 +20,7 @@
import '../build_info.dart';
import '../cache.dart';
import '../flutter_manifest.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'android_sdk.dart';
@@ -107,12 +107,12 @@
/// Returns true if the current version of the Gradle plugin is supported.
bool _isSupportedVersion(AndroidProject project) {
final File plugin = project.hostAppGradleRoot.childFile(
- fs.path.join('buildSrc', 'src', 'main', 'groovy', 'FlutterPlugin.groovy'));
+ globals.fs.path.join('buildSrc', 'src', 'main', 'groovy', 'FlutterPlugin.groovy'));
if (plugin.existsSync()) {
return false;
}
final File appGradle = project.hostAppGradleRoot.childFile(
- fs.path.join('app', 'build.gradle'));
+ globals.fs.path.join('app', 'build.gradle'));
if (!appGradle.existsSync()) {
return false;
}
@@ -136,7 +136,7 @@
/// Runs `gradlew dependencies`, ensuring that dependencies are resolved and
/// potentially downloaded.
Future<void> checkGradleDependencies() async {
- final Status progress = logger.startProgress(
+ final Status progress = globals.logger.startProgress(
'Ensuring gradle dependencies are up to date...',
timeout: timeoutConfiguration.slowOperation,
);
@@ -168,15 +168,15 @@
}
final String currentFileContent = currentSettingsFile.readAsStringSync();
- final String newSettingsRelativeFile = fs.path.relative(newSettingsFile.path);
- final Status status = logger.startProgress('✏️ Creating `$newSettingsRelativeFile`...',
+ final String newSettingsRelativeFile = globals.fs.path.relative(newSettingsFile.path);
+ final Status status = globals.logger.startProgress('✏️ Creating `$newSettingsRelativeFile`...',
timeout: timeoutConfiguration.fastOperation);
- final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
- final File deprecatedFile = fs.file(fs.path.join(flutterRoot, 'packages','flutter_tools',
+ final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
+ final File deprecatedFile = globals.fs.file(globals.fs.path.join(flutterRoot, 'packages','flutter_tools',
'gradle', 'deprecated_settings.gradle'));
assert(deprecatedFile.existsSync());
- final String settingsAarContent = fs.file(fs.path.join(flutterRoot, 'packages','flutter_tools',
+ final String settingsAarContent = globals.fs.file(globals.fs.path.join(flutterRoot, 'packages','flutter_tools',
'gradle', 'settings_aar.gradle.tmpl')).readAsStringSync();
// Get the `settings.gradle` content variants that should be patched.
@@ -192,16 +192,16 @@
}
if (!exactMatch) {
status.cancel();
- printStatus('$warningMark Flutter tried to create the file `$newSettingsRelativeFile`, but failed.');
+ globals.printStatus('$warningMark Flutter tried to create the file `$newSettingsRelativeFile`, but failed.');
// Print how to manually update the file.
- printStatus(fs.file(fs.path.join(flutterRoot, 'packages','flutter_tools',
+ globals.printStatus(globals.fs.file(globals.fs.path.join(flutterRoot, 'packages','flutter_tools',
'gradle', 'manual_migration_settings.gradle.md')).readAsStringSync());
throwToolExit('Please create the file and run this command again.');
}
// Copy the new file.
newSettingsFile.writeAsStringSync(settingsAarContent);
status.stop();
- printStatus('$successMark `$newSettingsRelativeFile` created successfully.');
+ globals.printStatus('$successMark `$newSettingsRelativeFile` created successfully.');
}
/// Builds an app.
@@ -244,8 +244,8 @@
BuildEvent('app-using-android-x').send();
} else if (!usesAndroidX) {
BuildEvent('app-not-using-android-x').send();
- printStatus('$warningMark Your app isn\'t using AndroidX.', emphasis: true);
- printStatus(
+ globals.printStatus('$warningMark Your app isn\'t using AndroidX.', emphasis: true);
+ globals.printStatus(
'To avoid potential build failures, you can quickly migrate your app '
'by following the steps on https://goo.gl/CP92wY.',
indent: 4,
@@ -270,7 +270,7 @@
? getBundleTaskFor(buildInfo)
: getAssembleTaskFor(buildInfo);
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Running Gradle task \'$assembleTask\'...',
timeout: timeoutConfiguration.slowOperation,
multilineOutput: true,
@@ -279,18 +279,18 @@
final List<String> command = <String>[
gradleUtils.getExecutable(project),
];
- if (logger.isVerbose) {
+ if (globals.logger.isVerbose) {
command.add('-Pverbose=true');
} else {
command.add('-q');
}
- if (artifacts is LocalEngineArtifacts) {
- final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
+ if (globals.artifacts is LocalEngineArtifacts) {
+ final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final Directory localEngineRepo = _getLocalEngineRepo(
engineOutPath: localEngineArtifacts.engineOutPath,
androidBuildInfo: androidBuildInfo,
);
- printTrace(
+ globals.printTrace(
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
'Local Maven repo: ${localEngineRepo.path}'
);
@@ -448,8 +448,8 @@
? '' // Don't display the size when building a debug variant.
: ' (${getSizeAsMB(bundleFile.lengthSync())})';
- printStatus(
- '$successMark Built ${fs.path.relative(bundleFile.path)}$appSize.',
+ globals.printStatus(
+ '$successMark Built ${globals.fs.path.relative(bundleFile.path)}$appSize.',
color: TerminalColor.green,
);
return;
@@ -460,7 +460,7 @@
// Copy the first APK to app.apk, so `flutter run` can find it.
// TODO(egarciad): Handle multiple APKs.
apkFiles.first.copySync(apkDirectory.childFile('app.apk').path);
- printTrace('calculateSha: $apkDirectory/app.apk');
+ globals.printTrace('calculateSha: $apkDirectory/app.apk');
final File apkShaFile = apkDirectory.childFile('app.apk.sha1');
apkShaFile.writeAsStringSync(_calculateSha(apkFiles.first));
@@ -469,8 +469,8 @@
final String appSize = (buildInfo.mode == BuildMode.debug)
? '' // Don't display the size when building a debug variant.
: ' (${getSizeAsMB(apkFile.lengthSync())})';
- printStatus(
- '$successMark Built ${fs.path.relative(apkFile.path)}$appSize.',
+ globals.printStatus(
+ '$successMark Built ${globals.fs.path.relative(apkFile.path)}$appSize.',
color: TerminalColor.green,
);
}
@@ -501,14 +501,14 @@
}
final String aarTask = getAarTaskFor(androidBuildInfo.buildInfo);
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Running Gradle task \'$aarTask\'...',
timeout: timeoutConfiguration.slowOperation,
multilineOutput: true,
);
- final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
- final String initScript = fs.path.join(
+ final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
+ final String initScript = globals.fs.path.join(
flutterRoot,
'packages',
'flutter_tools',
@@ -533,13 +533,13 @@
.map(getPlatformNameForAndroidArch).join(',');
command.add('-Ptarget-platform=$targetPlatforms');
}
- if (artifacts is LocalEngineArtifacts) {
- final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
+ if (globals.artifacts is LocalEngineArtifacts) {
+ final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final Directory localEngineRepo = _getLocalEngineRepo(
engineOutPath: localEngineArtifacts.engineOutPath,
androidBuildInfo: androidBuildInfo,
);
- printTrace(
+ globals.printTrace(
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
'Local Maven repo: ${localEngineRepo.path}'
);
@@ -565,8 +565,8 @@
flutterUsage.sendTiming('build', 'gradle-aar', sw.elapsed);
if (result.exitCode != 0) {
- printStatus(result.stdout, wrap: false);
- printError(result.stderr, wrap: false);
+ globals.printStatus(result.stdout, wrap: false);
+ globals.printError(result.stderr, wrap: false);
throwToolExit(
'Gradle task $aarTask failed with exit code $exitCode.',
exitCode: exitCode,
@@ -574,15 +574,15 @@
}
final Directory repoDirectory = getRepoDirectory(outputDirectory);
if (!repoDirectory.existsSync()) {
- printStatus(result.stdout, wrap: false);
- printError(result.stderr, wrap: false);
+ globals.printStatus(result.stdout, wrap: false);
+ globals.printError(result.stderr, wrap: false);
throwToolExit(
'Gradle task $aarTask failed to produce $repoDirectory.',
exitCode: exitCode,
);
}
- printStatus(
- '$successMark Built ${fs.path.relative(repoDirectory.path)}.',
+ globals.printStatus(
+ '$successMark Built ${globals.fs.path.relative(repoDirectory.path)}.',
color: TerminalColor.green,
);
}
@@ -599,10 +599,10 @@
assert(repoDirectory != null);
buildNumber ??= '1.0';
- printStatus('''
+ globals.printStatus('''
-${terminal.bolden('Consuming the Module')}
- 1. Open ${fs.path.join('<host>', 'app', 'build.gradle')}
+${globals.terminal.bolden('Consuming the Module')}
+ 1. Open ${globals.fs.path.join('<host>', 'app', 'build.gradle')}
2. Ensure you have the repositories configured, otherwise add them:
repositories {
@@ -619,16 +619,16 @@
dependencies {''');
for (String buildMode in buildModes) {
- printStatus('''
+ globals.printStatus('''
${buildMode}Implementation '$androidPackage:flutter_$buildMode:$buildNumber''');
}
-printStatus('''
+ globals.printStatus('''
}
''');
if (buildModes.contains('profile')) {
- printStatus('''
+ globals.printStatus('''
4. Add the `profile` build type:
@@ -642,7 +642,7 @@
''');
}
-printStatus('To learn more, visit https://flutter.dev/go/build-aar''');
+ globals.printStatus('To learn more, visit https://flutter.dev/go/build-aar''');
}
String _hex(List<int> bytes) {
@@ -656,11 +656,11 @@
String _calculateSha(File file) {
final Stopwatch sw = Stopwatch()..start();
final List<int> bytes = file.readAsBytesSync();
- printTrace('calculateSha: reading file took ${sw.elapsedMilliseconds}us');
+ globals.printTrace('calculateSha: reading file took ${sw.elapsedMilliseconds}us');
flutterUsage.sendTiming('build', 'apk-sha-read', sw.elapsed);
sw.reset();
final String sha = _hex(sha1.convert(bytes).bytes);
- printTrace('calculateSha: computing sha took ${sw.elapsedMilliseconds}us');
+ globals.printTrace('calculateSha: computing sha took ${sw.elapsedMilliseconds}us');
flutterUsage.sendTiming('build', 'apk-sha-calc', sw.elapsed);
return sha;
}
@@ -712,16 +712,16 @@
if (pluginParts.length != 2) {
continue;
}
- final Directory pluginDirectory = fs.directory(pluginParts.last);
+ final Directory pluginDirectory = globals.fs.directory(pluginParts.last);
assert(pluginDirectory.existsSync());
final String pluginName = pluginParts.first;
final File buildGradleFile = pluginDirectory.childDirectory('android').childFile('build.gradle');
if (!buildGradleFile.existsSync()) {
- printTrace('Skipping plugin $pluginName since it doesn\'t have a android/build.gradle file');
+ globals.printTrace('Skipping plugin $pluginName since it doesn\'t have a android/build.gradle file');
continue;
}
- logger.printStatus('Building plugin $pluginName...');
+ globals.logger.printStatus('Building plugin $pluginName...');
try {
await buildGradleAar(
project: FlutterProject.fromDirectory(pluginDirectory),
@@ -848,11 +848,11 @@
}
void _createSymlink(String targetPath, String linkPath) {
- final File targetFile = fs.file(targetPath);
+ final File targetFile = globals.fs.file(targetPath);
if (!targetFile.existsSync()) {
throwToolExit('The file $targetPath wasn\'t found in the local engine out directory.');
}
- final File linkFile = fs.file(linkPath);
+ final File linkFile = globals.fs.file(linkPath);
final Link symlink = linkFile.parent.childLink(linkFile.basename);
try {
symlink.createSync(targetPath, recursive: true);
@@ -864,7 +864,7 @@
}
String _getLocalArtifactVersion(String pomPath) {
- final File pomFile = fs.file(pomPath);
+ final File pomFile = globals.fs.file(pomPath);
if (!pomFile.existsSync()) {
throwToolExit('The file $pomPath wasn\'t found in the local engine out directory.');
}
@@ -903,7 +903,7 @@
assert(androidBuildInfo != null);
final String abi = getEnumName(androidBuildInfo.targetArchs.first);
- final Directory localEngineRepo = fs.systemTempDirectory
+ final Directory localEngineRepo = globals.fs.systemTempDirectory
.createTempSync('flutter_tool_local_engine_repo.');
// Remove the local engine repo before the tool exits.
@@ -914,7 +914,7 @@
final String buildMode = androidBuildInfo.buildInfo.modeName;
final String artifactVersion = _getLocalArtifactVersion(
- fs.path.join(
+ globals.fs.path.join(
engineOutPath,
'flutter_embedding_$buildMode.pom',
)
@@ -922,11 +922,11 @@
for (String artifact in const <String>['pom', 'jar']) {
// The Android embedding artifacts.
_createSymlink(
- fs.path.join(
+ globals.fs.path.join(
engineOutPath,
'flutter_embedding_$buildMode.$artifact',
),
- fs.path.join(
+ globals.fs.path.join(
localEngineRepo.path,
'io',
'flutter',
@@ -937,11 +937,11 @@
);
// The engine artifacts (libflutter.so).
_createSymlink(
- fs.path.join(
+ globals.fs.path.join(
engineOutPath,
'${abi}_$buildMode.$artifact',
),
- fs.path.join(
+ globals.fs.path.join(
localEngineRepo.path,
'io',
'flutter',
diff --git a/packages/flutter_tools/lib/src/android/gradle_errors.dart b/packages/flutter_tools/lib/src/android/gradle_errors.dart
index 4b8fc2c..be2c00a 100644
--- a/packages/flutter_tools/lib/src/android/gradle_errors.dart
+++ b/packages/flutter_tools/lib/src/android/gradle_errors.dart
@@ -6,7 +6,7 @@
import '../base/process.dart';
import '../base/terminal.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'gradle_utils.dart';
@@ -85,8 +85,8 @@
bool usesAndroidX,
bool shouldBuildPluginAsAar,
}) async {
- printStatus('$warningMark Gradle does not have execution permission.', emphasis: true);
- printStatus(
+ globals.printStatus('$warningMark Gradle does not have execution permission.', emphasis: true);
+ globals.printStatus(
'You should change the ownership of the project directory to your user, '
'or move the project to a directory with execute permissions.',
indent: 4
@@ -115,7 +115,7 @@
bool usesAndroidX,
bool shouldBuildPluginAsAar,
}) async {
- printError(
+ globals.printError(
'$warningMark Gradle threw an error while trying to update itself. '
'Retrying the update...'
);
@@ -136,9 +136,9 @@
bool usesAndroidX,
bool shouldBuildPluginAsAar,
}) async {
- printStatus('$warningMark The shrinker may have failed to optimize the Java bytecode.', emphasis: true);
- printStatus('To disable the shrinker, pass the `--no-shrink` flag to this command.', indent: 4);
- printStatus('To learn more, see: https://developer.android.com/studio/build/shrink-code', indent: 4);
+ globals.printStatus('$warningMark The shrinker may have failed to optimize the Java bytecode.', emphasis: true);
+ globals.printStatus('To disable the shrinker, pass the `--no-shrink` flag to this command.', indent: 4);
+ globals.printStatus('To learn more, see: https://developer.android.com/studio/build/shrink-code', indent: 4);
return GradleBuildStatus.exit;
},
eventLabel: 'r8',
@@ -187,7 +187,7 @@
if (hasPlugins && !usesAndroidX) {
// If the app isn't using AndroidX, then the app is likely using
// a plugin already migrated to AndroidX.
- printStatus(
+ globals.printStatus(
'AndroidX incompatibilities may have caused this build to fail. '
'Please migrate your app to AndroidX. See https://goo.gl/CP92wY.'
);
@@ -206,7 +206,7 @@
).send();
}
if (hasPlugins && usesAndroidX && !shouldBuildPluginAsAar) {
- printStatus(
+ globals.printStatus(
'The built failed likely due to AndroidX incompatibilities in a plugin. '
'The tool is about to try using Jetfier to solve the incompatibility.'
);
@@ -242,7 +242,7 @@
final RegExp licenseFailure = RegExp(licenseNotAcceptedMatcher, multiLine: true);
assert(licenseFailure != null);
final Match licenseMatch = licenseFailure.firstMatch(line);
- printStatus(
+ globals.printStatus(
'$warningMark Unable to download needed Android SDK components, as the '
'following licenses have not been accepted:\n'
'${licenseMatch.group(1)}\n\n'
@@ -303,18 +303,18 @@
}
}
}
- printStatus(
+ globals.printStatus(
'\n$warningMark Gradle project does not define a task suitable '
'for the requested build.'
);
if (productFlavors.isEmpty) {
- printStatus(
+ globals.printStatus(
'The android/app/build.gradle file does not define '
'any custom product flavors. '
'You cannot use the --flavor option.'
);
} else {
- printStatus(
+ globals.printStatus(
'The android/app/build.gradle file defines product '
'flavors: ${productFlavors.join(', ')} '
'You must specify a --flavor option to select one of them.'
diff --git a/packages/flutter_tools/lib/src/android/gradle_utils.dart b/packages/flutter_tools/lib/src/android/gradle_utils.dart
index 7802358..8a97665 100644
--- a/packages/flutter_tools/lib/src/android/gradle_utils.dart
+++ b/packages/flutter_tools/lib/src/android/gradle_utils.dart
@@ -9,13 +9,12 @@
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/terminal.dart';
import '../base/utils.dart';
import '../base/version.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'android_sdk.dart';
@@ -23,7 +22,7 @@
/// The environment variables needed to run Gradle.
Map<String, String> get gradleEnvironment {
- final Map<String, String> environment = Map<String, String>.from(platform.environment);
+ final Map<String, String> environment = Map<String, String>.from(globals.platform.environment);
if (javaPath != null) {
// Use java bundled with Android Studio.
environment['JAVA_HOME'] = javaPath;
@@ -50,10 +49,10 @@
gradleUtils.injectGradleWrapperIfNeeded(androidDir);
final File gradle = androidDir.childFile(
- platform.isWindows ? 'gradlew.bat' : 'gradlew',
+ globals.platform.isWindows ? 'gradlew.bat' : 'gradlew',
);
if (gradle.existsSync()) {
- printTrace('Using gradle from ${gradle.absolute.path}.');
+ globals.printTrace('Using gradle from ${gradle.absolute.path}.');
// If the Gradle executable doesn't have execute permission,
// then attempt to set it.
_giveExecutePermissionIfNeeded(gradle);
@@ -79,10 +78,10 @@
}
final String propertiesContent = gradleProperties.readAsStringSync();
if (propertiesContent.contains('android.enableR8')) {
- printTrace('gradle.properties already sets `android.enableR8`');
+ globals.printTrace('gradle.properties already sets `android.enableR8`');
return;
}
- printTrace('set `android.enableR8=true` in gradle.properties');
+ globals.printTrace('set `android.enableR8=true` in gradle.properties');
try {
if (propertiesContent.isNotEmpty && !propertiesContent.endsWith('\n')) {
// Add a new line if the file doesn't end with a new line.
@@ -100,7 +99,7 @@
/// Injects the Gradle wrapper files if any of these files don't exist in [directory].
void injectGradleWrapperIfNeeded(Directory directory) {
copyDirectorySync(
- cache.getArtifactDirectory('gradle_wrapper'),
+ globals.cache.getArtifactDirectory('gradle_wrapper'),
directory,
shouldCopyFile: (File sourceFile, File destinationFile) {
// Don't override the existing files in the project.
@@ -114,7 +113,7 @@
);
// Add the `gradle-wrapper.properties` file if it doesn't exist.
final File propertiesFile = directory.childFile(
- fs.path.join('gradle', 'wrapper', 'gradle-wrapper.properties'));
+ globals.fs.path.join('gradle', 'wrapper', 'gradle-wrapper.properties'));
if (!propertiesFile.existsSync()) {
final String gradleVersion = getGradleVersionForAndroidPlugin(directory);
propertiesFile.writeAsStringSync('''
@@ -157,7 +156,7 @@
bool _hasAllExecutableFlagSet(File executable) {
final FileStat stat = executable.statSync();
assert(stat.type != FileSystemEntityType.notFound);
- printTrace('${executable.path} mode: ${stat.mode} ${stat.modeString()}.');
+ globals.printTrace('${executable.path} mode: ${stat.mode} ${stat.modeString()}.');
return stat.mode & _kExecPermissionMask == _kExecPermissionMask;
}
@@ -165,14 +164,14 @@
bool _hasAnyExecutableFlagSet(File executable) {
final FileStat stat = executable.statSync();
assert(stat.type != FileSystemEntityType.notFound);
- printTrace('${executable.path} mode: ${stat.mode} ${stat.modeString()}.');
+ globals.printTrace('${executable.path} mode: ${stat.mode} ${stat.modeString()}.');
return stat.mode & _kExecPermissionMask != 0;
}
/// Gives execute permission to [executable] if it doesn't have it already.
void _giveExecutePermissionIfNeeded(File executable) {
if (!_hasAllExecutableFlagSet(executable)) {
- printTrace('Trying to give execute permission to ${executable.path}.');
+ globals.printTrace('Trying to give execute permission to ${executable.path}.');
os.makeExecutable(executable);
}
}
diff --git a/packages/flutter_tools/lib/src/aot.dart b/packages/flutter_tools/lib/src/aot.dart
index 6803581..bbf4c0e 100644
--- a/packages/flutter_tools/lib/src/aot.dart
+++ b/packages/flutter_tools/lib/src/aot.dart
@@ -8,7 +8,6 @@
import 'base/build.dart';
import 'base/common.dart';
-import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart';
import 'base/process.dart';
@@ -16,7 +15,7 @@
import 'build_system/build_system.dart';
import 'build_system/targets/dart.dart';
import 'dart/package_map.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'ios/bitcode.dart';
import 'project.dart';
@@ -61,8 +60,8 @@
Status status;
if (!quiet) {
- final String typeName = artifacts.getEngineType(platform, buildMode);
- status = logger.startProgress(
+ final String typeName = globals.artifacts.getEngineType(platform, buildMode);
+ status = globals.logger.startProgress(
'Building AOT snapshot in ${getFriendlyModeName(buildMode)} mode ($typeName)...',
timeout: timeoutConfiguration.slowOperation,
);
@@ -91,7 +90,7 @@
// Determine which iOS architectures to build for.
final Map<DarwinArch, String> iosBuilds = <DarwinArch, String>{};
for (DarwinArch arch in iosBuildArchs) {
- iosBuilds[arch] = fs.path.join(outputPath, getNameForDarwinArch(arch));
+ iosBuilds[arch] = globals.fs.path.join(outputPath, getNameForDarwinArch(arch));
}
// Generate AOT snapshot and compile to arch-specific App.framework.
@@ -115,14 +114,14 @@
// Merge arch-specific App.frameworks into a multi-arch App.framework.
if ((await Future.wait<int>(exitCodes.values)).every((int buildExitCode) => buildExitCode == 0)) {
final Iterable<String> dylibs = iosBuilds.values.map<String>(
- (String outputDir) => fs.path.join(outputDir, 'App.framework', 'App'));
- fs.directory(fs.path.join(outputPath, 'App.framework'))..createSync();
+ (String outputDir) => globals.fs.path.join(outputDir, 'App.framework', 'App'));
+ globals.fs.directory(globals.fs.path.join(outputPath, 'App.framework'))..createSync();
await processUtils.run(
<String>[
'lipo',
...dylibs,
'-create',
- '-output', fs.path.join(outputPath, 'App.framework', 'App'),
+ '-output', globals.fs.path.join(outputPath, 'App.framework', 'App'),
],
throwOnError: true,
);
@@ -130,7 +129,7 @@
status?.cancel();
exitCodes.forEach((DarwinArch iosArch, Future<int> exitCodeFuture) async {
final int buildExitCode = await exitCodeFuture;
- printError('Snapshotting ($iosArch) exited with non-zero exit code: $buildExitCode');
+ globals.printError('Snapshotting ($iosArch) exited with non-zero exit code: $buildExitCode');
});
}
} else {
@@ -152,7 +151,7 @@
} on ProcessException catch (error) {
// Catch the String exceptions thrown from the `runSync` methods below.
status?.cancel();
- printError(error.toString());
+ globals.printError(error.toString());
return;
}
status?.stop();
@@ -161,11 +160,11 @@
throwToolExit(null);
}
- final String builtMessage = 'Built to $outputPath${fs.path.separator}.';
+ final String builtMessage = 'Built to $outputPath${globals.fs.path.separator}.';
if (quiet) {
- printTrace(builtMessage);
+ globals.printTrace(builtMessage);
} else {
- printStatus(builtMessage);
+ globals.printStatus(builtMessage);
}
return;
}
@@ -199,8 +198,8 @@
}) async {
Status status;
if (!quiet) {
- final String typeName = artifacts.getEngineType(targetPlatform, buildMode);
- status = logger.startProgress(
+ final String typeName = globals.artifacts.getEngineType(targetPlatform, buildMode);
+ status = globals.logger.startProgress(
'Building AOT snapshot in ${getFriendlyModeName(buildMode)} mode ($typeName)...',
timeout: timeoutConfiguration.slowOperation,
);
@@ -213,7 +212,7 @@
final BuildResult result = await buildSystem.build(target, Environment(
projectDir: flutterProject.directory,
- outputDir: fs.directory(outputDir),
+ outputDir: globals.fs.directory(outputDir),
buildDir: flutterProject.directory
.childDirectory('.dart_tool')
.childDirectory('flutter_build'),
@@ -226,7 +225,7 @@
status?.stop();
if (!result.success) {
for (ExceptionMeasurement measurement in result.exceptions.values) {
- printError('Target ${measurement.target} failed: ${measurement.exception}',
+ globals.printError('Target ${measurement.target} failed: ${measurement.exception}',
stackTrace: measurement.fatal
? measurement.stackTrace
: null,
@@ -234,11 +233,11 @@
}
throwToolExit('Failed to build aot.');
}
- final String builtMessage = 'Built to $outputDir${fs.path.separator}.';
+ final String builtMessage = 'Built to $outputDir${globals.fs.path.separator}.';
if (quiet) {
- printTrace(builtMessage);
+ globals.printTrace(builtMessage);
} else {
- printStatus(builtMessage);
+ globals.printStatus(builtMessage);
}
}
}
diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart
index 51af55d..27625a3 100644
--- a/packages/flutter_tools/lib/src/application_package.dart
+++ b/packages/flutter_tools/lib/src/application_package.dart
@@ -19,7 +19,7 @@
import 'base/user_messages.dart';
import 'build_info.dart';
import 'fuchsia/application_package.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'ios/plist_parser.dart';
import 'linux/application_package.dart';
import 'macos/application_package.dart';
@@ -112,7 +112,7 @@
factory AndroidApk.fromApk(File apk) {
final String aaptPath = androidSdk?.latestVersion?.aaptPath;
if (aaptPath == null) {
- printError(userMessages.aaptNotFound);
+ globals.printError(userMessages.aaptNotFound);
return null;
}
@@ -129,19 +129,19 @@
throwOnError: true,
).stdout.trim();
} on ProcessException catch (error) {
- printError('Failed to extract manifest from APK: $error.');
+ globals.printError('Failed to extract manifest from APK: $error.');
return null;
}
final ApkManifestData data = ApkManifestData.parseFromXmlDump(apptStdout);
if (data == null) {
- printError('Unable to read manifest info from ${apk.path}.');
+ globals.printError('Unable to read manifest info from ${apk.path}.');
return null;
}
if (data.packageName == null || data.launchableActivityName == null) {
- printError('Unable to read manifest info from ${apk.path}.');
+ globals.printError('Unable to read manifest info from ${apk.path}.');
return null;
}
@@ -177,14 +177,14 @@
// command will grab a new AndroidApk after building, to get the updated
// IDs.
} else {
- apkFile = fs.file(fs.path.join(getAndroidBuildDirectory(), 'app.apk'));
+ apkFile = globals.fs.file(globals.fs.path.join(getAndroidBuildDirectory(), 'app.apk'));
}
final File manifest = androidProject.appManifestFile;
if (!manifest.existsSync()) {
- printError('AndroidManifest.xml could not be found.');
- printError('Please check ${manifest.path} for errors.');
+ globals.printError('AndroidManifest.xml could not be found.');
+ globals.printError('Please check ${manifest.path} for errors.');
return null;
}
@@ -195,19 +195,19 @@
} on xml.XmlParserException catch (exception) {
String manifestLocation;
if (androidProject.isUsingGradle) {
- manifestLocation = fs.path.join(androidProject.hostAppGradleRoot.path, 'app', 'src', 'main', 'AndroidManifest.xml');
+ manifestLocation = globals.fs.path.join(androidProject.hostAppGradleRoot.path, 'app', 'src', 'main', 'AndroidManifest.xml');
} else {
- manifestLocation = fs.path.join(androidProject.hostAppGradleRoot.path, 'AndroidManifest.xml');
+ manifestLocation = globals.fs.path.join(androidProject.hostAppGradleRoot.path, 'AndroidManifest.xml');
}
- printError('AndroidManifest.xml is not a valid XML document.');
- printError('Please check $manifestLocation for errors.');
+ globals.printError('AndroidManifest.xml is not a valid XML document.');
+ globals.printError('Please check $manifestLocation for errors.');
throwToolExit('XML Parser error message: ${exception.toString()}');
}
final Iterable<xml.XmlElement> manifests = document.findElements('manifest');
if (manifests.isEmpty) {
- printError('AndroidManifest.xml has no manifest element.');
- printError('Please check ${manifest.path} for errors.');
+ globals.printError('AndroidManifest.xml has no manifest element.');
+ globals.printError('Please check ${manifest.path} for errors.');
return null;
}
final String packageId = manifests.first.getAttribute('package');
@@ -243,8 +243,8 @@
}
if (packageId == null || launchActivity == null) {
- printError('package identifier or launch activity not found.');
- printError('Please check ${manifest.path} for errors.');
+ globals.printError('package identifier or launch activity not found.');
+ globals.printError('Please check ${manifest.path} for errors.');
return null;
}
@@ -271,46 +271,46 @@
/// Creates a new IOSApp from an existing app bundle or IPA.
factory IOSApp.fromPrebuiltApp(FileSystemEntity applicationBinary) {
- final FileSystemEntityType entityType = fs.typeSync(applicationBinary.path);
+ final FileSystemEntityType entityType = globals.fs.typeSync(applicationBinary.path);
if (entityType == FileSystemEntityType.notFound) {
- printError(
+ globals.printError(
'File "${applicationBinary.path}" does not exist. Use an app bundle or an ipa.');
return null;
}
Directory bundleDir;
if (entityType == FileSystemEntityType.directory) {
- final Directory directory = fs.directory(applicationBinary);
+ final Directory directory = globals.fs.directory(applicationBinary);
if (!_isBundleDirectory(directory)) {
- printError('Folder "${applicationBinary.path}" is not an app bundle.');
+ globals.printError('Folder "${applicationBinary.path}" is not an app bundle.');
return null;
}
- bundleDir = fs.directory(applicationBinary);
+ bundleDir = globals.fs.directory(applicationBinary);
} else {
// Try to unpack as an ipa.
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_app.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_app.');
addShutdownHook(() async {
await tempDir.delete(recursive: true);
}, ShutdownStage.STILL_RECORDING);
- os.unzip(fs.file(applicationBinary), tempDir);
- final Directory payloadDir = fs.directory(
- fs.path.join(tempDir.path, 'Payload'),
+ os.unzip(globals.fs.file(applicationBinary), tempDir);
+ final Directory payloadDir = globals.fs.directory(
+ globals.fs.path.join(tempDir.path, 'Payload'),
);
if (!payloadDir.existsSync()) {
- printError(
+ globals.printError(
'Invalid prebuilt iOS ipa. Does not contain a "Payload" directory.');
return null;
}
try {
bundleDir = payloadDir.listSync().whereType<Directory>().singleWhere(_isBundleDirectory);
} on StateError {
- printError(
+ globals.printError(
'Invalid prebuilt iOS ipa. Does not contain a single app bundle.');
return null;
}
}
- final String plistPath = fs.path.join(bundleDir.path, 'Info.plist');
- if (!fs.file(plistPath).existsSync()) {
- printError('Invalid prebuilt iOS app. Does not contain Info.plist.');
+ final String plistPath = globals.fs.path.join(bundleDir.path, 'Info.plist');
+ if (!globals.fs.file(plistPath).existsSync()) {
+ globals.printError('Invalid prebuilt iOS app. Does not contain Info.plist.');
return null;
}
final String id = PlistParser.instance.getValueFromFile(
@@ -318,13 +318,13 @@
PlistParser.kCFBundleIdentifierKey,
);
if (id == null) {
- printError('Invalid prebuilt iOS app. Info.plist does not contain bundle identifier');
+ globals.printError('Invalid prebuilt iOS app. Info.plist does not contain bundle identifier');
return null;
}
return PrebuiltIOSApp(
bundleDir: bundleDir,
- bundleName: fs.path.basename(bundleDir.path),
+ bundleName: globals.fs.path.basename(bundleDir.path),
projectBundleId: id,
);
}
@@ -339,11 +339,11 @@
return null;
}
if (!project.xcodeProject.existsSync()) {
- printError('Expected ios/Runner.xcodeproj but this file is missing.');
+ globals.printError('Expected ios/Runner.xcodeproj but this file is missing.');
return null;
}
if (!project.xcodeProjectInfoFile.existsSync()) {
- printError('Expected ios/Runner.xcodeproj/project.pbxproj but this file is missing.');
+ globals.printError('Expected ios/Runner.xcodeproj/project.pbxproj but this file is missing.');
return null;
}
return BuildableIOSApp.fromProject(project);
@@ -378,7 +378,7 @@
String get deviceBundlePath => _buildAppPath('iphoneos');
String _buildAppPath(String type) {
- return fs.path.join(getIosBuildDirectory(), type, name);
+ return globals.fs.path.join(getIosBuildDirectory(), type, name);
}
}
@@ -598,7 +598,7 @@
final String packageName = package.value.substring(1, package.value.indexOf('" '));
if (launchActivity == null) {
- printError('Error running $packageName. Default activity not found');
+ globals.printError('Error running $packageName. Default activity not found');
return null;
}
@@ -610,16 +610,16 @@
// Example format: (type 0x10)0x1
final _Attribute versionCodeAttr = manifest.firstAttribute('android:versionCode');
if (versionCodeAttr == null) {
- printError('Error running $packageName. Manifest versionCode not found');
+ globals.printError('Error running $packageName. Manifest versionCode not found');
return null;
}
if (!versionCodeAttr.value.startsWith('(type 0x10)')) {
- printError('Error running $packageName. Manifest versionCode invalid');
+ globals.printError('Error running $packageName. Manifest versionCode invalid');
return null;
}
final int versionCode = int.tryParse(versionCodeAttr.value.substring(11));
if (versionCode == null) {
- printError('Error running $packageName. Manifest versionCode invalid');
+ globals.printError('Error running $packageName. Manifest versionCode invalid');
return null;
}
diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart
index 5f11a8c..60f6ef6 100644
--- a/packages/flutter_tools/lib/src/artifacts.dart
+++ b/packages/flutter_tools/lib/src/artifacts.dart
@@ -4,14 +4,11 @@
import 'package:meta/meta.dart';
-import 'base/context.dart';
import 'base/file_system.dart';
-import 'base/platform.dart';
-import 'base/process_manager.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'dart/sdk.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
enum Artifact {
/// The tool which compiles a dart kernel file into native code.
@@ -158,8 +155,6 @@
// Manages the engine artifacts of Flutter.
abstract class Artifacts {
- static Artifacts get instance => context.get<Artifacts>();
-
static LocalEngineArtifacts getLocalEngine(String engineSrcPath, EngineBuildPaths engineBuildPaths) {
return LocalEngineArtifacts(engineSrcPath, engineBuildPaths.targetEngine, engineBuildPaths.hostEngine);
}
@@ -173,13 +168,13 @@
}
TargetPlatform get _currentHostPlatform {
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
return TargetPlatform.darwin_x64;
}
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
return TargetPlatform.linux_x64;
}
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
return TargetPlatform.windows_x64;
}
throw UnimplementedError('Host OS not supported.');
@@ -214,7 +209,7 @@
@override
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) {
- return fs.path.basename(_getEngineArtifactsPath(platform, mode));
+ return globals.fs.path.basename(_getEngineArtifactsPath(platform, mode));
}
String _getDarwinArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
@@ -222,7 +217,7 @@
// and not the gen_snapshot for darwin as a target platform.
if (platform != null && artifact == Artifact.genSnapshot) {
final String engineDir = _getEngineArtifactsPath(platform, mode);
- return fs.path.join(engineDir, _artifactToFileName(artifact));
+ return globals.fs.path.join(engineDir, _artifactToFileName(artifact));
}
return _getHostArtifactPath(artifact, platform ?? _currentHostPlatform, mode);
}
@@ -232,11 +227,11 @@
switch (artifact) {
case Artifact.frontendServerSnapshotForEngineDartSdk:
assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.');
- return fs.path.join(engineDir, _artifactToFileName(artifact));
+ return globals.fs.path.join(engineDir, _artifactToFileName(artifact));
case Artifact.genSnapshot:
assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.');
final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform());
- return fs.path.join(engineDir, hostPlatform, _artifactToFileName(artifact));
+ return globals.fs.path.join(engineDir, hostPlatform, _artifactToFileName(artifact));
default:
return _getHostArtifactPath(artifact, platform, mode);
}
@@ -250,31 +245,31 @@
case Artifact.frontendServerSnapshotForEngineDartSdk:
final String artifactFileName = _artifactToFileName(artifact);
final String engineDir = _getEngineArtifactsPath(platform, mode);
- return fs.path.join(engineDir, artifactFileName);
+ return globals.fs.path.join(engineDir, artifactFileName);
case Artifact.ideviceId:
case Artifact.ideviceinfo:
case Artifact.idevicescreenshot:
case Artifact.idevicesyslog:
case Artifact.idevicename:
final String artifactFileName = _artifactToFileName(artifact);
- return cache.getArtifactDirectory('libimobiledevice').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('libimobiledevice').childFile(artifactFileName).path;
case Artifact.iosDeploy:
final String artifactFileName = _artifactToFileName(artifact);
- return cache.getArtifactDirectory('ios-deploy').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('ios-deploy').childFile(artifactFileName).path;
case Artifact.ideviceinstaller:
final String artifactFileName = _artifactToFileName(artifact);
- return cache.getArtifactDirectory('ideviceinstaller').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('ideviceinstaller').childFile(artifactFileName).path;
case Artifact.iproxy:
final String artifactFileName = _artifactToFileName(artifact);
- return cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName).path;
default:
return _getHostArtifactPath(artifact, platform, mode);
}
}
String _getFuchsiaArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
- final String root = fs.path.join(
- cache.getArtifactDirectory('flutter_runner').path,
+ final String root = globals.fs.path.join(
+ globals.cache.getArtifactDirectory('flutter_runner').path,
'flutter',
fuchsiaArchForTargetPlatform(platform),
mode.isRelease ? 'release' : mode.toString(),
@@ -283,32 +278,32 @@
switch (artifact) {
case Artifact.genSnapshot:
final String genSnapshot = mode.isRelease ? 'gen_snapshot_product' : 'gen_snapshot';
- return fs.path.join(root, runtime, 'dart_binaries', genSnapshot);
+ return globals.fs.path.join(root, runtime, 'dart_binaries', genSnapshot);
case Artifact.flutterPatchedSdkPath:
const String artifactFileName = 'flutter_runner_patched_sdk';
- return fs.path.join(root, runtime, artifactFileName);
+ return globals.fs.path.join(root, runtime, artifactFileName);
case Artifact.platformKernelDill:
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
- return fs.path.join(root, runtime, 'flutter_runner_patched_sdk', artifactFileName);
+ return globals.fs.path.join(root, runtime, 'flutter_runner_patched_sdk', artifactFileName);
case Artifact.fuchsiaKernelCompiler:
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
- return fs.path.join(root, runtime, 'dart_binaries', artifactFileName);
+ return globals.fs.path.join(root, runtime, 'dart_binaries', artifactFileName);
case Artifact.fuchsiaFlutterRunner:
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
- return fs.path.join(root, runtime, artifactFileName);
+ return globals.fs.path.join(root, runtime, artifactFileName);
default:
return _getHostArtifactPath(artifact, platform, mode);
}
}
String _getFlutterPatchedSdkPath(BuildMode mode) {
- final String engineArtifactsPath = cache.getArtifactDirectory('engine').path;
- return fs.path.join(engineArtifactsPath, 'common',
+ final String engineArtifactsPath = globals.cache.getArtifactDirectory('engine').path;
+ return globals.fs.path.join(engineArtifactsPath, 'common',
mode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk');
}
String _getFlutterWebSdkPath() {
- return cache.getWebSdkDirectory().path;
+ return globals.cache.getWebSdkDirectory().path;
}
String _getHostArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) {
@@ -322,29 +317,29 @@
case Artifact.vmSnapshotData:
case Artifact.isolateSnapshotData:
case Artifact.frontendServerSnapshotForEngineDartSdk:
- final String engineArtifactsPath = cache.getArtifactDirectory('engine').path;
+ final String engineArtifactsPath = globals.cache.getArtifactDirectory('engine').path;
final String platformDirName = getNameForTargetPlatform(platform);
- return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
+ return globals.fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
case Artifact.engineDartSdkPath:
return dartSdkPath;
case Artifact.engineDartBinary:
- return fs.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact, platform));
+ return globals.fs.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact, platform));
case Artifact.platformKernelDill:
- return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact));
+ return globals.fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact));
case Artifact.platformLibrariesJson:
- return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact));
+ return globals.fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath:
return _getFlutterPatchedSdkPath(mode);
case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath();
case Artifact.webPlatformKernelDill:
- return fs.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact));
+ return globals.fs.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact));
case Artifact.dart2jsSnapshot:
- return fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
+ return globals.fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
case Artifact.dartdevcSnapshot:
- return fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
+ return globals.fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
case Artifact.kernelWorkerSnapshot:
- return fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
+ return globals.fs.path.join(dartSdkPath, 'bin', 'snapshots', _artifactToFileName(artifact));
case Artifact.flutterMacOSFramework:
case Artifact.linuxDesktopPath:
case Artifact.windowsDesktopPath:
@@ -356,11 +351,11 @@
if (mode == BuildMode.profile || mode == BuildMode.release) {
platformDirName = '$platformDirName-${getNameForBuildMode(mode)}';
}
- final String engineArtifactsPath = cache.getArtifactDirectory('engine').path;
- return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
+ final String engineArtifactsPath = globals.cache.getArtifactDirectory('engine').path;
+ return globals.fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact, platform, mode));
case Artifact.skyEnginePath:
- final Directory dartPackageDirectory = cache.getCacheDir('pkg');
- return fs.path.join(dartPackageDirectory.path, _artifactToFileName(artifact));
+ final Directory dartPackageDirectory = globals.cache.getCacheDir('pkg');
+ return globals.fs.path.join(dartPackageDirectory.path, _artifactToFileName(artifact));
default:
assert(false, 'Artifact $artifact not available for platform $platform.');
return null;
@@ -368,7 +363,7 @@
}
String _getEngineArtifactsPath(TargetPlatform platform, [ BuildMode mode ]) {
- final String engineDir = cache.getArtifactDirectory('engine').path;
+ final String engineDir = globals.cache.getArtifactDirectory('engine').path;
final String platformName = getNameForTargetPlatform(platform);
switch (platform) {
case TargetPlatform.linux_x64:
@@ -378,16 +373,16 @@
// under a separate directory from the host artifacts.
// https://github.com/flutter/flutter/issues/38935
if (mode == BuildMode.debug || mode == null) {
- return fs.path.join(engineDir, platformName);
+ return globals.fs.path.join(engineDir, platformName);
}
final String suffix = mode != BuildMode.debug ? '-${snakeCase(getModeName(mode), '-')}' : '';
- return fs.path.join(engineDir, platformName + suffix);
+ return globals.fs.path.join(engineDir, platformName + suffix);
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
assert(mode == null, 'Platform $platform does not support different build modes.');
- return fs.path.join(engineDir, platformName);
+ return globals.fs.path.join(engineDir, platformName);
case TargetPlatform.ios:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
@@ -395,7 +390,7 @@
case TargetPlatform.android_x86:
assert(mode != null, 'Need to specify a build mode for platform $platform.');
final String suffix = mode != BuildMode.debug ? '-${snakeCase(getModeName(mode), '-')}' : '';
- return fs.path.join(engineDir, platformName + suffix);
+ return globals.fs.path.join(engineDir, platformName + suffix);
case TargetPlatform.android:
assert(false, 'cannot use TargetPlatform.android to look up artifacts');
return null;
@@ -419,79 +414,79 @@
final String artifactFileName = _artifactToFileName(artifact, platform, mode);
switch (artifact) {
case Artifact.snapshotDart:
- return fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', artifactFileName);
+ return globals.fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', artifactFileName);
case Artifact.genSnapshot:
return _genSnapshotPath();
case Artifact.flutterTester:
return _flutterTesterPath(platform);
case Artifact.isolateSnapshotData:
case Artifact.vmSnapshotData:
- return fs.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', artifactFileName);
+ return globals.fs.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', artifactFileName);
case Artifact.platformKernelDill:
if (platform == TargetPlatform.fuchsia_x64 || platform == TargetPlatform.fuchsia_arm64) {
- return fs.path.join(engineOutPath, 'flutter_runner_patched_sdk', artifactFileName);
+ return globals.fs.path.join(engineOutPath, 'flutter_runner_patched_sdk', artifactFileName);
}
- return fs.path.join(_getFlutterPatchedSdkPath(mode), artifactFileName);
+ return globals.fs.path.join(_getFlutterPatchedSdkPath(mode), artifactFileName);
case Artifact.platformLibrariesJson:
- return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', artifactFileName);
+ return globals.fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', artifactFileName);
case Artifact.flutterFramework:
- return fs.path.join(engineOutPath, artifactFileName);
+ return globals.fs.path.join(engineOutPath, artifactFileName);
case Artifact.flutterMacOSFramework:
- return fs.path.join(engineOutPath, artifactFileName);
+ return globals.fs.path.join(engineOutPath, artifactFileName);
case Artifact.flutterPatchedSdkPath:
// When using local engine always use [BuildMode.debug] regardless of
// what was specified in [mode] argument because local engine will
// have only one flutter_patched_sdk in standard location, that
// is happen to be what debug(non-release) mode is using.
if (platform == TargetPlatform.fuchsia_x64 || platform == TargetPlatform.fuchsia_arm64) {
- return fs.path.join(engineOutPath, 'flutter_runner_patched_sdk');
+ return globals.fs.path.join(engineOutPath, 'flutter_runner_patched_sdk');
}
return _getFlutterPatchedSdkPath(BuildMode.debug);
case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath();
case Artifact.frontendServerSnapshotForEngineDartSdk:
- return fs.path.join(_hostEngineOutPath, 'gen', artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, 'gen', artifactFileName);
case Artifact.engineDartSdkPath:
- return fs.path.join(_hostEngineOutPath, 'dart-sdk');
+ return globals.fs.path.join(_hostEngineOutPath, 'dart-sdk');
case Artifact.engineDartBinary:
- return fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', artifactFileName);
case Artifact.dart2jsSnapshot:
- return fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
case Artifact.dartdevcSnapshot:
- return fs.path.join(dartSdkPath, 'bin', 'snapshots', artifactFileName);
+ return globals.fs.path.join(dartSdkPath, 'bin', 'snapshots', artifactFileName);
case Artifact.kernelWorkerSnapshot:
- return fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName);
case Artifact.ideviceId:
case Artifact.ideviceinfo:
case Artifact.idevicename:
case Artifact.idevicescreenshot:
case Artifact.idevicesyslog:
- return cache.getArtifactDirectory('libimobiledevice').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('libimobiledevice').childFile(artifactFileName).path;
case Artifact.ideviceinstaller:
- return cache.getArtifactDirectory('ideviceinstaller').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('ideviceinstaller').childFile(artifactFileName).path;
case Artifact.iosDeploy:
- return cache.getArtifactDirectory('ios-deploy').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('ios-deploy').childFile(artifactFileName).path;
case Artifact.iproxy:
- return cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName).path;
+ return globals.cache.getArtifactDirectory('usbmuxd').childFile(artifactFileName).path;
case Artifact.linuxDesktopPath:
- return fs.path.join(_hostEngineOutPath, artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, artifactFileName);
case Artifact.windowsDesktopPath:
- return fs.path.join(_hostEngineOutPath, artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, artifactFileName);
case Artifact.skyEnginePath:
- return fs.path.join(_hostEngineOutPath, 'gen', 'dart-pkg', artifactFileName);
+ return globals.fs.path.join(_hostEngineOutPath, 'gen', 'dart-pkg', artifactFileName);
case Artifact.flutterMacOSPodspec:
- return fs.path.join(_hostEngineOutPath, _artifactToFileName(artifact));
+ return globals.fs.path.join(_hostEngineOutPath, _artifactToFileName(artifact));
case Artifact.webPlatformKernelDill:
- return fs.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact));
+ return globals.fs.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact));
case Artifact.fuchsiaKernelCompiler:
final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform());
final String modeName = mode.isRelease ? 'release' : mode.toString();
final String dartBinaries = 'dart_binaries-$modeName-$hostPlatform';
- return fs.path.join(engineOutPath, 'host_bundle', dartBinaries, 'kernel_compiler.dart.snapshot');
+ return globals.fs.path.join(engineOutPath, 'host_bundle', dartBinaries, 'kernel_compiler.dart.snapshot');
case Artifact.fuchsiaFlutterRunner:
final String jitOrAot = mode.isJit ? '_jit' : '_aot';
final String productOrNo = mode.isRelease ? '_product' : '';
- return fs.path.join(engineOutPath, 'flutter$jitOrAot${productOrNo}_runner-0.far');
+ return globals.fs.path.join(engineOutPath, 'flutter$jitOrAot${productOrNo}_runner-0.far');
}
assert(false, 'Invalid artifact $artifact.');
return null;
@@ -499,24 +494,24 @@
@override
String getEngineType(TargetPlatform platform, [ BuildMode mode ]) {
- return fs.path.basename(engineOutPath);
+ return globals.fs.path.basename(engineOutPath);
}
String _getFlutterPatchedSdkPath(BuildMode buildMode) {
- return fs.path.join(engineOutPath,
+ return globals.fs.path.join(engineOutPath,
buildMode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk');
}
String _getFlutterWebSdkPath() {
- return fs.path.join(engineOutPath, 'flutter_web_sdk');
+ return globals.fs.path.join(engineOutPath, 'flutter_web_sdk');
}
String _genSnapshotPath() {
const List<String> clangDirs = <String>['.', 'clang_x64', 'clang_x86', 'clang_i386'];
final String genSnapshotName = _artifactToFileName(Artifact.genSnapshot);
for (String clangDir in clangDirs) {
- final String genSnapshotPath = fs.path.join(engineOutPath, clangDir, genSnapshotName);
- if (processManager.canRun(genSnapshotPath)) {
+ final String genSnapshotPath = globals.fs.path.join(engineOutPath, clangDir, genSnapshotName);
+ if (globals.processManager.canRun(genSnapshotPath)) {
return genSnapshotPath;
}
}
@@ -525,11 +520,11 @@
String _flutterTesterPath(TargetPlatform platform) {
if (getCurrentHostPlatform() == HostPlatform.linux_x64) {
- return fs.path.join(engineOutPath, _artifactToFileName(Artifact.flutterTester));
+ return globals.fs.path.join(engineOutPath, _artifactToFileName(Artifact.flutterTester));
} else if (getCurrentHostPlatform() == HostPlatform.darwin_x64) {
- return fs.path.join(engineOutPath, 'flutter_tester');
+ return globals.fs.path.join(engineOutPath, 'flutter_tester');
} else if (getCurrentHostPlatform() == HostPlatform.windows_x64) {
- return fs.path.join(engineOutPath, 'flutter_tester.exe');
+ return globals.fs.path.join(engineOutPath, 'flutter_tester.exe');
}
throw Exception('Unsupported platform $platform.');
}
diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart
index d00a3de..3c151c9 100644
--- a/packages/flutter_tools/lib/src/asset.dart
+++ b/packages/flutter_tools/lib/src/asset.dart
@@ -8,7 +8,6 @@
import 'base/context.dart';
import 'base/file_system.dart';
-import 'base/platform.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'cache.dart';
@@ -16,7 +15,7 @@
import 'dart/package_map.dart';
import 'devfs.dart';
import 'flutter_manifest.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
const AssetBundleFactory _kManifestFactory = _ManifestAssetBundleFactory();
@@ -85,7 +84,7 @@
return true;
}
- final FileStat stat = fs.file(manifestPath).statSync();
+ final FileStat stat = globals.fs.file(manifestPath).statSync();
if (stat.type == FileSystemEntityType.notFound) {
return true;
}
@@ -117,13 +116,13 @@
bool reportLicensedPackages = false,
}) async {
assetDirPath ??= getAssetBuildDirectory();
- packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
+ packagesPath ??= globals.fs.path.absolute(PackageMap.globalPackagesPath);
FlutterManifest flutterManifest;
try {
flutterManifest = FlutterManifest.createFromPath(manifestPath);
} catch (e) {
- printStatus('Error detected in pubspec.yaml:', emphasis: true);
- printError('$e');
+ globals.printStatus('Error detected in pubspec.yaml:', emphasis: true);
+ globals.printError('$e');
return 1;
}
if (flutterManifest == null) {
@@ -139,7 +138,7 @@
return 0;
}
- final String assetBasePath = fs.path.dirname(fs.path.absolute(manifestPath));
+ final String assetBasePath = globals.fs.path.dirname(globals.fs.path.absolute(manifestPath));
final PackageMap packageMap = PackageMap(packagesPath);
final List<Uri> wildcardDirectories = <Uri>[];
@@ -170,7 +169,7 @@
for (String packageName in packageMap.map.keys) {
final Uri package = packageMap.map[packageName];
if (package != null && package.scheme == 'file') {
- final String packageManifestPath = fs.path.fromUri(package.resolve('../pubspec.yaml'));
+ final String packageManifestPath = globals.fs.path.fromUri(package.resolve('../pubspec.yaml'));
final FlutterManifest packageFlutterManifest = FlutterManifest.createFromPath(packageManifestPath);
if (packageFlutterManifest == null) {
continue;
@@ -179,7 +178,7 @@
if (packageFlutterManifest.appName == flutterManifest.appName) {
continue;
}
- final String packageBasePath = fs.path.dirname(packageManifestPath);
+ final String packageBasePath = globals.fs.path.dirname(packageManifestPath);
final Map<_Asset, List<_Asset>> packageAssets = _parseAssets(
packageMap,
@@ -207,8 +206,8 @@
// asset in entries.
for (_Asset asset in assetVariants.keys) {
if (!asset.assetFileExists && assetVariants[asset].isEmpty) {
- printStatus('Error detected in pubspec.yaml:', emphasis: true);
- printError('No file or variants found for $asset.\n');
+ globals.printStatus('Error detected in pubspec.yaml:', emphasis: true);
+ globals.printError('No file or variants found for $asset.\n');
return 1;
}
// The file name for an asset's "main" entry is whatever appears in
@@ -238,7 +237,7 @@
// Update wildcard directories we we can detect changes in them.
for (Uri uri in wildcardDirectories) {
- _wildcardDirectories[uri] ??= fs.directory(uri);
+ _wildcardDirectories[uri] ??= globals.fs.directory(uri);
}
entries[_assetManifestJson] = _createAssetManifest(assetVariants);
@@ -265,7 +264,7 @@
final Uri entryUri;
File get assetFile {
- return fs.file(fs.path.join(baseDir, fs.path.fromUri(relativeUri)));
+ return globals.fs.file(globals.fs.path.join(baseDir, globals.fs.path.fromUri(relativeUri)));
}
bool get assetFileExists => assetFile.existsSync();
@@ -306,10 +305,10 @@
}
Map<String, dynamic> _readMaterialFontsManifest() {
- final String fontsPath = fs.path.join(fs.path.absolute(Cache.flutterRoot),
+ final String fontsPath = globals.fs.path.join(globals.fs.path.absolute(Cache.flutterRoot),
'packages', 'flutter_tools', 'schema', 'material_fonts.yaml');
- return castStringKeyedMap(loadYaml(fs.file(fontsPath).readAsStringSync()));
+ return castStringKeyedMap(loadYaml(globals.fs.file(fontsPath).readAsStringSync()));
}
final Map<String, dynamic> _materialFontsManifest = _readMaterialFontsManifest();
@@ -324,9 +323,9 @@
for (Map<String, dynamic> family in _getMaterialFonts(fontSet)) {
for (Map<dynamic, dynamic> font in family['fonts']) {
- final Uri entryUri = fs.path.toUri(font['asset'] as String);
+ final Uri entryUri = globals.fs.path.toUri(font['asset'] as String);
result.add(_Asset(
- baseDir: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
+ baseDir: globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
relativeUri: Uri(path: entryUri.pathSegments.last),
entryUri: entryUri,
));
@@ -364,7 +363,7 @@
if (package == null || package.scheme != 'file') {
continue;
}
- final File file = fs.file(package.resolve('../LICENSE'));
+ final File file = globals.fs.file(package.resolve('../LICENSE'));
if (!file.existsSync()) {
continue;
}
@@ -392,8 +391,8 @@
if (reportPackages) {
final List<String> allPackagesList = allPackages.toList()..sort();
- printStatus('Licenses were found for the following packages:');
- printStatus(allPackagesList.join(', '));
+ globals.printStatus('Licenses were found for the following packages:');
+ globals.printStatus(allPackagesList.join(', '));
}
final List<String> combinedLicensesList = packageLicenses.keys.map<String>(
@@ -464,7 +463,7 @@
for (FontAsset fontAsset in font.fontAssets) {
final Uri assetUri = fontAsset.assetUri;
if (assetUri.pathSegments.first == 'packages' &&
- !fs.isFileSync(fs.path.fromUri(packageMap.map[packageName].resolve('../${assetUri.path}')))) {
+ !globals.fs.isFileSync(globals.fs.path.fromUri(packageMap.map[packageName].resolve('../${assetUri.path}')))) {
packageFontAssets.add(FontAsset(
fontAsset.assetUri,
weight: fontAsset.weight,
@@ -498,33 +497,33 @@
// variantsFor('assets/bar') => []
class _AssetDirectoryCache {
_AssetDirectoryCache(Iterable<String> excluded) {
- _excluded = excluded.map<String>((String path) => fs.path.absolute(path) + fs.path.separator);
+ _excluded = excluded.map<String>((String path) => globals.fs.path.absolute(path) + globals.fs.path.separator);
}
Iterable<String> _excluded;
final Map<String, Map<String, List<String>>> _cache = <String, Map<String, List<String>>>{};
List<String> variantsFor(String assetPath) {
- final String assetName = fs.path.basename(assetPath);
- final String directory = fs.path.dirname(assetPath);
+ final String assetName = globals.fs.path.basename(assetPath);
+ final String directory = globals.fs.path.dirname(assetPath);
- if (!fs.directory(directory).existsSync()) {
+ if (!globals.fs.directory(directory).existsSync()) {
return const <String>[];
}
if (_cache[directory] == null) {
final List<String> paths = <String>[];
- for (FileSystemEntity entity in fs.directory(directory).listSync(recursive: true)) {
+ for (FileSystemEntity entity in globals.fs.directory(directory).listSync(recursive: true)) {
final String path = entity.path;
- if (fs.isFileSync(path) && !_excluded.any((String exclude) => path.startsWith(exclude))) {
+ if (globals.fs.isFileSync(path) && !_excluded.any((String exclude) => path.startsWith(exclude))) {
paths.add(path);
}
}
final Map<String, List<String>> variants = <String, List<String>>{};
for (String path in paths) {
- final String variantName = fs.path.basename(path);
- if (directory == fs.path.dirname(path)) {
+ final String variantName = globals.fs.path.basename(path);
+ if (directory == globals.fs.path.dirname(path)) {
continue;
}
variants[variantName] ??= <String>[];
@@ -596,7 +595,7 @@
packageName,
);
if (!baseAsset.assetFileExists) {
- printError('Error: unable to locate asset entry in pubspec.yaml: "${fontAsset.assetUri}".');
+ globals.printError('Error: unable to locate asset entry in pubspec.yaml: "${fontAsset.assetUri}".');
return null;
}
@@ -617,21 +616,21 @@
List<String> excludeDirs = const <String>[],
String packageName,
}) {
- final String directoryPath = fs.path.join(
- assetBase, assetUri.toFilePath(windows: platform.isWindows));
+ final String directoryPath = globals.fs.path.join(
+ assetBase, assetUri.toFilePath(windows: globals.platform.isWindows));
- if (!fs.directory(directoryPath).existsSync()) {
- printError('Error: unable to find directory entry in pubspec.yaml: $directoryPath');
+ if (!globals.fs.directory(directoryPath).existsSync()) {
+ globals.printError('Error: unable to find directory entry in pubspec.yaml: $directoryPath');
return;
}
- final List<FileSystemEntity> lister = fs.directory(directoryPath).listSync();
+ final List<FileSystemEntity> lister = globals.fs.directory(directoryPath).listSync();
for (FileSystemEntity entity in lister) {
if (entity is File) {
- final String relativePath = fs.path.relative(entity.path, from: assetBase);
+ final String relativePath = globals.fs.path.relative(entity.path, from: assetBase);
- final Uri uri = Uri.file(relativePath, windows: platform.isWindows);
+ final Uri uri = Uri.file(relativePath, windows: globals.platform.isWindows);
_parseAssetFromFile(packageMap, flutterManifest, assetBase, cache, result,
uri, packageName: packageName);
@@ -657,8 +656,8 @@
);
final List<_Asset> variants = <_Asset>[];
for (String path in cache.variantsFor(asset.assetFile.path)) {
- final String relativePath = fs.path.relative(path, from: asset.baseDir);
- final Uri relativeUri = fs.path.toUri(relativePath);
+ final String relativePath = globals.fs.path.relative(path, from: asset.baseDir);
+ final Uri relativeUri = globals.fs.path.toUri(relativePath);
final Uri entryUri = asset.symbolicPrefixUri == null
? relativeUri
: asset.symbolicPrefixUri.resolveUri(relativeUri);
@@ -681,8 +680,8 @@
Uri assetUri,
String packageName,
) {
- final String assetPath = fs.path.fromUri(assetUri);
- if (assetUri.pathSegments.first == 'packages' && !fs.isFileSync(fs.path.join(assetsBaseDir, assetPath))) {
+ final String assetPath = globals.fs.path.fromUri(assetUri);
+ if (assetUri.pathSegments.first == 'packages' && !globals.fs.isFileSync(globals.fs.path.join(assetsBaseDir, assetPath))) {
// The asset is referenced in the pubspec.yaml as
// 'packages/PACKAGE_NAME/PATH/TO/ASSET .
final _Asset packageAsset = _resolvePackageAsset(assetUri, packageMap);
@@ -707,13 +706,13 @@
final Uri packageUri = packageMap.map[packageName];
if (packageUri != null && packageUri.scheme == 'file') {
return _Asset(
- baseDir: fs.path.fromUri(packageUri),
+ baseDir: globals.fs.path.fromUri(packageUri),
entryUri: assetUri,
relativeUri: Uri(pathSegments: assetUri.pathSegments.sublist(2)),
);
}
}
- printStatus('Error detected in pubspec.yaml:', emphasis: true);
- printError('Could not resolve package for asset $assetUri.\n');
+ globals.printStatus('Error detected in pubspec.yaml:', emphasis: true);
+ globals.printError('Could not resolve package for asset $assetUri.\n');
return null;
}
diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart
index 32aa189..9d5c8fc 100644
--- a/packages/flutter_tools/lib/src/base/build.dart
+++ b/packages/flutter_tools/lib/src/base/build.dart
@@ -11,7 +11,7 @@
import '../bundle.dart';
import '../compile.dart';
import '../dart/package_map.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../macos/xcode.dart';
import '../project.dart';
import '../reporting/reporting.dart';
@@ -39,7 +39,7 @@
const GenSnapshot();
static String getSnapshotterPath(SnapshotType snapshotType) {
- return artifacts.getArtifactPath(
+ return globals.artifacts.getArtifactPath(
Artifact.genSnapshot, platform: snapshotType.platform, mode: snapshotType.mode);
}
@@ -97,12 +97,12 @@
bool quiet = false,
}) async {
if (bitcode && platform != TargetPlatform.ios) {
- printError('Bitcode is only supported for iOS.');
+ globals.printError('Bitcode is only supported for iOS.');
return 1;
}
if (!_isValidAotPlatform(platform, buildMode)) {
- printError('${getNameForTargetPlatform(platform)} does not support AOT compilation.');
+ globals.printError('${getNameForTargetPlatform(platform)} does not support AOT compilation.');
return 1;
}
// TODO(cbracken): replace IOSArch with TargetPlatform.ios_{armv7,arm64}.
@@ -111,16 +111,16 @@
final PackageMap packageMap = PackageMap(packagesPath);
final String packageMapError = packageMap.checkValid();
if (packageMapError != null) {
- printError(packageMapError);
+ globals.printError(packageMapError);
return 1;
}
- final Directory outputDir = fs.directory(outputPath);
+ final Directory outputDir = globals.fs.directory(outputPath);
outputDir.createSync(recursive: true);
final String skyEnginePkg = _getPackagePath(packageMap, 'sky_engine');
- final String uiPath = fs.path.join(skyEnginePkg, 'lib', 'ui', 'ui.dart');
- final String vmServicePath = fs.path.join(skyEnginePkg, 'sdk_ext', 'vmservice_io.dart');
+ final String uiPath = globals.fs.path.join(skyEnginePkg, 'lib', 'ui', 'ui.dart');
+ final String vmServicePath = globals.fs.path.join(skyEnginePkg, 'sdk_ext', 'vmservice_io.dart');
final List<String> inputPaths = <String>[uiPath, vmServicePath, mainPath];
final Set<String> outputPaths = <String>{};
@@ -128,18 +128,18 @@
'--deterministic',
];
if (extraGenSnapshotOptions != null && extraGenSnapshotOptions.isNotEmpty) {
- printTrace('Extra gen_snapshot options: $extraGenSnapshotOptions');
+ globals.printTrace('Extra gen_snapshot options: $extraGenSnapshotOptions');
genSnapshotArgs.addAll(extraGenSnapshotOptions);
}
- final String assembly = fs.path.join(outputDir.path, 'snapshot_assembly.S');
+ final String assembly = globals.fs.path.join(outputDir.path, 'snapshot_assembly.S');
if (platform == TargetPlatform.ios || platform == TargetPlatform.darwin_x64) {
// Assembly AOT snapshot.
outputPaths.add(assembly);
genSnapshotArgs.add('--snapshot_kind=app-aot-assembly');
genSnapshotArgs.add('--assembly=$assembly');
} else {
- final String aotSharedLibrary = fs.path.join(outputDir.path, 'app.so');
+ final String aotSharedLibrary = globals.fs.path.join(outputDir.path, 'app.so');
outputPaths.add(aotSharedLibrary);
genSnapshotArgs.add('--snapshot_kind=app-aot-elf');
genSnapshotArgs.add('--elf=$aotSharedLibrary');
@@ -160,9 +160,9 @@
// TODO(jonahwilliams): fully remove input checks once all callers are
// using assemble.
- final Iterable<String> missingInputs = inputPaths.where((String p) => !fs.isFileSync(p));
+ final Iterable<String> missingInputs = inputPaths.where((String p) => !globals.fs.isFileSync(p));
if (missingInputs.isNotEmpty) {
- printTrace('Missing input files: $missingInputs from $inputPaths');
+ globals.printTrace('Missing input files: $missingInputs from $inputPaths');
}
final SnapshotType snapshotType = SnapshotType(platform, buildMode);
@@ -174,7 +174,7 @@
darwinArch: darwinArch,
));
if (genSnapshotExitCode != 0) {
- printError('Dart snapshot generator failed with exit code $genSnapshotExitCode');
+ globals.printError('Dart snapshot generator failed with exit code $genSnapshotExitCode');
return genSnapshotExitCode;
}
@@ -184,8 +184,8 @@
// gen_snapshot would provide an argument to do this automatically.
final bool stripSymbols = platform == TargetPlatform.ios && buildMode == BuildMode.release && bitcode;
if (stripSymbols) {
- final IOSink sink = fs.file('$assembly.stripped.S').openWrite();
- for (String line in fs.file(assembly).readAsLinesSync()) {
+ final IOSink sink = globals.fs.file('$assembly.stripped.S').openWrite();
+ for (String line in globals.fs.file(assembly).readAsLinesSync()) {
if (line.startsWith('.section __DWARF')) {
break;
}
@@ -231,7 +231,7 @@
}) async {
final String targetArch = getNameForDarwinArch(appleArch);
if (!quiet) {
- printStatus('Building App.framework for $targetArch...');
+ globals.printStatus('Building App.framework for $targetArch...');
}
final List<String> commonBuildOptions = <String>[
@@ -241,7 +241,7 @@
];
const String embedBitcodeArg = '-fembed-bitcode';
- final String assemblyO = fs.path.join(outputPath, 'snapshot_assembly.o');
+ final String assemblyO = globals.fs.path.join(outputPath, 'snapshot_assembly.o');
List<String> isysrootArgs;
if (isIOS) {
final String iPhoneSDKLocation = await xcode.sdkLocation(SdkType.iPhone);
@@ -259,13 +259,13 @@
assemblyO,
]);
if (compileResult.exitCode != 0) {
- printError('Failed to compile AOT snapshot. Compiler terminated with exit code ${compileResult.exitCode}');
+ globals.printError('Failed to compile AOT snapshot. Compiler terminated with exit code ${compileResult.exitCode}');
return compileResult;
}
- final String frameworkDir = fs.path.join(outputPath, 'App.framework');
- fs.directory(frameworkDir).createSync(recursive: true);
- final String appLib = fs.path.join(frameworkDir, 'App');
+ final String frameworkDir = globals.fs.path.join(outputPath, 'App.framework');
+ globals.fs.directory(frameworkDir).createSync(recursive: true);
+ final String appLib = globals.fs.path.join(frameworkDir, 'App');
final List<String> linkArgs = <String>[
...commonBuildOptions,
'-dynamiclib',
@@ -279,7 +279,7 @@
];
final RunResult linkResult = await xcode.clang(linkArgs);
if (linkResult.exitCode != 0) {
- printError('Failed to link AOT snapshot. Linker terminated with exit code ${compileResult.exitCode}');
+ globals.printError('Failed to link AOT snapshot. Linker terminated with exit code ${compileResult.exitCode}');
}
return linkResult;
}
@@ -298,25 +298,25 @@
List<String> extraFrontEndOptions = const <String>[],
}) async {
final FlutterProject flutterProject = FlutterProject.current();
- final Directory outputDir = fs.directory(outputPath);
+ final Directory outputDir = globals.fs.directory(outputPath);
outputDir.createSync(recursive: true);
- printTrace('Compiling Dart to kernel: $mainPath');
+ globals.printTrace('Compiling Dart to kernel: $mainPath');
if ((extraFrontEndOptions != null) && extraFrontEndOptions.isNotEmpty) {
- printTrace('Extra front-end options: $extraFrontEndOptions');
+ globals.printTrace('Extra front-end options: $extraFrontEndOptions');
}
- final String depfilePath = fs.path.join(outputPath, 'kernel_compile.d');
+ final String depfilePath = globals.fs.path.join(outputPath, 'kernel_compile.d');
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject);
final CompilerOutput compilerOutput =
await _timedStep('frontend(CompileTime)', 'aot-kernel',
() => kernelCompiler.compile(
- sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
+ sdkRoot: globals.artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
mainPath: mainPath,
packagesPath: packagesPath,
outputFilePath: getKernelPathForTransformerOptions(
- fs.path.join(outputPath, 'app.dill'),
+ globals.fs.path.join(outputPath, 'app.dill'),
trackWidgetCreation: trackWidgetCreation,
),
depFilePath: depfilePath,
@@ -329,8 +329,8 @@
));
// Write path to frontend_server, since things need to be re-generated when that changes.
- final String frontendPath = artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk);
- fs.directory(outputPath).childFile('frontend_server.d').writeAsStringSync('frontend_server.d: $frontendPath\n');
+ final String frontendPath = globals.artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk);
+ globals.fs.directory(outputPath).childFile('frontend_server.d').writeAsStringSync('frontend_server.d: $frontendPath\n');
return compilerOutput?.outputFilename;
}
@@ -349,7 +349,7 @@
}
String _getPackagePath(PackageMap packageMap, String package) {
- return fs.path.dirname(fs.path.fromUri(packageMap.map[package]));
+ return globals.fs.path.dirname(globals.fs.path.fromUri(packageMap.map[package]));
}
/// This method is used to measure duration of an action and emit it into
@@ -361,7 +361,7 @@
final Stopwatch sw = Stopwatch()..start();
final T value = await action();
if (reportTimings) {
- printStatus('$marker: ${sw.elapsedMilliseconds} ms.');
+ globals.printStatus('$marker: ${sw.elapsedMilliseconds} ms.');
}
flutterUsage.sendTiming('build', analyticsVar, Duration(milliseconds: sw.elapsedMilliseconds));
return value;
diff --git a/packages/flutter_tools/lib/src/base/common.dart b/packages/flutter_tools/lib/src/base/common.dart
index 75d7d7e..965e46c 100644
--- a/packages/flutter_tools/lib/src/base/common.dart
+++ b/packages/flutter_tools/lib/src/base/common.dart
@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'file_system.dart';
-import 'platform.dart';
+import '../globals.dart' as globals;
/// Whether the tool started from the daemon, as opposed to the command line.
// TODO(jonahwilliams): remove once IDE updates have rolled.
@@ -11,11 +10,11 @@
/// Return the absolute path of the user's home directory
String get homeDirPath {
- String path = platform.isWindows
- ? platform.environment['USERPROFILE']
- : platform.environment['HOME'];
+ String path = globals.platform.isWindows
+ ? globals.platform.environment['USERPROFILE']
+ : globals.platform.environment['HOME'];
if (path != null) {
- path = fs.path.absolute(path);
+ path = globals.fs.path.absolute(path);
}
return path;
}
diff --git a/packages/flutter_tools/lib/src/base/config.dart b/packages/flutter_tools/lib/src/base/config.dart
index a872b64..619116a 100644
--- a/packages/flutter_tools/lib/src/base/config.dart
+++ b/packages/flutter_tools/lib/src/base/config.dart
@@ -3,16 +3,15 @@
// found in the LICENSE file.
import '../convert.dart';
-import '../globals.dart';
-import 'context.dart';
+import '../globals.dart' as globals;
import 'file_system.dart';
import 'logger.dart';
import 'utils.dart';
class Config {
Config([File configFile, Logger localLogger]) {
- final Logger loggerInstance = localLogger ?? logger;
- _configFile = configFile ?? fs.file(fs.path.join(userHomePath(), '.flutter_settings'));
+ final Logger loggerInstance = localLogger ?? globals.logger;
+ _configFile = configFile ?? globals.fs.file(globals.fs.path.join(userHomePath(), '.flutter_settings'));
if (_configFile.existsSync()) {
try {
_values = castStringKeyedMap(json.decode(_configFile.readAsStringSync()));
@@ -28,8 +27,6 @@
}
}
- static Config get instance => context.get<Config>();
-
File _configFile;
String get configPath => _configFile.path;
diff --git a/packages/flutter_tools/lib/src/base/error_handling_file_system.dart b/packages/flutter_tools/lib/src/base/error_handling_file_system.dart
index 325cbf6..308266c 100644
--- a/packages/flutter_tools/lib/src/base/error_handling_file_system.dart
+++ b/packages/flutter_tools/lib/src/base/error_handling_file_system.dart
@@ -8,8 +8,8 @@
import 'package:file/file.dart';
import 'package:meta/meta.dart';
+import '../globals.dart' as globals;
import 'common.dart' show throwToolExit;
-import 'platform.dart';
// The Flutter tool hits file system errors that only the end-user can address.
// We would like these errors to not hit crash logging. In these cases, we
@@ -129,7 +129,7 @@
try {
return await op();
} on FileSystemException catch (e) {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
_handleWindowsException(e, failureMessage);
}
rethrow;
@@ -140,7 +140,7 @@
try {
return op();
} on FileSystemException catch (e) {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
_handleWindowsException(e, failureMessage);
}
rethrow;
diff --git a/packages/flutter_tools/lib/src/base/file_system.dart b/packages/flutter_tools/lib/src/base/file_system.dart
index b9e927a..4100d77 100644
--- a/packages/flutter_tools/lib/src/base/file_system.dart
+++ b/packages/flutter_tools/lib/src/base/file_system.dart
@@ -3,36 +3,22 @@
// found in the LICENSE file.
import 'package:file/file.dart';
-import 'package:file/local.dart';
-import 'package:file/memory.dart';
import 'package:meta/meta.dart';
+import '../globals.dart' as globals;
import 'common.dart' show throwToolExit;
-import 'context.dart';
-import 'error_handling_file_system.dart';
-import 'platform.dart';
export 'package:file/file.dart';
export 'package:file/local.dart';
-const FileSystem _kLocalFs = LocalFileSystem();
-
-/// Currently active implementation of the file system.
-///
-/// By default it uses local disk-based implementation. Override this in tests
-/// with [MemoryFileSystem].
-FileSystem get fs => ErrorHandlingFileSystem(
- context.get<FileSystem>() ?? _kLocalFs,
-);
-
/// Create the ancestor directories of a file path if they do not already exist.
void ensureDirectoryExists(String filePath) {
- final String dirPath = fs.path.dirname(filePath);
- if (fs.isDirectorySync(dirPath)) {
+ final String dirPath = globals.fs.path.dirname(filePath);
+ if (globals.fs.isDirectorySync(dirPath)) {
return;
}
try {
- fs.directory(dirPath).createSync(recursive: true);
+ globals.fs.directory(dirPath).createSync(recursive: true);
} on FileSystemException catch (e) {
throwToolExit('Failed to create directory "$dirPath": ${e.osError.message}');
}
@@ -84,13 +70,13 @@
/// `package:path`. However, unlike the original, it does not change the ASCII
/// case of the path. Changing the case can break hot reload in some situations,
/// for an example see: https://github.com/flutter/flutter/issues/9539.
-String canonicalizePath(String path) => fs.path.normalize(fs.path.absolute(path));
+String canonicalizePath(String path) => globals.fs.path.normalize(globals.fs.path.absolute(path));
/// Escapes [path].
///
/// On Windows it replaces all '\' with '\\'. On other platforms, it returns the
/// path unchanged.
-String escapePath(String path) => platform.isWindows ? path.replaceAll('\\', '\\\\') : path;
+String escapePath(String path) => globals.platform.isWindows ? path.replaceAll('\\', '\\\\') : path;
/// Returns true if the file system [entity] has not been modified since the
/// latest modification to [referenceFile].
@@ -120,6 +106,6 @@
///
/// If the searched environment variables are not set, '.' is returned instead.
String userHomePath() {
- final String envKey = platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
- return platform.environment[envKey] ?? '.';
+ final String envKey = globals.platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
+ return globals.platform.environment[envKey] ?? '.';
}
diff --git a/packages/flutter_tools/lib/src/base/fingerprint.dart b/packages/flutter_tools/lib/src/base/fingerprint.dart
index 38c9004..5fc0b2f 100644
--- a/packages/flutter_tools/lib/src/base/fingerprint.dart
+++ b/packages/flutter_tools/lib/src/base/fingerprint.dart
@@ -7,7 +7,7 @@
import 'package:quiver/core.dart' show hash2;
import '../convert.dart' show json;
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../version.dart';
import 'file_system.dart';
import 'utils.dart';
@@ -50,17 +50,17 @@
bool doesFingerprintMatch() {
try {
- final File fingerprintFile = fs.file(fingerprintPath);
+ final File fingerprintFile = globals.fs.file(fingerprintPath);
if (!fingerprintFile.existsSync()) {
return false;
}
- if (!_depfilePaths.every(fs.isFileSync)) {
+ if (!_depfilePaths.every(globals.fs.isFileSync)) {
return false;
}
final List<String> paths = _getPaths();
- if (!paths.every(fs.isFileSync)) {
+ if (!paths.every(globals.fs.isFileSync)) {
return false;
}
@@ -69,7 +69,7 @@
return oldFingerprint == newFingerprint;
} catch (e) {
// Log exception and continue, fingerprinting is only a performance improvement.
- printTrace('Fingerprint check error: $e');
+ globals.printTrace('Fingerprint check error: $e');
}
return false;
}
@@ -77,10 +77,10 @@
void writeFingerprint() {
try {
final Fingerprint fingerprint = buildFingerprint();
- fs.file(fingerprintPath).writeAsStringSync(fingerprint.toJson());
+ globals.fs.file(fingerprintPath).writeAsStringSync(fingerprint.toJson());
} catch (e) {
// Log exception and continue, fingerprinting is only a performance improvement.
- printTrace('Fingerprint write error: $e');
+ globals.printTrace('Fingerprint write error: $e');
}
}
@@ -101,7 +101,7 @@
/// See [Fingerprinter].
class Fingerprint {
Fingerprint.fromBuildInputs(Map<String, String> properties, Iterable<String> inputPaths) {
- final Iterable<File> files = inputPaths.map<File>(fs.file);
+ final Iterable<File> files = inputPaths.map<File>(globals.fs.file);
final Iterable<File> missingInputs = files.where((File file) => !file.existsSync());
if (missingInputs.isNotEmpty) {
throw ArgumentError('Missing input files:\n' + missingInputs.join('\n'));
@@ -181,7 +181,7 @@
Set<String> readDepfile(String depfilePath) {
// Depfile format:
// outfile1 outfile2 : file1.dart file2.dart file3.dart
- final String contents = fs.file(depfilePath).readAsStringSync();
+ final String contents = globals.fs.file(depfilePath).readAsStringSync();
final String dependencies = contents.split(': ')[1];
return dependencies
diff --git a/packages/flutter_tools/lib/src/base/io.dart b/packages/flutter_tools/lib/src/base/io.dart
index 158d2f7..4748512 100644
--- a/packages/flutter_tools/lib/src/base/io.dart
+++ b/packages/flutter_tools/lib/src/base/io.dart
@@ -45,8 +45,8 @@
import 'package:meta/meta.dart';
+import '../globals.dart' as globals;
import 'context.dart';
-import 'platform.dart';
import 'process.dart';
export 'dart:io'
@@ -180,7 +180,7 @@
///
/// This is implemented by sending the signal using [Process.killPid].
bool send(int pid) {
- assert(!platform.isWindows || this == ProcessSignal.SIGTERM);
+ assert(!globals.platform.isWindows || this == ProcessSignal.SIGTERM);
return io.Process.killPid(pid, _delegate);
}
@@ -197,7 +197,7 @@
@override
Stream<ProcessSignal> watch() {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
return const Stream<ProcessSignal>.empty();
}
return super.watch();
diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart
index 71bf003..0291f5a 100644
--- a/packages/flutter_tools/lib/src/base/logger.dart
+++ b/packages/flutter_tools/lib/src/base/logger.dart
@@ -7,8 +7,8 @@
import 'package:meta/meta.dart';
import '../base/context.dart';
+import '../globals.dart' as globals;
import 'io.dart';
-import 'platform.dart';
import 'terminal.dart';
import 'utils.dart';
@@ -44,7 +44,7 @@
bool quiet = false;
- bool get supportsColor => terminal.supportsColor;
+ bool get supportsColor => globals.terminal.supportsColor;
bool get hasTerminal => stdio.hasTerminal;
@@ -174,9 +174,9 @@
message ??= '';
message = wrapText(message, indent: indent, hangingIndent: hangingIndent, shouldWrap: wrap);
if (emphasis == true) {
- message = terminal.bolden(message);
+ message = globals.terminal.bolden(message);
}
- message = terminal.color(message, color ?? TerminalColor.red);
+ message = globals.terminal.color(message, color ?? TerminalColor.red);
stderr.writeln(message);
if (stackTrace != null) {
stderr.writeln(stackTrace.toString());
@@ -198,10 +198,10 @@
message ??= '';
message = wrapText(message, indent: indent, hangingIndent: hangingIndent, shouldWrap: wrap);
if (emphasis == true) {
- message = terminal.bolden(message);
+ message = globals.terminal.bolden(message);
}
if (color != null) {
- message = terminal.color(message, color);
+ message = globals.terminal.color(message, color);
}
if (newline != false) {
message = '$message\n';
@@ -234,7 +234,7 @@
onFinish: _clearStatus,
)..start();
}
- if (terminal.supportsColor) {
+ if (globals.terminal.supportsColor) {
_status = AnsiStatus(
message: message,
timeout: timeout,
@@ -305,7 +305,7 @@
int hangingIndent,
bool wrap,
}) {
- _error.writeln(terminal.color(
+ _error.writeln(globals.terminal.color(
wrapText(message, indent: indent, hangingIndent: hangingIndent, shouldWrap: wrap),
color ?? TerminalColor.red,
));
@@ -356,7 +356,7 @@
}
class VerboseLogger extends Logger {
- VerboseLogger(this.parent) : assert(terminal != null) {
+ VerboseLogger(this.parent) : assert(globals.terminal != null) {
_stopwatch.start();
}
@@ -446,7 +446,7 @@
} else {
prefix = '+$millis ms'.padLeft(prefixWidth);
if (millis >= 100) {
- prefix = terminal.bolden(prefix);
+ prefix = globals.terminal.bolden(prefix);
}
}
prefix = '[$prefix] ';
@@ -455,12 +455,12 @@
final String indentMessage = message.replaceAll('\n', '\n$indent');
if (type == _LogType.error) {
- parent.printError(prefix + terminal.bolden(indentMessage));
+ parent.printError(prefix + globals.terminal.bolden(indentMessage));
if (stackTrace != null) {
parent.printError(indent + stackTrace.toString().replaceAll('\n', '\n$indent'));
}
} else if (type == _LogType.status) {
- parent.printStatus(prefix + terminal.bolden(indentMessage));
+ parent.printStatus(prefix + globals.terminal.bolden(indentMessage));
} else {
parent.printStatus(prefix + indentMessage);
}
@@ -504,7 +504,7 @@
VoidCallback onFinish,
SlowWarningCallback slowWarningCallback,
}) {
- if (terminal.supportsColor) {
+ if (globals.terminal.supportsColor) {
return AnsiSpinner(
timeout: timeout,
onFinish: onFinish,
@@ -663,7 +663,7 @@
Timer timer;
// Windows console font has a limited set of Unicode characters.
- List<String> get _animation => platform.isWindows
+ List<String> get _animation => globals.platform.isWindows
? <String>[r'-', r'\', r'|', r'/']
: <String>['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'];
diff --git a/packages/flutter_tools/lib/src/base/net.dart b/packages/flutter_tools/lib/src/base/net.dart
index c52ffbd..150e1a1 100644
--- a/packages/flutter_tools/lib/src/base/net.dart
+++ b/packages/flutter_tools/lib/src/base/net.dart
@@ -6,11 +6,10 @@
import '../base/context.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'common.dart';
import 'file_system.dart';
import 'io.dart';
-import 'platform.dart';
const int kNetworkProblemExitCode = 50;
@@ -52,10 +51,10 @@
}
if (maxAttempts != null && attempts >= maxAttempts) {
- printStatus('Download failed -- retry $attempts');
+ globals.printStatus('Download failed -- retry $attempts');
return null;
}
- printStatus('Download failed -- attempting retry $attempts in '
+ globals.printStatus('Download failed -- attempting retry $attempts in '
'$durationSeconds second${ durationSeconds == 1 ? "" : "s"}...');
await Future<void>.delayed(Duration(seconds: durationSeconds));
if (durationSeconds < 64) {
@@ -73,7 +72,7 @@
bool onlyHeaders = false,
}) async {
assert(onlyHeaders || destSink != null);
- printTrace('Downloading: $url');
+ globals.printTrace('Downloading: $url');
HttpClient httpClient;
if (context.get<HttpClientFactory>() != null) {
httpClient = context.get<HttpClientFactory>()();
@@ -90,9 +89,9 @@
}
response = await request.close();
} on ArgumentError catch (error) {
- final String overrideUrl = platform.environment['FLUTTER_STORAGE_BASE_URL'];
+ final String overrideUrl = globals.platform.environment['FLUTTER_STORAGE_BASE_URL'];
if (overrideUrl != null && url.toString().contains(overrideUrl)) {
- printError(error.toString());
+ globals.printError(error.toString());
throwToolExit(
'The value of FLUTTER_STORAGE_BASE_URL ($overrideUrl) could not be '
'parsed as a valid url. Please see https://flutter.dev/community/china '
@@ -100,10 +99,10 @@
'Full URL: $url',
exitCode: kNetworkProblemExitCode,);
}
- printError(error.toString());
+ globals.printError(error.toString());
rethrow;
} on HandshakeException catch (error) {
- printTrace(error.toString());
+ globals.printTrace(error.toString());
throwToolExit(
'Could not authenticate download server. You may be experiencing a man-in-the-middle attack,\n'
'your network may be compromised, or you may have malware installed on your computer.\n'
@@ -111,10 +110,10 @@
exitCode: kNetworkProblemExitCode,
);
} on SocketException catch (error) {
- printTrace('Download error: $error');
+ globals.printTrace('Download error: $error');
return false;
} on HttpException catch (error) {
- printTrace('Download error: $error');
+ globals.printTrace('Download error: $error');
return false;
}
assert(response != null);
@@ -134,16 +133,16 @@
);
}
// 5xx errors are server errors and we can try again
- printTrace('Download error: ${response.statusCode} ${response.reasonPhrase}');
+ globals.printTrace('Download error: ${response.statusCode} ${response.reasonPhrase}');
return false;
}
- printTrace('Received response from server, collecting bytes...');
+ globals.printTrace('Received response from server, collecting bytes...');
try {
assert(destSink != null);
await response.forEach(destSink.add);
return true;
} on IOException catch (error) {
- printTrace('Download error: $error');
+ globals.printTrace('Download error: $error');
return false;
} finally {
await destSink?.flush();
diff --git a/packages/flutter_tools/lib/src/base/os.dart b/packages/flutter_tools/lib/src/base/os.dart
index 698a955..f07c758 100644
--- a/packages/flutter_tools/lib/src/base/os.dart
+++ b/packages/flutter_tools/lib/src/base/os.dart
@@ -4,20 +4,18 @@
import 'package:archive/archive.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'context.dart';
import 'file_system.dart';
import 'io.dart';
-import 'platform.dart';
import 'process.dart';
-import 'process_manager.dart';
/// Returns [OperatingSystemUtils] active in the current app context (i.e. zone).
OperatingSystemUtils get os => context.get<OperatingSystemUtils>();
abstract class OperatingSystemUtils {
factory OperatingSystemUtils() {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
return _WindowsUtils();
} else {
return _PosixUtils();
@@ -75,7 +73,7 @@
'linux': 'Linux',
'windows': 'Windows',
};
- final String osName = platform.operatingSystem;
+ final String osName = globals.platform.operatingSystem;
return osNames.containsKey(osName) ? osNames[osName] : osName;
}
@@ -103,10 +101,10 @@
if (!ipv6) {
return findFreePort(ipv6: true);
}
- printTrace('findFreePort failed: $e');
+ globals.printTrace('findFreePort failed: $e');
} catch (e) {
// Failures are signaled by a return value of 0 from this function.
- printTrace('findFreePort failed: $e');
+ globals.printTrace('findFreePort failed: $e');
} finally {
if (serverSocket != null) {
await serverSocket.close();
@@ -127,16 +125,16 @@
@override
void chmod(FileSystemEntity entity, String mode) {
try {
- final ProcessResult result = processManager.runSync(<String>['chmod', mode, entity.path]);
+ final ProcessResult result = globals.processManager.runSync(<String>['chmod', mode, entity.path]);
if (result.exitCode != 0) {
- printTrace(
+ globals.printTrace(
'Error trying to run chmod on ${entity.absolute.path}'
'\nstdout: ${result.stdout}'
'\nstderr: ${result.stderr}',
);
}
} on ProcessException catch (error) {
- printTrace('Error trying to run chmod on ${entity.absolute.path}: $error');
+ globals.printTrace('Error trying to run chmod on ${entity.absolute.path}: $error');
}
}
@@ -147,12 +145,12 @@
if (all) '-a',
execName,
];
- final ProcessResult result = processManager.runSync(command);
+ final ProcessResult result = globals.processManager.runSync(command);
if (result.exitCode != 0) {
return const <File>[];
}
final String stdout = result.stdout as String;
- return stdout.trim().split('\n').map<File>((String path) => fs.file(path.trim())).toList();
+ return stdout.trim().split('\n').map<File>((String path) => globals.fs.file(path.trim())).toList();
}
@override
@@ -196,7 +194,7 @@
<String>['mkfifo', path],
throwOnError: true,
);
- return fs.file(path);
+ return globals.fs.file(path);
}
String _name;
@@ -204,7 +202,7 @@
@override
String get name {
if (_name == null) {
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
final List<RunResult> results = <RunResult>[
processUtils.runSync(<String>['sw_vers', '-productName']),
processUtils.runSync(<String>['sw_vers', '-productVersion']),
@@ -236,15 +234,15 @@
@override
List<File> _which(String execName, { bool all = false }) {
// `where` always returns all matches, not just the first one.
- final ProcessResult result = processManager.runSync(<String>['where', execName]);
+ final ProcessResult result = globals.processManager.runSync(<String>['where', execName]);
if (result.exitCode != 0) {
return const <File>[];
}
final List<String> lines = (result.stdout as String).trim().split('\n');
if (all) {
- return lines.map<File>((String path) => fs.file(path.trim())).toList();
+ return lines.map<File>((String path) => globals.fs.file(path.trim())).toList();
}
- return <File>[fs.file(lines.first.trim())];
+ return <File>[globals.fs.file(lines.first.trim())];
}
@override
@@ -307,7 +305,7 @@
continue;
}
- final File destFile = fs.file(fs.path.join(targetDirectory.path, archiveFile.name));
+ final File destFile = globals.fs.file(globals.fs.path.join(targetDirectory.path, archiveFile.name));
if (!destFile.parent.existsSync()) {
destFile.parent.createSync(recursive: true);
}
@@ -325,7 +323,7 @@
@override
String get name {
if (_name == null) {
- final ProcessResult result = processManager.runSync(
+ final ProcessResult result = globals.processManager.runSync(
<String>['ver'], runInShell: true);
if (result.exitCode == 0) {
_name = (result.stdout as String).trim();
@@ -346,12 +344,12 @@
/// or if the project root is the flutter repository root.
String findProjectRoot([ String directory ]) {
const String kProjectRootSentinel = 'pubspec.yaml';
- directory ??= fs.currentDirectory.path;
+ directory ??= globals.fs.currentDirectory.path;
while (true) {
- if (fs.isFileSync(fs.path.join(directory, kProjectRootSentinel))) {
+ if (globals.fs.isFileSync(globals.fs.path.join(directory, kProjectRootSentinel))) {
return directory;
}
- final String parent = fs.path.dirname(directory);
+ final String parent = globals.fs.path.dirname(directory);
if (directory == parent) {
return null;
}
diff --git a/packages/flutter_tools/lib/src/base/platform.dart b/packages/flutter_tools/lib/src/base/platform.dart
deleted file mode 100644
index 9cea8c9..0000000
--- a/packages/flutter_tools/lib/src/base/platform.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2014 The Flutter 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 'package:platform/platform.dart';
-
-import 'context.dart';
-
-export 'package:platform/platform.dart';
-
-const Platform _kLocalPlatform = LocalPlatform();
-
-Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart
index 35cd92b..e2e6128 100644
--- a/packages/flutter_tools/lib/src/base/process.dart
+++ b/packages/flutter_tools/lib/src/base/process.dart
@@ -5,12 +5,10 @@
import 'dart:async';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'common.dart';
import 'context.dart';
-import 'file_system.dart';
import 'io.dart';
-import 'process_manager.dart';
import 'utils.dart';
typedef StringConverter = String Function(String string);
@@ -77,11 +75,11 @@
/// guaranteed to run to completion before shutdown hooks in the next stage are
/// started.
Future<void> runShutdownHooks() async {
- printTrace('Running shutdown hooks');
+ globals.printTrace('Running shutdown hooks');
_shutdownHooksRunning = true;
try {
for (ShutdownStage stage in _shutdownHooks.keys.toList()..sort()) {
- printTrace('Shutdown hook priority ${stage.priority}');
+ globals.printTrace('Shutdown hook priority ${stage.priority}');
final List<ShutdownHook> hooks = _shutdownHooks.remove(stage);
final List<Future<dynamic>> futures = <Future<dynamic>>[];
for (ShutdownHook shutdownHook in hooks) {
@@ -96,7 +94,7 @@
_shutdownHooksRunning = false;
}
assert(_shutdownHooks.isEmpty);
- printTrace('Shutdown hooks complete');
+ globals.printTrace('Shutdown hooks complete');
}
class ProcessExit implements Exception {
@@ -261,15 +259,15 @@
_traceCommand(cmd, workingDirectory: workingDirectory);
// When there is no timeout, there's no need to kill a running process, so
- // we can just use processManager.run().
+ // we can just use globals.processManager.run().
if (timeout == null) {
- final ProcessResult results = await processManager.run(
+ final ProcessResult results = await globals.processManager.run(
cmd,
workingDirectory: workingDirectory,
environment: _environment(allowReentrantFlutter, environment),
);
final RunResult runResult = RunResult(results, cmd);
- printTrace(runResult.toString());
+ globals.printTrace(runResult.toString());
if (throwOnError && runResult.exitCode != 0 &&
(whiteListFailures == null || !whiteListFailures(runResult.exitCode))) {
runResult.throwException('Process exited abnormally:\n$runResult');
@@ -278,7 +276,7 @@
}
// When there is a timeout, we have to kill the running process, so we have
- // to use processManager.start() through _runCommand() above.
+ // to use globals.processManager.start() through _runCommand() above.
while (true) {
assert(timeoutRetries >= 0);
timeoutRetries = timeoutRetries - 1;
@@ -304,7 +302,7 @@
int exitCode;
exitCode = await process.exitCode.timeout(timeout, onTimeout: () {
// The process timed out. Kill it.
- processManager.killPid(process.pid);
+ globals.processManager.killPid(process.pid);
return null;
});
@@ -333,7 +331,7 @@
// If the process did not timeout. We are done.
if (exitCode != null) {
- printTrace(runResult.toString());
+ globals.printTrace(runResult.toString());
if (throwOnError && runResult.exitCode != 0 &&
(whiteListFailures == null || !whiteListFailures(exitCode))) {
runResult.throwException('Process exited abnormally:\n$runResult');
@@ -347,7 +345,7 @@
}
// Log the timeout with a trace message in verbose mode.
- printTrace('Process "${cmd[0]}" timed out. $timeoutRetries attempts left:\n'
+ globals.printTrace('Process "${cmd[0]}" timed out. $timeoutRetries attempts left:\n'
'$runResult');
}
@@ -365,14 +363,14 @@
bool allowReentrantFlutter = false,
}) {
_traceCommand(cmd, workingDirectory: workingDirectory);
- final ProcessResult results = processManager.runSync(
+ final ProcessResult results = globals.processManager.runSync(
cmd,
workingDirectory: workingDirectory,
environment: _environment(allowReentrantFlutter, environment),
);
final RunResult runResult = RunResult(results, cmd);
- printTrace('Exit code ${runResult.exitCode} from: ${cmd.join(' ')}');
+ globals.printTrace('Exit code ${runResult.exitCode} from: ${cmd.join(' ')}');
bool failedExitCode = runResult.exitCode != 0;
if (whiteListFailures != null && failedExitCode) {
@@ -381,17 +379,17 @@
if (runResult.stdout.isNotEmpty && !hideStdout) {
if (failedExitCode && throwOnError) {
- printStatus(runResult.stdout.trim());
+ globals.printStatus(runResult.stdout.trim());
} else {
- printTrace(runResult.stdout.trim());
+ globals.printTrace(runResult.stdout.trim());
}
}
if (runResult.stderr.isNotEmpty) {
if (failedExitCode && throwOnError) {
- printError(runResult.stderr.trim());
+ globals.printError(runResult.stderr.trim());
} else {
- printTrace(runResult.stderr.trim());
+ globals.printTrace(runResult.stderr.trim());
}
}
@@ -410,7 +408,7 @@
Map<String, String> environment,
}) {
_traceCommand(cmd, workingDirectory: workingDirectory);
- return processManager.start(
+ return globals.processManager.start(
cmd,
workingDirectory: workingDirectory,
environment: _environment(allowReentrantFlutter, environment),
@@ -445,9 +443,9 @@
if (line != null) {
final String message = '$prefix$line';
if (trace) {
- printTrace(message);
+ globals.printTrace(message);
} else {
- printStatus(message, wrap: false);
+ globals.printStatus(message, wrap: false);
}
}
});
@@ -460,7 +458,7 @@
line = mapFunction(line);
}
if (line != null) {
- printError('$prefix$line', wrap: false);
+ globals.printError('$prefix$line', wrap: false);
}
});
@@ -489,9 +487,9 @@
}) {
_traceCommand(cli);
try {
- return processManager.runSync(cli, environment: environment).exitCode == 0;
+ return globals.processManager.runSync(cli, environment: environment).exitCode == 0;
} catch (error) {
- printTrace('$cli failed with $error');
+ globals.printTrace('$cli failed with $error');
return false;
}
}
@@ -503,9 +501,9 @@
}) async {
_traceCommand(cli);
try {
- return (await processManager.run(cli, environment: environment)).exitCode == 0;
+ return (await globals.processManager.run(cli, environment: environment)).exitCode == 0;
} catch (error) {
- printTrace('$cli failed with $error');
+ globals.printTrace('$cli failed with $error');
return false;
}
}
@@ -527,9 +525,9 @@
void _traceCommand(List<String> args, { String workingDirectory }) {
final String argsText = args.join(' ');
if (workingDirectory == null) {
- printTrace('executing: $argsText');
+ globals.printTrace('executing: $argsText');
} else {
- printTrace('executing: [$workingDirectory${fs.path.separator}] $argsText');
+ globals.printTrace('executing: [$workingDirectory${globals.fs.path.separator}] $argsText');
}
}
}
diff --git a/packages/flutter_tools/lib/src/base/process_manager.dart b/packages/flutter_tools/lib/src/base/process_manager.dart
deleted file mode 100644
index 4aa69a7..0000000
--- a/packages/flutter_tools/lib/src/base/process_manager.dart
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2014 The Flutter 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 'package:process/process.dart';
-
-import 'context.dart';
-
-const ProcessManager _kLocalProcessManager = LocalProcessManager();
-
-/// The active process manager.
-ProcessManager get processManager => context.get<ProcessManager>() ?? _kLocalProcessManager;
diff --git a/packages/flutter_tools/lib/src/base/terminal.dart b/packages/flutter_tools/lib/src/base/terminal.dart
index 83192c7..e017556 100644
--- a/packages/flutter_tools/lib/src/base/terminal.dart
+++ b/packages/flutter_tools/lib/src/base/terminal.dart
@@ -5,10 +5,9 @@
import 'dart:async';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'context.dart';
import 'io.dart' as io;
-import 'platform.dart';
enum TerminalColor {
red,
@@ -20,22 +19,16 @@
grey,
}
-AnsiTerminal get terminal {
- return context?.get<AnsiTerminal>() ?? _defaultAnsiTerminal;
-}
-
/// Warning mark to use in stdout or stderr.
String get warningMark {
- return terminal.bolden(terminal.color('[!]', TerminalColor.red));
+ return globals.terminal.bolden(globals.terminal.color('[!]', TerminalColor.red));
}
/// Success mark to use in stdout.
String get successMark {
- return terminal.bolden(terminal.color('✓', TerminalColor.green));
+ return globals.terminal.bolden(globals.terminal.color('✓', TerminalColor.green));
}
-final AnsiTerminal _defaultAnsiTerminal = AnsiTerminal();
-
OutputPreferences get outputPreferences {
return context?.get<OutputPreferences>() ?? _defaultOutputPreferences;
}
@@ -50,7 +43,7 @@
bool showColor,
}) : wrapText = wrapText ?? io.stdio.hasTerminal,
_overrideWrapColumn = wrapColumn,
- showColor = showColor ?? platform.stdoutSupportsAnsi ?? false;
+ showColor = showColor ?? globals.platform.stdoutSupportsAnsi ?? false;
/// A version of this class for use in tests.
OutputPreferences.test() : wrapText = false, _overrideWrapColumn = null, showColor = false;
@@ -114,7 +107,7 @@
static String colorCode(TerminalColor color) => _colorMap[color];
- bool get supportsColor => platform.stdoutSupportsAnsi ?? false;
+ bool get supportsColor => globals.platform.stdoutSupportsAnsi ?? false;
final RegExp _boldControls = RegExp('(${RegExp.escape(resetBold)}|${RegExp.escape(bold)})');
/// Whether we are interacting with the flutter tool via the terminal.
@@ -227,14 +220,14 @@
singleCharMode = true;
while (choice == null || choice.length > 1 || !acceptedCharacters.contains(choice)) {
if (prompt != null) {
- printStatus(prompt, emphasis: true, newline: false);
+ globals.printStatus(prompt, emphasis: true, newline: false);
if (displayAcceptedCharacters) {
- printStatus(' [${charactersToDisplay.join("|")}]', newline: false);
+ globals.printStatus(' [${charactersToDisplay.join("|")}]', newline: false);
}
- printStatus(': ', emphasis: true, newline: false);
+ globals.printStatus(': ', emphasis: true, newline: false);
}
choice = await keystrokes.first;
- printStatus(choice);
+ globals.printStatus(choice);
}
singleCharMode = false;
if (defaultChoiceIndex != null && choice == '\n') {
diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart
index 4e2618a..0cfcc72 100644
--- a/packages/flutter_tools/lib/src/base/utils.dart
+++ b/packages/flutter_tools/lib/src/base/utils.dart
@@ -8,10 +8,10 @@
import 'package:intl/intl.dart';
import '../convert.dart';
+import '../globals.dart' as globals;
import 'context.dart';
import 'file_system.dart';
import 'io.dart' as io;
-import 'platform.dart';
import 'terminal.dart';
const BotDetector _kBotDetector = BotDetector();
@@ -22,40 +22,40 @@
bool get isRunningOnBot {
if (
// Explicitly stated to not be a bot.
- platform.environment['BOT'] == 'false'
+ globals.platform.environment['BOT'] == 'false'
// Set by the IDEs to the IDE name, so a strong signal that this is not a bot.
- || platform.environment.containsKey('FLUTTER_HOST')
+ || globals.platform.environment.containsKey('FLUTTER_HOST')
// When set, GA logs to a local file (normally for tests) so we don't need to filter.
- || platform.environment.containsKey('FLUTTER_ANALYTICS_LOG_FILE')
+ || globals.platform.environment.containsKey('FLUTTER_ANALYTICS_LOG_FILE')
) {
return false;
}
- return platform.environment['BOT'] == 'true'
+ return globals.platform.environment['BOT'] == 'true'
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
- || platform.environment['TRAVIS'] == 'true'
- || platform.environment['CONTINUOUS_INTEGRATION'] == 'true'
- || platform.environment.containsKey('CI') // Travis and AppVeyor
+ || globals.platform.environment['TRAVIS'] == 'true'
+ || globals.platform.environment['CONTINUOUS_INTEGRATION'] == 'true'
+ || globals.platform.environment.containsKey('CI') // Travis and AppVeyor
// https://www.appveyor.com/docs/environment-variables/
- || platform.environment.containsKey('APPVEYOR')
+ || globals.platform.environment.containsKey('APPVEYOR')
// https://cirrus-ci.org/guide/writing-tasks/#environment-variables
- || platform.environment.containsKey('CIRRUS_CI')
+ || globals.platform.environment.containsKey('CIRRUS_CI')
// https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
- || (platform.environment.containsKey('AWS_REGION') &&
- platform.environment.containsKey('CODEBUILD_INITIATOR'))
+ || (globals.platform.environment.containsKey('AWS_REGION') &&
+ globals.platform.environment.containsKey('CODEBUILD_INITIATOR'))
// https://wiki.jenkins.io/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-belowJenkinsSetEnvironmentVariables
- || platform.environment.containsKey('JENKINS_URL')
+ || globals.platform.environment.containsKey('JENKINS_URL')
// Properties on Flutter's Chrome Infra bots.
- || platform.environment['CHROME_HEADLESS'] == '1'
- || platform.environment.containsKey('BUILDBOT_BUILDERNAME')
- || platform.environment.containsKey('SWARMING_TASK_ID');
+ || globals.platform.environment['CHROME_HEADLESS'] == '1'
+ || globals.platform.environment.containsKey('BUILDBOT_BUILDERNAME')
+ || globals.platform.environment.containsKey('SWARMING_TASK_ID');
}
}
@@ -107,7 +107,7 @@
while (true) {
final String name = '${baseName}_${i.toString().padLeft(2, '0')}.$ext';
- final File file = fs.file(fs.path.join(dir.path, name));
+ final File file = fs.file(globals.fs.path.join(dir.path, name));
if (!file.existsSync()) {
return file;
}
@@ -139,7 +139,7 @@
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String getDisplayPath(String fullPath) {
- final String cwd = fs.currentDirectory.path + fs.path.separator;
+ final String cwd = globals.fs.currentDirectory.path + globals.fs.path.separator;
return fullPath.startsWith(cwd) ? fullPath.substring(cwd.length) : fullPath;
}
@@ -368,7 +368,7 @@
void writePidFile(String pidFile) {
if (pidFile != null) {
// Write our pid to the file.
- fs.file(pidFile).writeAsStringSync(io.pid.toString());
+ globals.fs.file(pidFile).writeAsStringSync(io.pid.toString());
}
}
diff --git a/packages/flutter_tools/lib/src/build_info.dart b/packages/flutter_tools/lib/src/build_info.dart
index 2f51d60..3821ea1 100644
--- a/packages/flutter_tools/lib/src/build_info.dart
+++ b/packages/flutter_tools/lib/src/build_info.dart
@@ -3,10 +3,8 @@
// found in the LICENSE file.
import 'base/context.dart';
-import 'base/file_system.dart';
-import 'base/platform.dart';
import 'base/utils.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
/// Information about a build to be performed or used.
class BuildInfo {
@@ -221,7 +219,7 @@
}
tmpBuildNumber = segments.join('.');
if (tmpBuildNumber != buildNumber) {
- printTrace('Invalid build-number: $buildNumber for iOS/macOS, overridden by $tmpBuildNumber.\n'
+ globals.printTrace('Invalid build-number: $buildNumber for iOS/macOS, overridden by $tmpBuildNumber.\n'
'See CFBundleVersion at https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html');
}
return tmpBuildNumber;
@@ -239,7 +237,7 @@
}
tmpBuildNumberStr = tmpBuildNumberInt.toString();
if (tmpBuildNumberStr != buildNumber) {
- printTrace('Invalid build-number: $buildNumber for Android, overridden by $tmpBuildNumberStr.\n'
+ globals.printTrace('Invalid build-number: $buildNumber for Android, overridden by $tmpBuildNumberStr.\n'
'See versionCode at https://developer.android.com/studio/publish/versioning');
}
return tmpBuildNumberStr;
@@ -268,7 +266,7 @@
}
tmpBuildName = segments.join('.');
if (tmpBuildName != buildName) {
- printTrace('Invalid build-name: $buildName for iOS/macOS, overridden by $tmpBuildName.\n'
+ globals.printTrace('Invalid build-name: $buildName for iOS/macOS, overridden by $tmpBuildName.\n'
'See CFBundleShortVersionString at https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html');
}
return tmpBuildName;
@@ -507,17 +505,17 @@
}
HostPlatform getCurrentHostPlatform() {
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
return HostPlatform.darwin_x64;
}
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
return HostPlatform.linux_x64;
}
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
return HostPlatform.windows_x64;
}
- printError('Unsupported host platform, defaulting to Linux');
+ globals.printError('Unsupported host platform, defaulting to Linux');
return HostPlatform.linux_x64;
}
@@ -526,14 +524,14 @@
String getBuildDirectory() {
// TODO(johnmccutchan): Stop calling this function as part of setting
// up command line argument processing.
- if (context == null || config == null) {
+ if (context == null || globals.config == null) {
return 'build';
}
- final String buildDir = config.getValue('build-dir') as String ?? 'build';
- if (fs.path.isAbsolute(buildDir)) {
+ final String buildDir = globals.config.getValue('build-dir') as String ?? 'build';
+ if (globals.fs.path.isAbsolute(buildDir)) {
throw Exception(
- 'build-dir config setting in ${config.configPath} must be relative');
+ 'build-dir config setting in ${globals.config.configPath} must be relative');
}
return buildDir;
}
@@ -546,40 +544,40 @@
/// Returns the AOT build output directory.
String getAotBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'aot');
+ return globals.fs.path.join(getBuildDirectory(), 'aot');
}
/// Returns the asset build output directory.
String getAssetBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'flutter_assets');
+ return globals.fs.path.join(getBuildDirectory(), 'flutter_assets');
}
/// Returns the iOS build output directory.
String getIosBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'ios');
+ return globals.fs.path.join(getBuildDirectory(), 'ios');
}
/// Returns the macOS build output directory.
String getMacOSBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'macos');
+ return globals.fs.path.join(getBuildDirectory(), 'macos');
}
/// Returns the web build output directory.
String getWebBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'web');
+ return globals.fs.path.join(getBuildDirectory(), 'web');
}
/// Returns the Linux build output directory.
String getLinuxBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'linux');
+ return globals.fs.path.join(getBuildDirectory(), 'linux');
}
/// Returns the Windows build output directory.
String getWindowsBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'windows');
+ return globals.fs.path.join(getBuildDirectory(), 'windows');
}
/// Returns the Fuchsia build output directory.
String getFuchsiaBuildDirectory() {
- return fs.path.join(getBuildDirectory(), 'fuchsia');
+ return globals.fs.path.join(getBuildDirectory(), 'fuchsia');
}
diff --git a/packages/flutter_tools/lib/src/build_runner/build_runner.dart b/packages/flutter_tools/lib/src/build_runner/build_runner.dart
index 98df72e..082605f 100644
--- a/packages/flutter_tools/lib/src/build_runner/build_runner.dart
+++ b/packages/flutter_tools/lib/src/build_runner/build_runner.dart
@@ -17,12 +17,10 @@
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
import '../codegen.dart';
import '../dart/pub.dart';
import '../dart/sdk.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
/// The minimum version of build_runner we can support in the flutter tool.
@@ -39,8 +37,8 @@
@override
Future<void> generateBuildScript(FlutterProject flutterProject) async {
- final Directory entrypointDirectory = fs.directory(fs.path.join(flutterProject.dartTool.path, 'build', 'entrypoint'));
- final Directory generatedDirectory = fs.directory(fs.path.join(flutterProject.dartTool.path, 'flutter_tool'));
+ final Directory entrypointDirectory = globals.fs.directory(globals.fs.path.join(flutterProject.dartTool.path, 'build', 'entrypoint'));
+ final Directory generatedDirectory = globals.fs.directory(globals.fs.path.join(flutterProject.dartTool.path, 'flutter_tool'));
final File buildSnapshot = entrypointDirectory.childFile('build.dart.snapshot');
final File scriptIdFile = entrypointDirectory.childFile('id');
final File syntheticPubspec = generatedDirectory.childFile('pubspec.yaml');
@@ -69,7 +67,7 @@
if (flutterProject.dartTool.existsSync()) {
flutterProject.dartTool.deleteSync(recursive: true);
}
- final Status status = logger.startProgress('generating build script...', timeout: null);
+ final Status status = globals.logger.startProgress('generating build script...', timeout: null);
try {
generatedDirectory.createSync(recursive: true);
entrypointDirectory.createSync(recursive: true);
@@ -86,8 +84,8 @@
// parent directories.
if (node is YamlMap && node['path'] != null) {
final String path = node['path'] as String;
- if (fs.path.isRelative(path)) {
- final String convertedPath = fs.path.join('..', '..', path);
+ if (globals.fs.path.isRelative(path)) {
+ final String convertedPath = globals.fs.path.join('..', '..', path);
stringBuffer.writeln(' $name:');
stringBuffer.writeln(' path: $convertedPath');
} else {
@@ -112,18 +110,18 @@
scriptIdFile.createSync(recursive: true);
}
scriptIdFile.writeAsBytesSync(appliedBuilderDigest);
- final ProcessResult generateResult = await processManager.run(<String>[
+ final ProcessResult generateResult = await globals.processManager.run(<String>[
sdkBinaryName('pub'), 'run', 'build_runner', 'generate-build-script',
], workingDirectory: syntheticPubspec.parent.path);
if (generateResult.exitCode != 0) {
throwToolExit('Error generating build_script snapshot: ${generateResult.stderr}');
}
- final File buildScript = fs.file(generateResult.stdout.trim());
- final ProcessResult result = await processManager.run(<String>[
- artifacts.getArtifactPath(Artifact.engineDartBinary),
+ final File buildScript = globals.fs.file(generateResult.stdout.trim());
+ final ProcessResult result = await globals.processManager.run(<String>[
+ globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
'--snapshot=${buildSnapshot.path}',
'--snapshot-kind=app-jit',
- '--packages=${fs.path.join(generatedDirectory.path, '.packages')}',
+ '--packages=${globals.fs.path.join(generatedDirectory.path, '.packages')}',
buildScript.path,
]);
if (result.exitCode != 0) {
@@ -143,7 +141,7 @@
List<String> extraFrontEndOptions = const <String> [],
}) async {
await generateBuildScript(flutterProject);
- final String engineDartBinaryPath = artifacts.getArtifactPath(Artifact.engineDartBinary);
+ final String engineDartBinaryPath = globals.artifacts.getArtifactPath(Artifact.engineDartBinary);
final File buildSnapshot = flutterProject
.dartTool
.childDirectory('build')
@@ -154,7 +152,7 @@
.childDirectory('flutter_tool')
.childFile('.packages')
.path;
- final Status status = logger.startProgress('starting build daemon...', timeout: null);
+ final Status status = globals.logger.startProgress('starting build daemon...', timeout: null);
BuildDaemonClient buildDaemonClient;
try {
final List<String> command = <String>[
@@ -170,7 +168,7 @@
command,
logHandler: (ServerLog log) {
if (log.message != null) {
- printTrace(log.message);
+ globals.printTrace(log.message);
}
},
);
@@ -228,7 +226,7 @@
// Sorts the builders by name and produces a hashcode of the resulting iterable.
List<int> _produceScriptId(YamlMap builders) {
if (builders == null || builders.isEmpty) {
- return md5.convert(platform.version.codeUnits).bytes;
+ return md5.convert(globals.platform.version.codeUnits).bytes;
}
final List<String> orderedBuilderNames = builders.keys
.cast<String>()
@@ -239,6 +237,6 @@
return md5.convert(<String>[
...orderedBuilderNames,
...orderedBuilderValues,
- platform.version,
+ globals.platform.version,
].join('').codeUnits).bytes;
}
diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
index 8c28756..491046b 100644
--- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
+++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
@@ -14,7 +14,6 @@
import '../application_package.dart';
import '../base/async_guard.dart';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
import '../base/net.dart';
@@ -26,7 +25,7 @@
import '../devfs.dart';
import '../device.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../resident_runner.dart';
@@ -87,7 +86,7 @@
@required this.dartDefines,
}) : super(
<FlutterDevice>[],
- target: target ?? fs.path.join('lib', 'main.dart'),
+ target: target ?? globals.fs.path.join('lib', 'main.dart'),
debuggingOptions: debuggingOptions,
ipv6: ipv6,
stayResident: stayResident,
@@ -172,18 +171,18 @@
const String rawMessage =
' To hot restart changes while running, press "r". '
'To hot restart (and refresh the browser), press "R".';
- final String message = terminal.color(
- fire + terminal.bolden(rawMessage),
+ final String message = globals.terminal.color(
+ fire + globals.terminal.bolden(rawMessage),
TerminalColor.red,
);
- printStatus(
+ globals.printStatus(
'Warning: Flutter\'s support for web development is not stable yet and hasn\'t');
- printStatus('been thoroughly tested in production environments.');
- printStatus('For more information see https://flutter.dev/web');
- printStatus('');
- printStatus(message);
+ globals.printStatus('been thoroughly tested in production environments.');
+ globals.printStatus('For more information see https://flutter.dev/web');
+ globals.printStatus('');
+ globals.printStatus(message);
const String quitMessage = 'To quit, press "q".';
- printStatus('For a more detailed help message, press "h". $quitMessage');
+ globals.printStatus('For a more detailed help message, press "h". $quitMessage');
}
@override
@@ -240,7 +239,7 @@
args: <String, Object>{
'value': platform,
});
- printStatus('Switched operating system to $platform');
+ globals.printStatus('Switched operating system to $platform');
} on vmservice.RPCError {
return;
}
@@ -353,7 +352,7 @@
}) : super(
device,
flutterProject: flutterProject,
- target: target ?? fs.path.join('lib', 'main.dart'),
+ target: target ?? globals.fs.path.join('lib', 'main.dart'),
debuggingOptions: debuggingOptions,
ipv6: ipv6,
stayResident: stayResident,
@@ -375,21 +374,21 @@
applicationBinary: null,
);
if (package == null) {
- printError('This application is not configured to build on the web.');
- printError('To add web support to a project, run `flutter create .`.');
+ globals.printError('This application is not configured to build on the web.');
+ globals.printError('To add web support to a project, run `flutter create .`.');
return 1;
}
- if (!fs.isFileSync(mainPath)) {
+ if (!globals.fs.isFileSync(mainPath)) {
String message = 'Tried to run $mainPath, but that file does not exist.';
if (target == null) {
message +=
'\nConsider using the -t option to specify the Dart file to start.';
}
- printError(message);
+ globals.printError(message);
return 1;
}
final String modeName = debuggingOptions.buildInfo.friendlyModeName;
- printStatus('Launching ${getDisplayPath(target)} on ${device.device.name} in $modeName mode...');
+ globals.printStatus('Launching ${getDisplayPath(target)} on ${device.device.name} in $modeName mode...');
final String effectiveHostname = debuggingOptions.hostname ?? 'localhost';
final int hostPort = debuggingOptions.port == null
? await os.findFreePort()
@@ -424,7 +423,7 @@
bool benchmarkMode = false,
}) async {
final Stopwatch timer = Stopwatch()..start();
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Performing hot restart...',
timeout: supportsServiceProtocol
? timeoutConfiguration.fastOperation
@@ -454,13 +453,13 @@
});
}
} on WipError catch (err) {
- printError(err.toString());
+ globals.printError(err.toString());
return OperationResult(1, err.toString());
} finally {
status.stop();
}
final String verb = fullRestart ? 'Restarted' : 'Reloaded';
- printStatus('$verb application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
+ globals.printStatus('$verb application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
if (!fullRestart) {
flutterUsage.sendTiming('hot', 'web-incremental-restart', timer.elapsed);
}
@@ -479,7 +478,7 @@
final bool isFirstUpload = !assetBundle.wasBuiltOnce();
final bool rebuildBundle = assetBundle.needsBuild();
if (rebuildBundle) {
- printTrace('Updating assets');
+ globals.printTrace('Updating assets');
final int result = await assetBundle.build();
if (result != 0) {
return UpdateFSReport(success: false);
@@ -491,7 +490,7 @@
urisToMonitor: device.devFS.sources,
packagesPath: packagesFilePath,
);
- final Status devFSStatus = logger.startProgress(
+ final Status devFSStatus = globals.logger.startProgress(
'Syncing files to device ${device.device.name}...',
timeout: timeoutConfiguration.fastOperation,
);
@@ -510,7 +509,7 @@
trackWidgetCreation: true,
);
devFSStatus.stop();
- printTrace('Synced ${getSizeAsMB(report.syncedBytes)}.');
+ globals.printTrace('Synced ${getSizeAsMB(report.syncedBytes)}.');
return report;
}
@@ -552,7 +551,7 @@
}) : super(
device,
flutterProject: flutterProject,
- target: target ?? fs.path.join('lib', 'main.dart'),
+ target: target ?? globals.fs.path.join('lib', 'main.dart'),
debuggingOptions: debuggingOptions,
ipv6: ipv6,
stayResident: stayResident,
@@ -573,21 +572,21 @@
applicationBinary: null,
);
if (package == null) {
- printError('This application is not configured to build on the web.');
- printError('To add web support to a project, run `flutter create .`.');
+ globals.printError('This application is not configured to build on the web.');
+ globals.printError('To add web support to a project, run `flutter create .`.');
return 1;
}
- if (!fs.isFileSync(mainPath)) {
+ if (!globals.fs.isFileSync(mainPath)) {
String message = 'Tried to run $mainPath, but that file does not exist.';
if (target == null) {
message +=
'\nConsider using the -t option to specify the Dart file to start.';
}
- printError(message);
+ globals.printError(message);
return 1;
}
final String modeName = debuggingOptions.buildInfo.friendlyModeName;
- printStatus(
+ globals.printStatus(
'Launching ${getDisplayPath(target)} on ${device.device.name} in $modeName mode...');
Status buildStatus;
bool statusActive = false;
@@ -595,7 +594,7 @@
// dwds does not handle uncaught exceptions from its servers. To work
// around this, we need to catch all uncaught exceptions and determine if
// they are fatal or not.
- buildStatus = logger.startProgress('Building application for the web...', timeout: null);
+ buildStatus = globals.logger.startProgress('Building application for the web...', timeout: null);
statusActive = true;
final int result = await asyncGuard(() async {
_webFs = await webFsFactory(
@@ -614,7 +613,7 @@
buildStatus.stop();
statusActive = false;
if (supportsServiceProtocol) {
- buildStatus = logger.startProgress(
+ buildStatus = globals.logger.startProgress(
'Attempting to connect to browser instance..',
timeout: const Duration(seconds: 30),
);
@@ -697,7 +696,7 @@
bool benchmarkMode = false,
}) async {
final Stopwatch timer = Stopwatch()..start();
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Performing hot restart...',
timeout: supportsServiceProtocol
? timeoutConfiguration.fastOperation
@@ -718,7 +717,7 @@
? await _vmService.callServiceExtension('fullReload')
: await _vmService.callServiceExtension('hotRestart');
final String verb = fullRestart ? 'Restarted' : 'Reloaded';
- printStatus(
+ globals.printStatus(
'$verb application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
// Send timing analytics for full restart and for refresh.
@@ -761,7 +760,7 @@
}
}
status.stop();
- printStatus('Recompile complete. Page requires refresh.');
+ globals.printStatus('Recompile complete. Page requires refresh.');
return OperationResult.ok;
}
@@ -788,7 +787,7 @@
}
_stdOutSub = _vmService.onStdoutEvent.listen((vmservice.Event log) {
final String message = utf8.decode(base64.decode(log.bytes)).trim();
- printStatus(message);
+ globals.printStatus(message);
});
unawaited(_vmService.registerService('reloadSources', 'FlutterTools'));
websocketUri = Uri.parse(_connectionResult.debugConnection.uri);
@@ -807,7 +806,7 @@
}
}
if (websocketUri != null) {
- printStatus('Debug service listening on $websocketUri');
+ globals.printStatus('Debug service listening on $websocketUri');
}
connectionInfoCompleter?.complete(DebugConnectionInfo(wsUri: websocketUri));
diff --git a/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart b/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart
index 4f8ae4f..de5f20d 100644
--- a/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart
+++ b/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart
@@ -16,6 +16,7 @@
import '../base/file_system.dart';
import '../build_info.dart';
import '../convert.dart';
+import '../globals.dart' as globals;
import '../platform_plugins.dart';
import '../plugins.dart';
import '../project.dart';
@@ -81,14 +82,14 @@
.listSync()
.whereType<Directory>();
for (Directory childDirectory in childDirectories) {
- final String path = fs.path.join(testOutputDir, 'packages',
- fs.path.basename(childDirectory.path));
- copyDirectorySync(childDirectory.childDirectory('lib'), fs.directory(path));
+ final String path = globals.fs.path.join(testOutputDir, 'packages',
+ globals.fs.path.basename(childDirectory.path));
+ copyDirectorySync(childDirectory.childDirectory('lib'), globals.fs.directory(path));
}
final Directory outputDirectory = rootDirectory
.childDirectory(projectName)
.childDirectory('test');
- copyDirectorySync(outputDirectory, fs.directory(fs.path.join(testOutputDir)));
+ copyDirectorySync(outputDirectory, globals.fs.directory(globals.fs.path.join(testOutputDir)));
}
return success;
}
@@ -133,18 +134,18 @@
@override
Stream<AssetId> findAssets(Glob glob, {String package}) async* {
if (package == null || packageGraph.root.name == package) {
- final String generatedRoot = fs.path.join(generatedDirectory.path, packageGraph.root.name);
+ final String generatedRoot = globals.fs.path.join(generatedDirectory.path, packageGraph.root.name);
await for (io.FileSystemEntity entity in glob.list(followLinks: true, root: packageGraph.root.path)) {
- if (entity is io.File && _isNotHidden(entity) && !fs.path.isWithin(generatedRoot, entity.path)) {
+ if (entity is io.File && _isNotHidden(entity) && !globals.fs.path.isWithin(generatedRoot, entity.path)) {
yield _fileToAssetId(entity, packageGraph.root);
}
}
- if (!fs.isDirectorySync(generatedRoot)) {
+ if (!globals.fs.isDirectorySync(generatedRoot)) {
return;
}
await for (io.FileSystemEntity entity in glob.list(followLinks: true, root: generatedRoot)) {
if (entity is io.File && _isNotHidden(entity)) {
- yield _fileToAssetId(entity, packageGraph.root, fs.path.relative(generatedRoot), true);
+ yield _fileToAssetId(entity, packageGraph.root, globals.fs.path.relative(generatedRoot), true);
}
}
return;
@@ -157,11 +158,11 @@
}
bool _missingSource(AssetId id) {
- return !fs.file(path.joinAll(<String>[packageGraph.root.path, ...id.pathSegments])).existsSync();
+ return !globals.fs.file(path.joinAll(<String>[packageGraph.root.path, ...id.pathSegments])).existsSync();
}
File _generatedFile(AssetId id) {
- return fs.file(
+ return globals.fs.file(
path.joinAll(<String>[generatedDirectory.path, packageGraph.root.name, ...id.pathSegments])
);
}
diff --git a/packages/flutter_tools/lib/src/build_runner/web_fs.dart b/packages/flutter_tools/lib/src/build_runner/web_fs.dart
index b996a67..1e9c0bd 100644
--- a/packages/flutter_tools/lib/src/build_runner/web_fs.dart
+++ b/packages/flutter_tools/lib/src/build_runner/web_fs.dart
@@ -28,13 +28,12 @@
import '../base/io.dart';
import '../base/net.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../cache.dart';
import '../dart/package_map.dart';
import '../dart/pub.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../platform_plugins.dart';
import '../plugins.dart';
import '../project.dart';
@@ -186,8 +185,8 @@
flutterProject.dartTool.createSync(recursive: true);
}
// Workaround for https://github.com/flutter/flutter/issues/41681.
- final String toolPath = fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools');
- if (!fs.isFileSync(fs.path.join(toolPath, '.packages'))) {
+ final String toolPath = globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools');
+ if (!globals.fs.isFileSync(globals.fs.path.join(toolPath, '.packages'))) {
await pub.get(
context: PubContext.pubGet,
directory: toolPath,
@@ -202,10 +201,10 @@
// Initialize the asset bundle.
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
await assetBundle.build();
- await writeBundle(fs.directory(getAssetBuildDirectory()), assetBundle.entries);
+ await writeBundle(globals.fs.directory(getAssetBuildDirectory()), assetBundle.entries);
- final String targetBaseName = fs.path
- .withoutExtension(target).replaceFirst('lib${fs.path.separator}', '');
+ final String targetBaseName = globals.fs.path
+ .withoutExtension(target).replaceFirst('lib${globals.fs.path.separator}', '');
final Map<String, String> mappedUrls = <String, String>{
'main.dart.js': 'packages/${flutterProject.manifest.appName}/'
'${targetBaseName}_web_entrypoint.dart.js',
@@ -251,7 +250,7 @@
.any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
// Start the build daemon and run an initial build.
client = await buildDaemonCreator
- .startBuildDaemon(fs.currentDirectory.path,
+ .startBuildDaemon(globals.fs.currentDirectory.path,
release: buildInfo.isRelease,
profile: buildInfo.isProfile,
hasPlugins: hasWebPlugins,
@@ -279,12 +278,12 @@
firstBuildCompleter.complete(true);
}
});
- final int daemonAssetPort = buildDaemonCreator.assetServerPort(fs.currentDirectory);
+ final int daemonAssetPort = buildDaemonCreator.assetServerPort(globals.fs.currentDirectory);
// Initialize the asset bundle.
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
await assetBundle.build();
- await writeBundle(fs.directory(getAssetBuildDirectory()), assetBundle.entries);
+ await writeBundle(globals.fs.directory(getAssetBuildDirectory()), assetBundle.entries);
if (!skipDwds) {
final BuildRunnerAssetHandler assetHandler = BuildRunnerAssetHandler(
daemonAssetPort,
@@ -303,7 +302,7 @@
verbose: false,
enableDebugExtension: true,
urlEncoder: urlTunneller,
- logWriter: (dynamic level, String message) => printTrace(message),
+ logWriter: (dynamic level, String message) => globals.printTrace(message),
);
handler = pipeline.addHandler(dwds.handler);
} else {
@@ -360,9 +359,9 @@
class ReleaseAssetServer extends AssetServer {
// Locations where source files, assets, or source maps may be located.
final List<Uri> _searchPaths = <Uri>[
- fs.directory(getWebBuildDirectory()).uri,
- fs.directory(Cache.flutterRoot).parent.uri,
- fs.currentDirectory.childDirectory('lib').uri,
+ globals.fs.directory(getWebBuildDirectory()).uri,
+ globals.fs.directory(Cache.flutterRoot).parent.uri,
+ globals.fs.currentDirectory.childDirectory('lib').uri,
];
@override
@@ -370,7 +369,7 @@
Uri fileUri;
for (Uri uri in _searchPaths) {
final Uri potential = uri.resolve(request.url.path);
- if (potential == null || !fs.isFileSync(potential.toFilePath())) {
+ if (potential == null || !globals.fs.isFileSync(potential.toFilePath())) {
continue;
}
fileUri = potential;
@@ -378,7 +377,7 @@
}
if (fileUri != null) {
- final File file = fs.file(fileUri);
+ final File file = globals.fs.file(fileUri);
final Uint8List bytes = file.readAsBytesSync();
// Fallback to "application/octet-stream" on null which
// makes no claims as to the structure of the data.
@@ -389,7 +388,7 @@
});
}
if (request.url.path == '') {
- final File file = fs.file(fs.path.join(getWebBuildDirectory(), 'index.html'));
+ final File file = globals.fs.file(globals.fs.path.join(getWebBuildDirectory(), 'index.html'));
return Response.ok(file.readAsBytesSync(), headers: <String, String>{
'Content-Type': 'text/html',
});
@@ -410,7 +409,7 @@
Future<Response> handle(Request request) async {
if (request.url.path.endsWith('.html')) {
final Uri htmlUri = flutterProject.web.directory.uri.resolveUri(request.url);
- final File htmlFile = fs.file(htmlUri);
+ final File htmlFile = globals.fs.file(htmlUri);
if (htmlFile.existsSync()) {
return Response.ok(htmlFile.readAsBytesSync(), headers: <String, String>{
'Content-Type': 'text/html',
@@ -418,8 +417,8 @@
}
return Response.notFound('');
} else if (request.url.path.contains('stack_trace_mapper')) {
- final File file = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.engineDartSdkPath),
+ final File file = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath),
'lib',
'dev_compiler',
'web',
@@ -434,7 +433,7 @@
// entrypoint + a "part" suffix (Though the actual names are arbitrary).
// To make this easier to deal with they are copied into a temp directory.
if (partFiles == null) {
- final File dart2jsArchive = fs.file(fs.path.join(
+ final File dart2jsArchive = globals.fs.file(globals.fs.path.join(
flutterProject.dartTool.path,
'build',
'flutter_web',
@@ -444,20 +443,20 @@
));
if (dart2jsArchive.existsSync()) {
final Archive archive = TarDecoder().decodeBytes(dart2jsArchive.readAsBytesSync());
- partFiles = fs.systemTempDirectory.createTempSync('flutter_tool.')
+ partFiles = globals.fs.systemTempDirectory.createTempSync('flutter_tool.')
..createSync();
for (ArchiveFile file in archive) {
partFiles.childFile(file.name).writeAsBytesSync(file.content as List<int>);
}
}
}
- final String fileName = fs.path.basename(request.url.path);
+ final String fileName = globals.fs.path.basename(request.url.path);
return Response.ok(partFiles.childFile(fileName).readAsBytesSync(), headers: <String, String>{
'Content-Type': 'text/javascript',
});
} else if (request.url.path.contains('require.js')) {
- final File file = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.engineDartSdkPath),
+ final File file = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath),
'lib',
'dev_compiler',
'kernel',
@@ -468,16 +467,16 @@
'Content-Type': 'text/javascript',
});
} else if (request.url.path.endsWith('dart_sdk.js.map')) {
- final File file = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.flutterWebSdk),
+ final File file = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
'amd',
'dart_sdk.js.map',
));
return Response.ok(file.readAsBytesSync());
} else if (request.url.path.endsWith('dart_sdk.js')) {
- final File file = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.flutterWebSdk),
+ final File file = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
'amd',
'dart_sdk.js',
@@ -498,16 +497,16 @@
// Handle sdk requests that have mangled urls from engine build.
if (request.url.path.contains('dart-sdk')) {
// Note: the request is a uri and not a file path, so they always use `/`.
- final String sdkPath = fs.path.joinAll(request.url.path.split('dart-sdk/').last.split('/'));
- final String dartSdkPath = artifacts.getArtifactPath(Artifact.engineDartSdkPath);
- final File candidateFile = fs.file(fs.path.join(dartSdkPath, sdkPath));
+ final String sdkPath = globals.fs.path.joinAll(request.url.path.split('dart-sdk/').last.split('/'));
+ final String dartSdkPath = globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath);
+ final File candidateFile = globals.fs.file(globals.fs.path.join(dartSdkPath, sdkPath));
return Response.ok(candidateFile.readAsBytesSync());
}
// See if it is a flutter sdk path.
- final String webSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
- final File candidateFile = fs.file(fs.path.join(webSdkPath,
- basePath.split('/').join(platform.pathSeparator)));
+ final String webSdkPath = globals.artifacts.getArtifactPath(Artifact.flutterWebSdk);
+ final File candidateFile = globals.fs.file(globals.fs.path.join(webSdkPath,
+ basePath.split('/').join(globals.platform.pathSeparator)));
if (candidateFile.existsSync()) {
return Response.ok(candidateFile.readAsBytesSync());
}
@@ -515,25 +514,25 @@
final String packageName = request.url.pathSegments.length == 1
? flutterProject.manifest.appName
: request.url.pathSegments.first;
- String filePath = fs.path.joinAll(request.url.pathSegments.length == 1
+ String filePath = globals.fs.path.joinAll(request.url.pathSegments.length == 1
? request.url.pathSegments
: request.url.pathSegments.skip(1));
- String packagePath = packageMap.map[packageName]?.toFilePath(windows: platform.isWindows);
+ String packagePath = packageMap.map[packageName]?.toFilePath(windows: globals.platform.isWindows);
// If the package isn't found, then we have an issue with relative
// paths within the main project.
if (packagePath == null) {
packagePath = packageMap.map[flutterProject.manifest.appName]
- .toFilePath(windows: platform.isWindows);
+ .toFilePath(windows: globals.platform.isWindows);
filePath = request.url.path;
}
- final File file = fs.file(fs.path.join(packagePath, filePath));
+ final File file = globals.fs.file(globals.fs.path.join(packagePath, filePath));
if (file.existsSync()) {
return Response.ok(file.readAsBytesSync());
}
return Response.notFound('');
} else if (request.url.path.contains('assets')) {
final String assetPath = request.url.path.replaceFirst('assets/', '');
- final File file = fs.file(fs.path.join(getAssetBuildDirectory(), assetPath));
+ final File file = globals.fs.file(globals.fs.path.join(getAssetBuildDirectory(), assetPath));
if (file.existsSync()) {
final Uint8List bytes = file.readAsBytesSync();
// Fallback to "application/octet-stream" on null which
@@ -643,15 +642,15 @@
bool initializePlatform,
WebTestTargetManifest testTargets,
}) {
- final String flutterToolsPackages = fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', '.packages');
- final String buildScript = fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'lib', 'src', 'build_runner', 'build_script.dart');
- final String flutterWebSdk = artifacts.getArtifactPath(Artifact.flutterWebSdk);
+ final String flutterToolsPackages = globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', '.packages');
+ final String buildScript = globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'lib', 'src', 'build_runner', 'build_script.dart');
+ final String flutterWebSdk = globals.artifacts.getArtifactPath(Artifact.flutterWebSdk);
// On Windows we need to call the snapshot directly otherwise
// the process will start in a disjoint cmd without access to
// STDIO.
final List<String> args = <String>[
- artifacts.getArtifactPath(Artifact.engineDartBinary),
+ globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
'--packages=$flutterToolsPackages',
buildScript,
'daemon',
@@ -682,19 +681,19 @@
serverLog.message.contains(_ignoredLine3)) {
return;
}
- printError(serverLog.message);
+ globals.printError(serverLog.message);
if (serverLog.error != null) {
- printError(serverLog.error);
+ globals.printError(serverLog.error);
}
if (serverLog.stackTrace != null) {
- printTrace(serverLog.stackTrace);
+ globals.printTrace(serverLog.stackTrace);
}
break;
default:
if (serverLog.message.contains('Skipping compiling')) {
- printError(serverLog.message);
+ globals.printError(serverLog.message);
} else {
- printTrace(serverLog.message);
+ globals.printTrace(serverLog.message);
}
}
},
@@ -704,7 +703,7 @@
/// Retrieve the asset server port for the current daemon.
int assetServerPort(Directory workingDirectory) {
- final String portFilePath = fs.path.join(daemon.daemonWorkspace(workingDirectory.path), '.asset_server_port');
- return int.tryParse(fs.file(portFilePath).readAsStringSync());
+ final String portFilePath = globals.fs.path.join(daemon.daemonWorkspace(workingDirectory.path), '.asset_server_port');
+ return int.tryParse(globals.fs.file(portFilePath).readAsStringSync());
}
}
diff --git a/packages/flutter_tools/lib/src/build_system/build_system.dart b/packages/flutter_tools/lib/src/build_system/build_system.dart
index f8c25d4d..1f67a56 100644
--- a/packages/flutter_tools/lib/src/build_system/build_system.dart
+++ b/packages/flutter_tools/lib/src/build_system/build_system.dart
@@ -12,11 +12,10 @@
import '../base/context.dart';
import '../base/file_system.dart';
-import '../base/platform.dart';
import '../base/utils.dart';
import '../cache.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'exceptions.dart';
import 'file_hash_store.dart';
import 'source.dart';
@@ -256,7 +255,7 @@
/// Use a hard-coded path or directory relative to the current working
/// directory to write an output file.
///
-/// fs.file('build/linux/out')
+/// globals.fs.file('build/linux/out')
/// ..createSync()
/// ..writeAsStringSync('output data');
///
@@ -309,9 +308,9 @@
projectDir: projectDir,
buildDir: buildDirectory,
rootBuildDir: rootBuildDir,
- cacheDir: Cache.instance.getRoot(),
+ cacheDir: globals.cache.getRoot(),
defines: defines,
- flutterRootDir: fs.directory(Cache.flutterRoot),
+ flutterRootDir: globals.fs.directory(Cache.flutterRoot),
);
}
@@ -411,7 +410,7 @@
environment.outputDir.createSync(recursive: true);
// Load file hash store from previous builds.
- final FileHashStore fileCache = FileHashStore(environment, fs)
+ final FileHashStore fileCache = FileHashStore(environment, globals.fs)
..initialize();
// Perform sanity checks on build.
@@ -461,7 +460,7 @@
/// An active instance of a build.
class _BuildInstance {
_BuildInstance(this.environment, this.fileCache, this.buildSystemConfig)
- : resourcePool = Pool(buildSystemConfig.resourcePoolSize ?? platform?.numberOfProcessors ?? 1);
+ : resourcePool = Pool(buildSystemConfig.resourcePoolSize ?? globals.platform?.numberOfProcessors ?? 1);
final BuildSystemConfig buildSystemConfig;
final Pool resourcePool;
@@ -523,13 +522,13 @@
if (canSkip) {
skipped = true;
- printTrace('Skipping target: ${node.target.name}');
+ globals.printTrace('Skipping target: ${node.target.name}');
updateGraph();
return passed;
}
- printTrace('${node.target.name}: Starting due to ${node.invalidatedReasons}');
+ globals.printTrace('${node.target.name}: Starting due to ${node.invalidatedReasons}');
await node.target.build(environment);
- printTrace('${node.target.name}: Complete');
+ globals.printTrace('${node.target.name}: Complete');
node.inputs
..clear()
@@ -555,7 +554,7 @@
if (outputFiles.containsKey(previousOutput)) {
continue;
}
- final File previousFile = fs.file(previousOutput);
+ final File previousFile = globals.fs.file(previousOutput);
if (previousFile.existsSync()) {
previousFile.deleteSync();
}
@@ -769,7 +768,7 @@
// if this isn't a current output file there is no reason to compute the hash.
continue;
}
- final File file = fs.file(previousOutput);
+ final File file = globals.fs.file(previousOutput);
if (!file.existsSync()) {
invalidatedReasons.add(InvalidatedReason.outputMissing);
_dirty = true;
@@ -794,7 +793,7 @@
if (missingInputs.isNotEmpty) {
_dirty = true;
final String missingMessage = missingInputs.map((File file) => file.path).join(', ');
- printTrace('invalidated build due to missing files: $missingMessage');
+ globals.printTrace('invalidated build due to missing files: $missingMessage');
invalidatedReasons.add(InvalidatedReason.inputMissing);
}
diff --git a/packages/flutter_tools/lib/src/build_system/depfile.dart b/packages/flutter_tools/lib/src/build_system/depfile.dart
index 4d815c0..6e777af 100644
--- a/packages/flutter_tools/lib/src/build_system/depfile.dart
+++ b/packages/flutter_tools/lib/src/build_system/depfile.dart
@@ -3,8 +3,7 @@
// found in the LICENSE file.
import '../base/file_system.dart';
-import '../base/platform.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
/// A class for representing depfile formats.
class Depfile {
@@ -18,7 +17,7 @@
final String contents = file.readAsStringSync();
final List<String> colonSeparated = contents.split(': ');
if (colonSeparated.length != 2) {
- printError('Invalid depfile: ${file.path}');
+ globals.printError('Invalid depfile: ${file.path}');
return const Depfile(<File>[], <File>[]);
}
final List<File> inputs = _processList(colonSeparated[1].trim());
@@ -43,7 +42,7 @@
if (fileUri.scheme != 'file') {
continue;
}
- inputs.add(fs.file(fileUri));
+ inputs.add(globals.fs.file(fileUri));
}
return Depfile(inputs, <File>[output]);
}
@@ -74,7 +73,7 @@
void _writeFilesToBuffer(List<File> files, StringBuffer buffer) {
for (File outputFile in files) {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
// Paths in a depfile have to be escaped on windows.
final String escapedPath = outputFile.path.replaceAll(r'\', r'\\');
buffer.write(' $escapedPath');
@@ -98,7 +97,7 @@
// The tool doesn't write duplicates to these lists. This call is an attempt to
// be resillient to the outputs of other tools which write or user edits to depfiles.
.toSet()
- .map((String path) => fs.file(path))
+ .map((String path) => globals.fs.file(path))
.toList();
}
}
diff --git a/packages/flutter_tools/lib/src/build_system/file_hash_store.dart b/packages/flutter_tools/lib/src/build_system/file_hash_store.dart
index 9d687b1..72925ee 100644
--- a/packages/flutter_tools/lib/src/build_system/file_hash_store.dart
+++ b/packages/flutter_tools/lib/src/build_system/file_hash_store.dart
@@ -12,7 +12,7 @@
import '../base/file_system.dart';
import '../base/utils.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'build_system.dart';
/// An encoded representation of all file hashes.
@@ -88,7 +88,7 @@
/// Read file hashes from disk.
void initialize() {
- printTrace('Initializing file store');
+ globals.printTrace('Initializing file store');
final File cacheFile = fileSystem.file(_cachePath);
if (!cacheFile.existsSync()) {
return;
@@ -97,7 +97,7 @@
try {
data = cacheFile.readAsBytesSync();
} on FileSystemException catch (err) {
- printError(
+ globals.printError(
'Failed to read file store at ${cacheFile.path} due to $err.\n'
'Build artifacts will not be cached. Try clearing the cache directories '
'with "flutter clean"',
@@ -109,24 +109,24 @@
try {
fileStorage = FileStorage.fromBuffer(data);
} catch (err) {
- printTrace('Filestorage format changed');
+ globals.printTrace('Filestorage format changed');
cacheFile.deleteSync();
return;
}
if (fileStorage.version != _kVersion) {
- printTrace('file cache format updating, clearing old hashes.');
+ globals.printTrace('file cache format updating, clearing old hashes.');
cacheFile.deleteSync();
return;
}
for (FileHash fileHash in fileStorage.files) {
previousHashes[fileHash.path] = fileHash.hash;
}
- printTrace('Done initializing file store');
+ globals.printTrace('Done initializing file store');
}
/// Persist file hashes to disk.
void persist() {
- printTrace('Persisting file store');
+ globals.printTrace('Persisting file store');
final File cacheFile = fileSystem.file(_cachePath);
if (!cacheFile.existsSync()) {
cacheFile.createSync(recursive: true);
@@ -143,13 +143,13 @@
try {
cacheFile.writeAsBytesSync(buffer);
} on FileSystemException catch (err) {
- printError(
+ globals.printError(
'Failed to persist file store at ${cacheFile.path} due to $err.\n'
'Build artifacts will not be cached. Try clearing the cache directories '
'with "flutter clean"',
);
}
- printTrace('Done persisting file store');
+ globals.printTrace('Done persisting file store');
}
/// Computes a hash of the provided files and returns a list of entities
diff --git a/packages/flutter_tools/lib/src/build_system/source.dart b/packages/flutter_tools/lib/src/build_system/source.dart
index c7f4385..eb35f95 100644
--- a/packages/flutter_tools/lib/src/build_system/source.dart
+++ b/packages/flutter_tools/lib/src/build_system/source.dart
@@ -5,7 +5,7 @@
import '../artifacts.dart';
import '../base/file_system.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'build_system.dart';
import 'exceptions.dart';
@@ -56,7 +56,7 @@
final String contents = depfile.readAsStringSync();
final List<String> colonSeparated = contents.split(': ');
if (colonSeparated.length != 2) {
- printError('Invalid depfile: ${depfile.path}');
+ globals.printError('Invalid depfile: ${depfile.path}');
return;
}
if (inputs) {
@@ -78,7 +78,7 @@
.map<String>((String path) => path.replaceAllMapped(_escapeExpr, (Match match) => match.group(1)).trim())
.where((String path) => path.isNotEmpty)
.toSet()
- .map((String path) => fs.file(path));
+ .map((String path) => globals.fs.file(path));
}
/// Visit a [Source] which contains a file URL.
@@ -101,35 +101,35 @@
switch (rawParts.first) {
case Environment.kProjectDirectory:
segments.addAll(
- fs.path.split(environment.projectDir.resolveSymbolicLinksSync()));
+ globals.fs.path.split(environment.projectDir.resolveSymbolicLinksSync()));
break;
case Environment.kBuildDirectory:
- segments.addAll(fs.path.split(
+ segments.addAll(globals.fs.path.split(
environment.buildDir.resolveSymbolicLinksSync()));
break;
case Environment.kCacheDirectory:
segments.addAll(
- fs.path.split(environment.cacheDir.resolveSymbolicLinksSync()));
+ globals.fs.path.split(environment.cacheDir.resolveSymbolicLinksSync()));
break;
case Environment.kFlutterRootDirectory:
// flutter root will not contain a symbolic link.
segments.addAll(
- fs.path.split(environment.flutterRootDir.absolute.path));
+ globals.fs.path.split(environment.flutterRootDir.absolute.path));
break;
case Environment.kOutputDirectory:
segments.addAll(
- fs.path.split(environment.outputDir.resolveSymbolicLinksSync()));
+ globals.fs.path.split(environment.outputDir.resolveSymbolicLinksSync()));
break;
default:
throw InvalidPatternException(pattern);
}
rawParts.skip(1).forEach(segments.add);
- final String filePath = fs.path.joinAll(segments);
+ final String filePath = globals.fs.path.joinAll(segments);
if (!hasWildcard) {
- if (optional && !fs.isFileSync(filePath)) {
+ if (optional && !globals.fs.isFileSync(filePath)) {
return;
}
- sources.add(fs.file(fs.path.normalize(filePath)));
+ sources.add(globals.fs.file(globals.fs.path.normalize(filePath)));
return;
}
// Perform a simple match by splitting the wildcard containing file one
@@ -143,21 +143,21 @@
if (wildcardSegments.length > 2) {
throw InvalidPatternException(pattern);
}
- if (!fs.directory(filePath).existsSync()) {
+ if (!globals.fs.directory(filePath).existsSync()) {
throw Exception('$filePath does not exist!');
}
- for (FileSystemEntity entity in fs.directory(filePath).listSync()) {
- final String filename = fs.path.basename(entity.path);
+ for (FileSystemEntity entity in globals.fs.directory(filePath).listSync()) {
+ final String filename = globals.fs.path.basename(entity.path);
if (wildcardSegments.isEmpty) {
- sources.add(fs.file(entity.absolute));
+ sources.add(globals.fs.file(entity.absolute));
} else if (wildcardSegments.length == 1) {
if (filename.startsWith(wildcardSegments[0]) ||
filename.endsWith(wildcardSegments[0])) {
- sources.add(fs.file(entity.absolute));
+ sources.add(globals.fs.file(entity.absolute));
}
} else if (filename.startsWith(wildcardSegments[0])) {
if (filename.substring(wildcardSegments[0].length).endsWith(wildcardSegments[1])) {
- sources.add(fs.file(entity.absolute));
+ sources.add(globals.fs.file(entity.absolute));
}
}
}
@@ -167,15 +167,15 @@
///
/// If the [Artifact] points to a directory then all child files are included.
void visitArtifact(Artifact artifact, TargetPlatform platform, BuildMode mode) {
- final String path = artifacts.getArtifactPath(artifact, platform: platform, mode: mode);
- if (fs.isDirectorySync(path)) {
+ final String path = globals.artifacts.getArtifactPath(artifact, platform: platform, mode: mode);
+ if (globals.fs.isDirectorySync(path)) {
sources.addAll(<File>[
- for (FileSystemEntity entity in fs.directory(path).listSync(recursive: true))
+ for (FileSystemEntity entity in globals.fs.directory(path).listSync(recursive: true))
if (entity is File)
entity,
]);
} else {
- sources.add(fs.file(path));
+ sources.add(globals.fs.file(path));
}
}
}
diff --git a/packages/flutter_tools/lib/src/build_system/targets/android.dart b/packages/flutter_tools/lib/src/build_system/targets/android.dart
index 45ad5d6..cc282be 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/android.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/android.dart
@@ -6,7 +6,7 @@
import '../../base/build.dart';
import '../../base/file_system.dart';
import '../../build_info.dart';
-import '../../globals.dart';
+import '../../globals.dart' as globals;
import '../build_system.dart';
import '../depfile.dart';
import '../exceptions.dart';
@@ -50,13 +50,13 @@
// Only copy the prebuilt runtimes and kernel blob in debug mode.
if (buildMode == BuildMode.debug) {
- final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug);
- final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug);
+ final String vmSnapshotData = globals.artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug);
+ final String isolateSnapshotData = globals.artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug);
environment.buildDir.childFile('app.dill')
.copySync(outputDirectory.childFile('kernel_blob.bin').path);
- fs.file(vmSnapshotData)
+ globals.fs.file(vmSnapshotData)
.copySync(outputDirectory.childFile('vm_snapshot_data').path);
- fs.file(isolateSnapshotData)
+ globals.fs.file(isolateSnapshotData)
.copySync(outputDirectory.childFile('isolate_snapshot_data').path);
}
if (_copyAssets) {
diff --git a/packages/flutter_tools/lib/src/build_system/targets/assets.dart b/packages/flutter_tools/lib/src/build_system/targets/assets.dart
index 6080f11..fb3c3df 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/assets.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/assets.dart
@@ -7,6 +7,7 @@
import '../../asset.dart';
import '../../base/file_system.dart';
import '../../devfs.dart';
+import '../../globals.dart' as globals;
import '../../plugins.dart';
import '../../project.dart';
import '../build_system.dart';
@@ -39,12 +40,12 @@
// to `%23.ext`. However, we have to keep it this way since the
// platform channels in the framework will URI encode these values,
// and the native APIs will look for files this way.
- final File file = fs.file(fs.path.join(outputDirectory.path, entry.key));
+ final File file = globals.fs.file(globals.fs.path.join(outputDirectory.path, entry.key));
outputs.add(file);
file.parent.createSync(recursive: true);
final DevFSContent content = entry.value;
if (content is DevFSFileContent && content.file is File) {
- inputs.add(fs.file(content.file.path));
+ inputs.add(globals.fs.file(content.file.path));
await (content.file as File).copy(file.path);
} else {
await file.writeAsBytes(await entry.value.contentsAsBytes());
diff --git a/packages/flutter_tools/lib/src/build_system/targets/dart.dart b/packages/flutter_tools/lib/src/build_system/targets/dart.dart
index 800cd12..ab237da 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/dart.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/dart.dart
@@ -8,7 +8,7 @@
import '../../build_info.dart';
import '../../compile.dart';
import '../../convert.dart';
-import '../../globals.dart';
+import '../../globals.dart' as globals;
import '../../project.dart';
import '../build_system.dart';
import '../depfile.dart';
@@ -99,13 +99,13 @@
// Only copy the prebuilt runtimes and kernel blob in debug mode.
if (buildMode == BuildMode.debug) {
- final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug);
- final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug);
+ final String vmSnapshotData = globals.artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug);
+ final String isolateSnapshotData = globals.artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug);
environment.buildDir.childFile('app.dill')
.copySync(environment.outputDir.childFile('kernel_blob.bin').path);
- fs.file(vmSnapshotData)
+ globals.fs.file(vmSnapshotData)
.copySync(environment.outputDir.childFile('vm_snapshot_data').path);
- fs.file(isolateSnapshotData)
+ globals.fs.file(isolateSnapshotData)
.copySync(environment.outputDir.childFile('isolate_snapshot_data').path);
}
final Depfile assetDepfile = await copyAssets(environment, environment.outputDir);
@@ -180,9 +180,9 @@
throw MissingDefineException(kTargetPlatform, 'kernel_snapshot');
}
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
- final String targetFile = environment.defines[kTargetFile] ?? fs.path.join('lib', 'main.dart');
+ final String targetFile = environment.defines[kTargetFile] ?? globals.fs.path.join('lib', 'main.dart');
final String packagesPath = environment.projectDir.childFile('.packages').path;
- final String targetFileAbsolute = fs.file(targetFile).absolute.path;
+ final String targetFileAbsolute = globals.fs.file(targetFile).absolute.path;
// everything besides 'false' is considered to be enabled.
final bool trackWidgetCreation = environment.defines[kTrackWidgetCreation] != 'false';
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
@@ -214,7 +214,7 @@
}
final CompilerOutput output = await compiler.compile(
- sdkRoot: artifacts.getArtifactPath(
+ sdkRoot: globals.artifacts.getArtifactPath(
Artifact.flutterPatchedSdkPath,
platform: targetPlatform,
mode: buildMode,
diff --git a/packages/flutter_tools/lib/src/build_system/targets/ios.dart b/packages/flutter_tools/lib/src/build_system/targets/ios.dart
index 47b41f4..1d9152a 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart
@@ -8,8 +8,8 @@
import '../../base/file_system.dart';
import '../../base/io.dart';
import '../../base/process.dart';
-import '../../base/process_manager.dart';
import '../../build_info.dart';
+import '../../globals.dart' as globals;
import '../../macos/xcode.dart';
import '../build_system.dart';
import '../exceptions.dart';
@@ -65,7 +65,7 @@
buildMode: buildMode,
mainPath: environment.buildDir.childFile('app.dill').path,
packagesPath: environment.projectDir.childFile('.packages').path,
- outputPath: fs.path.join(buildOutputPath, getNameForDarwinArch(iosArch)),
+ outputPath: globals.fs.path.join(buildOutputPath, getNameForDarwinArch(iosArch)),
darwinArch: iosArch,
bitcode: bitcode,
));
@@ -74,13 +74,13 @@
if (results.any((int result) => result != 0)) {
throw Exception('AOT snapshotter exited with code ${results.join()}');
}
- final ProcessResult result = await processManager.run(<String>[
+ final ProcessResult result = await globals.processManager.run(<String>[
'lipo',
...iosArchs.map((DarwinArch iosArch) =>
- fs.path.join(buildOutputPath, getNameForDarwinArch(iosArch), 'App.framework', 'App')),
+ globals.fs.path.join(buildOutputPath, getNameForDarwinArch(iosArch), 'App.framework', 'App')),
'-create',
'-output',
- fs.path.join(environment.outputDir.path, 'App.framework', 'App'),
+ globals.fs.path.join(environment.outputDir.path, 'App.framework', 'App'),
]);
if (result.exitCode != 0) {
throw Exception('lipo exited with code ${result.exitCode}');
@@ -164,7 +164,7 @@
throwToolExit('Failed to create App.framework stub at ${outputFile.path}');
}
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_stub_source.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_stub_source.');
try {
final File stubSource = tempDir.childFile('debug_app.cc')
..writeAsStringSync(r'''
diff --git a/packages/flutter_tools/lib/src/build_system/targets/linux.dart b/packages/flutter_tools/lib/src/build_system/targets/linux.dart
index 73c06da..706b788 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/linux.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/linux.dart
@@ -5,7 +5,7 @@
import '../../artifacts.dart';
import '../../base/file_system.dart';
import '../../build_info.dart';
-import '../../globals.dart';
+import '../../globals.dart' as globals;
import '../build_system.dart';
import '../depfile.dart';
import '../exceptions.dart';
@@ -48,10 +48,10 @@
@override
Future<void> build(Environment environment) async {
- final String basePath = artifacts.getArtifactPath(Artifact.linuxDesktopPath);
+ final String basePath = globals.artifacts.getArtifactPath(Artifact.linuxDesktopPath);
final List<File> inputs = <File>[];
final List<File> outputs = <File>[];
- final String outputPrefix = fs.path.join(
+ final String outputPrefix = globals.fs.path.join(
environment.projectDir.path,
'linux',
'flutter',
@@ -60,18 +60,18 @@
// The native linux artifacts are composed of 6 files and a directory (listed above)
// which need to be copied to the target directory.
for (String artifact in _kLinuxArtifacts) {
- final String entityPath = fs.path.join(basePath, artifact);
+ final String entityPath = globals.fs.path.join(basePath, artifact);
// If this artifact is a file, just copy the source over.
- if (fs.isFileSync(entityPath)) {
- final String outputPath = fs.path.join(
+ if (globals.fs.isFileSync(entityPath)) {
+ final String outputPath = globals.fs.path.join(
outputPrefix,
- fs.path.relative(entityPath, from: basePath),
+ globals.fs.path.relative(entityPath, from: basePath),
);
- final File destinationFile = fs.file(outputPath);
+ final File destinationFile = globals.fs.file(outputPath);
if (!destinationFile.parent.existsSync()) {
destinationFile.parent.createSync(recursive: true);
}
- final File inputFile = fs.file(entityPath);
+ final File inputFile = globals.fs.file(entityPath);
inputFile.copySync(destinationFile.path);
inputs.add(inputFile);
outputs.add(destinationFile);
@@ -79,18 +79,18 @@
}
// If the artifact is the directory cpp_client_wrapper, recursively
// copy every file from it.
- for (File input in fs.directory(entityPath)
+ for (File input in globals.fs.directory(entityPath)
.listSync(recursive: true)
.whereType<File>()) {
- final String outputPath = fs.path.join(
+ final String outputPath = globals.fs.path.join(
outputPrefix,
- fs.path.relative(input.path, from: basePath),
+ globals.fs.path.relative(input.path, from: basePath),
);
- final File destinationFile = fs.file(outputPath);
+ final File destinationFile = globals.fs.file(outputPath);
if (!destinationFile.parent.existsSync()) {
destinationFile.parent.createSync(recursive: true);
}
- final File inputFile = fs.file(input);
+ final File inputFile = globals.fs.file(input);
inputFile.copySync(destinationFile.path);
inputs.add(inputFile);
outputs.add(destinationFile);
diff --git a/packages/flutter_tools/lib/src/build_system/targets/macos.dart b/packages/flutter_tools/lib/src/build_system/targets/macos.dart
index 950f8c0..fb9cd8c 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/macos.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/macos.dart
@@ -7,9 +7,8 @@
import '../../base/file_system.dart';
import '../../base/io.dart';
import '../../base/process.dart';
-import '../../base/process_manager.dart';
import '../../build_info.dart';
-import '../../globals.dart';
+import '../../globals.dart' as globals;
import '../../macos/xcode.dart';
import '../build_system.dart';
import '../depfile.dart';
@@ -76,14 +75,14 @@
throw MissingDefineException(kBuildMode, 'unpack_macos');
}
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
- final String basePath = artifacts.getArtifactPath(Artifact.flutterMacOSFramework, mode: buildMode);
+ final String basePath = globals.artifacts.getArtifactPath(Artifact.flutterMacOSFramework, mode: buildMode);
final Directory targetDirectory = environment
.outputDir
.childDirectory('FlutterMacOS.framework');
if (targetDirectory.existsSync()) {
targetDirectory.deleteSync(recursive: true);
}
- final ProcessResult result = await processManager
+ final ProcessResult result = await globals.processManager
.run(<String>['cp', '-R', basePath, targetDirectory.path]);
if (result.exitCode != 0) {
throw Exception(
@@ -149,7 +148,7 @@
@override
Future<void> build(Environment environment) async {
- final File outputFile = fs.file(fs.path.join(
+ final File outputFile = globals.fs.file(globals.fs.path.join(
environment.buildDir.path, 'App.framework', 'App'));
outputFile.createSync(recursive: true);
final File debugApp = environment.buildDir.childFile('debug_app.cc')
@@ -324,13 +323,13 @@
}
// Copy precompiled runtimes.
try {
- final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData,
+ final String vmSnapshotData = globals.artifacts.getArtifactPath(Artifact.vmSnapshotData,
platform: TargetPlatform.darwin_x64, mode: BuildMode.debug);
- final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData,
+ final String isolateSnapshotData = globals.artifacts.getArtifactPath(Artifact.isolateSnapshotData,
platform: TargetPlatform.darwin_x64, mode: BuildMode.debug);
- fs.file(vmSnapshotData).copySync(
+ globals.fs.file(vmSnapshotData).copySync(
assetDirectory.childFile('vm_snapshot_data').path);
- fs.file(isolateSnapshotData).copySync(
+ globals.fs.file(isolateSnapshotData).copySync(
assetDirectory.childFile('isolate_snapshot_data').path);
} catch (err) {
throw Exception('Failed to copy precompiled runtimes: $err');
@@ -343,7 +342,7 @@
final Link currentVersion = outputDirectory.parent
.childLink('Current');
if (!currentVersion.existsSync()) {
- final String linkPath = fs.path.relative(outputDirectory.path,
+ final String linkPath = globals.fs.path.relative(outputDirectory.path,
from: outputDirectory.parent.path);
currentVersion.createSync(linkPath);
}
@@ -351,7 +350,7 @@
final Link currentResources = frameworkRootDirectory
.childLink('Resources');
if (!currentResources.existsSync()) {
- final String linkPath = fs.path.relative(fs.path.join(currentVersion.path, 'Resources'),
+ final String linkPath = globals.fs.path.relative(globals.fs.path.join(currentVersion.path, 'Resources'),
from: frameworkRootDirectory.path);
currentResources.createSync(linkPath);
}
@@ -359,7 +358,7 @@
final Link currentFramework = frameworkRootDirectory
.childLink('App');
if (!currentFramework.existsSync()) {
- final String linkPath = fs.path.relative(fs.path.join(currentVersion.path, 'App'),
+ final String linkPath = globals.fs.path.relative(globals.fs.path.join(currentVersion.path, 'App'),
from: frameworkRootDirectory.path);
currentFramework.createSync(linkPath);
}
diff --git a/packages/flutter_tools/lib/src/build_system/targets/web.dart b/packages/flutter_tools/lib/src/build_system/targets/web.dart
index 96e52fa..97e0a00 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/web.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/web.dart
@@ -5,11 +5,10 @@
import '../../artifacts.dart';
import '../../base/file_system.dart';
import '../../base/io.dart';
-import '../../base/process_manager.dart';
import '../../build_info.dart';
import '../../compile.dart';
import '../../dart/package_map.dart';
-import '../../globals.dart';
+import '../../globals.dart' as globals;
import '../../project.dart';
import '../build_system.dart';
import '../depfile.dart';
@@ -52,7 +51,7 @@
final String targetFile = environment.defines[kTargetFile];
final bool shouldInitializePlatform = environment.defines[kInitializePlatform] == 'true';
final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true';
- final String importPath = fs.path.absolute(targetFile);
+ final String importPath = globals.fs.path.absolute(targetFile);
// Use the package uri mapper to find the correct package-scheme import path
// for the user application. If the application has a mix of package-scheme
@@ -71,7 +70,7 @@
// have an entry for the user's application or if the main file is
// outside of the lib/ directory.
final String mainImport = packageUriMapper.map(importPath)?.toString()
- ?? fs.file(importPath).absolute.uri.toString();
+ ?? globals.fs.file(importPath).absolute.uri.toString();
String contents;
if (hasPlugins) {
@@ -148,15 +147,15 @@
Future<void> build(Environment environment) async {
final String dart2jsOptimization = environment.defines[kDart2jsOptimization];
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
- final String specPath = fs.path.join(artifacts.getArtifactPath(Artifact.flutterWebSdk), 'libraries.json');
+ final String specPath = globals.fs.path.join(globals.artifacts.getArtifactPath(Artifact.flutterWebSdk), 'libraries.json');
final String packageFile = FlutterProject.fromDirectory(environment.projectDir).hasBuilders
? PackageMap.globalGeneratedPackagesPath
: PackageMap.globalPackagesPath;
final File outputFile = environment.buildDir.childFile('main.dart.js');
- final ProcessResult result = await processManager.run(<String>[
- artifacts.getArtifactPath(Artifact.engineDartBinary),
- artifacts.getArtifactPath(Artifact.dart2jsSnapshot),
+ final ProcessResult result = await globals.processManager.run(<String>[
+ globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
+ globals.artifacts.getArtifactPath(Artifact.dart2jsSnapshot),
'--libraries-spec=$specPath',
if (dart2jsOptimization != null)
'-$dart2jsOptimization'
@@ -181,7 +180,7 @@
final File dart2jsDeps = environment.buildDir
.childFile('main.dart.js.deps');
if (!dart2jsDeps.existsSync()) {
- printError('Warning: dart2js did not produced expected deps list at '
+ globals.printError('Warning: dart2js did not produced expected deps list at '
'${dart2jsDeps.path}');
return;
}
@@ -226,11 +225,11 @@
@override
Future<void> build(Environment environment) async {
for (File outputFile in environment.buildDir.listSync(recursive: true).whereType<File>()) {
- if (!fs.path.basename(outputFile.path).contains('main.dart.js')) {
+ if (!globals.fs.path.basename(outputFile.path).contains('main.dart.js')) {
continue;
}
outputFile.copySync(
- environment.outputDir.childFile(fs.path.basename(outputFile.path)).path
+ environment.outputDir.childFile(globals.fs.path.basename(outputFile.path)).path
);
}
final Directory outputDirectory = environment.outputDir.childDirectory('assets');
@@ -238,7 +237,7 @@
environment.projectDir
.childDirectory('web')
.childFile('index.html')
- .copySync(fs.path.join(environment.outputDir.path, 'index.html'));
+ .copySync(globals.fs.path.join(environment.outputDir.path, 'index.html'));
final Depfile depfile = await copyAssets(environment, environment.outputDir.childDirectory('assets'));
depfile.writeToFile(environment.buildDir.childFile('flutter_assets.d'));
}
diff --git a/packages/flutter_tools/lib/src/build_system/targets/windows.dart b/packages/flutter_tools/lib/src/build_system/targets/windows.dart
index da1169f..5b05aa1 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/windows.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/windows.dart
@@ -5,7 +5,7 @@
import '../../artifacts.dart';
import '../../base/file_system.dart';
import '../../build_info.dart';
-import '../../globals.dart';
+import '../../globals.dart' as globals;
import '../build_system.dart';
/// Copies the Windows desktop embedding files to the copy directory.
@@ -40,21 +40,21 @@
@override
Future<void> build(Environment environment) async {
// This path needs to match the prefix in the rule below.
- final String basePath = artifacts.getArtifactPath(Artifact.windowsDesktopPath);
- for (File input in fs.directory(basePath)
+ final String basePath = globals.artifacts.getArtifactPath(Artifact.windowsDesktopPath);
+ for (File input in globals.fs.directory(basePath)
.listSync(recursive: true)
.whereType<File>()) {
- final String outputPath = fs.path.join(
+ final String outputPath = globals.fs.path.join(
environment.projectDir.path,
'windows',
'flutter',
- fs.path.relative(input.path, from: basePath),
+ globals.fs.path.relative(input.path, from: basePath),
);
- final File destinationFile = fs.file(outputPath);
+ final File destinationFile = globals.fs.file(outputPath);
if (!destinationFile.parent.existsSync()) {
destinationFile.parent.createSync(recursive: true);
}
- fs.file(input).copySync(destinationFile.path);
+ globals.fs.file(input).copySync(destinationFile.path);
}
}
}
diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart
index e3799bf..2a3c938 100644
--- a/packages/flutter_tools/lib/src/bundle.dart
+++ b/packages/flutter_tools/lib/src/bundle.dart
@@ -17,17 +17,17 @@
import 'build_system/targets/dart.dart';
import 'dart/package_map.dart';
import 'devfs.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'project.dart';
-String get defaultMainPath => fs.path.join('lib', 'main.dart');
+String get defaultMainPath => globals.fs.path.join('lib', 'main.dart');
const String defaultAssetBasePath = '.';
const String defaultManifestPath = 'pubspec.yaml';
-String get defaultDepfilePath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
+String get defaultDepfilePath => globals.fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
String getDefaultApplicationKernelPath({ @required bool trackWidgetCreation }) {
return getKernelPathForTransformerOptions(
- fs.path.join(getBuildDirectory(), 'app.dill'),
+ globals.fs.path.join(getBuildDirectory(), 'app.dill'),
trackWidgetCreation: trackWidgetCreation,
);
}
@@ -71,7 +71,7 @@
mainPath ??= defaultMainPath;
depfilePath ??= defaultDepfilePath;
assetDirPath ??= getAssetBuildDirectory();
- packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
+ packagesPath ??= globals.fs.path.absolute(PackageMap.globalPackagesPath);
final FlutterProject flutterProject = FlutterProject.current();
await buildWithAssemble(
buildMode: buildMode ?? BuildMode.debug,
@@ -85,7 +85,7 @@
);
// Work around for flutter_tester placing kernel artifacts in odd places.
if (applicationKernelFilePath != null) {
- final File outputDill = fs.directory(assetDirPath).childFile('kernel_blob.bin');
+ final File outputDill = globals.fs.directory(assetDirPath).childFile('kernel_blob.bin');
if (outputDill.existsSync()) {
outputDill.copySync(applicationKernelFilePath);
}
@@ -111,7 +111,7 @@
buildMode = precompiled ? buildMode : BuildMode.debug;
final Environment environment = Environment(
projectDir: flutterProject.directory,
- outputDir: fs.directory(outputDir),
+ outputDir: globals.fs.directory(outputDir),
buildDir: flutterProject.dartTool.childDirectory('flutter_build'),
defines: <String, String>{
kTargetFile: mainPath,
@@ -127,7 +127,7 @@
if (!result.success) {
for (ExceptionMeasurement measurement in result.exceptions.values) {
- printError('Target ${measurement.target} failed: ${measurement.exception}',
+ globals.printError('Target ${measurement.target} failed: ${measurement.exception}',
stackTrace: measurement.fatal
? measurement.stackTrace
: null,
@@ -137,7 +137,7 @@
}
if (depfilePath != null) {
final Depfile depfile = Depfile(result.inputFiles, result.outputFiles);
- final File outputDepfile = fs.file(depfilePath);
+ final File outputDepfile = globals.fs.file(depfilePath);
if (!outputDepfile.parent.existsSync()) {
outputDepfile.parent.createSync(recursive: true);
}
@@ -153,7 +153,7 @@
bool reportLicensedPackages = false,
}) async {
assetDirPath ??= getAssetBuildDirectory();
- packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
+ packagesPath ??= globals.fs.path.absolute(PackageMap.globalPackagesPath);
// Build the asset bundle.
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
@@ -176,7 +176,7 @@
Map<String, DevFSContent> assetEntries,
{ Logger loggerOverride }
) async {
- loggerOverride ??= logger;
+ loggerOverride ??= globals.logger;
if (bundleDir.existsSync()) {
try {
bundleDir.deleteSync(recursive: true);
@@ -200,7 +200,7 @@
// to `%23.ext`. However, we have to keep it this way since the
// platform channels in the framework will URI encode these values,
// and the native APIs will look for files this way.
- final File file = fs.file(fs.path.join(bundleDir.path, entry.key));
+ final File file = globals.fs.file(globals.fs.path.join(bundleDir.path, entry.key));
file.parent.createSync(recursive: true);
await file.writeAsBytes(await entry.value.contentsAsBytes());
} finally {
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
index dc4031e..821f4c2 100644
--- a/packages/flutter_tools/lib/src/cache.dart
+++ b/packages/flutter_tools/lib/src/cache.dart
@@ -8,16 +8,14 @@
import 'android/gradle_utils.dart';
import 'base/common.dart';
-import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart' show SocketException;
import 'base/logger.dart';
import 'base/net.dart';
import 'base/os.dart';
-import 'base/platform.dart';
import 'base/process.dart';
import 'features.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
/// A tag for a set of development artifacts that need to be cached.
class DevelopmentArtifact {
@@ -168,12 +166,12 @@
}
assert(_lock == null);
final File lockFile =
- fs.file(fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile'));
+ globals.fs.file(globals.fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile'));
try {
_lock = lockFile.openSync(mode: FileMode.write);
} on FileSystemException catch (e) {
- printError('Failed to open or create the artifact cache lockfile: "$e"');
- printError('Please ensure you have permissions to create or open '
+ globals.printError('Failed to open or create the artifact cache lockfile: "$e"');
+ globals.printError('Please ensure you have permissions to create or open '
'${lockFile.path}');
throwToolExit('Failed to open or create the lockfile');
}
@@ -185,8 +183,8 @@
locked = true;
} on FileSystemException {
if (!printed) {
- printTrace('Waiting to be able to obtain lock of Flutter binary artifacts directory: ${_lock.path}');
- printStatus('Waiting for another flutter command to release the startup lock...');
+ globals.printTrace('Waiting to be able to obtain lock of Flutter binary artifacts directory: ${_lock.path}');
+ globals.printStatus('Waiting for another flutter command to release the startup lock...');
printed = true;
}
await Future<void>.delayed(const Duration(milliseconds: 50));
@@ -206,7 +204,7 @@
/// Checks if the current process owns the lock for the cache directory at
/// this very moment; throws a [StateError] if it doesn't.
static void checkLockAcquired() {
- if (_lockEnabled && _lock == null && platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') {
+ if (_lockEnabled && _lock == null && globals.platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') {
throw StateError(
'The current process does not own the lock for the cache directory. This is a bug in Flutter CLI tools.',
);
@@ -219,7 +217,7 @@
if (_dartSdkVersion == null) {
// Make the version string more customer-friendly.
// Changes '2.1.0-dev.8.0.flutter-4312ae32' to '2.1.0 (build 2.1.0-dev.8.0 4312ae32)'
- final String justVersion = platform.version.split(' ')[0];
+ final String justVersion = globals.platform.version.split(' ')[0];
_dartSdkVersion = justVersion.replaceFirstMapped(RegExp(r'(\d+\.\d+\.\d+)(.+)'), (Match match) {
final String noFlutter = match[2].replaceAll('.flutter-', ' ');
return '${match[1]} (build ${match[1]}$noFlutter)';
@@ -236,7 +234,7 @@
String _engineRevision;
String get storageBaseUrl {
- final String overrideUrl = platform.environment['FLUTTER_STORAGE_BASE_URL'];
+ final String overrideUrl = globals.platform.environment['FLUTTER_STORAGE_BASE_URL'];
if (overrideUrl == null) {
return 'https://storage.googleapis.com';
}
@@ -256,27 +254,25 @@
if (_hasWarnedAboutStorageOverride) {
return;
}
- logger.printStatus(
+ globals.logger.printStatus(
'Flutter assets will be downloaded from $overrideUrl. Make sure you trust this source!',
emphasis: true,
);
_hasWarnedAboutStorageOverride = true;
}
- static Cache get instance => context.get<Cache>();
-
/// Return the top-level directory in the cache; this is `bin/cache`.
Directory getRoot() {
if (_rootOverride != null) {
- return fs.directory(fs.path.join(_rootOverride.path, 'bin', 'cache'));
+ return globals.fs.directory(globals.fs.path.join(_rootOverride.path, 'bin', 'cache'));
} else {
- return fs.directory(fs.path.join(flutterRoot, 'bin', 'cache'));
+ return globals.fs.directory(globals.fs.path.join(flutterRoot, 'bin', 'cache'));
}
}
/// Return a directory in the cache dir. For `pkg`, this will return `bin/cache/pkg`.
Directory getCacheDir(String name) {
- final Directory dir = fs.directory(fs.path.join(getRoot().path, name));
+ final Directory dir = globals.fs.directory(globals.fs.path.join(getRoot().path, name));
if (!dir.existsSync()) {
dir.createSync(recursive: true);
os.chmod(dir, '755');
@@ -291,7 +287,7 @@
Directory getCacheArtifacts() => getCacheDir('artifacts');
/// Location of LICENSE file.
- File getLicenseFile() => fs.file(fs.path.join(flutterRoot, 'LICENSE'));
+ File getLicenseFile() => globals.fs.file(globals.fs.path.join(flutterRoot, 'LICENSE'));
/// Get a named directory from with the cache's artifact directory; for example,
/// `material_fonts` would return `bin/cache/artifacts/material_fonts`.
@@ -327,7 +323,7 @@
}
String getVersionFor(String artifactName) {
- final File versionFile = fs.file(fs.path.join(
+ final File versionFile = globals.fs.file(globals.fs.path.join(
_rootOverride?.path ?? flutterRoot, 'bin', 'internal',
'$artifactName.version'));
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
@@ -343,7 +339,7 @@
}
File getStampFileFor(String artifactName) {
- return fs.file(fs.path.join(getRoot().path, '$artifactName.stamp'));
+ return globals.fs.file(globals.fs.path.join(getRoot().path, '$artifactName.stamp'));
}
/// Returns `true` if either [entity] is older than the tools stamp or if
@@ -359,13 +355,13 @@
final Uri url = Uri.parse(urlStr);
final Directory thirdPartyDir = getArtifactDirectory('third_party');
- final Directory serviceDir = fs.directory(fs.path.join(thirdPartyDir.path, serviceName));
+ final Directory serviceDir = globals.fs.directory(globals.fs.path.join(thirdPartyDir.path, serviceName));
if (!serviceDir.existsSync()) {
serviceDir.createSync(recursive: true);
os.chmod(serviceDir, '755');
}
- final File cachedFile = fs.file(fs.path.join(serviceDir.path, url.pathSegments.last));
+ final File cachedFile = globals.fs.file(globals.fs.path.join(serviceDir.path, url.pathSegments.last));
if (!cachedFile.existsSync()) {
try {
await _downloadFile(url, cachedFile);
@@ -384,7 +380,7 @@
}
for (ArtifactSet artifact in _artifacts) {
if (!requiredArtifacts.contains(artifact.developmentArtifact)) {
- printTrace('Artifact $artifact is not required, skipping update.');
+ globals.printTrace('Artifact $artifact is not required, skipping update.');
continue;
}
if (artifact.isUpToDate()) {
@@ -394,7 +390,7 @@
await artifact.update();
} on SocketException catch (e) {
if (_hostsBlockedInChina.contains(e.address?.host)) {
- printError(
+ globals.printError(
'Failed to retrieve Flutter tool dependencies: ${e.message}.\n'
'If you\'re in China, please see this page: '
'https://flutter.dev/community/china',
@@ -410,15 +406,15 @@
String engineVersion,
bool includeAllPlatforms = true,
}) async {
- final bool includeAllPlatformsState = cache.includeAllPlatforms;
+ final bool includeAllPlatformsState = globals.cache.includeAllPlatforms;
bool allAvailible = true;
- cache.includeAllPlatforms = includeAllPlatforms;
+ globals.cache.includeAllPlatforms = includeAllPlatforms;
for (ArtifactSet cachedArtifact in _artifacts) {
if (cachedArtifact is EngineCachedArtifact) {
allAvailible &= await cachedArtifact.checkForArtifacts(engineVersion);
}
}
- cache.includeAllPlatforms = includeAllPlatformsState;
+ globals.cache.includeAllPlatforms = includeAllPlatformsState;
return allAvailible;
}
}
@@ -486,7 +482,7 @@
try {
location.createSync(recursive: true);
} on FileSystemException catch (err) {
- printError(err.toString());
+ globals.printError(err.toString());
throwToolExit(
'Failed to create directory for flutter cache at ${location.path}. '
'Flutter may be missing permissions in its cache directory.'
@@ -504,7 +500,7 @@
try {
f.deleteSync();
} on FileSystemException catch (e) {
- printError('Failed to delete "${f.path}". Please delete manually. $e');
+ globals.printError('Failed to delete "${f.path}". Please delete manually. $e');
continue;
}
for (Directory d = f.parent; d.absolute.path != cache.getDownloadDir().absolute.path; d = d.parent) {
@@ -520,6 +516,7 @@
/// Hook method for extra checks for being up-to-date.
bool isUpToDateInner() => true;
+
/// Template method to perform artifact update.
Future<void> updateInner();
@@ -529,7 +526,7 @@
Future<void> _downloadArchive(String message, Uri url, Directory location, bool verifier(File f), void extractor(File f, Directory d)) {
return _withDownloadFile('${flattenNameSubdirs(url)}', (File tempFile) async {
if (!verifier(tempFile)) {
- final Status status = logger.startProgress(message, timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress(message, timeout: timeoutConfiguration.slowOperation);
try {
await _downloadFile(url, tempFile);
status.stop();
@@ -538,7 +535,7 @@
rethrow;
}
} else {
- logger.printTrace('$message (cached)');
+ globals.logger.printTrace('$message (cached)');
}
_ensureExists(location);
extractor(tempFile, location);
@@ -558,7 +555,7 @@
/// Create a temporary file and invoke [onTemporaryFile] with the file as
/// argument, then add the temporary file to the [downloadedFiles].
Future<void> _withDownloadFile(String name, Future<void> onTemporaryFile(File file)) async {
- final File tempFile = fs.file(fs.path.join(cache.getDownloadDir().path, name));
+ final File tempFile = globals.fs.file(globals.fs.path.join(cache.getDownloadDir().path, name));
downloadedFiles.add(tempFile);
await onTemporaryFile(tempFile);
}
@@ -599,11 +596,11 @@
@override
Future<void> updateInner() async {
String platformName = 'flutter-web-sdk-';
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
platformName += 'darwin-x64';
- } else if (platform.isLinux) {
+ } else if (globals.platform.isLinux) {
platformName += 'linux-x64';
- } else if (platform.isWindows) {
+ } else if (globals.platform.isWindows) {
platformName += 'windows-x64';
}
final Uri url = Uri.parse('${cache.storageBaseUrl}/flutter_infra/flutter/$version/$platformName.zip');
@@ -611,10 +608,10 @@
// This is a temporary work-around for not being able to safely download into a shared directory.
for (FileSystemEntity entity in location.listSync(recursive: true)) {
if (entity is File) {
- final List<String> segments = fs.path.split(entity.path);
+ final List<String> segments = globals.fs.path.split(entity.path);
segments.remove('flutter_web_sdk');
- final String newPath = fs.path.joinAll(segments);
- final File newFile = fs.file(newPath);
+ final String newPath = globals.fs.path.joinAll(segments);
+ final File newFile = globals.fs.file(newPath);
if (!newFile.existsSync()) {
newFile.createSync(recursive: true);
}
@@ -647,21 +644,21 @@
bool isUpToDateInner() {
final Directory pkgDir = cache.getCacheDir('pkg');
for (String pkgName in getPackageDirs()) {
- final String pkgPath = fs.path.join(pkgDir.path, pkgName);
- if (!fs.directory(pkgPath).existsSync()) {
+ final String pkgPath = globals.fs.path.join(pkgDir.path, pkgName);
+ if (!globals.fs.directory(pkgPath).existsSync()) {
return false;
}
}
for (List<String> toolsDir in getBinaryDirs()) {
- final Directory dir = fs.directory(fs.path.join(location.path, toolsDir[0]));
+ final Directory dir = globals.fs.directory(globals.fs.path.join(location.path, toolsDir[0]));
if (!dir.existsSync()) {
return false;
}
}
for (String licenseDir in getLicenseDirs()) {
- final File file = fs.file(fs.path.join(location.path, licenseDir, 'LICENSE'));
+ final File file = globals.fs.file(globals.fs.path.join(location.path, licenseDir, 'LICENSE'));
if (!file.existsSync()) {
return false;
}
@@ -681,16 +678,16 @@
for (List<String> toolsDir in getBinaryDirs()) {
final String cacheDir = toolsDir[0];
final String urlPath = toolsDir[1];
- final Directory dir = fs.directory(fs.path.join(location.path, cacheDir));
+ final Directory dir = globals.fs.directory(globals.fs.path.join(location.path, cacheDir));
await _downloadZipArchive('Downloading $cacheDir tools...', Uri.parse(url + urlPath), dir);
_makeFilesExecutable(dir);
const List<String> frameworkNames = <String>['Flutter', 'FlutterMacOS'];
for (String frameworkName in frameworkNames) {
- final File frameworkZip = fs.file(fs.path.join(dir.path, '$frameworkName.framework.zip'));
+ final File frameworkZip = globals.fs.file(globals.fs.path.join(dir.path, '$frameworkName.framework.zip'));
if (frameworkZip.existsSync()) {
- final Directory framework = fs.directory(fs.path.join(dir.path, '$frameworkName.framework'));
+ final Directory framework = globals.fs.directory(globals.fs.path.join(dir.path, '$frameworkName.framework'));
framework.createSync();
os.unzip(frameworkZip, framework);
}
@@ -699,7 +696,7 @@
final File licenseSource = cache.getLicenseFile();
for (String licenseDir in getLicenseDirs()) {
- final String licenseDestinationPath = fs.path.join(location.path, licenseDir, 'LICENSE');
+ final String licenseDestinationPath = globals.fs.path.join(location.path, licenseDir, 'LICENSE');
await licenseSource.copy(licenseDestinationPath);
}
}
@@ -766,11 +763,11 @@
<String>['linux-x64', 'linux-x64/artifacts.zip'],
<String>['darwin-x64', 'darwin-x64/artifacts.zip'],
]
- else if (platform.isWindows)
+ else if (globals.platform.isWindows)
<String>['windows-x64', 'windows-x64/artifacts.zip']
- else if (platform.isMacOS)
+ else if (globals.platform.isMacOS)
<String>['darwin-x64', 'darwin-x64/artifacts.zip']
- else if (platform.isLinux)
+ else if (globals.platform.isLinux)
<String>['linux-x64', 'linux-x64/artifacts.zip'],
];
}
@@ -791,7 +788,7 @@
@override
List<List<String>> getBinaryDirs() {
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
return _macOSDesktopBinaryDirs;
}
return const <List<String>>[];
@@ -813,7 +810,7 @@
@override
List<List<String>> getBinaryDirs() {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
return _windowsDesktopBinaryDirs;
}
return const <List<String>>[];
@@ -835,7 +832,7 @@
@override
List<List<String>> getBinaryDirs() {
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
return _linuxDesktopBinaryDirs;
}
return const <List<String>>[];
@@ -864,11 +861,11 @@
..._linuxBinaryDirs,
..._windowsBinaryDirs,
..._dartSdks,
- ] else if (platform.isWindows)
+ ] else if (globals.platform.isWindows)
..._windowsBinaryDirs
- else if (platform.isMacOS)
+ else if (globals.platform.isMacOS)
..._osxBinaryDirs
- else if (platform.isLinux)
+ else if (globals.platform.isLinux)
..._linuxBinaryDirs,
];
}
@@ -905,13 +902,13 @@
@override
Future<void> update() async {
final Directory tempDir =
- fs.systemTempDirectory.createTempSync('flutter_gradle_wrapper.');
+ globals.fs.systemTempDirectory.createTempSync('flutter_gradle_wrapper.');
gradleUtils.injectGradleWrapperIfNeeded(tempDir);
- final Status status = logger.startProgress('Downloading Android Maven dependencies...',
+ final Status status = globals.logger.startProgress('Downloading Android Maven dependencies...',
timeout: timeoutConfiguration.slowOperation);
final File gradle = tempDir.childFile(
- platform.isWindows ? 'gradlew.bat' : 'gradlew',
+ globals.platform.isWindows ? 'gradlew.bat' : 'gradlew',
);
try {
final String gradleExecutable = gradle.absolute.path;
@@ -919,13 +916,13 @@
final RunResult processResult = await processUtils.run(
<String>[
gradleExecutable,
- '-b', fs.path.join(flutterSdk, 'packages', 'flutter_tools', 'gradle', 'resolve_dependencies.gradle'),
+ '-b', globals.fs.path.join(flutterSdk, 'packages', 'flutter_tools', 'gradle', 'resolve_dependencies.gradle'),
'--project-cache-dir', tempDir.path,
'resolveDependencies',
],
environment: gradleEnvironment);
if (processResult.exitCode != 0) {
- printError('Failed to download the Android dependencies');
+ globals.printError('Failed to download the Android dependencies');
}
} finally {
status.stop();
@@ -952,14 +949,14 @@
@override
List<List<String>> getBinaryDirs() {
return <List<String>>[
- if (platform.isMacOS || cache.includeAllPlatforms)
+ if (globals.platform.isMacOS || cache.includeAllPlatforms)
..._iosBinaryDirs,
];
}
@override
List<String> getLicenseDirs() {
- if (cache.includeAllPlatforms || platform.isMacOS) {
+ if (cache.includeAllPlatforms || globals.platform.isMacOS) {
return const <String>['ios', 'ios-profile', 'ios-release'];
}
return const <String>[];
@@ -984,32 +981,32 @@
List<String> get _gradleScripts => <String>['gradlew', 'gradlew.bat'];
- String get _gradleWrapper => fs.path.join('gradle', 'wrapper', 'gradle-wrapper.jar');
+ String get _gradleWrapper => globals.fs.path.join('gradle', 'wrapper', 'gradle-wrapper.jar');
@override
Future<void> updateInner() {
final Uri archiveUri = _toStorageUri(version);
return _downloadZippedTarball('Downloading Gradle Wrapper...', archiveUri, location).then<void>((_) {
// Delete property file, allowing templates to provide it.
- fs.file(fs.path.join(location.path, 'gradle', 'wrapper', 'gradle-wrapper.properties')).deleteSync();
+ globals.fs.file(globals.fs.path.join(location.path, 'gradle', 'wrapper', 'gradle-wrapper.properties')).deleteSync();
// Remove NOTICE file. Should not be part of the template.
- fs.file(fs.path.join(location.path, 'NOTICE')).deleteSync();
+ globals.fs.file(globals.fs.path.join(location.path, 'NOTICE')).deleteSync();
});
}
@override
bool isUpToDateInner() {
- final Directory wrapperDir = cache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper'));
- if (!fs.directory(wrapperDir).existsSync()) {
+ final Directory wrapperDir = cache.getCacheDir(globals.fs.path.join('artifacts', 'gradle_wrapper'));
+ if (!globals.fs.directory(wrapperDir).existsSync()) {
return false;
}
for (String scriptName in _gradleScripts) {
- final File scriptFile = fs.file(fs.path.join(wrapperDir.path, scriptName));
+ final File scriptFile = globals.fs.file(globals.fs.path.join(wrapperDir.path, scriptName));
if (!scriptFile.existsSync()) {
return false;
}
}
- final File gradleWrapperJar = fs.file(fs.path.join(wrapperDir.path, _gradleWrapper));
+ final File gradleWrapperJar = globals.fs.file(globals.fs.path.join(wrapperDir.path, _gradleWrapper));
if (!gradleWrapperJar.existsSync()) {
return false;
}
@@ -1058,7 +1055,7 @@
@override
Future<void> updateInner() async {
- if (!platform.isLinux && !platform.isMacOS) {
+ if (!globals.platform.isLinux && !globals.platform.isMacOS) {
return Future<void>.value();
}
final String url = '$_cipdBaseUrl/flutter/fuchsia/+/git_revision:$version';
@@ -1115,7 +1112,7 @@
@override
Future<void> updateInner() async {
- if (!platform.isLinux && !platform.isMacOS) {
+ if (!globals.platform.isLinux && !globals.platform.isMacOS) {
return Future<void>.value();
}
await _downloadDebugSymbols('x64');
@@ -1129,7 +1126,7 @@
@override
Future<void> updateInner() {
- if (!platform.isLinux) {
+ if (!globals.platform.isLinux) {
return Future<void>.value();
}
return _doUpdate();
@@ -1142,7 +1139,7 @@
@override
Future<void> updateInner() async {
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
return Future<void>.value();
}
return _doUpdate();
@@ -1202,7 +1199,7 @@
@override
Future<void> updateInner() {
- if (!platform.isMacOS && !cache.includeAllPlatforms) {
+ if (!globals.platform.isMacOS && !cache.includeAllPlatforms) {
return Future<void>.value();
}
if (location.existsSync()) {
@@ -1244,7 +1241,7 @@
String flattenNameSubdirs(Uri url) {
final List<String> pieces = <String>[url.host, ...url.pathSegments];
final Iterable<String> convertedPieces = pieces.map<String>(_flattenNameNoSubdirs);
- return fs.path.joinAll(convertedPieces);
+ return globals.fs.path.joinAll(convertedPieces);
}
/// Download a file from the given [url] and write it to [location].
@@ -1254,7 +1251,7 @@
}
Future<bool> _doesRemoteExist(String message, Uri url) async {
- final Status status = logger.startProgress(message, timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress(message, timeout: timeoutConfiguration.slowOperation);
final bool exists = await doesRemoteFileExist(url);
status.stop();
return exists;
diff --git a/packages/flutter_tools/lib/src/codegen.dart b/packages/flutter_tools/lib/src/codegen.dart
index 1f48a12..75e1072 100644
--- a/packages/flutter_tools/lib/src/codegen.dart
+++ b/packages/flutter_tools/lib/src/codegen.dart
@@ -6,12 +6,10 @@
import 'artifacts.dart';
import 'base/context.dart';
-import 'base/file_system.dart';
-import 'base/platform.dart';
import 'build_info.dart';
import 'compile.dart';
import 'dart/package_map.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'project.dart';
// Arbitrarily chosen multi-root file scheme. This is used to configure the
@@ -48,11 +46,11 @@
/// scheme. To support codegen on arbitrary packages we would need to do
/// this for each dependency.
void updatePackages(FlutterProject flutterProject) {
- final String oldPackagesContents = fs.file(PackageMap.globalPackagesPath).readAsStringSync();
+ final String oldPackagesContents = globals.fs.file(PackageMap.globalPackagesPath).readAsStringSync();
final String appName = flutterProject.manifest.appName;
final String newPackagesContents = oldPackagesContents.replaceFirst('$appName:lib/', '$appName:$kMultiRootScheme:/');
- final String generatedPackagesPath = fs.path.setExtension(PackageMap.globalPackagesPath, '.generated');
- fs.file(generatedPackagesPath).writeAsStringSync(newPackagesContents);
+ final String generatedPackagesPath = globals.fs.path.setExtension(PackageMap.globalPackagesPath, '.generated');
+ globals.fs.file(generatedPackagesPath).writeAsStringSync(newPackagesContents);
}
}
@@ -112,7 +110,7 @@
List<String> dartDefines,
}) async {
if (fileSystemRoots != null || fileSystemScheme != null || depFilePath != null || targetModel != null || sdkRoot != null || packagesPath != null) {
- printTrace('fileSystemRoots, fileSystemScheme, depFilePath, targetModel,'
+ globals.printTrace('fileSystemRoots, fileSystemScheme, depFilePath, targetModel,'
'sdkRoot, packagesPath are not supported when using the experimental '
'build* pipeline');
}
@@ -122,7 +120,7 @@
codegenDaemon.startBuild();
await for (CodegenStatus codegenStatus in codegenDaemon.buildResults) {
if (codegenStatus == CodegenStatus.Failed) {
- printError('Code generation failed, build may have compile errors.');
+ globals.printError('Code generation failed, build may have compile errors.');
break;
}
if (codegenStatus == CodegenStatus.Succeeded) {
@@ -141,8 +139,8 @@
sdkRoot: sdkRoot,
packagesPath: PackageMap.globalGeneratedPackagesPath,
fileSystemRoots: <String>[
- fs.path.join(flutterProject.generated.path, 'lib${platform.pathSeparator}'),
- fs.path.join(flutterProject.directory.path, 'lib${platform.pathSeparator}'),
+ globals.fs.path.join(flutterProject.generated.path, 'lib${globals.platform.pathSeparator}'),
+ globals.fs.path.join(flutterProject.directory.path, 'lib${globals.platform.pathSeparator}'),
],
fileSystemScheme: kMultiRootScheme,
depFilePath: depFilePath,
@@ -168,7 +166,7 @@
@required FlutterProject flutterProject,
@required BuildMode buildMode,
bool trackWidgetCreation = false,
- CompilerMessageConsumer compilerMessageConsumer = printError,
+ CompilerMessageConsumer compilerMessageConsumer = globals.printError,
bool unsafePackageSerialization = false,
String outputPath,
String initializeFromDill,
@@ -178,7 +176,7 @@
}) async {
codeGenerator.updatePackages(flutterProject);
final ResidentCompiler residentCompiler = ResidentCompiler(
- artifacts.getArtifactPath(
+ globals.artifacts.getArtifactPath(
Artifact.flutterPatchedSdkPath,
platform: targetPlatform,
mode: buildMode,
@@ -187,8 +185,8 @@
trackWidgetCreation: trackWidgetCreation,
packagesPath: PackageMap.globalGeneratedPackagesPath,
fileSystemRoots: <String>[
- fs.path.join(flutterProject.generated.path, 'lib${platform.pathSeparator}'),
- fs.path.join(flutterProject.directory.path, 'lib${platform.pathSeparator}'),
+ globals.fs.path.join(flutterProject.generated.path, 'lib${globals.platform.pathSeparator}'),
+ globals.fs.path.join(flutterProject.directory.path, 'lib${globals.platform.pathSeparator}'),
],
fileSystemScheme: kMultiRootScheme,
targetModel: TargetModel.flutter,
@@ -205,7 +203,7 @@
return status == CodegenStatus.Succeeded || status == CodegenStatus.Failed;
});
if (status == CodegenStatus.Failed) {
- printError('Code generation failed, build may have compile errors.');
+ globals.printError('Code generation failed, build may have compile errors.');
}
return CodeGeneratingResidentCompiler._(residentCompiler, codegenDaemon, flutterProject);
}
@@ -232,13 +230,13 @@
});
}
if (_codegenDaemon.lastStatus == CodegenStatus.Failed) {
- printError('Code generation failed, build may have compile errors.');
+ globals.printError('Code generation failed, build may have compile errors.');
}
// Update the generated packages file if the original packages file has changes.
- if (fs.statSync(PackageMap.globalPackagesPath).modified.millisecondsSinceEpoch >
- fs.statSync(PackageMap.globalGeneratedPackagesPath).modified.millisecondsSinceEpoch) {
+ if (globals.fs.statSync(PackageMap.globalPackagesPath).modified.millisecondsSinceEpoch >
+ globals.fs.statSync(PackageMap.globalGeneratedPackagesPath).modified.millisecondsSinceEpoch) {
codeGenerator.updatePackages(_flutterProject);
- invalidatedFiles.add(fs.file(PackageMap.globalGeneratedPackagesPath).uri);
+ invalidatedFiles.add(globals.fs.file(PackageMap.globalGeneratedPackagesPath).uri);
}
return _residentCompiler.recompile(
mainPath,
diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart
index c4123c0..a3661a1 100644
--- a/packages/flutter_tools/lib/src/commands/analyze.dart
+++ b/packages/flutter_tools/lib/src/commands/analyze.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import '../base/file_system.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import 'analyze_continuously.dart';
import 'analyze_once.dart';
@@ -72,7 +73,7 @@
}
// Or we're not in a project directory.
- if (!fs.file('pubspec.yaml').existsSync()) {
+ if (!globals.fs.file('pubspec.yaml').existsSync()) {
return false;
}
diff --git a/packages/flutter_tools/lib/src/commands/analyze_base.dart b/packages/flutter_tools/lib/src/commands/analyze_base.dart
index 32c7aad..568e117 100644
--- a/packages/flutter_tools/lib/src/commands/analyze_base.dart
+++ b/packages/flutter_tools/lib/src/commands/analyze_base.dart
@@ -11,7 +11,7 @@
import '../base/file_system.dart';
import '../base/utils.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
/// Common behavior for `flutter analyze` and `flutter analyze --watch`
abstract class AnalyzeBase {
@@ -26,7 +26,7 @@
void dumpErrors(Iterable<String> errors) {
if (argResults['write'] != null) {
try {
- final RandomAccessFile resultsFile = fs.file(argResults['write']).openSync(mode: FileMode.write);
+ final RandomAccessFile resultsFile = globals.fs.file(argResults['write']).openSync(mode: FileMode.write);
try {
resultsFile.lockSync();
resultsFile.writeStringSync(errors.join('\n'));
@@ -34,7 +34,7 @@
resultsFile.close();
}
} catch (e) {
- printError('Failed to save output to "${argResults['write']}": $e');
+ globals.printError('Failed to save output to "${argResults['write']}": $e');
}
}
}
@@ -46,8 +46,8 @@
'issues': errorCount,
'missingDartDocs': membersMissingDocumentation,
};
- fs.file(benchmarkOut).writeAsStringSync(toPrettyJson(data));
- printStatus('Analysis benchmark written to $benchmarkOut ($data).');
+ globals.fs.file(benchmarkOut).writeAsStringSync(toPrettyJson(data));
+ globals.printStatus('Analysis benchmark written to $benchmarkOut ($data).');
}
bool get isBenchmarking => argResults['benchmark'] as bool;
@@ -57,12 +57,12 @@
/// If [fileList] is empty, then return true if the current directory resides inside the Flutter repository.
bool inRepo(List<String> fileList) {
if (fileList == null || fileList.isEmpty) {
- fileList = <String>[fs.path.current];
+ fileList = <String>[globals.fs.path.current];
}
- final String root = fs.path.normalize(fs.path.absolute(Cache.flutterRoot));
- final String prefix = root + fs.path.separator;
+ final String root = globals.fs.path.normalize(globals.fs.path.absolute(Cache.flutterRoot));
+ final String prefix = root + globals.fs.path.separator;
for (String file in fileList) {
- file = fs.path.normalize(fs.path.absolute(file));
+ file = globals.fs.path.normalize(globals.fs.path.absolute(file));
if (file == root || file.startsWith(prefix)) {
return true;
}
@@ -85,11 +85,11 @@
}
bool get hasConflict => values.length > 1;
bool get hasConflictAffectingFlutterRepo {
- assert(fs.path.isAbsolute(Cache.flutterRoot));
+ assert(globals.fs.path.isAbsolute(Cache.flutterRoot));
for (List<String> targetSources in values.values) {
for (String source in targetSources) {
- assert(fs.path.isAbsolute(source));
- if (fs.path.isWithin(Cache.flutterRoot, source)) {
+ assert(globals.fs.path.isAbsolute(source));
+ if (globals.fs.path.isWithin(Cache.flutterRoot, source)) {
return true;
}
}
@@ -132,8 +132,8 @@
/// Read the .packages file in [directory] and add referenced packages to [dependencies].
void addDependenciesFromPackagesFileIn(Directory directory) {
- final String dotPackagesPath = fs.path.join(directory.path, '.packages');
- final File dotPackages = fs.file(dotPackagesPath);
+ final String dotPackagesPath = globals.fs.path.join(directory.path, '.packages');
+ final File dotPackages = globals.fs.file(dotPackagesPath);
if (dotPackages.existsSync()) {
// this directory has opinions about what we should be using
final Iterable<String> lines = dotPackages
@@ -144,12 +144,12 @@
final int colon = line.indexOf(':');
if (colon > 0) {
final String packageName = line.substring(0, colon);
- final String packagePath = fs.path.fromUri(line.substring(colon+1));
+ final String packagePath = globals.fs.path.fromUri(line.substring(colon+1));
// Ensure that we only add `analyzer` and dependent packages defined in the vended SDK (and referred to with a local
- // fs.path. directive). Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored
+ // globals.fs.path. directive). Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored
// since they would produce spurious conflicts.
if (!_vendedSdkPackages.contains(packageName) || packagePath.startsWith('..')) {
- add(packageName, fs.path.normalize(fs.path.absolute(directory.path, packagePath)), dotPackagesPath);
+ add(packageName, globals.fs.path.normalize(globals.fs.path.absolute(directory.path, packagePath)), dotPackagesPath);
}
}
}
@@ -166,17 +166,17 @@
void checkForConflictingDependencies(Iterable<Directory> pubSpecDirectories, PackageDependencyTracker dependencies) {
for (Directory directory in pubSpecDirectories) {
- final String pubSpecYamlPath = fs.path.join(directory.path, 'pubspec.yaml');
- final File pubSpecYamlFile = fs.file(pubSpecYamlPath);
+ final String pubSpecYamlPath = globals.fs.path.join(directory.path, 'pubspec.yaml');
+ final File pubSpecYamlFile = globals.fs.file(pubSpecYamlPath);
if (pubSpecYamlFile.existsSync()) {
// we are analyzing the actual canonical source for this package;
// make sure we remember that, in case all the packages are actually
// pointing elsewhere somehow.
- final dynamic pubSpecYaml = yaml.loadYaml(fs.file(pubSpecYamlPath).readAsStringSync());
+ final dynamic pubSpecYaml = yaml.loadYaml(globals.fs.file(pubSpecYamlPath).readAsStringSync());
if (pubSpecYaml is yaml.YamlMap) {
final dynamic packageName = pubSpecYaml['name'];
if (packageName is String) {
- final String packagePath = fs.path.normalize(fs.path.absolute(fs.path.join(directory.path, 'lib')));
+ final String packagePath = globals.fs.path.normalize(globals.fs.path.absolute(globals.fs.path.join(directory.path, 'lib')));
dependencies.addCanonicalCase(packageName, packagePath, pubSpecYamlPath);
} else {
throwToolExit('pubspec.yaml is malformed. The name should be a String.');
diff --git a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart
index 89d386f..2e9802c 100644
--- a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart
+++ b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart
@@ -10,12 +10,11 @@
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
-import '../base/terminal.dart';
import '../base/utils.dart';
import '../cache.dart';
import '../dart/analysis.dart';
import '../dart/sdk.dart' as sdk;
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'analyze_base.dart';
class AnalyzeContinuously extends AnalyzeBase {
@@ -43,13 +42,13 @@
directories = repoRoots;
analysisTarget = 'Flutter repository';
- printTrace('Analyzing Flutter repository:');
+ globals.printTrace('Analyzing Flutter repository:');
for (String projectPath in repoRoots) {
- printTrace(' ${fs.path.relative(projectPath)}');
+ globals.printTrace(' ${globals.fs.path.relative(projectPath)}');
}
} else {
- directories = <String>[fs.currentDirectory.path];
- analysisTarget = fs.currentDirectory.path;
+ directories = <String>[globals.fs.currentDirectory.path];
+ analysisTarget = globals.fs.currentDirectory.path;
}
final String sdkPath = argResults['dart-sdk'] as String ?? sdk.dartSdkPath;
@@ -67,7 +66,7 @@
if (exitCode != 0) {
throwToolExit(message, exitCode: exitCode);
}
- printStatus(message);
+ globals.printStatus(message);
if (server.didServerErrorOccur) {
throwToolExit('Server error(s) occurred.');
@@ -78,9 +77,9 @@
if (isAnalyzing) {
analysisStatus?.cancel();
if (!firstAnalysis) {
- printStatus('\n');
+ globals.printStatus('\n');
}
- analysisStatus = logger.startProgress('Analyzing $analysisTarget...', timeout: timeoutConfiguration.slowOperation);
+ analysisStatus = globals.logger.startProgress('Analyzing $analysisTarget...', timeout: timeoutConfiguration.slowOperation);
analyzedPaths.clear();
analysisTimer = Stopwatch()..start();
} else {
@@ -88,12 +87,12 @@
analysisStatus = null;
analysisTimer.stop();
- logger.printStatus(terminal.clearScreen(), newline: false);
+ globals.logger.printStatus(globals.terminal.clearScreen(), newline: false);
// Remove errors for deleted files, sort, and print errors.
final List<AnalysisError> errors = <AnalysisError>[];
for (String path in analysisErrors.keys.toList()) {
- if (fs.isFileSync(path)) {
+ if (globals.fs.isFileSync(path)) {
errors.addAll(analysisErrors[path]);
} else {
analysisErrors.remove(path);
@@ -114,9 +113,9 @@
errors.sort();
for (AnalysisError error in errors) {
- printStatus(error.toString());
+ globals.printStatus(error.toString());
if (error.code != null) {
- printTrace('error code: ${error.code}');
+ globals.printTrace('error code: ${error.code}');
}
}
@@ -149,9 +148,9 @@
final String files = '${analyzedPaths.length} ${pluralize('file', analyzedPaths.length)}';
final String seconds = (analysisTimer.elapsedMilliseconds / 1000.0).toStringAsFixed(2);
if (undocumentedMembers > 0) {
- printStatus('$errorsMessage • $dartdocMessage • analyzed $files in $seconds seconds');
+ globals.printStatus('$errorsMessage • $dartdocMessage • analyzed $files in $seconds seconds');
} else {
- printStatus('$errorsMessage • analyzed $files in $seconds seconds');
+ globals.printStatus('$errorsMessage • analyzed $files in $seconds seconds');
}
if (firstAnalysis && isBenchmarking) {
diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart
index c339a49..aaa44df 100644
--- a/packages/flutter_tools/lib/src/commands/analyze_once.dart
+++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart
@@ -13,7 +13,7 @@
import '../cache.dart';
import '../dart/analysis.dart';
import '../dart/sdk.dart' as sdk;
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'analyze.dart';
import 'analyze_base.dart';
@@ -35,14 +35,14 @@
@override
Future<void> analyze() async {
final String currentDirectory =
- (workingDirectory ?? fs.currentDirectory).path;
+ (workingDirectory ?? globals.fs.currentDirectory).path;
// find directories from argResults.rest
final Set<String> directories = Set<String>.from(argResults.rest
- .map<String>((String path) => fs.path.canonicalize(path)));
+ .map<String>((String path) => globals.fs.path.canonicalize(path)));
if (directories.isNotEmpty) {
for (String directory in directories) {
- final FileSystemEntityType type = fs.typeSync(directory);
+ final FileSystemEntityType type = globals.fs.typeSync(directory);
if (type == FileSystemEntityType.notFound) {
throwToolExit("'$directory' does not exist");
@@ -108,9 +108,9 @@
final Stopwatch timer = Stopwatch()..start();
final String message = directories.length > 1
? '${directories.length} ${directories.length == 1 ? 'directory' : 'directories'}'
- : fs.path.basename(directories.first);
+ : globals.fs.path.basename(directories.first);
final Status progress = argResults['preamble'] as bool
- ? logger.startProgress('Analyzing $message...', timeout: timeoutConfiguration.slowOperation)
+ ? globals.logger.startProgress('Analyzing $message...', timeout: timeoutConfiguration.slowOperation)
: null;
await analysisCompleter.future;
@@ -135,11 +135,11 @@
// report errors
if (errors.isNotEmpty && (argResults['preamble'] as bool)) {
- printStatus('');
+ globals.printStatus('');
}
errors.sort();
for (AnalysisError error in errors) {
- printStatus(error.toString(), hangingIndent: 7);
+ globals.printStatus(error.toString(), hangingIndent: 7);
}
final String seconds = (timer.elapsedMilliseconds / 1000.0).toStringAsFixed(1);
@@ -154,7 +154,7 @@
// We consider any level of error to be an error exit (we don't report different levels).
if (errors.isNotEmpty) {
final int errorCount = errors.length;
- printStatus('');
+ globals.printStatus('');
if (undocumentedMembers > 0) {
throwToolExit('$errorCount ${pluralize('issue', errorCount)} found. (ran in ${seconds}s; $dartdocMessage)');
} else {
@@ -168,9 +168,9 @@
if (argResults['congratulate'] as bool) {
if (undocumentedMembers > 0) {
- printStatus('No issues found! (ran in ${seconds}s; $dartdocMessage)');
+ globals.printStatus('No issues found! (ran in ${seconds}s; $dartdocMessage)');
} else {
- printStatus('No issues found! (ran in ${seconds}s)');
+ globals.printStatus('No issues found! (ran in ${seconds}s)');
}
}
}
diff --git a/packages/flutter_tools/lib/src/commands/assemble.dart b/packages/flutter_tools/lib/src/commands/assemble.dart
index 0c6fbda..583412b 100644
--- a/packages/flutter_tools/lib/src/commands/assemble.dart
+++ b/packages/flutter_tools/lib/src/commands/assemble.dart
@@ -16,7 +16,7 @@
import '../build_system/targets/macos.dart';
import '../build_system/targets/web.dart';
import '../build_system/targets/windows.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
@@ -137,11 +137,11 @@
throwToolExit('--output directory is required for assemble.');
}
// If path is relative, make it absolute from flutter project.
- if (fs.path.isRelative(output)) {
- output = fs.path.join(flutterProject.directory.path, output);
+ if (globals.fs.path.isRelative(output)) {
+ output = globals.fs.path.join(flutterProject.directory.path, output);
}
final Environment result = Environment(
- outputDir: fs.directory(output),
+ outputDir: globals.fs.directory(output),
buildDir: flutterProject.directory
.childDirectory('.dart_tool')
.childDirectory('flutter_build'),
@@ -180,7 +180,7 @@
));
if (!result.success) {
for (ExceptionMeasurement measurement in result.exceptions.values) {
- printError('Target ${measurement.target} failed: ${measurement.exception}',
+ globals.printError('Target ${measurement.target} failed: ${measurement.exception}',
stackTrace: measurement.fatal
? measurement.stackTrace
: null,
@@ -188,7 +188,7 @@
}
throwToolExit('build failed.');
}
- printTrace('build succeeded.');
+ globals.printTrace('build succeeded.');
if (argResults.wasParsed('build-inputs')) {
writeListIfChanged(result.inputFiles, stringArg('build-inputs'));
}
@@ -196,9 +196,9 @@
writeListIfChanged(result.outputFiles, stringArg('build-outputs'));
}
if (argResults.wasParsed('depfile')) {
- final File depfileFile = fs.file(stringArg('depfile'));
+ final File depfileFile = globals.fs.file(stringArg('depfile'));
final Depfile depfile = Depfile(result.inputFiles, result.outputFiles);
- depfile.writeToFile(fs.file(depfileFile));
+ depfile.writeToFile(globals.fs.file(depfileFile));
}
return null;
}
@@ -206,7 +206,7 @@
@visibleForTesting
void writeListIfChanged(List<File> files, String path) {
- final File file = fs.file(path);
+ final File file = globals.fs.file(path);
final StringBuffer buffer = StringBuffer();
// These files are already sorted.
for (File file in files) {
diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart
index da717c3..3ce4a89 100644
--- a/packages/flutter_tools/lib/src/commands/attach.dart
+++ b/packages/flutter_tools/lib/src/commands/attach.dart
@@ -11,14 +11,13 @@
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/terminal.dart';
import '../base/utils.dart';
import '../cache.dart';
import '../commands/daemon.dart';
import '../compile.dart';
import '../device.dart';
import '../fuchsia/fuchsia_device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/devices.dart';
import '../ios/simulators.dart';
import '../mdns_discovery.dart';
@@ -172,11 +171,11 @@
final Device device = await findTargetDevice();
- final Artifacts artifacts = device.artifactOverrides ?? Artifacts.instance;
+ final Artifacts overrideArtifacts = device.artifactOverrides ?? globals.artifacts;
await context.run<void>(
body: () => _attachToDevice(device),
overrides: <Type, Generator>{
- Artifacts: () => artifacts,
+ Artifacts: () => overrideArtifacts,
});
return null;
@@ -254,7 +253,7 @@
devicePort: deviceVmservicePort,
hostPort: hostVmservicePort,
);
- printStatus('Waiting for a connection from Flutter on ${device.name}...');
+ globals.printStatus('Waiting for a connection from Flutter on ${device.name}...');
observatoryUri = observatoryDiscovery.uris;
// Determine ipv6 status from the scanned logs.
usesIpv6 = observatoryDiscovery.ipv6;
@@ -272,7 +271,7 @@
).asBroadcastStream();
}
- terminal.usesTerminalUi = daemon == null;
+ globals.terminal.usesTerminalUi = daemon == null;
try {
int result;
@@ -291,7 +290,7 @@
device,
null,
true,
- fs.currentDirectory,
+ globals.fs.currentDirectory,
LaunchMode.attach,
);
} catch (error) {
@@ -326,7 +325,7 @@
if (runner.exited || !runner.isWaitingForObservatory) {
break;
}
- printStatus('Waiting for a new connection from Flutter on ${device.name}...');
+ globals.printStatus('Waiting for a new connection from Flutter on ${device.name}...');
}
} finally {
final List<ForwardedPort> ports = device.portForwarder.forwardedPorts.toList();
diff --git a/packages/flutter_tools/lib/src/commands/build_apk.dart b/packages/flutter_tools/lib/src/commands/build_apk.dart
index 05948bc..3307656 100644
--- a/packages/flutter_tools/lib/src/commands/build_apk.dart
+++ b/packages/flutter_tools/lib/src/commands/build_apk.dart
@@ -10,7 +10,7 @@
import '../base/terminal.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
@@ -93,19 +93,19 @@
if (buildInfo.isRelease && !androidBuildInfo.splitPerAbi && androidBuildInfo.targetArchs.length > 1) {
final String targetPlatforms = stringsArg('target-platform').join(', ');
- printStatus('You are building a fat APK that includes binaries for '
+ globals.printStatus('You are building a fat APK that includes binaries for '
'$targetPlatforms.', emphasis: true, color: TerminalColor.green);
- printStatus('If you are deploying the app to the Play Store, '
+ globals.printStatus('If you are deploying the app to the Play Store, '
'it\'s recommended to use app bundles or split the APK to reduce the APK size.', emphasis: true);
- printStatus('To generate an app bundle, run:', emphasis: true, indent: 4);
- printStatus('flutter build appbundle '
+ globals.printStatus('To generate an app bundle, run:', emphasis: true, indent: 4);
+ globals.printStatus('flutter build appbundle '
'--target-platform ${targetPlatforms.replaceAll(' ', '')}',indent: 8);
- printStatus('Learn more on: https://developer.android.com/guide/app-bundle',indent: 8);
- printStatus('To split the APKs per ABI, run:', emphasis: true, indent: 4);
- printStatus('flutter build apk '
+ globals.printStatus('Learn more on: https://developer.android.com/guide/app-bundle',indent: 8);
+ globals.printStatus('To split the APKs per ABI, run:', emphasis: true, indent: 4);
+ globals.printStatus('flutter build apk '
'--target-platform ${targetPlatforms.replaceAll(' ', '')} '
'--split-per-abi', indent: 8);
- printStatus('Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split',indent: 8);
+ globals.printStatus('Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split',indent: 8);
}
await androidBuilder.buildApk(
project: FlutterProject.current(),
diff --git a/packages/flutter_tools/lib/src/commands/build_bundle.dart b/packages/flutter_tools/lib/src/commands/build_bundle.dart
index 78b3747..90b1c73 100644
--- a/packages/flutter_tools/lib/src/commands/build_bundle.dart
+++ b/packages/flutter_tools/lib/src/commands/build_bundle.dart
@@ -5,10 +5,10 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../features.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart' show FlutterOptions, FlutterCommandResult;
@@ -82,7 +82,7 @@
@override
Future<Map<CustomDimensions, String>> get usageValues async {
- final String projectDir = fs.file(targetFile).parent.parent.path;
+ final String projectDir = globals.fs.file(targetFile).parent.parent.path;
final FlutterProject futterProject = FlutterProject.fromPath(projectDir);
if (futterProject == null) {
return const <CustomDimensions, String>{};
diff --git a/packages/flutter_tools/lib/src/commands/build_fuchsia.dart b/packages/flutter_tools/lib/src/commands/build_fuchsia.dart
index c64f128..b0a8c71 100644
--- a/packages/flutter_tools/lib/src/commands/build_fuchsia.dart
+++ b/packages/flutter_tools/lib/src/commands/build_fuchsia.dart
@@ -5,11 +5,11 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
import '../fuchsia/fuchsia_build.dart';
import '../fuchsia/fuchsia_pm.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import 'build.dart';
@@ -56,7 +56,7 @@
Cache.releaseLockEarly();
final BuildInfo buildInfo = getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current();
- if (!platform.isLinux && !platform.isMacOS) {
+ if (!globals.platform.isLinux && !globals.platform.isMacOS) {
throwToolExit('"build fuchsia" is only supported on Linux and MacOS hosts.');
}
if (!flutterProject.fuchsia.existsSync()) {
diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart
index 62849ee..3f28e77 100644
--- a/packages/flutter_tools/lib/src/commands/build_ios.dart
+++ b/packages/flutter_tools/lib/src/commands/build_ios.dart
@@ -6,10 +6,9 @@
import '../application_package.dart';
import '../base/common.dart';
-import '../base/platform.dart';
import '../base/utils.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/mac.dart';
import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult;
import 'build.dart';
@@ -51,7 +50,7 @@
final bool forSimulator = boolArg('simulator');
defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release;
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
throwToolExit('Building for iOS is only supported on the Mac.');
}
@@ -64,7 +63,7 @@
final bool shouldCodesign = boolArg('codesign');
if (!forSimulator && !shouldCodesign) {
- printStatus('Warning: Building for device with codesigning disabled. You will '
+ globals.printStatus('Warning: Building for device with codesigning disabled. You will '
'have to manually codesign before deploying to device.');
}
final BuildInfo buildInfo = getBuildInfo();
@@ -74,8 +73,8 @@
final String logTarget = forSimulator ? 'simulator' : 'device';
- final String typeName = artifacts.getEngineType(TargetPlatform.ios, buildInfo.mode);
- printStatus('Building $app for $logTarget ($typeName)...');
+ final String typeName = globals.artifacts.getEngineType(TargetPlatform.ios, buildInfo.mode);
+ globals.printStatus('Building $app for $logTarget ($typeName)...');
final XcodeBuildResult result = await buildXcodeProject(
app: app,
buildInfo: buildInfo,
@@ -90,7 +89,7 @@
}
if (result.output != null) {
- printStatus('Built ${result.output}.');
+ globals.printStatus('Built ${result.output}.');
}
return null;
diff --git a/packages/flutter_tools/lib/src/commands/build_ios_framework.dart b/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
index 0cf45b1..bd48a12 100644
--- a/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
+++ b/packages/flutter_tools/lib/src/commands/build_ios_framework.dart
@@ -13,14 +13,13 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../build_system/targets/ios.dart';
import '../bundle.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../macos/cocoapod_utils.dart';
import '../macos/xcode.dart';
import '../plugins.dart';
@@ -121,7 +120,7 @@
throwToolExit('Building frameworks for iOS is only supported from a module.');
}
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
throwToolExit('Building frameworks for iOS is only supported on the Mac.');
}
@@ -141,7 +140,7 @@
Cache.releaseLockEarly();
final String outputArgument = stringArg('output')
- ?? fs.path.join(fs.currentDirectory.path, 'build', 'ios', 'framework');
+ ?? globals.fs.path.join(globals.fs.currentDirectory.path, 'build', 'ios', 'framework');
if (outputArgument.isEmpty) {
throwToolExit('--output is required.');
@@ -153,14 +152,14 @@
throwToolExit("Module's iOS folder missing");
}
- final Directory outputDirectory = fs.directory(fs.path.absolute(fs.path.normalize(outputArgument)));
+ final Directory outputDirectory = globals.fs.directory(globals.fs.path.absolute(globals.fs.path.normalize(outputArgument)));
aotBuilder ??= AotBuilder();
bundleBuilder ??= BundleBuilder();
- cache ??= Cache.instance;
+ cache ??= globals.cache;
for (BuildMode mode in buildModes) {
- printStatus('Building framework for $iosProject in ${getNameForBuildMode(mode)} mode...');
+ globals.printStatus('Building framework for $iosProject in ${getNameForBuildMode(mode)} mode...');
final String xcodeBuildConfiguration = toTitleCase(getNameForBuildMode(mode));
final Directory modeDirectory = outputDirectory.childDirectory(xcodeBuildConfiguration);
@@ -188,7 +187,8 @@
await _producePlugins(mode, xcodeBuildConfiguration, iPhoneBuildOutput, simulatorBuildOutput, modeDirectory, outputDirectory);
}
- final Status status = logger.startProgress(' └─Moving to ${fs.path.relative(modeDirectory.path)}', timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress(
+ ' └─Moving to ${globals.fs.path.relative(modeDirectory.path)}', timeout: timeoutConfiguration.slowOperation);
try {
// Delete the intermediaries since they would have been copied into our
// output frameworks.
@@ -203,7 +203,7 @@
}
}
- printStatus('Frameworks written to ${outputDirectory.path}.');
+ globals.printStatus('Frameworks written to ${outputDirectory.path}.');
return null;
}
@@ -212,7 +212,7 @@
/// vendored framework caching.
@visibleForTesting
void produceFlutterPodspec(BuildMode mode, Directory modeDirectory) {
- final Status status = logger.startProgress(' ├─Creating Flutter.podspec...', timeout: timeoutConfiguration.fastOperation);
+ final Status status = globals.logger.startProgress(' ├─Creating Flutter.podspec...', timeout: timeoutConfiguration.fastOperation);
try {
final GitTagVersion gitTagVersion = flutterVersion.gitTagVersion;
if (gitTagVersion.x == null || gitTagVersion.y == null || gitTagVersion.z == null || gitTagVersion.commits != 0) {
@@ -267,14 +267,14 @@
}
Future<void> _produceFlutterFramework(Directory outputDirectory, BuildMode mode, Directory iPhoneBuildOutput, Directory simulatorBuildOutput, Directory modeDirectory) async {
- final Status status = logger.startProgress(' ├─Populating Flutter.framework...', timeout: timeoutConfiguration.slowOperation);
- final String engineCacheFlutterFrameworkDirectory = artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: mode);
- final String flutterFrameworkFileName = fs.path.basename(engineCacheFlutterFrameworkDirectory);
+ final Status status = globals.logger.startProgress(' ├─Populating Flutter.framework...', timeout: timeoutConfiguration.slowOperation);
+ final String engineCacheFlutterFrameworkDirectory = globals.artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: mode);
+ final String flutterFrameworkFileName = globals.fs.path.basename(engineCacheFlutterFrameworkDirectory);
final Directory fatFlutterFrameworkCopy = modeDirectory.childDirectory(flutterFrameworkFileName);
try {
// Copy universal engine cache framework to mode directory.
- copyDirectorySync(fs.directory(engineCacheFlutterFrameworkDirectory), fatFlutterFrameworkCopy);
+ copyDirectorySync(globals.fs.directory(engineCacheFlutterFrameworkDirectory), fatFlutterFrameworkCopy);
if (mode != BuildMode.debug) {
final File fatFlutterFrameworkBinary = fatFlutterFrameworkCopy.childFile('Flutter');
@@ -312,7 +312,7 @@
destinationAppFrameworkDirectory.createSync(recursive: true);
if (mode == BuildMode.debug) {
- final Status status = logger.startProgress(' ├─Adding placeholder App.framework for debug...', timeout: timeoutConfiguration.fastOperation);
+ final Status status = globals.logger.startProgress(' ├─Adding placeholder App.framework for debug...', timeout: timeoutConfiguration.fastOperation);
try {
await _produceStubAppFrameworkIfNeeded(mode, iPhoneBuildOutput, simulatorBuildOutput, destinationAppFrameworkDirectory);
} finally {
@@ -327,13 +327,14 @@
destinationInfoPlist.writeAsBytesSync(sourceInfoPlist.readAsBytesSync());
- final Status status = logger.startProgress(' ├─Assembling Flutter resources for App.framework...', timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress(
+ ' ├─Assembling Flutter resources for App.framework...', timeout: timeoutConfiguration.slowOperation);
try {
await bundleBuilder.build(
platform: TargetPlatform.ios,
buildMode: mode,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
- mainPath: fs.path.absolute(targetFile),
+ mainPath: globals.fs.path.absolute(targetFile),
assetDirPath: destinationAppFrameworkDirectory.childDirectory('flutter_assets').path,
precompiledSnapshot: mode != BuildMode.debug,
);
@@ -382,14 +383,15 @@
if (mode == BuildMode.debug) {
return;
}
- final Status status = logger.startProgress(' ├─Building Dart AOT for App.framework...', timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress(
+ ' ├─Building Dart AOT for App.framework...', timeout: timeoutConfiguration.slowOperation);
try {
await aotBuilder.build(
platform: TargetPlatform.ios,
outputPath: iPhoneBuildOutput.path,
buildMode: mode,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
- mainDartFile: fs.path.absolute(targetFile),
+ mainDartFile: globals.fs.path.absolute(targetFile),
quiet: true,
bitcode: true,
reportTimings: false,
@@ -412,7 +414,8 @@
Directory modeDirectory,
Directory outputDirectory,
) async {
- final Status status = logger.startProgress(' ├─Building plugins...', timeout: timeoutConfiguration.slowOperation);
+ final Status status = globals.logger.startProgress(
+ ' ├─Building plugins...', timeout: timeoutConfiguration.slowOperation);
try {
List<String> pluginsBuildCommand = <String>[
'xcrun',
@@ -470,15 +473,15 @@
for (Directory builtProduct in iPhoneBuildConfiguration.listSync(followLinks: false).whereType<Directory>()) {
for (FileSystemEntity podProduct in builtProduct.listSync(followLinks: false)) {
final String podFrameworkName = podProduct.basename;
- if (fs.path.extension(podFrameworkName) == '.framework') {
- final String binaryName = fs.path.basenameWithoutExtension(podFrameworkName);
+ if (globals.fs.path.extension(podFrameworkName) == '.framework') {
+ final String binaryName = globals.fs.path.basenameWithoutExtension(podFrameworkName);
if (boolArg('universal')) {
copyDirectorySync(podProduct as Directory, modeDirectory.childDirectory(podFrameworkName));
final List<String> lipoCommand = <String>[
'xcrun',
'lipo',
'-create',
- fs.path.join(podProduct.path, binaryName),
+ globals.fs.path.join(podProduct.path, binaryName),
if (mode == BuildMode.debug)
simulatorBuildConfiguration.childDirectory(binaryName).childDirectory(podFrameworkName).childFile(binaryName).path,
'-output',
@@ -531,10 +534,10 @@
void _produceXCFramework(BuildMode mode, Directory fatFramework) {
if (boolArg('xcframework')) {
- final String frameworkBinaryName = fs.path.basenameWithoutExtension(
+ final String frameworkBinaryName = globals.fs.path.basenameWithoutExtension(
fatFramework.basename);
- final Status status = logger.startProgress(' ├─Creating $frameworkBinaryName.xcframework...', timeout: timeoutConfiguration.fastOperation);
+ final Status status = globals.logger.startProgress(' ├─Creating $frameworkBinaryName.xcframework...', timeout: timeoutConfiguration.fastOperation);
try {
if (mode == BuildMode.debug) {
_produceDebugXCFramework(fatFramework, frameworkBinaryName);
@@ -555,7 +558,7 @@
final String frameworkFileName = fatFramework.basename;
final File fatFlutterFrameworkBinary = fatFramework.childFile(
frameworkBinaryName);
- final Directory temporaryOutput = fs.systemTempDirectory.createTempSync(
+ final Directory temporaryOutput = globals.fs.systemTempDirectory.createTempSync(
'flutter_tool_build_ios_framework.');
try {
// Copy universal framework to variant directory.
diff --git a/packages/flutter_tools/lib/src/commands/build_linux.dart b/packages/flutter_tools/lib/src/commands/build_linux.dart
index eb2d447..b3e9b78 100644
--- a/packages/flutter_tools/lib/src/commands/build_linux.dart
+++ b/packages/flutter_tools/lib/src/commands/build_linux.dart
@@ -5,10 +5,10 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
import '../features.dart';
+import '../globals.dart' as globals;
import '../linux/build_linux.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
@@ -25,7 +25,7 @@
final String name = 'linux';
@override
- bool get hidden => !featureFlags.isLinuxEnabled || !platform.isLinux;
+ bool get hidden => !featureFlags.isLinuxEnabled || !globals.platform.isLinux;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
@@ -43,7 +43,7 @@
if (!featureFlags.isLinuxEnabled) {
throwToolExit('"build linux" is not currently supported.');
}
- if (!platform.isLinux) {
+ if (!globals.platform.isLinux) {
throwToolExit('"build linux" only supported on Linux hosts.');
}
if (!flutterProject.linux.existsSync()) {
diff --git a/packages/flutter_tools/lib/src/commands/build_macos.dart b/packages/flutter_tools/lib/src/commands/build_macos.dart
index 8ee6c45..c966f3c 100644
--- a/packages/flutter_tools/lib/src/commands/build_macos.dart
+++ b/packages/flutter_tools/lib/src/commands/build_macos.dart
@@ -5,10 +5,10 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
import '../features.dart';
+import '../globals.dart' as globals;
import '../macos/build_macos.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
@@ -25,7 +25,7 @@
final String name = 'macos';
@override
- bool get hidden => !featureFlags.isMacOSEnabled || !platform.isMacOS;
+ bool get hidden => !featureFlags.isMacOSEnabled || !globals.platform.isMacOS;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
@@ -43,7 +43,7 @@
if (!featureFlags.isMacOSEnabled) {
throwToolExit('"build macos" is not currently supported.');
}
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
throwToolExit('"build macos" only supported on macOS hosts.');
}
if (!flutterProject.macos.existsSync()) {
diff --git a/packages/flutter_tools/lib/src/commands/build_windows.dart b/packages/flutter_tools/lib/src/commands/build_windows.dart
index 24d154d..7be232b 100644
--- a/packages/flutter_tools/lib/src/commands/build_windows.dart
+++ b/packages/flutter_tools/lib/src/commands/build_windows.dart
@@ -5,10 +5,10 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/platform.dart';
import '../build_info.dart';
import '../cache.dart';
import '../features.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import '../windows/build_windows.dart';
@@ -25,7 +25,7 @@
final String name = 'windows';
@override
- bool get hidden => !featureFlags.isWindowsEnabled || !platform.isWindows;
+ bool get hidden => !featureFlags.isWindowsEnabled || !globals.platform.isWindows;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
@@ -43,7 +43,7 @@
if (!featureFlags.isWindowsEnabled) {
throwToolExit('"build windows" is not currently supported.');
}
- if (!platform.isWindows) {
+ if (!globals.platform.isWindows) {
throwToolExit('"build windows" only supported on Windows hosts.');
}
if (!flutterProject.windows.existsSync()) {
diff --git a/packages/flutter_tools/lib/src/commands/channel.dart b/packages/flutter_tools/lib/src/commands/channel.dart
index 2071d19..2b9461f 100644
--- a/packages/flutter_tools/lib/src/commands/channel.dart
+++ b/packages/flutter_tools/lib/src/commands/channel.dart
@@ -7,7 +7,7 @@
import '../base/common.dart';
import '../base/process.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import '../version.dart';
@@ -60,7 +60,7 @@
showAll = showAll || currentChannel != currentBranch;
- printStatus('Flutter channels:');
+ globals.printStatus('Flutter channels:');
final int result = await processUtils.stream(
<String>['git', 'branch', '-r'],
workingDirectory: Cache.flutterRoot,
@@ -94,12 +94,12 @@
}
Future<void> _switchChannel(String branchName) {
- printStatus("Switching to flutter channel '$branchName'...");
+ globals.printStatus("Switching to flutter channel '$branchName'...");
if (FlutterVersion.obsoleteBranches.containsKey(branchName)) {
final String alternative = FlutterVersion.obsoleteBranches[branchName];
- printStatus("This channel is obsolete. Consider switching to the '$alternative' channel instead.");
+ globals.printStatus("This channel is obsolete. Consider switching to the '$alternative' channel instead.");
} else if (!FlutterVersion.officialChannels.contains(branchName)) {
- printStatus('This is not an official channel. For a list of available channels, try "flutter channel".');
+ globals.printStatus('This is not an official channel. For a list of available channels, try "flutter channel".');
}
return _checkout(branchName);
}
@@ -108,7 +108,7 @@
final String channel = FlutterVersion.instance.channel;
if (FlutterVersion.obsoleteBranches.containsKey(channel)) {
final String alternative = FlutterVersion.obsoleteBranches[channel];
- printStatus("Transitioning from '$channel' to '$alternative'...");
+ globals.printStatus("Transitioning from '$channel' to '$alternative'...");
return _checkout(alternative);
}
}
diff --git a/packages/flutter_tools/lib/src/commands/clean.dart b/packages/flutter_tools/lib/src/commands/clean.dart
index f1b7140..5d7bc07 100644
--- a/packages/flutter_tools/lib/src/commands/clean.dart
+++ b/packages/flutter_tools/lib/src/commands/clean.dart
@@ -8,9 +8,8 @@
import '../base/file_system.dart';
import '../base/logger.dart';
-import '../base/platform.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/xcodeproj.dart';
import '../macos/xcode.dart';
import '../project.dart';
@@ -40,7 +39,7 @@
await _cleanXcode(flutterProject.macos);
}
- final Directory buildDir = fs.directory(getBuildDirectory());
+ final Directory buildDir = globals.fs.directory(getBuildDirectory());
deleteFile(buildDir);
deleteFile(flutterProject.dartTool);
@@ -67,7 +66,10 @@
if (!xcodeProject.existsSync()) {
return;
}
- final Status xcodeStatus = logger.startProgress('Cleaning Xcode workspace...', timeout: timeoutConfiguration.slowOperation);
+ final Status xcodeStatus = globals.logger.startProgress(
+ 'Cleaning Xcode workspace...',
+ timeout: timeoutConfiguration.slowOperation,
+ );
try {
final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace;
final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path);
@@ -75,7 +77,7 @@
xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme);
}
} catch (error) {
- printTrace('Could not clean Xcode workspace: $error');
+ globals.printTrace('Could not clean Xcode workspace: $error');
} finally {
xcodeStatus?.stop();
}
@@ -89,22 +91,25 @@
return;
}
} on FileSystemException catch (err) {
- printError('Cannot clean ${file.path}.\n$err');
+ globals.printError('Cannot clean ${file.path}.\n$err');
return;
}
- final Status deletionStatus = logger.startProgress('Deleting ${file.basename}...', timeout: timeoutConfiguration.fastOperation);
+ final Status deletionStatus = globals.logger.startProgress(
+ 'Deleting ${file.basename}...',
+ timeout: timeoutConfiguration.fastOperation,
+ );
try {
file.deleteSync(recursive: true);
} on FileSystemException catch (error) {
final String path = file.path;
- if (platform.isWindows) {
- printError(
+ if (globals.platform.isWindows) {
+ globals.printError(
'Failed to remove $path. '
'A program may still be using a file in the directory or the directory itself. '
'To find and stop such a program, see: '
'https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used');
} else {
- printError('Failed to remove $path: $error');
+ globals.printError('Failed to remove $path: $error');
}
} finally {
deletionStatus.stop();
diff --git a/packages/flutter_tools/lib/src/commands/config.dart b/packages/flutter_tools/lib/src/commands/config.dart
index bbe6044..d1626ac 100644
--- a/packages/flutter_tools/lib/src/commands/config.dart
+++ b/packages/flutter_tools/lib/src/commands/config.dart
@@ -7,10 +7,9 @@
import '../android/android_sdk.dart';
import '../android/android_studio.dart';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../convert.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
import '../version.dart';
@@ -75,7 +74,7 @@
featuresByName[feature.configSetting] = feature;
}
}
- String values = config.keys
+ String values = globals.config.keys
.map<String>((String key) {
String configFooter = '';
if (featuresByName.containsKey(key)) {
@@ -84,7 +83,7 @@
configFooter = '(Unavailable)';
}
}
- return ' $key: ${config.getValue(key)} $configFooter';
+ return ' $key: ${globals.config.getValue(key)} $configFooter';
}).join('\n');
if (values.isEmpty) {
values = ' No settings have been configured.';
@@ -108,7 +107,7 @@
if (boolArg('clear-features')) {
for (Feature feature in allFeatures) {
if (feature.configSetting != null) {
- config.removeValue(feature.configSetting);
+ globals.config.removeValue(feature.configSetting);
}
}
return null;
@@ -118,7 +117,7 @@
final bool value = boolArg('analytics');
flutterUsage.enabled = value;
AnalyticsConfigEvent(enabled: value).send();
- printStatus('Analytics reporting ${value ? 'enabled' : 'disabled'}.');
+ globals.printStatus('Analytics reporting ${value ? 'enabled' : 'disabled'}.');
}
if (argResults.wasParsed('android-sdk')) {
@@ -135,7 +134,7 @@
if (argResults.wasParsed('build-dir')) {
final String buildDir = stringArg('build-dir');
- if (fs.path.isAbsolute(buildDir)) {
+ if (globals.fs.path.isAbsolute(buildDir)) {
throwToolExit('build-dir should be a relative path');
}
_updateConfig('build-dir', buildDir);
@@ -147,15 +146,15 @@
}
if (argResults.wasParsed(feature.configSetting)) {
final bool keyValue = boolArg(feature.configSetting);
- config.setValue(feature.configSetting, keyValue);
- printStatus('Setting "${feature.configSetting}" value to "$keyValue".');
+ globals.config.setValue(feature.configSetting, keyValue);
+ globals.printStatus('Setting "${feature.configSetting}" value to "$keyValue".');
}
}
if (argResults.arguments.isEmpty) {
- printStatus(usage);
+ globals.printStatus(usage);
} else {
- printStatus('\nYou may need to restart any open editors for them to read new settings.');
+ globals.printStatus('\nYou may need to restart any open editors for them to read new settings.');
}
return null;
@@ -164,8 +163,8 @@
Future<void> handleMachine() async {
// Get all the current values.
final Map<String, dynamic> results = <String, dynamic>{};
- for (String key in config.keys) {
- results[key] = config.getValue(key);
+ for (String key in globals.config.keys) {
+ results[key] = globals.config.getValue(key);
}
// Ensure we send any calculated ones, if overrides don't exist.
@@ -176,16 +175,16 @@
results['android-sdk'] = androidSdk.directory;
}
- printStatus(const JsonEncoder.withIndent(' ').convert(results));
+ globals.printStatus(const JsonEncoder.withIndent(' ').convert(results));
}
void _updateConfig(String keyName, String keyValue) {
if (keyValue.isEmpty) {
- config.removeValue(keyName);
- printStatus('Removing "$keyName" value.');
+ globals.config.removeValue(keyName);
+ globals.printStatus('Removing "$keyName" value.');
} else {
- config.setValue(keyName, keyValue);
- printStatus('Setting "$keyName" value to "$keyValue".');
+ globals.config.setValue(keyName, keyValue);
+ globals.printStatus('Setting "$keyName" value to "$keyValue".');
}
}
}
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index 071d4a7..823da6a 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -20,7 +20,7 @@
import '../dart/pub.dart';
import '../doctor.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
@@ -176,7 +176,7 @@
if (!projectDir.existsSync()) {
return null;
}
- final File metadataFile = fs.file(fs.path.join(projectDir.absolute.path, '.metadata'));
+ final File metadataFile = globals.fs.file(globals.fs.path.join(projectDir.absolute.path, '.metadata'));
if (!metadataFile.existsSync()) {
return null;
}
@@ -190,7 +190,7 @@
}
bool exists(List<String> path) {
- return fs.directory(fs.path.joinAll(<String>[projectDir.absolute.path, ...path])).existsSync();
+ return globals.fs.directory(globals.fs.path.joinAll(<String>[projectDir.absolute.path, ...path])).existsSync();
}
// If it exists, the project type in the metadata is definitive.
@@ -243,7 +243,7 @@
/// [outputFilePath].
Future<void> _writeSamplesJson(String outputFilePath) async {
try {
- final File outputFile = fs.file(outputFilePath);
+ final File outputFile = globals.fs.file(outputFilePath);
if (outputFile.existsSync()) {
throwToolExit('File "$outputFilePath" already exists', exitCode: 1);
}
@@ -253,7 +253,7 @@
}
else {
outputFile.writeAsStringSync(samplesJson);
- printStatus('Wrote samples JSON to "$outputFilePath"');
+ globals.printStatus('Wrote samples JSON to "$outputFilePath"');
}
} catch (e) {
throwToolExit('Failed to write samples JSON to "$outputFilePath": $e', exitCode: 2);
@@ -320,21 +320,21 @@
'variable was specified. Unable to find package:flutter.', exitCode: 2);
}
- final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
+ final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
- final String flutterPackagesDirectory = fs.path.join(flutterRoot, 'packages');
- final String flutterPackagePath = fs.path.join(flutterPackagesDirectory, 'flutter');
- if (!fs.isFileSync(fs.path.join(flutterPackagePath, 'pubspec.yaml'))) {
+ final String flutterPackagesDirectory = globals.fs.path.join(flutterRoot, 'packages');
+ final String flutterPackagePath = globals.fs.path.join(flutterPackagesDirectory, 'flutter');
+ if (!globals.fs.isFileSync(globals.fs.path.join(flutterPackagePath, 'pubspec.yaml'))) {
throwToolExit('Unable to find package:flutter in $flutterPackagePath', exitCode: 2);
}
- final String flutterDriverPackagePath = fs.path.join(flutterRoot, 'packages', 'flutter_driver');
- if (!fs.isFileSync(fs.path.join(flutterDriverPackagePath, 'pubspec.yaml'))) {
+ final String flutterDriverPackagePath = globals.fs.path.join(flutterRoot, 'packages', 'flutter_driver');
+ if (!globals.fs.isFileSync(globals.fs.path.join(flutterDriverPackagePath, 'pubspec.yaml'))) {
throwToolExit('Unable to find package:flutter_driver in $flutterDriverPackagePath', exitCode: 2);
}
- final Directory projectDir = fs.directory(argResults.rest.first);
- final String projectDirPath = fs.path.normalize(projectDir.absolute.path);
+ final Directory projectDir = globals.fs.directory(argResults.rest.first);
+ final String projectDirPath = globals.fs.path.normalize(projectDir.absolute.path);
String sampleCode;
if (argResults['sample'] != null) {
@@ -372,7 +372,7 @@
throwToolExit(error);
}
- final String projectName = stringArg('project-name') ?? fs.path.basename(projectDirPath);
+ final String projectName = stringArg('project-name') ?? globals.fs.path.basename(projectDirPath);
error = _validateProjectName(projectName);
if (error != null) {
throwToolExit(error);
@@ -392,18 +392,18 @@
macos: featureFlags.isMacOSEnabled,
);
- final String relativeDirPath = fs.path.relative(projectDirPath);
+ final String relativeDirPath = globals.fs.path.relative(projectDirPath);
if (!projectDir.existsSync() || projectDir.listSync().isEmpty) {
- printStatus('Creating project $relativeDirPath... androidx: ${boolArg('androidx')}');
+ globals.printStatus('Creating project $relativeDirPath... androidx: ${boolArg('androidx')}');
} else {
if (sampleCode != null && !overwrite) {
throwToolExit('Will not overwrite existing project in $relativeDirPath: '
'must specify --overwrite for samples to overwrite.');
}
- printStatus('Recreating project $relativeDirPath...');
+ globals.printStatus('Recreating project $relativeDirPath...');
}
- final Directory relativeDir = fs.directory(projectDirPath);
+ final Directory relativeDir = globals.fs.directory(projectDirPath);
int generatedFileCount = 0;
switch (template) {
case _ProjectType.app:
@@ -422,36 +422,36 @@
if (sampleCode != null) {
generatedFileCount += _applySample(relativeDir, sampleCode);
}
- printStatus('Wrote $generatedFileCount files.');
- printStatus('\nAll done!');
+ globals.printStatus('Wrote $generatedFileCount files.');
+ globals.printStatus('\nAll done!');
final String application = sampleCode != null ? 'sample application' : 'application';
if (generatePackage) {
- final String relativeMainPath = fs.path.normalize(fs.path.join(
+ final String relativeMainPath = globals.fs.path.normalize(globals.fs.path.join(
relativeDirPath,
'lib',
'${templateContext['projectName']}.dart',
));
- printStatus('Your package code is in $relativeMainPath');
+ globals.printStatus('Your package code is in $relativeMainPath');
} else if (generateModule) {
- final String relativeMainPath = fs.path.normalize(fs.path.join(
+ final String relativeMainPath = globals.fs.path.normalize(globals.fs.path.join(
relativeDirPath,
'lib',
'main.dart',
));
- printStatus('Your module code is in $relativeMainPath.');
+ globals.printStatus('Your module code is in $relativeMainPath.');
} else {
// Run doctor; tell the user the next steps.
final FlutterProject project = FlutterProject.fromPath(projectDirPath);
final FlutterProject app = project.hasExampleApp ? project.example : project;
- final String relativeAppPath = fs.path.normalize(fs.path.relative(app.directory.path));
- final String relativeAppMain = fs.path.join(relativeAppPath, 'lib', 'main.dart');
- final String relativePluginPath = fs.path.normalize(fs.path.relative(projectDirPath));
- final String relativePluginMain = fs.path.join(relativePluginPath, 'lib', '$projectName.dart');
+ final String relativeAppPath = globals.fs.path.normalize(globals.fs.path.relative(app.directory.path));
+ final String relativeAppMain = globals.fs.path.join(relativeAppPath, 'lib', 'main.dart');
+ final String relativePluginPath = globals.fs.path.normalize(globals.fs.path.relative(projectDirPath));
+ final String relativePluginMain = globals.fs.path.join(relativePluginPath, 'lib', '$projectName.dart');
if (doctor.canLaunchAnything) {
// Let them know a summary of the state of their tooling.
await doctor.summary();
- printStatus('''
+ globals.printStatus('''
In order to run your $application, type:
\$ cd $relativeAppPath
@@ -460,7 +460,7 @@
Your $application code is in $relativeAppMain.
''');
if (generatePlugin) {
- printStatus('''
+ globals.printStatus('''
Your plugin code is in $relativePluginMain.
Host platform code is in the "android" and "ios" directories under $relativePluginPath.
@@ -468,18 +468,18 @@
''');
}
} else {
- printStatus("You'll need to install additional components before you can run "
+ globals.printStatus("You'll need to install additional components before you can run "
'your Flutter app:');
- printStatus('');
+ globals.printStatus('');
// Give the user more detailed analysis.
await doctor.diagnose();
- printStatus('');
- printStatus("After installing components, run 'flutter doctor' in order to "
+ globals.printStatus('');
+ globals.printStatus("After installing components, run 'flutter doctor' in order to "
're-validate your setup.');
- printStatus("When complete, type 'flutter run' from the '$relativeAppPath' "
+ globals.printStatus("When complete, type 'flutter run' from the '$relativeAppPath' "
'directory in order to launch your app.');
- printStatus('Your $application code is in $relativeAppMain');
+ globals.printStatus('Your $application code is in $relativeAppMain');
}
}
@@ -492,7 +492,7 @@
? stringArg('description')
: 'A new flutter module project.';
templateContext['description'] = description;
- generatedCount += _renderTemplate(fs.path.join('module', 'common'), directory, templateContext, overwrite: overwrite);
+ generatedCount += _renderTemplate(globals.fs.path.join('module', 'common'), directory, templateContext, overwrite: overwrite);
if (boolArg('pub')) {
await pub.get(
context: PubContext.create,
@@ -602,7 +602,7 @@
bool web = false,
bool macos = false,
}) {
- flutterRoot = fs.path.normalize(flutterRoot);
+ flutterRoot = globals.fs.path.normalize(flutterRoot);
final String pluginDartClass = _createPluginClassName(projectName);
final String pluginClass = pluginDartClass.endsWith('Plugin')
@@ -652,7 +652,7 @@
int _injectGradleWrapper(FlutterProject project) {
int filesCreated = 0;
copyDirectorySync(
- cache.getArtifactDirectory('gradle_wrapper'),
+ globals.cache.getArtifactDirectory('gradle_wrapper'),
project.android.hostAppGradleRoot,
onFileCopied: (File sourceFile, File destinationFile) {
filesCreated++;
@@ -850,14 +850,14 @@
/// Return null if the project directory is legal. Return a validation message
/// if we should disallow the directory name.
String _validateProjectDir(String dirPath, { String flutterRoot, bool overwrite = false }) {
- if (fs.path.isWithin(flutterRoot, dirPath)) {
+ if (globals.fs.path.isWithin(flutterRoot, dirPath)) {
return 'Cannot create a project within the Flutter SDK. '
"Target directory '$dirPath' is within the Flutter SDK at '$flutterRoot'.";
}
// If the destination directory is actually a file, then we refuse to
// overwrite, on the theory that the user probably didn't expect it to exist.
- if (fs.isFileSync(dirPath)) {
+ if (globals.fs.isFileSync(dirPath)) {
return "Invalid project name: '$dirPath' - refers to an existing file."
'${overwrite ? ' Refusing to overwrite a file with a directory.' : ''}';
}
@@ -866,7 +866,7 @@
return null;
}
- final FileSystemEntityType type = fs.typeSync(dirPath);
+ final FileSystemEntityType type = globals.fs.typeSync(dirPath);
if (type != FileSystemEntityType.notFound) {
switch (type) {
diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart
index d4dd562..0c30d60 100644
--- a/packages/flutter_tools/lib/src/commands/daemon.dart
+++ b/packages/flutter_tools/lib/src/commands/daemon.dart
@@ -18,7 +18,7 @@
import '../convert.dart';
import '../device.dart';
import '../emulator.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../resident_runner.dart';
import '../run_cold.dart';
@@ -50,7 +50,7 @@
@override
Future<FlutterCommandResult> runCommand() async {
- printStatus('Starting device daemon...');
+ globals.printStatus('Starting device daemon...');
isRunningFromDaemon = true;
final NotifyingLogger notifyingLogger = NotifyingLogger();
@@ -361,7 +361,7 @@
if (res is Map<String, dynamic> && res['url'] is String) {
return res['url'] as String;
} else {
- printError('Invalid response to exposeUrl - params should include a String url field');
+ globals.printError('Invalid response to exposeUrl - params should include a String url field');
return url;
}
}
@@ -387,7 +387,7 @@
try {
// TODO(jonahwilliams): replace this with a project metadata check once
// that has been implemented.
- final FlutterProject flutterProject = FlutterProject.fromDirectory(fs.directory(projectRoot));
+ final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.directory(projectRoot));
if (flutterProject.linux.existsSync()) {
result.add('linux');
}
@@ -472,8 +472,8 @@
throw '${toTitleCase(options.buildInfo.friendlyModeName)} mode is not supported for emulators.';
}
// We change the current working directory for the duration of the `start` command.
- final Directory cwd = fs.currentDirectory;
- fs.currentDirectory = fs.directory(projectDirectory);
+ final Directory cwd = globals.fs.currentDirectory;
+ globals.fs.currentDirectory = globals.fs.directory(projectDirectory);
final FlutterProject flutterProject = FlutterProject.current();
final FlutterDevice flutterDevice = await FlutterDevice.create(
@@ -600,7 +600,7 @@
'trace': '$trace',
});
} finally {
- fs.currentDirectory = cwd;
+ globals.fs.currentDirectory = cwd;
_apps.remove(app);
}
});
@@ -779,7 +779,7 @@
final Map<String, Object> response = await _deviceToMap(device);
sendEvent(eventName, response);
} catch (err) {
- printError('$err');
+ globals.printError('$err');
}
});
};
@@ -1011,7 +1011,7 @@
}
Future<T> _runInZone<T>(AppDomain domain, FutureOr<T> method()) {
- _logger ??= _AppRunLogger(domain, this, parent: logToStdout ? logger : null);
+ _logger ??= _AppRunLogger(domain, this, parent: logToStdout ? globals.logger : null);
return context.run<T>(
body: method,
diff --git a/packages/flutter_tools/lib/src/commands/devices.dart b/packages/flutter_tools/lib/src/commands/devices.dart
index b9842f5..dbae667 100644
--- a/packages/flutter_tools/lib/src/commands/devices.dart
+++ b/packages/flutter_tools/lib/src/commands/devices.dart
@@ -8,7 +8,7 @@
import '../base/utils.dart';
import '../device.dart';
import '../doctor.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
class DevicesCommand extends FlutterCommand {
@@ -30,20 +30,20 @@
final List<Device> devices = await deviceManager.getAllConnectedDevices().toList();
if (devices.isEmpty) {
- printStatus(
+ globals.printStatus(
'No devices detected.\n\n'
"Run 'flutter emulators' to list and start any available device emulators.\n\n"
'Or, if you expected your device to be detected, please run "flutter doctor" to diagnose '
'potential issues, or visit https://flutter.dev/setup/ for troubleshooting tips.');
final List<String> diagnostics = await deviceManager.getDeviceDiagnostics();
if (diagnostics.isNotEmpty) {
- printStatus('');
+ globals.printStatus('');
for (String diagnostic in diagnostics) {
- printStatus('• $diagnostic', hangingIndent: 2);
+ globals.printStatus('• $diagnostic', hangingIndent: 2);
}
}
} else {
- printStatus('${devices.length} connected ${pluralize('device', devices.length)}:\n');
+ globals.printStatus('${devices.length} connected ${pluralize('device', devices.length)}:\n');
await Device.printDevices(devices);
}
diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart
index 5245c61..c69fe0b 100644
--- a/packages/flutter_tools/lib/src/commands/drive.dart
+++ b/packages/flutter_tools/lib/src/commands/drive.dart
@@ -12,7 +12,7 @@
import '../dart/package_map.dart';
import '../dart/sdk.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../resident_runner.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
@@ -131,13 +131,13 @@
throwToolExit(null);
}
- if (await fs.type(testFile) != FileSystemEntityType.file) {
+ if (await globals.fs.type(testFile) != FileSystemEntityType.file) {
throwToolExit('Test file not found: $testFile');
}
String observatoryUri;
if (argResults['use-existing-app'] == null) {
- printStatus('Starting application: $targetFile');
+ globals.printStatus('Starting application: $targetFile');
if (getBuildInfo().isRelease) {
// This is because we need VM service to be able to drive the app.
@@ -155,7 +155,7 @@
}
observatoryUri = result.observatoryUri.toString();
} else {
- printStatus('Will connect to already running application instance.');
+ globals.printStatus('Will connect to already running application instance.');
observatoryUri = stringArg('use-existing-app');
}
@@ -178,9 +178,9 @@
throwToolExit('CAUGHT EXCEPTION: $error\n$stackTrace');
} finally {
if (boolArg('keep-app-running') ?? (argResults['use-existing-app'] != null)) {
- printStatus('Leaving the application running.');
+ globals.printStatus('Leaving the application running.');
} else {
- printStatus('Stopping application instance.');
+ globals.printStatus('Stopping application instance.');
await appStopper(this);
}
}
@@ -195,28 +195,28 @@
// If the --driver argument wasn't provided, then derive the value from
// the target file.
- String appFile = fs.path.normalize(targetFile);
+ String appFile = globals.fs.path.normalize(targetFile);
// This command extends `flutter run` and therefore CWD == package dir
- final String packageDir = fs.currentDirectory.path;
+ final String packageDir = globals.fs.currentDirectory.path;
// Make appFile path relative to package directory because we are looking
// for the corresponding test file relative to it.
- if (!fs.path.isRelative(appFile)) {
- if (!fs.path.isWithin(packageDir, appFile)) {
- printError(
+ if (!globals.fs.path.isRelative(appFile)) {
+ if (!globals.fs.path.isWithin(packageDir, appFile)) {
+ globals.printError(
'Application file $appFile is outside the package directory $packageDir'
);
return null;
}
- appFile = fs.path.relative(appFile, from: packageDir);
+ appFile = globals.fs.path.relative(appFile, from: packageDir);
}
- final List<String> parts = fs.path.split(appFile);
+ final List<String> parts = globals.fs.path.split(appFile);
if (parts.length < 2) {
- printError(
+ globals.printError(
'Application file $appFile must reside in one of the sub-directories '
'of the package structure, not in the root directory.'
);
@@ -226,9 +226,9 @@
// Look for the test file inside `test_driver/` matching the sub-path, e.g.
// if the application is `lib/foo/bar.dart`, the test file is expected to
// be `test_driver/foo/bar_test.dart`.
- final String pathWithNoExtension = fs.path.withoutExtension(fs.path.joinAll(
+ final String pathWithNoExtension = globals.fs.path.withoutExtension(globals.fs.path.joinAll(
<String>[packageDir, 'test_driver', ...parts.skip(1)]));
- return '${pathWithNoExtension}_test${fs.path.extension(appFile)}';
+ return '${pathWithNoExtension}_test${globals.fs.path.extension(appFile)}';
}
}
@@ -237,11 +237,11 @@
if (deviceManager.hasSpecifiedDeviceId) {
if (devices.isEmpty) {
- printStatus("No devices found with name or id matching '${deviceManager.specifiedDeviceId}'");
+ globals.printStatus("No devices found with name or id matching '${deviceManager.specifiedDeviceId}'");
return null;
}
if (devices.length > 1) {
- printStatus("Found ${devices.length} devices with name or id matching '${deviceManager.specifiedDeviceId}':");
+ globals.printStatus("Found ${devices.length} devices with name or id matching '${deviceManager.specifiedDeviceId}':");
await Device.printDevices(devices);
return null;
}
@@ -249,13 +249,13 @@
}
if (devices.isEmpty) {
- printError('No devices found.');
+ globals.printError('No devices found.');
return null;
} else if (devices.length > 1) {
- printStatus('Found multiple connected devices:');
+ globals.printStatus('Found multiple connected devices:');
await Device.printDevices(devices);
}
- printStatus('Using device ${devices.first.name}.');
+ globals.printStatus('Using device ${devices.first.name}.');
return devices.first;
}
@@ -269,19 +269,19 @@
Future<LaunchResult> _startApp(DriveCommand command) async {
final String mainPath = findMainDartFile(command.targetFile);
- if (await fs.type(mainPath) != FileSystemEntityType.file) {
- printError('Tried to run $mainPath, but that file does not exist.');
+ if (await globals.fs.type(mainPath) != FileSystemEntityType.file) {
+ globals.printError('Tried to run $mainPath, but that file does not exist.');
return null;
}
- printTrace('Stopping previously running application, if any.');
+ globals.printTrace('Stopping previously running application, if any.');
await appStopper(command);
final ApplicationPackage package = await command.applicationPackages
.getPackageForPlatform(await command.device.targetPlatform);
if (command.shouldBuild) {
- printTrace('Installing application package.');
+ globals.printTrace('Installing application package.');
if (await command.device.isAppInstalled(package)) {
await command.device.uninstallApp(package);
}
@@ -293,14 +293,14 @@
platformArgs['trace-startup'] = command.traceStartup;
}
- printTrace('Starting application.');
+ globals.printTrace('Starting application.');
// Forward device log messages to the terminal window running the "drive" command.
command._deviceLogSubscription = command
.device
.getLogReader(app: package)
.logLines
- .listen(printStatus);
+ .listen(globals.printStatus);
final LaunchResult result = await command.device.startApp(
package,
@@ -334,10 +334,10 @@
}
Future<void> _runTests(List<String> testArgs, Map<String, String> environment) async {
- printTrace('Running driver tests.');
+ globals.printTrace('Running driver tests.');
- PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
- final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
+ PackageMap.globalPackagesPath = globals.fs.path.normalize(globals.fs.path.absolute(PackageMap.globalPackagesPath));
+ final String dartVmPath = globals.fs.path.join(dartSdkPath, 'bin', 'dart');
final int result = await processUtils.stream(
<String>[
dartVmPath,
@@ -362,7 +362,7 @@
}
Future<bool> _stopApp(DriveCommand command) async {
- printTrace('Stopping application.');
+ globals.printTrace('Stopping application.');
final ApplicationPackage package = await command.applicationPackages.getPackageForPlatform(await command.device.targetPlatform);
final bool stopped = await command.device.stopApp(package);
await command._deviceLogSubscription?.cancel();
diff --git a/packages/flutter_tools/lib/src/commands/emulators.dart b/packages/flutter_tools/lib/src/commands/emulators.dart
index ae84aec..320884d 100644
--- a/packages/flutter_tools/lib/src/commands/emulators.dart
+++ b/packages/flutter_tools/lib/src/commands/emulators.dart
@@ -5,11 +5,10 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/platform.dart';
import '../base/utils.dart';
import '../doctor.dart';
import '../emulator.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
class EmulatorsCommand extends FlutterCommand {
@@ -38,7 +37,7 @@
throwToolExit(
'Unable to find any emulator sources. Please ensure you have some\n'
'Android AVD images ' +
- (platform.isMacOS ? 'or an iOS Simulator ' : '') +
+ (globals.platform.isMacOS ? 'or an iOS Simulator ' : '') +
'available.',
exitCode: 1);
}
@@ -63,7 +62,7 @@
await emulatorManager.getEmulatorsMatching(id);
if (emulators.isEmpty) {
- printStatus("No emulator found that matches '$id'.");
+ globals.printStatus("No emulator found that matches '$id'.");
} else if (emulators.length > 1) {
_printEmulatorList(
emulators,
@@ -75,7 +74,7 @@
}
catch (e) {
if (e is String) {
- printError(e);
+ globals.printError(e);
} else {
rethrow;
}
@@ -88,10 +87,10 @@
await emulatorManager.createEmulator(name: name);
if (createResult.success) {
- printStatus("Emulator '${createResult.emulatorName}' created successfully.");
+ globals.printStatus("Emulator '${createResult.emulatorName}' created successfully.");
} else {
- printStatus("Failed to create emulator '${createResult.emulatorName}'.\n");
- printStatus(createResult.error.trim());
+ globals.printStatus("Failed to create emulator '${createResult.emulatorName}'.\n");
+ globals.printStatus(createResult.error.trim());
_printAdditionalInfo();
}
}
@@ -102,7 +101,7 @@
: await emulatorManager.getEmulatorsMatching(searchText);
if (emulators.isEmpty) {
- printStatus('No emulators available.');
+ globals.printStatus('No emulators available.');
_printAdditionalInfo(showCreateInstruction: true);
} else {
_printEmulatorList(
@@ -113,7 +112,7 @@
}
void _printEmulatorList(List<Emulator> emulators, String message) {
- printStatus('$message\n');
+ globals.printStatus('$message\n');
Emulator.printEmulators(emulators);
_printAdditionalInfo(showCreateInstruction: true, showRunInstruction: true);
}
@@ -122,22 +121,22 @@
bool showRunInstruction = false,
bool showCreateInstruction = false,
}) {
- printStatus('');
+ globals.printStatus('');
if (showRunInstruction) {
- printStatus(
+ globals.printStatus(
"To run an emulator, run 'flutter emulators --launch <emulator id>'.");
}
if (showCreateInstruction) {
- printStatus(
+ globals.printStatus(
"To create a new emulator, run 'flutter emulators --create [--name xyz]'.");
}
if (showRunInstruction || showCreateInstruction) {
- printStatus('');
+ globals.printStatus('');
}
// TODO(dantup): Update this link to flutter.dev if/when we have a better page.
// That page can then link out to these places if required.
- printStatus('You can find more information on managing emulators at the links below:\n'
+ globals.printStatus('You can find more information on managing emulators at the links below:\n'
' https://developer.android.com/studio/run/managing-avds\n'
' https://developer.android.com/studio/command-line/avdmanager');
}
diff --git a/packages/flutter_tools/lib/src/commands/generate.dart b/packages/flutter_tools/lib/src/commands/generate.dart
index 5cf4fb3..7b23bae 100644
--- a/packages/flutter_tools/lib/src/commands/generate.dart
+++ b/packages/flutter_tools/lib/src/commands/generate.dart
@@ -6,7 +6,7 @@
import '../cache.dart';
import '../codegen.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../runner/flutter_command.dart';
@@ -28,7 +28,7 @@
codegenDaemon.startBuild();
await for (CodegenStatus codegenStatus in codegenDaemon.buildResults) {
if (codegenStatus == CodegenStatus.Failed) {
- printError('Code generation failed.');
+ globals.printError('Code generation failed.');
break;
}
if (codegenStatus ==CodegenStatus.Succeeded) {
@@ -48,12 +48,12 @@
try {
final List<Object> errorData = json.decode(errorFile.readAsStringSync()) as List<Object>;
final List<Object> stackData = errorData[1] as List<Object>;
- printError(errorData.first as String);
- printError(stackData[0] as String);
- printError(stackData[1] as String);
- printError(StackTrace.fromString(stackData[2] as String).toString());
+ globals.printError(errorData.first as String);
+ globals.printError(stackData[0] as String);
+ globals.printError(stackData[1] as String);
+ globals.printError(StackTrace.fromString(stackData[2] as String).toString());
} catch (err) {
- printError('Error reading error in ${errorFile.path}');
+ globals.printError('Error reading error in ${errorFile.path}');
}
}
return const FlutterCommandResult(ExitStatus.fail);
diff --git a/packages/flutter_tools/lib/src/commands/ide_config.dart b/packages/flutter_tools/lib/src/commands/ide_config.dart
index e343c69..fd1c6fc 100644
--- a/packages/flutter_tools/lib/src/commands/ide_config.dart
+++ b/packages/flutter_tools/lib/src/commands/ide_config.dart
@@ -7,7 +7,7 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import '../template.dart';
@@ -64,7 +64,7 @@
static const String _ideName = 'intellij';
Directory get _templateDirectory {
- return fs.directory(fs.path.join(
+ return globals.fs.directory(globals.fs.path.join(
Cache.flutterRoot,
'packages',
'flutter_tools',
@@ -74,7 +74,7 @@
}
Directory get _createTemplatesDirectory {
- return fs.directory(fs.path.join(
+ return globals.fs.directory(globals.fs.path.join(
Cache.flutterRoot,
'packages',
'flutter_tools',
@@ -82,16 +82,16 @@
));
}
- Directory get _flutterRoot => fs.directory(fs.path.absolute(Cache.flutterRoot));
+ Directory get _flutterRoot => globals.fs.directory(globals.fs.path.absolute(Cache.flutterRoot));
// Returns true if any entire path element is equal to dir.
bool _hasDirectoryInPath(FileSystemEntity entity, String dir) {
String path = entity.absolute.path;
- while (path.isNotEmpty && fs.path.dirname(path) != path) {
- if (fs.path.basename(path) == dir) {
+ while (path.isNotEmpty && globals.fs.path.dirname(path) != path) {
+ if (globals.fs.path.basename(path) == dir) {
return true;
}
- path = fs.path.dirname(path);
+ path = globals.fs.path.dirname(path);
}
return false;
}
@@ -127,7 +127,7 @@
final Set<String> manifest = <String>{};
final Iterable<File> flutterFiles = _flutterRoot.listSync(recursive: true).whereType<File>();
for (File srcFile in flutterFiles) {
- final String relativePath = fs.path.relative(srcFile.path, from: _flutterRoot.absolute.path);
+ final String relativePath = globals.fs.path.relative(srcFile.path, from: _flutterRoot.absolute.path);
// Skip template files in both the ide_templates and templates
// directories to avoid copying onto themselves.
@@ -148,30 +148,30 @@
continue;
}
- final File finalDestinationFile = fs.file(fs.path.absolute(
+ final File finalDestinationFile = globals.fs.file(globals.fs.path.absolute(
_templateDirectory.absolute.path, '$relativePath${Template.copyTemplateExtension}'));
final String relativeDestination =
- fs.path.relative(finalDestinationFile.path, from: _flutterRoot.absolute.path);
+ globals.fs.path.relative(finalDestinationFile.path, from: _flutterRoot.absolute.path);
if (finalDestinationFile.existsSync()) {
if (_fileIsIdentical(srcFile, finalDestinationFile)) {
- printTrace(' $relativeDestination (identical)');
+ globals.printTrace(' $relativeDestination (identical)');
manifest.add('$relativePath${Template.copyTemplateExtension}');
continue;
}
if (boolArg('overwrite')) {
finalDestinationFile.deleteSync();
- printStatus(' $relativeDestination (overwritten)');
+ globals.printStatus(' $relativeDestination (overwritten)');
} else {
- printTrace(' $relativeDestination (existing - skipped)');
+ globals.printTrace(' $relativeDestination (existing - skipped)');
manifest.add('$relativePath${Template.copyTemplateExtension}');
continue;
}
} else {
- printStatus(' $relativeDestination (added)');
+ globals.printStatus(' $relativeDestination (added)');
}
- final Directory finalDestinationDir = fs.directory(finalDestinationFile.dirname);
+ final Directory finalDestinationDir = globals.fs.directory(finalDestinationFile.dirname);
if (!finalDestinationDir.existsSync()) {
- printTrace(" ${finalDestinationDir.path} doesn't exist, creating.");
+ globals.printTrace(" ${finalDestinationDir.path} doesn't exist, creating.");
finalDestinationDir.createSync(recursive: true);
}
srcFile.copySync(finalDestinationFile.path);
@@ -187,24 +187,24 @@
// them.
final Iterable<File> templateFiles = _templateDirectory.listSync(recursive: true).whereType<File>();
for (File templateFile in templateFiles) {
- final String relativePath = fs.path.relative(
+ final String relativePath = globals.fs.path.relative(
templateFile.absolute.path,
from: _templateDirectory.absolute.path,
);
if (!manifest.contains(relativePath)) {
templateFile.deleteSync();
final String relativeDestination =
- fs.path.relative(templateFile.path, from: _flutterRoot.absolute.path);
- printStatus(' $relativeDestination (removed)');
+ globals.fs.path.relative(templateFile.path, from: _flutterRoot.absolute.path);
+ globals.printStatus(' $relativeDestination (removed)');
}
// If the directory is now empty, then remove it, and do the same for its parent,
// until we escape to the template directory.
- Directory parentDir = fs.directory(templateFile.dirname);
+ Directory parentDir = globals.fs.directory(templateFile.dirname);
while (parentDir.listSync().isEmpty) {
parentDir.deleteSync();
- printTrace(' ${fs.path.relative(parentDir.absolute.path)} (empty directory - removed)');
- parentDir = fs.directory(parentDir.dirname);
- if (fs.path.isWithin(_templateDirectory.absolute.path, parentDir.absolute.path)) {
+ globals.printTrace(' ${globals.fs.path.relative(parentDir.absolute.path)} (empty directory - removed)');
+ parentDir = globals.fs.directory(parentDir.dirname);
+ if (globals.fs.path.isWithin(_templateDirectory.absolute.path, parentDir.absolute.path)) {
break;
}
}
@@ -222,9 +222,9 @@
return null;
}
- final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
- final String dirPath = fs.path.normalize(
- fs.directory(fs.path.absolute(Cache.flutterRoot)).absolute.path,
+ final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
+ final String dirPath = globals.fs.path.normalize(
+ globals.fs.directory(globals.fs.path.absolute(Cache.flutterRoot)).absolute.path,
);
final String error = _validateFlutterDir(dirPath, flutterRoot: flutterRoot);
@@ -232,15 +232,15 @@
throwToolExit(error);
}
- printStatus('Updating IDE configuration for Flutter tree at $dirPath...');
+ globals.printStatus('Updating IDE configuration for Flutter tree at $dirPath...');
int generatedCount = 0;
generatedCount += _renderTemplate(_ideName, dirPath, <String, dynamic>{
'withRootModule': boolArg('with-root-module'),
});
- printStatus('Wrote $generatedCount files.');
- printStatus('');
- printStatus('Your IntelliJ configuration is now up to date. It is prudent to '
+ globals.printStatus('Wrote $generatedCount files.');
+ globals.printStatus('');
+ globals.printStatus('Your IntelliJ configuration is now up to date. It is prudent to '
'restart IntelliJ, if running.');
return null;
@@ -249,7 +249,7 @@
int _renderTemplate(String templateName, String dirPath, Map<String, dynamic> context) {
final Template template = Template(_templateDirectory, _templateDirectory);
return template.render(
- fs.directory(dirPath),
+ globals.fs.directory(dirPath),
context,
overwriteExisting: boolArg('overwrite'),
);
@@ -259,7 +259,7 @@
/// Return null if the flutter root directory is a valid destination. Return a
/// validation message if we should disallow the directory.
String _validateFlutterDir(String dirPath, { String flutterRoot }) {
- final FileSystemEntityType type = fs.typeSync(dirPath);
+ final FileSystemEntityType type = globals.fs.typeSync(dirPath);
if (type != FileSystemEntityType.notFound) {
switch (type) {
diff --git a/packages/flutter_tools/lib/src/commands/inject_plugins.dart b/packages/flutter_tools/lib/src/commands/inject_plugins.dart
index 72aad34..285670d 100644
--- a/packages/flutter_tools/lib/src/commands/inject_plugins.dart
+++ b/packages/flutter_tools/lib/src/commands/inject_plugins.dart
@@ -4,7 +4,7 @@
import 'dart:async';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../plugins.dart';
import '../project.dart';
import '../runner/flutter_command.dart';
@@ -33,9 +33,9 @@
await injectPlugins(project, checkProjects: true);
final bool result = hasPlugins(project);
if (result) {
- printStatus('GeneratedPluginRegistrants successfully written.');
+ globals.printStatus('GeneratedPluginRegistrants successfully written.');
} else {
- printStatus('This project does not use plugins, no GeneratedPluginRegistrants have been created.');
+ globals.printStatus('This project does not use plugins, no GeneratedPluginRegistrants have been created.');
}
return null;
diff --git a/packages/flutter_tools/lib/src/commands/install.dart b/packages/flutter_tools/lib/src/commands/install.dart
index 4ca851d..1a04de9 100644
--- a/packages/flutter_tools/lib/src/commands/install.dart
+++ b/packages/flutter_tools/lib/src/commands/install.dart
@@ -8,7 +8,7 @@
import '../base/common.dart';
import '../cache.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
@@ -39,7 +39,7 @@
Cache.releaseLockEarly();
- printStatus('Installing $package to $device...');
+ globals.printStatus('Installing $package to $device...');
if (!await installApp(device, package)) {
throwToolExit('Install failed');
@@ -55,9 +55,9 @@
}
if (uninstall && await device.isAppInstalled(package)) {
- printStatus('Uninstalling old version...');
+ globals.printStatus('Uninstalling old version...');
if (!await device.uninstallApp(package)) {
- printError('Warning: uninstalling old version failed');
+ globals.printError('Warning: uninstalling old version failed');
}
}
diff --git a/packages/flutter_tools/lib/src/commands/logs.dart b/packages/flutter_tools/lib/src/commands/logs.dart
index a38b614..8fefada 100644
--- a/packages/flutter_tools/lib/src/commands/logs.dart
+++ b/packages/flutter_tools/lib/src/commands/logs.dart
@@ -8,7 +8,7 @@
import '../base/io.dart';
import '../cache.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
class LogsCommand extends FlutterCommand {
@@ -50,13 +50,13 @@
Cache.releaseLockEarly();
- printStatus('Showing $logReader logs:');
+ globals.printStatus('Showing $logReader logs:');
final Completer<int> exitCompleter = Completer<int>();
// Start reading.
final StreamSubscription<String> subscription = logReader.logLines.listen(
- (String message) => printStatus(message, wrap: false),
+ (String message) => globals.printStatus(message, wrap: false),
onDone: () {
exitCompleter.complete(0);
},
@@ -68,7 +68,7 @@
// When terminating, close down the log reader.
ProcessSignal.SIGINT.watch().listen((ProcessSignal signal) {
subscription.cancel();
- printStatus('');
+ globals.printStatus('');
exitCompleter.complete(0);
});
ProcessSignal.SIGTERM.watch().listen((ProcessSignal signal) {
diff --git a/packages/flutter_tools/lib/src/commands/precache.dart b/packages/flutter_tools/lib/src/commands/precache.dart
index dbcc92b..d9a6dd2 100644
--- a/packages/flutter_tools/lib/src/commands/precache.dart
+++ b/packages/flutter_tools/lib/src/commands/precache.dart
@@ -6,7 +6,7 @@
import '../cache.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import '../version.dart';
@@ -60,10 +60,10 @@
@override
Future<FlutterCommandResult> runCommand() async {
if (boolArg('all-platforms')) {
- cache.includeAllPlatforms = true;
+ globals.cache.includeAllPlatforms = true;
}
if (boolArg('use-unsigned-mac-binaries')) {
- cache.useUnsignedMacBinaries = true;
+ globals.cache.useUnsignedMacBinaries = true;
}
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{};
for (DevelopmentArtifact artifact in DevelopmentArtifact.values) {
@@ -83,10 +83,10 @@
}
}
final bool forceUpdate = boolArg('force');
- if (forceUpdate || !cache.isUpToDate()) {
- await cache.updateAll(requiredArtifacts);
+ if (forceUpdate || !globals.cache.isUpToDate()) {
+ await globals.cache.updateAll(requiredArtifacts);
} else {
- printStatus('Already up-to-date.');
+ globals.printStatus('Already up-to-date.');
}
return null;
}
diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart
index 811761e..0fe5581 100644
--- a/packages/flutter_tools/lib/src/commands/run.dart
+++ b/packages/flutter_tools/lib/src/commands/run.dart
@@ -8,14 +8,13 @@
import '../base/common.dart';
import '../base/file_system.dart';
-import '../base/terminal.dart';
import '../base/time.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../cache.dart';
import '../device.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../resident_runner.dart';
@@ -271,7 +270,7 @@
final Iterable<File> swiftFiles = iosProject.hostAppRoot
.listSync(recursive: true, followLinks: false)
.whereType<File>()
- .where((File file) => fs.path.extension(file.path) == '.swift');
+ .where((File file) => globals.fs.path.extension(file.path) == '.swift');
hostLanguage.add(swiftFiles.isNotEmpty ? 'swift' : 'objc');
}
}
@@ -395,11 +394,11 @@
try {
final String applicationBinaryPath = stringArg('use-application-binary');
app = await daemon.appDomain.startApp(
- devices.first, fs.currentDirectory.path, targetFile, route,
+ devices.first, globals.fs.currentDirectory.path, targetFile, route,
_createDebuggingOptions(), hotMode,
applicationBinary: applicationBinaryPath == null
? null
- : fs.file(applicationBinaryPath),
+ : globals.fs.file(applicationBinaryPath),
trackWidgetCreation: boolArg('track-widget-creation'),
projectRootPath: stringArg('project-root'),
packagesFilePath: globalResults['packages'] as String,
@@ -420,7 +419,7 @@
endTimeOverride: appStartedTime,
);
}
- terminal.usesTerminalUi = true;
+ globals.terminal.usesTerminalUi = true;
if (argResults['dart-flags'] != null && !FlutterVersion.instance.isMaster) {
throw UsageException('--dart-flags is not available on the stable '
@@ -429,7 +428,7 @@
for (Device device in devices) {
if (!device.supportsFastStart && boolArg('fast-start')) {
- printStatus(
+ globals.printStatus(
'Using --fast-start option with device ${device.name}, but this device '
'does not support it. Overriding the setting to false.'
);
@@ -438,12 +437,12 @@
if (await device.supportsHardwareRendering) {
final bool enableSoftwareRendering = boolArg('enable-software-rendering') == true;
if (enableSoftwareRendering) {
- printStatus(
+ globals.printStatus(
'Using software rendering with device ${device.name}. You may get better performance '
'with hardware mode by configuring hardware rendering for your device.'
);
} else {
- printStatus(
+ globals.printStatus(
'Using hardware rendering with device ${device.name}. If you get graphics artifacts, '
'consider enabling software rendering with "--enable-software-rendering".'
);
@@ -501,7 +500,7 @@
benchmarkMode: boolArg('benchmark'),
applicationBinary: applicationBinaryPath == null
? null
- : fs.file(applicationBinaryPath),
+ : globals.fs.file(applicationBinaryPath),
projectRootPath: stringArg('project-root'),
packagesFilePath: globalResults['packages'] as String,
dillOutputPath: stringArg('output-dill'),
@@ -528,7 +527,7 @@
awaitFirstFrameWhenTracing: awaitFirstFrameWhenTracing,
applicationBinary: applicationBinaryPath == null
? null
- : fs.file(applicationBinaryPath),
+ : globals.fs.file(applicationBinaryPath),
ipv6: ipv6,
stayResident: stayResident,
);
diff --git a/packages/flutter_tools/lib/src/commands/screenshot.dart b/packages/flutter_tools/lib/src/commands/screenshot.dart
index 8f9b05b..47ec354 100644
--- a/packages/flutter_tools/lib/src/commands/screenshot.dart
+++ b/packages/flutter_tools/lib/src/commands/screenshot.dart
@@ -9,7 +9,7 @@
import '../base/utils.dart';
import '../convert.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import '../vmservice.dart';
@@ -91,7 +91,7 @@
Future<FlutterCommandResult> runCommand() async {
File outputFile;
if (argResults.wasParsed(_kOut)) {
- outputFile = fs.file(stringArg(_kOut));
+ outputFile = globals.fs.file(stringArg(_kOut));
}
switch (stringArg(_kType)) {
@@ -110,7 +110,7 @@
}
Future<void> runScreenshot(File outputFile) async {
- outputFile ??= getUniqueFile(fs.currentDirectory, 'flutter', 'png');
+ outputFile ??= getUniqueFile(globals.fs.currentDirectory, 'flutter', 'png');
try {
await device.takeScreenshot(outputFile);
} catch (error) {
@@ -121,7 +121,7 @@
Future<void> runSkia(File outputFile) async {
final Map<String, dynamic> skp = await _invokeVmServiceRpc('_flutter.screenshotSkp');
- outputFile ??= getUniqueFile(fs.currentDirectory, 'flutter', 'skp');
+ outputFile ??= getUniqueFile(globals.fs.currentDirectory, 'flutter', 'skp');
final IOSink sink = outputFile.openWrite();
sink.add(base64.decode(skp['skp'] as String));
await sink.close();
@@ -131,7 +131,7 @@
Future<void> runRasterizer(File outputFile) async {
final Map<String, dynamic> response = await _invokeVmServiceRpc('_flutter.screenshot');
- outputFile ??= getUniqueFile(fs.currentDirectory, 'flutter', 'png');
+ outputFile ??= getUniqueFile(globals.fs.currentDirectory, 'flutter', 'png');
final IOSink sink = outputFile.openWrite();
sink.add(base64.decode(response['screenshot'] as String));
await sink.close();
@@ -159,6 +159,6 @@
void _showOutputFileInfo(File outputFile) {
final int sizeKB = (outputFile.lengthSync()) ~/ 1024;
- printStatus('Screenshot written to ${fs.path.relative(outputFile.path)} (${sizeKB}kB).');
+ globals.printStatus('Screenshot written to ${globals.fs.path.relative(outputFile.path)} (${sizeKB}kB).');
}
}
diff --git a/packages/flutter_tools/lib/src/commands/shell_completion.dart b/packages/flutter_tools/lib/src/commands/shell_completion.dart
index 27dfdc2..7cf89e5 100644
--- a/packages/flutter_tools/lib/src/commands/shell_completion.dart
+++ b/packages/flutter_tools/lib/src/commands/shell_completion.dart
@@ -9,6 +9,7 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
class ShellCompletionCommand extends FlutterCommand {
@@ -52,7 +53,7 @@
return null;
}
- final File outputFile = fs.file(argResults.rest.first);
+ final File outputFile = globals.fs.file(argResults.rest.first);
if (outputFile.existsSync() && !boolArg('overwrite')) {
throwToolExit(
'Output file ${outputFile.path} already exists, will not overwrite. '
diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart
index bedf99a..21e2e0f 100644
--- a/packages/flutter_tools/lib/src/commands/test.dart
+++ b/packages/flutter_tools/lib/src/commands/test.dart
@@ -8,14 +8,13 @@
import '../asset.dart';
import '../base/common.dart';
import '../base/file_system.dart';
-import '../base/platform.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../cache.dart';
import '../codegen.dart';
import '../dart/pub.dart';
import '../devfs.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../runner/flutter_command.dart';
import '../test/coverage_collector.dart';
@@ -90,7 +89,7 @@
)
..addOption('concurrency',
abbr: 'j',
- defaultsTo: math.max<int>(1, platform.numberOfProcessors - 2).toString(),
+ defaultsTo: math.max<int>(1, globals.platform.numberOfProcessors - 2).toString(),
help: 'The number of concurrent test processes to run.',
valueHelp: 'jobs',
)
@@ -135,8 +134,8 @@
@override
Future<FlutterCommandResult> runCommand() async {
- await cache.updateAll(await requiredArtifacts);
- if (!fs.isFileSync('pubspec.yaml')) {
+ await globals.cache.updateAll(await requiredArtifacts);
+ if (!globals.fs.isFileSync('pubspec.yaml')) {
throwToolExit(
'Error: No pubspec.yaml file found in the current working directory.\n'
'Run this command from the root of your project. Test files must be '
@@ -155,7 +154,7 @@
await _buildTestAsset();
}
- List<String> files = argResults.rest.map<String>((String testPath) => fs.path.absolute(testPath)).toList();
+ List<String> files = argResults.rest.map<String>((String testPath) => globals.fs.path.absolute(testPath)).toList();
final bool startPaused = boolArg('start-paused');
if (startPaused && files.length != 1) {
@@ -176,7 +175,7 @@
if (files.isEmpty) {
// We don't scan the entire package, only the test/ subdirectory, so that
// files with names like like "hit_test.dart" don't get run.
- workDir = fs.directory('test');
+ workDir = globals.fs.directory('test');
if (!workDir.existsSync()) {
throwToolExit('Test directory "${workDir.path}" not found.');
}
@@ -190,8 +189,8 @@
} else {
files = <String>[
for (String path in files)
- if (fs.isDirectorySync(path))
- ..._findTests(fs.directory(path))
+ if (globals.fs.isDirectorySync(path))
+ ..._findTests(globals.fs.directory(path))
else
path,
];
@@ -281,18 +280,18 @@
throwToolExit('Error: Failed to build asset bundle');
}
if (_needRebuild(assetBundle.entries)) {
- await writeBundle(fs.directory(fs.path.join('build', 'unit_test_assets')),
+ await writeBundle(globals.fs.directory(globals.fs.path.join('build', 'unit_test_assets')),
assetBundle.entries);
}
}
bool _needRebuild(Map<String, DevFSContent> entries) {
- final File manifest = fs.file(fs.path.join('build', 'unit_test_assets', 'AssetManifest.json'));
+ final File manifest = globals.fs.file(globals.fs.path.join('build', 'unit_test_assets', 'AssetManifest.json'));
if (!manifest.existsSync()) {
return true;
}
final DateTime lastModified = manifest.lastModifiedSync();
- final File pub = fs.file('pubspec.yaml');
+ final File pub = globals.fs.file('pubspec.yaml');
if (pub.lastModifiedSync().isAfter(lastModified)) {
return true;
}
@@ -311,6 +310,6 @@
Iterable<String> _findTests(Directory directory) {
return directory.listSync(recursive: true, followLinks: false)
.where((FileSystemEntity entity) => entity.path.endsWith('_test.dart') &&
- fs.isFileSync(entity.path))
- .map((FileSystemEntity entity) => fs.path.absolute(entity.path));
+ globals.fs.isFileSync(entity.path))
+ .map((FileSystemEntity entity) => globals.fs.path.absolute(entity.path));
}
diff --git a/packages/flutter_tools/lib/src/commands/unpack.dart b/packages/flutter_tools/lib/src/commands/unpack.dart
index 5f2fec2..e2c228d 100644
--- a/packages/flutter_tools/lib/src/commands/unpack.dart
+++ b/packages/flutter_tools/lib/src/commands/unpack.dart
@@ -7,7 +7,7 @@
import '../base/file_system.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
/// The directory in the Flutter cache for each platform's artifacts.
@@ -73,14 +73,14 @@
Future<FlutterCommandResult> runCommand() async {
final String targetName = stringArg('target-platform');
final String targetDirectory = stringArg('cache-dir');
- if (!fs.directory(targetDirectory).existsSync()) {
- fs.directory(targetDirectory).createSync(recursive: true);
+ if (!globals.fs.directory(targetDirectory).existsSync()) {
+ globals.fs.directory(targetDirectory).createSync(recursive: true);
}
final TargetPlatform targetPlatform = getTargetPlatformForName(targetName);
final ArtifactUnpacker flutterArtifactFetcher = ArtifactUnpacker(targetPlatform);
bool success = true;
- if (artifacts is LocalEngineArtifacts) {
- final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
+ if (globals.artifacts is LocalEngineArtifacts) {
+ final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
success = flutterArtifactFetcher.copyLocalBuildArtifacts(
localEngineArtifacts.engineOutPath,
targetDirectory,
@@ -124,9 +124,9 @@
throwToolExit('Unsupported target platform: $platform');
}
final String targetHash =
- readHashFileIfPossible(Cache.instance.getStampFileFor(cacheStamp));
+ readHashFileIfPossible(globals.cache.getStampFileFor(cacheStamp));
if (targetHash == null) {
- printError('Failed to find engine stamp file');
+ globals.printError('Failed to find engine stamp file');
return false;
}
@@ -134,7 +134,7 @@
final String currentHash = _lastCopiedHash(targetDirectory);
if (currentHash == null || targetHash != currentHash) {
// Copy them to the target directory.
- final String flutterCacheDirectory = fs.path.join(
+ final String flutterCacheDirectory = globals.fs.path.join(
Cache.flutterRoot,
'bin',
'cache',
@@ -146,13 +146,13 @@
return false;
}
_setLastCopiedHash(targetDirectory, targetHash);
- printTrace('Copied artifacts for version $targetHash.');
+ globals.printTrace('Copied artifacts for version $targetHash.');
} else {
- printTrace('Artifacts for version $targetHash already present.');
+ globals.printTrace('Artifacts for version $targetHash already present.');
}
} catch (error, stackTrace) {
- printError(stackTrace.toString());
- printError(error.toString());
+ globals.printError(stackTrace.toString());
+ globals.printError(error.toString());
return false;
}
return true;
@@ -179,30 +179,30 @@
bool _copyArtifactFiles(String sourceDirectory, String targetDirectory) {
final List<String> artifactFiles = artifactFilesByPlatform[platform];
if (artifactFiles == null) {
- printError('Unsupported platform: $platform.');
+ globals.printError('Unsupported platform: $platform.');
return false;
}
try {
- fs.directory(targetDirectory).createSync(recursive: true);
+ globals.fs.directory(targetDirectory).createSync(recursive: true);
for (final String entityName in artifactFiles) {
- final String sourcePath = fs.path.join(sourceDirectory, entityName);
- final String targetPath = fs.path.join(targetDirectory, entityName);
+ final String sourcePath = globals.fs.path.join(sourceDirectory, entityName);
+ final String targetPath = globals.fs.path.join(targetDirectory, entityName);
if (entityName.endsWith('/')) {
copyDirectorySync(
- fs.directory(sourcePath),
- fs.directory(targetPath),
+ globals.fs.directory(sourcePath),
+ globals.fs.directory(targetPath),
);
} else {
- fs.file(sourcePath)
- .copySync(fs.path.join(targetDirectory, entityName));
+ globals.fs.file(sourcePath)
+ .copySync(globals.fs.path.join(targetDirectory, entityName));
}
}
- printTrace('Copied artifacts from $sourceDirectory.');
+ globals.printTrace('Copied artifacts from $sourceDirectory.');
} catch (e, stackTrace) {
- printError(e.message as String);
- printError(stackTrace.toString());
+ globals.printError(e.message as String);
+ globals.printError(stackTrace.toString());
return false;
}
return true;
@@ -211,7 +211,7 @@
/// Returns a File object for the file containing the last copied hash
/// in [directory].
File _lastCopiedHashFile(String directory) {
- return fs.file(fs.path.join(directory, '.last_artifact_version'));
+ return globals.fs.file(globals.fs.path.join(directory, '.last_artifact_version'));
}
/// Returns the hash of the artifacts last copied to [directory], or null if
@@ -220,11 +220,11 @@
// Sanity check that at least one file is present; this won't catch every
// case, but handles someone deleting all the non-hidden cached files to
// force fresh copy.
- final String artifactFilePath = fs.path.join(
+ final String artifactFilePath = globals.fs.path.join(
directory,
artifactFilesByPlatform[platform].first,
);
- if (!fs.file(artifactFilePath).existsSync()) {
+ if (!globals.fs.file(artifactFilePath).existsSync()) {
return null;
}
final File hashFile = _lastCopiedHashFile(directory);
diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart
index b7a3857..169e276 100644
--- a/packages/flutter_tools/lib/src/commands/update_packages.dart
+++ b/packages/flutter_tools/lib/src/commands/update_packages.dart
@@ -11,10 +11,9 @@
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/net.dart';
-import '../base/platform.dart';
import '../cache.dart';
import '../dart/pub.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
/// Map from package name to package version, used to artificially pin a pub
@@ -89,17 +88,17 @@
final bool hidden;
Future<void> _downloadCoverageData() async {
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Downloading lcov data for package:flutter...',
timeout: timeoutConfiguration.slowOperation,
);
- final String urlBase = platform.environment['FLUTTER_STORAGE_BASE_URL'] ?? 'https://storage.googleapis.com';
+ final String urlBase = globals.platform.environment['FLUTTER_STORAGE_BASE_URL'] ?? 'https://storage.googleapis.com';
final List<int> data = await fetchUrl(Uri.parse('$urlBase/flutter_infra/flutter/coverage/lcov.info'));
- final String coverageDir = fs.path.join(Cache.flutterRoot, 'packages/flutter/coverage');
- fs.file(fs.path.join(coverageDir, 'lcov.base.info'))
+ final String coverageDir = globals.fs.path.join(Cache.flutterRoot, 'packages/flutter/coverage');
+ globals.fs.file(globals.fs.path.join(coverageDir, 'lcov.base.info'))
..createSync(recursive: true)
..writeAsBytesSync(data, flush: true);
- fs.file(fs.path.join(coverageDir, 'lcov.info'))
+ globals.fs.file(globals.fs.path.join(coverageDir, 'lcov.info'))
..createSync(recursive: true)
..writeAsBytesSync(data, flush: true);
status.stop();
@@ -127,14 +126,14 @@
// ensure we only get flutter/packages
packages.retainWhere((Directory directory) {
return consumerPackages.any((String package) {
- return directory.path.endsWith('packages${fs.path.separator}$package');
+ return directory.path.endsWith('packages${globals.fs.path.separator}$package');
});
});
}
if (isVerifyOnly) {
bool needsUpdate = false;
- printStatus('Verifying pubspecs...');
+ globals.printStatus('Verifying pubspecs...');
for (Directory directory in packages) {
PubspecYaml pubspec;
try {
@@ -142,11 +141,11 @@
} on String catch (message) {
throwToolExit(message);
}
- printTrace('Reading pubspec.yaml from ${directory.path}');
+ globals.printTrace('Reading pubspec.yaml from ${directory.path}');
if (pubspec.checksum.value == null) {
// If the checksum is invalid or missing, we can just ask them run to run
// upgrade again to compute it.
- printError(
+ globals.printError(
'Warning: pubspec in ${directory.path} has out of date dependencies. '
'Please run "flutter update-packages --force-upgrade" to update them correctly.'
);
@@ -163,14 +162,14 @@
if (checksum != pubspec.checksum.value) {
// If the checksum doesn't match, they may have added or removed some dependencies.
// we need to run update-packages to recapture the transitive deps.
- printError(
+ globals.printError(
'Warning: pubspec in ${directory.path} has invalid dependencies. '
'Please run "flutter update-packages --force-upgrade" to update them correctly.'
);
needsUpdate = true;
} else {
// everything is correct in the pubspec.
- printTrace('pubspec in ${directory.path} is up to date!');
+ globals.printTrace('pubspec in ${directory.path} is up to date!');
}
}
if (needsUpdate) {
@@ -180,12 +179,12 @@
exitCode: 1,
);
}
- printStatus('All pubspecs were up to date.');
+ globals.printStatus('All pubspecs were up to date.');
return null;
}
if (upgrade || isPrintPaths || isPrintTransitiveClosure) {
- printStatus('Upgrading packages...');
+ globals.printStatus('Upgrading packages...');
// This feature attempts to collect all the packages used across all the
// pubspec.yamls in the repo (including via transitive dependencies), and
// find the latest version of each that can be used while keeping each
@@ -196,7 +195,7 @@
final Map<String, PubspecDependency> dependencies = <String, PubspecDependency>{};
final Set<String> specialDependencies = <String>{};
for (Directory directory in packages) { // these are all the directories with pubspec.yamls we care about
- printTrace('Reading pubspec.yaml from: ${directory.path}');
+ globals.printTrace('Reading pubspec.yaml from: ${directory.path}');
PubspecYaml pubspec;
try {
pubspec = PubspecYaml(directory); // this parses the pubspec.yaml
@@ -242,7 +241,7 @@
// pub tool will attempt to bring these dependencies up to the most recent
// possible versions while honoring all their constraints.
final PubDependencyTree tree = PubDependencyTree(); // object to collect results
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_update_packages.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_update_packages.');
try {
final File fakePackage = _pubspecFor(tempDir);
fakePackage.createSync();
@@ -288,7 +287,7 @@
if (isPrintTransitiveClosure) {
tree._dependencyTree.forEach((String from, Set<String> to) {
- printStatus('$from -> $to');
+ globals.printStatus('$from -> $to');
});
return null;
}
@@ -327,7 +326,7 @@
await _downloadCoverageData();
final double seconds = timer.elapsedMilliseconds / 1000.0;
- printStatus('\nRan \'pub\' $count time${count == 1 ? "" : "s"} and fetched coverage data in ${seconds.toStringAsFixed(1)}s.');
+ globals.printStatus('\nRan \'pub\' $count time${count == 1 ? "" : "s"} and fetched coverage data in ${seconds.toStringAsFixed(1)}s.');
return null;
}
@@ -373,11 +372,11 @@
buf.write(' <- ');
}
}
- printStatus(buf.toString(), wrap: false);
+ globals.printStatus(buf.toString(), wrap: false);
}
if (paths.isEmpty) {
- printStatus('No paths found from $from to $to');
+ globals.printStatus('No paths found from $from to $to');
}
}
}
@@ -1048,8 +1047,8 @@
}
if (_kind == DependencyKind.path &&
- !fs.path.isWithin(fs.path.join(Cache.flutterRoot, 'bin'), _lockTarget) &&
- fs.path.isWithin(Cache.flutterRoot, _lockTarget)) {
+ !globals.fs.path.isWithin(globals.fs.path.join(Cache.flutterRoot, 'bin'), _lockTarget) &&
+ globals.fs.path.isWithin(Cache.flutterRoot, _lockTarget)) {
return true;
}
@@ -1065,8 +1064,8 @@
assert(kind == DependencyKind.unknown);
if (line.startsWith(_pathPrefix)) {
// We're a path dependency; remember the (absolute) path.
- _lockTarget = fs.path.canonicalize(
- fs.path.absolute(fs.path.dirname(pubspecPath), line.substring(_pathPrefix.length, line.length))
+ _lockTarget = globals.fs.path.canonicalize(
+ globals.fs.path.absolute(globals.fs.path.dirname(pubspecPath), line.substring(_pathPrefix.length, line.length))
);
_kind = DependencyKind.path;
} else if (line.startsWith(_sdkPrefix)) {
@@ -1135,7 +1134,7 @@
/// Generates the File object for the pubspec.yaml file of a given Directory.
File _pubspecFor(Directory directory) {
- return fs.file(fs.path.join(directory.path, 'pubspec.yaml'));
+ return globals.fs.file(globals.fs.path.join(directory.path, 'pubspec.yaml'));
}
/// Generates the source of a fake pubspec.yaml file given a list of
@@ -1147,7 +1146,7 @@
result.writeln('dependencies:');
overrides.writeln('dependency_overrides:');
if (_kManuallyPinnedDependencies.isNotEmpty) {
- printStatus('WARNING: the following packages use hard-coded version constraints:');
+ globals.printStatus('WARNING: the following packages use hard-coded version constraints:');
final Set<String> allTransitive = <String>{
for (PubspecDependency dependency in dependencies)
dependency.name,
@@ -1155,12 +1154,12 @@
for (String package in _kManuallyPinnedDependencies.keys) {
// Don't add pinned dependency if it is not in the set of all transitive dependencies.
if (!allTransitive.contains(package)) {
- printStatus('Skipping $package because it was not transitive');
+ globals.printStatus('Skipping $package because it was not transitive');
continue;
}
final String version = _kManuallyPinnedDependencies[package];
result.writeln(' $package: $version');
- printStatus(' - $package: $version');
+ globals.printStatus(' - $package: $version');
}
}
for (PubspecDependency dependency in dependencies) {
diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart
index 10f236e..03a2b36 100644
--- a/packages/flutter_tools/lib/src/commands/upgrade.dart
+++ b/packages/flutter_tools/lib/src/commands/upgrade.dart
@@ -7,14 +7,12 @@
import 'package:meta/meta.dart';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../cache.dart';
import '../dart/pub.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../persistent_tool_state.dart';
import '../runner/flutter_command.dart';
import '../version.dart';
@@ -119,8 +117,8 @@
final bool alreadyUpToDate = await attemptFastForward(flutterVersion);
if (alreadyUpToDate) {
// If the upgrade was a no op, then do not continue with the second half.
- printStatus('Flutter is already up to date on channel ${flutterVersion.channel}');
- printStatus('$flutterVersion');
+ globals.printStatus('Flutter is already up to date on channel ${flutterVersion.channel}');
+ globals.printStatus('$flutterVersion');
} else {
await flutterUpgradeContinue();
}
@@ -129,14 +127,14 @@
Future<void> flutterUpgradeContinue() async {
final int code = await processUtils.stream(
<String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'upgrade',
'--continue',
'--no-version-check',
],
workingDirectory: Cache.flutterRoot,
allowReentrantFlutter: true,
- environment: Map<String, String>.of(platform.environment),
+ environment: Map<String, String>.of(globals.platform.environment),
);
if (code != 0) {
throwToolExit(null, exitCode: code);
@@ -227,7 +225,7 @@
/// If the user is on a deprecated channel, attempts to migrate them off of
/// it.
Future<void> upgradeChannel(FlutterVersion flutterVersion) async {
- printStatus('Upgrading Flutter from ${Cache.flutterRoot}...');
+ globals.printStatus('Upgrading Flutter from ${Cache.flutterRoot}...');
await ChannelCommand.upgradeChannel();
}
@@ -255,7 +253,7 @@
alreadyUpToDate = newFlutterVersion.channel == oldFlutterVersion.channel &&
newFlutterVersion.frameworkRevision == oldFlutterVersion.frameworkRevision;
} catch (e) {
- printTrace('Failed to determine FlutterVersion after upgrade fast-forward: $e');
+ globals.printTrace('Failed to determine FlutterVersion after upgrade fast-forward: $e');
}
return alreadyUpToDate;
}
@@ -266,15 +264,15 @@
/// shell script re-entrantly here so that it will download the updated
/// Dart and so forth if necessary.
Future<void> precacheArtifacts() async {
- printStatus('');
- printStatus('Upgrading engine...');
+ globals.printStatus('');
+ globals.printStatus('Upgrading engine...');
final int code = await processUtils.stream(
<String>[
- fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache',
+ globals.fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache',
],
workingDirectory: Cache.flutterRoot,
allowReentrantFlutter: true,
- environment: Map<String, String>.of(platform.environment),
+ environment: Map<String, String>.of(globals.platform.environment),
);
if (code != 0) {
throwToolExit(null, exitCode: code);
@@ -283,22 +281,22 @@
/// Update the user's packages.
Future<void> updatePackages(FlutterVersion flutterVersion) async {
- printStatus('');
- printStatus(flutterVersion.toString());
+ globals.printStatus('');
+ globals.printStatus(flutterVersion.toString());
final String projectRoot = findProjectRoot();
if (projectRoot != null) {
- printStatus('');
+ globals.printStatus('');
await pub.get(context: PubContext.pubUpgrade, directory: projectRoot, upgrade: true, checkLastModified: false);
}
}
/// Run flutter doctor in case requirements have changed.
Future<void> runDoctor() async {
- printStatus('');
- printStatus('Running flutter doctor...');
+ globals.printStatus('');
+ globals.printStatus('Running flutter doctor...');
await processUtils.stream(
<String>[
- fs.path.join('bin', 'flutter'), '--no-version-check', 'doctor',
+ globals.fs.path.join('bin', 'flutter'), '--no-version-check', 'doctor',
],
workingDirectory: Cache.flutterRoot,
allowReentrantFlutter: true,
diff --git a/packages/flutter_tools/lib/src/commands/version.dart b/packages/flutter_tools/lib/src/commands/version.dart
index e4f758d..dbba34a 100644
--- a/packages/flutter_tools/lib/src/commands/version.dart
+++ b/packages/flutter_tools/lib/src/commands/version.dart
@@ -5,14 +5,13 @@
import 'dart:async';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart';
import '../base/process.dart';
import '../base/version.dart';
import '../cache.dart';
import '../dart/pub.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import '../version.dart';
@@ -57,12 +56,12 @@
Future<FlutterCommandResult> runCommand() async {
final List<String> tags = await getTags();
if (argResults.rest.isEmpty) {
- tags.forEach(printStatus);
+ tags.forEach(globals.printStatus);
return const FlutterCommandResult(ExitStatus.success);
}
final String version = argResults.rest[0].replaceFirst('v', '');
if (!tags.contains('v$version')) {
- printError('There is no version: $version');
+ globals.printError('There is no version: $version');
}
// check min supported version
@@ -74,7 +73,7 @@
bool withForce = false;
if (targetVersion < minSupportedVersion) {
if (!boolArg('force')) {
- printError(
+ globals.printError(
'Version command is not supported in $targetVersion and it is supported since version $minSupportedVersion'
'which means if you switch to version $minSupportedVersion then you can not use version command.'
'If you really want to switch to version $targetVersion, please use `--force` flag: `flutter version --force $targetVersion`.'
@@ -96,16 +95,16 @@
final FlutterVersion flutterVersion = FlutterVersion();
- printStatus('Switching Flutter to version ${flutterVersion.frameworkVersion}${withForce ? ' with force' : ''}');
+ globals.printStatus('Switching Flutter to version ${flutterVersion.frameworkVersion}${withForce ? ' with force' : ''}');
// Check for and download any engine and pkg/ updates.
// We run the 'flutter' shell script re-entrantly here
// so that it will download the updated Dart and so forth
// if necessary.
- printStatus('');
- printStatus('Downloading engine...');
+ globals.printStatus('');
+ globals.printStatus('Downloading engine...');
int code = await processUtils.stream(<String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'--no-color',
'precache',
], workingDirectory: Cache.flutterRoot, allowReentrantFlutter: true);
@@ -114,12 +113,12 @@
throwToolExit(null, exitCode: code);
}
- printStatus('');
- printStatus(flutterVersion.toString());
+ globals.printStatus('');
+ globals.printStatus(flutterVersion.toString());
final String projectRoot = findProjectRoot();
if (projectRoot != null && shouldRunPub) {
- printStatus('');
+ globals.printStatus('');
await pub.get(
context: PubContext.pubUpgrade,
directory: projectRoot,
@@ -129,11 +128,11 @@
}
// Run a doctor check in case system requirements have changed.
- printStatus('');
- printStatus('Running flutter doctor...');
+ globals.printStatus('');
+ globals.printStatus('Running flutter doctor...');
code = await processUtils.stream(
<String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'doctor',
],
workingDirectory: Cache.flutterRoot,
diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart
index 3e5cf3c..30a03bb 100644
--- a/packages/flutter_tools/lib/src/compile.dart
+++ b/packages/flutter_tools/lib/src/compile.dart
@@ -10,16 +10,13 @@
import 'artifacts.dart';
import 'base/common.dart';
import 'base/context.dart';
-import 'base/file_system.dart';
import 'base/io.dart';
-import 'base/platform.dart';
-import 'base/process_manager.dart';
import 'base/terminal.dart';
import 'build_info.dart';
import 'codegen.dart';
import 'convert.dart';
import 'dart/package_map.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'project.dart';
KernelCompilerFactory get kernelCompilerFactory => context.get<KernelCompilerFactory>();
@@ -91,7 +88,7 @@
/// Handles stdin/stdout communication with the frontend server.
class StdoutHandler {
- StdoutHandler({this.consumer = printError}) {
+ StdoutHandler({this.consumer = globals.printError}) {
reset();
}
@@ -179,7 +176,7 @@
sources.remove(Uri.parse(message.substring(1)));
break;
default:
- printTrace('Unexpected prefix for $message uri - ignoring');
+ globals.printTrace('Unexpected prefix for $message uri - ignoring');
}
}
}
@@ -199,8 +196,8 @@
/// Converts filesystem paths to package URIs.
class PackageUriMapper {
PackageUriMapper(String scriptPath, String packagesPath, String fileSystemScheme, List<String> fileSystemRoots) {
- final Map<String, Uri> packageMap = PackageMap(fs.path.absolute(packagesPath)).map;
- final String scriptUri = Uri.file(scriptPath, windows: platform.isWindows).toString();
+ final Map<String, Uri> packageMap = PackageMap(globals.fs.path.absolute(packagesPath)).map;
+ final String scriptUri = Uri.file(scriptPath, windows: globals.platform.isWindows).toString();
for (String packageName in packageMap.keys) {
final String prefix = packageMap[packageName].toString();
// Only perform a multi-root mapping if there are multiple roots.
@@ -210,7 +207,7 @@
&& prefix.contains(fileSystemScheme)) {
_packageName = packageName;
_uriPrefixes = fileSystemRoots
- .map((String name) => Uri.file(name, windows: platform.isWindows).toString())
+ .map((String name) => Uri.file(name, windows:globals.platform.isWindows).toString())
.toList();
return;
}
@@ -229,7 +226,7 @@
if (_packageName == null) {
return null;
}
- final String scriptUri = Uri.file(scriptPath, windows: platform.isWindows).toString();
+ final String scriptUri = Uri.file(scriptPath, windows: globals.platform.isWindows).toString();
for (String uriPrefix in _uriPrefixes) {
if (scriptUri.startsWith(uriPrefix)) {
return Uri.parse('package:$_packageName/${scriptUri.substring(uriPrefix.length)}');
@@ -290,15 +287,15 @@
String platformDill,
@required List<String> dartDefines,
}) async {
- final String frontendServer = artifacts.getArtifactPath(
+ final String frontendServer = globals.artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk
);
// This is a URI, not a file path, so the forward slash is correct even on Windows.
if (!sdkRoot.endsWith('/')) {
sdkRoot = '$sdkRoot/';
}
- final String engineDartPath = artifacts.getArtifactPath(Artifact.engineDartBinary);
- if (!processManager.canRun(engineDartPath)) {
+ final String engineDartPath = globals.artifacts.getArtifactPath(Artifact.engineDartBinary);
+ if (!globals.processManager.canRun(engineDartPath)) {
throwToolExit('Unable to find Dart binary at $engineDartPath');
}
Uri mainUri;
@@ -307,8 +304,8 @@
}
// TODO(jonahwilliams): The output file must already exist, but this seems
// unnecessary.
- if (outputFilePath != null && !fs.isFileSync(outputFilePath)) {
- fs.file(outputFilePath).createSync(recursive: true);
+ if (outputFilePath != null && !globals.fs.isFileSync(outputFilePath)) {
+ globals.fs.file(outputFilePath).createSync(recursive: true);
}
final List<String> command = <String>[
engineDartPath,
@@ -359,18 +356,18 @@
mainUri?.toString() ?? mainPath,
];
- printTrace(command.join(' '));
- final Process server = await processManager
+ globals.printTrace(command.join(' '));
+ final Process server = await globals.processManager
.start(command)
.catchError((dynamic error, StackTrace stack) {
- printError('Failed to start frontend server $error, $stack');
+ globals.printError('Failed to start frontend server $error, $stack');
});
final StdoutHandler _stdoutHandler = StdoutHandler();
server.stderr
.transform<String>(utf8.decoder)
- .listen(printError);
+ .listen(globals.printError);
server.stdout
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
@@ -520,7 +517,7 @@
this.packagesPath,
this.fileSystemRoots,
this.fileSystemScheme,
- CompilerMessageConsumer compilerMessageConsumer = printError,
+ CompilerMessageConsumer compilerMessageConsumer = globals.printError,
this.initializeFromDill,
this.targetModel = TargetModel.flutter,
this.unsafePackageSerialization,
@@ -610,13 +607,13 @@
? _mapFilename(request.mainPath, packageUriMapper) + ' '
: '';
_server.stdin.writeln('recompile $mainUri$inputKey');
- printTrace('<- recompile $mainUri$inputKey');
+ globals.printTrace('<- recompile $mainUri$inputKey');
for (Uri fileUri in request.invalidatedFiles) {
_server.stdin.writeln(_mapFileUri(fileUri.toString(), packageUriMapper));
- printTrace('${_mapFileUri(fileUri.toString(), packageUriMapper)}');
+ globals.printTrace('${_mapFileUri(fileUri.toString(), packageUriMapper)}');
}
_server.stdin.writeln(inputKey);
- printTrace('<- $inputKey');
+ globals.printTrace('<- $inputKey');
return _stdoutHandler.compilerOutput.future;
}
@@ -643,11 +640,11 @@
String outputPath,
String packagesFilePath,
) async {
- final String frontendServer = artifacts.getArtifactPath(
+ final String frontendServer = globals.artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk
);
final List<String> command = <String>[
- artifacts.getArtifactPath(Artifact.engineDartBinary),
+ globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
frontendServer,
'--sdk-root',
sdkRoot,
@@ -690,8 +687,8 @@
if ((experimentalFlags != null) && experimentalFlags.isNotEmpty)
'--enable-experiment=${experimentalFlags.join(',')}',
];
- printTrace(command.join(' '));
- _server = await processManager.start(command);
+ globals.printTrace(command.join(' '));
+ _server = await globals.processManager.start(command);
_server.stdout
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
@@ -709,7 +706,7 @@
_server.stderr
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
- .listen((String message) { printError(message); });
+ .listen((String message) { globals.printError(message); });
unawaited(_server.exitCode.then((int code) {
if (code != 0) {
@@ -718,7 +715,7 @@
}));
_server.stdin.writeln('compile $scriptUri');
- printTrace('<- compile $scriptUri');
+ globals.printTrace('<- compile $scriptUri');
return _stdoutHandler.compilerOutput.future;
}
@@ -771,7 +768,7 @@
void accept() {
if (_compileRequestNeedsConfirmation) {
_server.stdin.writeln('accept');
- printTrace('<- accept');
+ globals.printTrace('<- accept');
}
_compileRequestNeedsConfirmation = false;
}
@@ -793,7 +790,7 @@
}
_stdoutHandler.reset(expectSources: false);
_server.stdin.writeln('reject');
- printTrace('<- reject');
+ globals.printTrace('<- reject');
_compileRequestNeedsConfirmation = false;
return _stdoutHandler.compilerOutput.future;
}
@@ -801,7 +798,7 @@
@override
void reset() {
_server?.stdin?.writeln('reset');
- printTrace('<- reset');
+ globals.printTrace('<- reset');
}
String _mapFilename(String filename, PackageUriMapper packageUriMapper) {
@@ -835,8 +832,8 @@
}
}
}
- if (platform.isWindows && fileSystemRoots != null && fileSystemRoots.length > 1) {
- return Uri.file(filename, windows: platform.isWindows).toString();
+ if (globals.platform.isWindows && fileSystemRoots != null && fileSystemRoots.length > 1) {
+ return Uri.file(filename, windows: globals.platform.isWindows).toString();
}
return null;
}
@@ -847,7 +844,7 @@
if (_server == null) {
return 0;
}
- printTrace('killing pid ${_server.pid}');
+ globals.printTrace('killing pid ${_server.pid}');
_server.kill();
return _server.exitCode;
}
diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart
index 6fdaf3a..e90cc72 100644
--- a/packages/flutter_tools/lib/src/context_runner.dart
+++ b/packages/flutter_tools/lib/src/context_runner.dart
@@ -17,7 +17,6 @@
import 'base/io.dart';
import 'base/logger.dart';
import 'base/os.dart';
-import 'base/platform.dart';
import 'base/process.dart';
import 'base/signals.dart';
import 'base/time.dart';
@@ -35,6 +34,7 @@
import 'fuchsia/fuchsia_device.dart' show FuchsiaDeviceTools;
import 'fuchsia/fuchsia_sdk.dart' show FuchsiaSdk, FuchsiaArtifacts;
import 'fuchsia/fuchsia_workflow.dart' show FuchsiaWorkflow;
+import 'globals.dart' as globals;
import 'ios/devices.dart' show IOSDeploy;
import 'ios/ios_workflow.dart';
import 'ios/mac.dart';
@@ -101,7 +101,7 @@
IOSWorkflow: () => const IOSWorkflow(),
KernelCompilerFactory: () => const KernelCompilerFactory(),
LinuxWorkflow: () => const LinuxWorkflow(),
- Logger: () => platform.isWindows ? WindowsStdoutLogger() : StdoutLogger(),
+ Logger: () => globals.platform.isWindows ? WindowsStdoutLogger() : StdoutLogger(),
MacOSWorkflow: () => const MacOSWorkflow(),
MDnsObservatoryDiscovery: () => MDnsObservatoryDiscovery(),
OperatingSystemUtils: () => OperatingSystemUtils(),
diff --git a/packages/flutter_tools/lib/src/dart/analysis.dart b/packages/flutter_tools/lib/src/dart/analysis.dart
index 50ffbdc..85b77fe 100644
--- a/packages/flutter_tools/lib/src/dart/analysis.dart
+++ b/packages/flutter_tools/lib/src/dart/analysis.dart
@@ -6,15 +6,11 @@
import 'dart:math' as math;
import '../base/common.dart';
-import '../base/file_system.dart' hide IOSink;
-import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
import '../base/terminal.dart';
import '../base/utils.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
class AnalysisServer {
AnalysisServer(this.sdkPath, this.directories);
@@ -33,9 +29,9 @@
Future<void> start() async {
final String snapshot =
- fs.path.join(sdkPath, 'bin/snapshots/analysis_server.dart.snapshot');
+ globals.fs.path.join(sdkPath, 'bin/snapshots/analysis_server.dart.snapshot');
final List<String> command = <String>[
- fs.path.join(sdkPath, 'bin', 'dart'),
+ globals.fs.path.join(sdkPath, 'bin', 'dart'),
snapshot,
'--disable-server-feature-completion',
'--disable-server-feature-search',
@@ -43,14 +39,14 @@
sdkPath,
];
- printTrace('dart ${command.skip(1).join(' ')}');
- _process = await processManager.start(command);
+ globals.printTrace('dart ${command.skip(1).join(' ')}');
+ _process = await globals.processManager.start(command);
// This callback hookup can't throw.
unawaited(_process.exitCode.whenComplete(() => _process = null));
final Stream<String> errorStream =
_process.stderr.transform<String>(utf8.decoder).transform<String>(const LineSplitter());
- errorStream.listen(printError);
+ errorStream.listen(globals.printError);
final Stream<String> inStream =
_process.stdout.transform<String>(utf8.decoder).transform<String>(const LineSplitter());
@@ -77,11 +73,11 @@
'params': params,
});
_process.stdin.writeln(message);
- printTrace('==> $message');
+ globals.printTrace('==> $message');
}
void _handleServerResponse(String line) {
- printTrace('<== $line');
+ globals.printTrace('<== $line');
final dynamic response = json.decode(line);
@@ -102,10 +98,10 @@
} else if (response['error'] != null) {
// Fields are 'code', 'message', and 'stackTrace'.
final Map<String, dynamic> error = castStringKeyedMap(response['error']);
- printError(
+ globals.printError(
'Error response from the server: ${error['code']} ${error['message']}');
if (error['stackTrace'] != null) {
- printError(error['stackTrace'] as String);
+ globals.printError(error['stackTrace'] as String);
}
}
}
@@ -121,9 +117,9 @@
void _handleServerError(Map<String, dynamic> error) {
// Fields are 'isFatal', 'message', and 'stackTrace'.
- printError('Error from the analysis server: ${error['message']}');
+ globals.printError('Error from the analysis server: ${error['message']}');
if (error['stackTrace'] != null) {
- printError(error['stackTrace'] as String);
+ globals.printError(error['stackTrace'] as String);
}
_didServerErrorOccur = true;
}
@@ -164,7 +160,7 @@
'ERROR': _AnalysisSeverity.error,
};
- static final String _separator = platform.isWindows ? '-' : '•';
+ static final String _separator = globals.platform.isWindows ? '-' : '•';
// "severity":"INFO","type":"TODO","location":{
// "file":"/Users/.../lib/test.dart","offset":362,"length":72,"startLine":15,"startColumn":4
@@ -175,9 +171,9 @@
String get colorSeverity {
switch(_severityLevel) {
case _AnalysisSeverity.error:
- return terminal.color(severity, TerminalColor.red);
+ return globals.terminal.color(severity, TerminalColor.red);
case _AnalysisSeverity.warning:
- return terminal.color(severity, TerminalColor.yellow);
+ return globals.terminal.color(severity, TerminalColor.yellow);
case _AnalysisSeverity.info:
case _AnalysisSeverity.none:
return severity;
@@ -228,7 +224,7 @@
final String padding = ' ' * math.max(0, 7 - severity.length);
return '$padding${colorSeverity.toLowerCase()} $_separator '
'$messageSentenceFragment $_separator '
- '${fs.path.relative(file)}:$startLine:$startColumn $_separator '
+ '${globals.fs.path.relative(file)}:$startLine:$startColumn $_separator '
'$code';
}
diff --git a/packages/flutter_tools/lib/src/dart/package_map.dart b/packages/flutter_tools/lib/src/dart/package_map.dart
index f7453c5..ef6b6df 100644
--- a/packages/flutter_tools/lib/src/dart/package_map.dart
+++ b/packages/flutter_tools/lib/src/dart/package_map.dart
@@ -4,15 +4,14 @@
import 'package:package_config/packages_file.dart' as packages_file;
-import '../base/file_system.dart';
-import '../base/platform.dart';
+import '../globals.dart' as globals;
const String kPackagesFileName = '.packages';
Map<String, Uri> _parse(String packagesPath) {
- final List<int> source = fs.file(packagesPath).readAsBytesSync();
+ final List<int> source = globals.fs.file(packagesPath).readAsBytesSync();
return packages_file.parse(source,
- Uri.file(packagesPath, windows: platform.isWindows));
+ Uri.file(packagesPath, windows: globals.platform.isWindows));
}
class PackageMap {
@@ -20,7 +19,7 @@
static String get globalPackagesPath => _globalPackagesPath ?? kPackagesFileName;
- static String get globalGeneratedPackagesPath => fs.path.setExtension(globalPackagesPath, '.generated');
+ static String get globalGeneratedPackagesPath => globals.fs.path.setExtension(globalPackagesPath, '.generated');
static set globalPackagesPath(String value) {
_globalPackagesPath = value;
@@ -55,17 +54,17 @@
if (packageBase == null) {
return null;
}
- final String packageRelativePath = fs.path.joinAll(pathSegments);
- return packageBase.resolveUri(fs.path.toUri(packageRelativePath));
+ final String packageRelativePath = globals.fs.path.joinAll(pathSegments);
+ return packageBase.resolveUri(globals.fs.path.toUri(packageRelativePath));
}
String checkValid() {
- if (fs.isFileSync(packagesPath)) {
+ if (globals.fs.isFileSync(packagesPath)) {
return null;
}
String message = '$packagesPath does not exist.';
- final String pubspecPath = fs.path.absolute(fs.path.dirname(packagesPath), 'pubspec.yaml');
- if (fs.isFileSync(pubspecPath)) {
+ final String pubspecPath = globals.fs.path.absolute(globals.fs.path.dirname(packagesPath), 'pubspec.yaml');
+ if (globals.fs.isFileSync(pubspecPath)) {
message += '\nDid you run "flutter pub get" in this directory?';
} else {
message += '\nDid you run this command from the same directory as your pubspec.yaml file?';
diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart
index 81dc46e..375fdd3 100644
--- a/packages/flutter_tools/lib/src/dart/pub.dart
+++ b/packages/flutter_tools/lib/src/dart/pub.dart
@@ -11,11 +11,10 @@
import '../base/file_system.dart';
import '../base/io.dart' as io;
import '../base/logger.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../base/utils.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
import 'sdk.dart';
@@ -73,7 +72,7 @@
if (pubSpecYaml.lastModifiedSync().isAfter(dotPackagesLastModified)) {
return true;
}
- final File flutterToolsStamp = Cache.instance.getStampFileFor('flutter_tools');
+ final File flutterToolsStamp = globals.cache.getStampFileFor('flutter_tools');
if (flutterToolsStamp.existsSync() &&
flutterToolsStamp.lastModifiedSync().isAfter(dotPackagesLastModified)) {
return true;
@@ -146,10 +145,10 @@
bool checkLastModified = true,
bool skipPubspecYamlCheck = false,
}) async {
- directory ??= fs.currentDirectory.path;
+ directory ??= globals.fs.currentDirectory.path;
- final File pubSpecYaml = fs.file(fs.path.join(directory, 'pubspec.yaml'));
- final File dotPackages = fs.file(fs.path.join(directory, '.packages'));
+ final File pubSpecYaml = globals.fs.file(globals.fs.path.join(directory, 'pubspec.yaml'));
+ final File dotPackages = globals.fs.file(globals.fs.path.join(directory, '.packages'));
if (!skipPubspecYamlCheck && !pubSpecYaml.existsSync()) {
if (!skipIfAbsent) {
@@ -162,8 +161,8 @@
if (!checkLastModified || _shouldRunPubGet(pubSpecYaml: pubSpecYaml, dotPackages: dotPackages)) {
final String command = upgrade ? 'upgrade' : 'get';
- final Status status = logger.startProgress(
- 'Running "flutter pub $command" in ${fs.path.basename(directory)}...',
+ final Status status = globals.logger.startProgress(
+ 'Running "flutter pub $command" in ${globals.fs.path.basename(directory)}...',
timeout: timeoutConfiguration.slowOperation,
);
final bool verbose = FlutterCommand.current != null && FlutterCommand.current.globalResults['verbose'] as bool;
@@ -200,8 +199,8 @@
// file to be more recently modified.
final DateTime now = DateTime.now();
if (now.isBefore(originalPubspecYamlModificationTime)) {
- printError(
- 'Warning: File "${fs.path.absolute(pubSpecYaml.path)}" was created in the future. '
+ globals.printError(
+ 'Warning: File "${globals.fs.path.absolute(pubSpecYaml.path)}" was created in the future. '
'Optimizations that rely on comparing time stamps will be unreliable. Check your '
'system clock for accuracy.\n'
'The timestamp was: $originalPubspecYamlModificationTime\n'
@@ -211,12 +210,12 @@
dotPackages.setLastModifiedSync(now);
final DateTime newDotPackagesTimestamp = dotPackages.lastModifiedSync();
if (newDotPackagesTimestamp.isBefore(originalPubspecYamlModificationTime)) {
- printError(
- 'Warning: Failed to set timestamp of "${fs.path.absolute(dotPackages.path)}". '
+ globals.printError(
+ 'Warning: Failed to set timestamp of "${globals.fs.path.absolute(dotPackages.path)}". '
'Tried to set timestamp to $now, but new timestamp is $newDotPackagesTimestamp.'
);
if (newDotPackagesTimestamp.isAfter(now)) {
- printError('Maybe the file was concurrently modified?');
+ globals.printError('Maybe the file was concurrently modified?');
}
}
}
@@ -272,7 +271,7 @@
}
assert(message != null);
versionSolvingFailed = false;
- printStatus('$failureMessage ($message) -- attempting retry $attempts in $duration second${ duration == 1 ? "" : "s"}...');
+ globals.printStatus('$failureMessage ($message) -- attempting retry $attempts in $duration second${ duration == 1 ? "" : "s"}...');
await Future<void>.delayed(Duration(seconds: duration));
if (duration < 64) {
duration *= 2;
@@ -366,7 +365,7 @@
String _getPubEnvironmentValue(PubContext pubContext) {
// DO NOT update this function without contacting kevmoo.
// We have server-side tooling that assumes the values are consistent.
- final String existing = platform.environment[_pubEnvironmentKey];
+ final String existing = globals.platform.environment[_pubEnvironmentKey];
final List<String> values = <String>[
if (existing != null && existing.isNotEmpty) existing,
if (isRunningOnBot) 'flutter_bot',
@@ -377,13 +376,13 @@
}
String _getRootPubCacheIfAvailable() {
- if (platform.environment.containsKey(_pubCacheEnvironmentKey)) {
- return platform.environment[_pubCacheEnvironmentKey];
+ if (globals.platform.environment.containsKey(_pubCacheEnvironmentKey)) {
+ return globals.platform.environment[_pubCacheEnvironmentKey];
}
- final String cachePath = fs.path.join(Cache.flutterRoot, '.pub-cache');
- if (fs.directory(cachePath).existsSync()) {
- printTrace('Using $cachePath for the pub cache.');
+ final String cachePath = globals.fs.path.join(Cache.flutterRoot, '.pub-cache');
+ if (globals.fs.directory(cachePath).existsSync()) {
+ globals.printTrace('Using $cachePath for the pub cache.');
return cachePath;
}
diff --git a/packages/flutter_tools/lib/src/dart/sdk.dart b/packages/flutter_tools/lib/src/dart/sdk.dart
index 995a0a3..446766f 100644
--- a/packages/flutter_tools/lib/src/dart/sdk.dart
+++ b/packages/flutter_tools/lib/src/dart/sdk.dart
@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import '../base/file_system.dart';
-import '../base/platform.dart';
import '../cache.dart';
+import '../globals.dart' as globals;
/// Locate the Dart SDK.
String get dartSdkPath {
- return fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
+ return globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
}
/// The required Dart language flags
@@ -18,5 +17,6 @@
/// ==> `pub.bat`. The default SDK location can be overridden with a specified
/// [sdkLocation].
String sdkBinaryName(String name, { String sdkLocation }) {
- return fs.path.absolute(fs.path.join(sdkLocation ?? dartSdkPath, 'bin', platform.isWindows ? '$name.bat' : name));
+ return globals.fs.path.absolute(
+ globals.fs.path.join(sdkLocation ?? dartSdkPath, 'bin', globals.platform.isWindows ? '$name.bat' : name));
}
diff --git a/packages/flutter_tools/lib/src/desktop_device.dart b/packages/flutter_tools/lib/src/desktop_device.dart
index 944f3db..0922824 100644
--- a/packages/flutter_tools/lib/src/desktop_device.dart
+++ b/packages/flutter_tools/lib/src/desktop_device.dart
@@ -10,12 +10,11 @@
import 'base/common.dart';
import 'base/io.dart';
import 'base/os.dart';
-import 'base/process_manager.dart';
import 'build_info.dart';
import 'cache.dart';
import 'convert.dart';
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'protocol_discovery.dart';
/// A partial implementation of Device for desktop-class devices to inherit
@@ -95,11 +94,11 @@
final BuildMode buildMode = debuggingOptions?.buildInfo?.mode;
final String executable = executablePathForDevice(package, buildMode);
if (executable == null) {
- printError('Unable to find executable to run');
+ globals.printError('Unable to find executable to run');
return LaunchResult.failed();
}
- final Process process = await processManager.start(<String>[
+ final Process process = await globals.processManager.start(<String>[
executable,
]);
_runningProcesses.add(process);
@@ -119,7 +118,7 @@
onAttached(package, buildMode, process);
return LaunchResult.succeeded(observatoryUri: observatoryUri);
} catch (error) {
- printError('Error waiting for a debug connection: $error');
+ globals.printError('Error waiting for a debug connection: $error');
return LaunchResult.failed();
} finally {
await observatoryDiscovery.cancel();
diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart
index 1e329e8..3400c82 100644
--- a/packages/flutter_tools/lib/src/devfs.dart
+++ b/packages/flutter_tools/lib/src/devfs.dart
@@ -17,7 +17,7 @@
import 'compile.dart';
import 'convert.dart' show base64, utf8;
import 'dart/package_map.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'vmservice.dart';
class DevFSConfig {
@@ -68,7 +68,7 @@
}
if (file is Link) {
// The link target.
- return fs.file(file.resolveSymbolicLinksSync());
+ return globals.fs.file(file.resolveSymbolicLinksSync());
}
return file as File;
}
@@ -89,7 +89,7 @@
if (_fileStat != null && _fileStat.type == FileSystemEntityType.link) {
// Resolve, stat, and maybe cache the symlink target.
final String resolved = file.resolveSymbolicLinksSync();
- final File linkTarget = fs.file(resolved);
+ final File linkTarget = globals.fs.file(resolved);
// Stat the link target.
final FileStat fileStat = linkTarget.statSync();
if (fileStat.type == FileSystemEntityType.notFound) {
@@ -100,7 +100,7 @@
}
}
if (_fileStat == null) {
- printError('Unable to get status of file "${file.path}": file not found.');
+ globals.printError('Unable to get status of file "${file.path}": file not found.');
}
}
@@ -252,7 +252,7 @@
},
);
} catch (error) {
- printTrace('DevFS: Failed to write $deviceUri: $error');
+ globals.printTrace('DevFS: Failed to write $deviceUri: $error');
}
}
}
@@ -316,15 +316,15 @@
await request.addStream(contents);
final HttpClientResponse response = await request.close();
response.listen((_) => null,
- onError: (dynamic error) { printTrace('error: $error'); },
+ onError: (dynamic error) { globals.printTrace('error: $error'); },
cancelOnError: true);
break;
} catch (error, trace) {
if (!_completer.isCompleted) {
- printTrace('Error writing "$deviceUri" to DevFS: $error');
+ globals.printTrace('Error writing "$deviceUri" to DevFS: $error');
if (retry > 0) {
retry--;
- printTrace('trying again in a few - $retry more attempts left');
+ globals.printTrace('trying again in a few - $retry more attempts left');
await Future<void>.delayed(const Duration(milliseconds: 500));
continue;
}
@@ -382,7 +382,7 @@
String packagesFilePath,
}) : _operations = ServiceProtocolDevFSOperations(serviceProtocol),
_httpWriter = _DevFSHttpWriter(fsName, serviceProtocol),
- _packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
+ _packagesFilePath = packagesFilePath ?? globals.fs.path.join(rootDirectory.path, kPackagesFileName);
DevFS.operations(
this._operations,
@@ -390,7 +390,7 @@
this.rootDirectory, {
String packagesFilePath,
}) : _httpWriter = null,
- _packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
+ _packagesFilePath = packagesFilePath ?? globals.fs.path.join(rootDirectory.path, kPackagesFileName);
final DevFSOperations _operations;
final _DevFSHttpWriter _httpWriter;
@@ -415,7 +415,7 @@
}
Future<Uri> create() async {
- printTrace('DevFS: Creating new filesystem on the device ($_baseUri)');
+ globals.printTrace('DevFS: Creating new filesystem on the device ($_baseUri)');
try {
_baseUri = await _operations.create(fsName);
} on rpc.RpcException catch (rpcException) {
@@ -423,18 +423,18 @@
if (rpcException.code != 1001) {
rethrow;
}
- printTrace('DevFS: Creating failed. Destroying and trying again');
+ globals.printTrace('DevFS: Creating failed. Destroying and trying again');
await destroy();
_baseUri = await _operations.create(fsName);
}
- printTrace('DevFS: Created new filesystem on the device ($_baseUri)');
+ globals.printTrace('DevFS: Created new filesystem on the device ($_baseUri)');
return _baseUri;
}
Future<void> destroy() async {
- printTrace('DevFS: Deleting filesystem on the device ($_baseUri)');
+ globals.printTrace('DevFS: Deleting filesystem on the device ($_baseUri)');
await _operations.destroy(fsName);
- printTrace('DevFS: Deleted filesystem on the device ($_baseUri)');
+ globals.printTrace('DevFS: Deleted filesystem on the device ($_baseUri)');
}
/// Updates files on the device.
@@ -465,12 +465,12 @@
int syncedBytes = 0;
if (bundle != null && !skipAssets) {
- printTrace('Scanning asset files');
+ globals.printTrace('Scanning asset files');
// We write the assets into the AssetBundle working dir so that they
// are in the same location in DevFS and the iOS simulator.
final String assetDirectory = getAssetBuildDirectory();
bundle.entries.forEach((String archivePath, DevFSContent content) {
- final Uri deviceUri = fs.path.toUri(fs.path.join(assetDirectory, archivePath));
+ final Uri deviceUri = globals.fs.path.toUri(globals.fs.path.join(assetDirectory, archivePath));
if (deviceUri.path.startsWith(assetBuildDirPrefix)) {
archivePath = deviceUri.path.substring(assetBuildDirPrefix.length);
}
@@ -488,7 +488,7 @@
if (fullRestart) {
generator.reset();
}
- printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
+ globals.printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
final CompilerOutput compilerOutput = await generator.recompile(
mainPath,
invalidatedFiles,
@@ -508,32 +508,32 @@
if (!bundleFirstUpload) {
final String compiledBinary = compilerOutput?.outputFilename;
if (compiledBinary != null && compiledBinary.isNotEmpty) {
- final Uri entryUri = fs.path.toUri(projectRootPath != null
- ? fs.path.relative(pathToReload, from: projectRootPath)
+ final Uri entryUri = globals.fs.path.toUri(projectRootPath != null
+ ? globals.fs.path.relative(pathToReload, from: projectRootPath)
: pathToReload,
);
- final DevFSFileContent content = DevFSFileContent(fs.file(compiledBinary));
+ final DevFSFileContent content = DevFSFileContent(globals.fs.file(compiledBinary));
syncedBytes += content.size;
dirtyEntries[entryUri] = content;
}
}
- printTrace('Updating files');
+ globals.printTrace('Updating files');
if (dirtyEntries.isNotEmpty) {
try {
await _httpWriter.write(dirtyEntries);
} on SocketException catch (socketException, stackTrace) {
- printTrace('DevFS sync failed. Lost connection to device: $socketException');
+ globals.printTrace('DevFS sync failed. Lost connection to device: $socketException');
throw DevFSException('Lost connection to device.', socketException, stackTrace);
} catch (exception, stackTrace) {
- printError('Could not update files on device: $exception');
+ globals.printError('Could not update files on device: $exception');
throw DevFSException('Sync failed', exception, stackTrace);
}
}
- printTrace('DevFS: Sync finished');
+ globals.printTrace('DevFS: Sync finished');
return UpdateFSReport(success: true, syncedBytes: syncedBytes,
invalidatedSourcesCount: invalidatedFiles.length);
}
}
/// Converts a platform-specific file path to a platform-independent URL path.
-String _asUriPath(String filePath) => fs.path.toUri(filePath).path + '/';
+String _asUriPath(String filePath) => globals.fs.path.toUri(filePath).path + '/';
diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart
index 452d471..d7ac151 100644
--- a/packages/flutter_tools/lib/src/device.dart
+++ b/packages/flutter_tools/lib/src/device.dart
@@ -16,7 +16,7 @@
import 'base/utils.dart';
import 'build_info.dart';
import 'fuchsia/fuchsia_device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'ios/devices.dart';
import 'ios/simulators.dart';
import 'linux/linux_device.dart';
@@ -269,7 +269,7 @@
final List<Device> devices = await pollingGetDevices().timeout(_pollingTimeout);
_items.updateWithNewList(devices);
} on TimeoutException {
- printTrace('Device poll timed out. Will retry.');
+ globals.printTrace('Device poll timed out. Will retry.');
}
_timer = _initTimer();
});
@@ -489,7 +489,7 @@
}
static Future<void> printDevices(List<Device> devices) async {
- await descriptions(devices).forEach(printStatus);
+ await descriptions(devices).forEach(globals.printStatus);
}
/// Clean up resources allocated by device
diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart
index e7ecb7c..ccaf690 100644
--- a/packages/flutter_tools/lib/src/doctor.dart
+++ b/packages/flutter_tools/lib/src/doctor.dart
@@ -13,7 +13,6 @@
import 'base/file_system.dart';
import 'base/logger.dart';
import 'base/os.dart';
-import 'base/platform.dart';
import 'base/process.dart';
import 'base/terminal.dart';
import 'base/user_messages.dart';
@@ -22,7 +21,7 @@
import 'cache.dart';
import 'device.dart';
import 'fuchsia/fuchsia_workflow.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'intellij/intellij.dart';
import 'ios/ios_workflow.dart';
import 'ios/plist_parser.dart';
@@ -170,7 +169,7 @@
/// Print a summary of the state of the tooling, as well as how to get more info.
Future<void> summary() async {
- printStatus(await _summaryText());
+ globals.printStatus(await _summaryText());
}
Future<String> _summaryText() async {
@@ -234,7 +233,7 @@
}
Future<bool> checkRemoteArtifacts(String engineRevision) async {
- return Cache.instance.areRemoteArtifactsAvailable(engineVersion: engineRevision);
+ return globals.cache.areRemoteArtifactsAvailable(engineVersion: engineRevision);
}
/// Print information about the state of installed tooling.
@@ -244,7 +243,7 @@
}
if (!verbose) {
- printStatus('Doctor summary (to see all details, run flutter doctor -v):');
+ globals.printStatus('Doctor summary (to see all details, run flutter doctor -v):');
}
bool doctorResult = true;
int issues = 0;
@@ -285,10 +284,10 @@
final String leadingBox = showColor ? result.coloredLeadingBox : result.leadingBox;
if (result.statusInfo != null) {
- printStatus('$leadingBox ${validator.title} (${result.statusInfo})',
+ globals.printStatus('$leadingBox ${validator.title} (${result.statusInfo})',
hangingIndent: result.leadingBox.length + 1);
} else {
- printStatus('$leadingBox ${validator.title}',
+ globals.printStatus('$leadingBox ${validator.title}',
hangingIndent: result.leadingBox.length + 1);
}
@@ -298,7 +297,7 @@
int indent = 4;
final String indicator = showColor ? message.coloredIndicator : message.indicator;
for (String line in '$indicator ${message.message}'.split('\n')) {
- printStatus(line, hangingIndent: hangingIndent, indent: indent, emphasis: true);
+ globals.printStatus(line, hangingIndent: hangingIndent, indent: indent, emphasis: true);
// Only do hanging indent for the first line.
hangingIndent = 0;
indent = 6;
@@ -306,19 +305,21 @@
}
}
if (verbose) {
- printStatus('');
+ globals.printStatus('');
}
}
// Make sure there's always one line before the summary even when not verbose.
if (!verbose) {
- printStatus('');
+ globals.printStatus('');
}
if (issues > 0) {
- printStatus('${showColor ? terminal.color('!', TerminalColor.yellow) : '!'} Doctor found issues in $issues categor${issues > 1 ? "ies" : "y"}.', hangingIndent: 2);
+ globals.printStatus('${showColor ? globals.terminal.color('!', TerminalColor.yellow) : '!'}'
+ ' Doctor found issues in $issues categor${issues > 1 ? "ies" : "y"}.', hangingIndent: 2);
} else {
- printStatus('${showColor ? terminal.color('•', TerminalColor.green) : '•'} No issues found!', hangingIndent: 2);
+ globals.printStatus('${showColor ? globals.terminal.color('•', TerminalColor.green) : '•'}'
+ ' No issues found!', hangingIndent: 2);
}
return doctorResult;
@@ -500,14 +501,14 @@
assert(type != null);
switch (type) {
case ValidationType.crash:
- return terminal.color(leadingBox, TerminalColor.red);
+ return globals.terminal.color(leadingBox, TerminalColor.red);
case ValidationType.missing:
- return terminal.color(leadingBox, TerminalColor.red);
+ return globals.terminal.color(leadingBox, TerminalColor.red);
case ValidationType.installed:
- return terminal.color(leadingBox, TerminalColor.green);
+ return globals.terminal.color(leadingBox, TerminalColor.green);
case ValidationType.notAvailable:
case ValidationType.partial:
- return terminal.color(leadingBox, TerminalColor.yellow);
+ return globals.terminal.color(leadingBox, TerminalColor.yellow);
}
return null;
}
@@ -556,11 +557,11 @@
String get coloredIndicator {
switch (type) {
case ValidationMessageType.error:
- return terminal.color(indicator, TerminalColor.red);
+ return globals.terminal.color(indicator, TerminalColor.red);
case ValidationMessageType.hint:
- return terminal.color(indicator, TerminalColor.yellow);
+ return globals.terminal.color(indicator, TerminalColor.yellow);
case ValidationMessageType.information:
- return terminal.color(indicator, TerminalColor.green);
+ return globals.terminal.color(indicator, TerminalColor.green);
}
return null;
}
@@ -613,13 +614,13 @@
}
final String genSnapshotPath =
- artifacts.getArtifactPath(Artifact.genSnapshot);
+ globals.artifacts.getArtifactPath(Artifact.genSnapshot);
// Check that the binaries we downloaded for this platform actually run on it.
if (!_genSnapshotRuns(genSnapshotPath)) {
final StringBuffer buf = StringBuffer();
buf.writeln(userMessages.flutterBinariesDoNotRun);
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
buf.writeln(userMessages.flutterBinariesLinuxRepairCommands);
}
messages.add(ValidationMessage.error(buf.toString()));
@@ -627,7 +628,8 @@
}
return ValidationResult(valid, messages,
- statusInfo: userMessages.flutterStatusInfo(versionChannel, frameworkVersion, os.name, platform.localeName),
+ statusInfo: userMessages.flutterStatusInfo(
+ versionChannel, frameworkVersion, os.name, globals.platform.localeName),
);
}
}
@@ -668,10 +670,10 @@
static final Version kMinIdeaVersion = Version(2017, 1, 0);
static Iterable<DoctorValidator> get installedValidators {
- if (platform.isLinux || platform.isWindows) {
+ if (globals.platform.isLinux || globals.platform.isWindows) {
return IntelliJValidatorOnLinuxAndWindows.installed;
}
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
return IntelliJValidatorOnMac.installed;
}
return <DoctorValidator>[];
@@ -751,20 +753,20 @@
validators.add(validator);
}
- for (FileSystemEntity dir in fs.directory(homeDirPath).listSync()) {
+ for (FileSystemEntity dir in globals.fs.directory(homeDirPath).listSync()) {
if (dir is Directory) {
- final String name = fs.path.basename(dir.path);
+ final String name = globals.fs.path.basename(dir.path);
IntelliJValidator._idToTitle.forEach((String id, String title) {
if (name.startsWith('.$id')) {
final String version = name.substring(id.length + 1);
String installPath;
try {
- installPath = fs.file(fs.path.join(dir.path, 'system', '.home')).readAsStringSync();
+ installPath = globals.fs.file(globals.fs.path.join(dir.path, 'system', '.home')).readAsStringSync();
} catch (e) {
// ignored
}
- if (installPath != null && fs.isDirectorySync(installPath)) {
- final String pluginsPath = fs.path.join(dir.path, 'config', 'plugins');
+ if (installPath != null && globals.fs.isDirectorySync(installPath)) {
+ final String pluginsPath = globals.fs.path.join(dir.path, 'config', 'plugins');
addValidator(title, version, installPath, pluginsPath);
}
}
@@ -788,10 +790,10 @@
static Iterable<DoctorValidator> get installed {
final List<DoctorValidator> validators = <DoctorValidator>[];
- final List<String> installPaths = <String>['/Applications', fs.path.join(homeDirPath, 'Applications')];
+ final List<String> installPaths = <String>['/Applications', globals.fs.path.join(homeDirPath, 'Applications')];
void checkForIntelliJ(Directory dir) {
- final String name = fs.path.basename(dir.path);
+ final String name = globals.fs.path.basename(dir.path);
_dirNameToId.forEach((String dirName, String id) {
if (name == dirName) {
final String title = IntelliJValidator._idToTitle[id];
@@ -802,7 +804,7 @@
try {
final Iterable<Directory> installDirs = installPaths
- .map<Directory>((String installPath) => fs.directory(installPath))
+ .map<Directory>((String installPath) => globals.fs.directory(installPath))
.map<List<FileSystemEntity>>((Directory dir) => dir.existsSync() ? dir.listSync() : <FileSystemEntity>[])
.expand<FileSystemEntity>((List<FileSystemEntity> mappedDirs) => mappedDirs)
.whereType<Directory>();
@@ -830,7 +832,7 @@
@override
String get version {
if (_version == null) {
- final String plistFile = fs.path.join(installPath, 'Contents', 'Info.plist');
+ final String plistFile = globals.fs.path.join(installPath, 'Contents', 'Info.plist');
_version = PlistParser.instance.getValueFromFile(
plistFile,
PlistParser.kCFBundleShortVersionStringKey,
@@ -845,7 +847,7 @@
final List<String> split = version.split('.');
final String major = split[0];
final String minor = split[1];
- return fs.path.join(homeDirPath, 'Library', 'Application Support', '$id$major.$minor');
+ return globals.fs.path.join(homeDirPath, 'Library', 'Application Support', '$id$major.$minor');
}
}
diff --git a/packages/flutter_tools/lib/src/emulator.dart b/packages/flutter_tools/lib/src/emulator.dart
index 49fec92..d29f281 100644
--- a/packages/flutter_tools/lib/src/emulator.dart
+++ b/packages/flutter_tools/lib/src/emulator.dart
@@ -10,7 +10,7 @@
import 'base/context.dart';
import 'base/process.dart';
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'ios/ios_emulators.dart';
EmulatorManager get emulatorManager => context.get<EmulatorManager>();
@@ -280,7 +280,7 @@
}
static void printEmulators(List<Emulator> emulators) {
- descriptions(emulators).forEach(printStatus);
+ descriptions(emulators).forEach(globals.printStatus);
}
}
diff --git a/packages/flutter_tools/lib/src/features.dart b/packages/flutter_tools/lib/src/features.dart
index e2b3de0..0f5b038 100644
--- a/packages/flutter_tools/lib/src/features.dart
+++ b/packages/flutter_tools/lib/src/features.dart
@@ -4,9 +4,8 @@
import 'package:meta/meta.dart';
-import 'base/config.dart';
import 'base/context.dart';
-import 'base/platform.dart';
+import 'globals.dart' as globals;
import 'version.dart';
/// The current [FeatureFlags] implementation.
@@ -53,13 +52,13 @@
}
bool isEnabled = featureSetting.enabledByDefault;
if (feature.configSetting != null) {
- final bool configOverride = Config.instance.getValue(feature.configSetting) as bool;
+ final bool configOverride = globals.config.getValue(feature.configSetting) as bool;
if (configOverride != null) {
isEnabled = configOverride;
}
}
if (feature.environmentOverride != null) {
- if (platform.environment[feature.environmentOverride]?.toLowerCase() == 'true') {
+ if (globals.platform.environment[feature.environmentOverride]?.toLowerCase() == 'true') {
isEnabled = true;
}
}
diff --git a/packages/flutter_tools/lib/src/flutter_manifest.dart b/packages/flutter_tools/lib/src/flutter_manifest.dart
index ab2c280..f3351a3 100644
--- a/packages/flutter_tools/lib/src/flutter_manifest.dart
+++ b/packages/flutter_tools/lib/src/flutter_manifest.dart
@@ -10,7 +10,7 @@
import 'base/user_messages.dart';
import 'base/utils.dart';
import 'cache.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'plugins.dart';
/// A wrapper around the `flutter` section in the `pubspec.yaml` file.
@@ -27,10 +27,10 @@
/// Returns null on invalid manifest. Returns empty manifest on missing file.
static FlutterManifest createFromPath(String path) {
- if (path == null || !fs.isFileSync(path)) {
+ if (path == null || !globals.fs.isFileSync(path)) {
return _createFromYaml(null);
}
- final String manifest = fs.file(path).readAsStringSync();
+ final String manifest = globals.fs.file(path).readAsStringSync();
return createFromString(manifest);
}
@@ -91,7 +91,7 @@
version = Version.parse(verStr);
} on Exception {
if (!_hasShowInvalidVersionMsg) {
- printStatus(userMessages.invalidVersionSettingHintMessage(verStr), emphasis: true);
+ globals.printStatus(userMessages.invalidVersionSettingHintMessage(verStr), emphasis: true);
_hasShowInvalidVersionMsg = true;
}
}
@@ -199,14 +199,14 @@
final List<Uri> results = <Uri>[];
for (Object asset in assets) {
if (asset is! String || asset == null || asset == '') {
- printError('Asset manifest contains a null or empty uri.');
+ globals.printError('Asset manifest contains a null or empty uri.');
continue;
}
final String stringAsset = asset as String;
try {
results.add(Uri.parse(Uri.encodeFull(stringAsset)));
} on FormatException {
- printError('Asset manifest contains invalid uri: $asset.');
+ globals.printError('Asset manifest contains invalid uri: $asset.');
}
}
return results;
@@ -229,11 +229,11 @@
final YamlList fontFiles = fontFamily['fonts'] as YamlList;
final String familyName = fontFamily['family'] as String;
if (familyName == null) {
- printError('Warning: Missing family name for font.', emphasis: true);
+ globals.printError('Warning: Missing family name for font.', emphasis: true);
continue;
}
if (fontFiles == null) {
- printError('Warning: No fonts specified for font $familyName', emphasis: true);
+ globals.printError('Warning: No fonts specified for font $familyName', emphasis: true);
continue;
}
@@ -241,7 +241,7 @@
for (Map<dynamic, dynamic> fontFile in fontFiles.cast<Map<dynamic, dynamic>>()) {
final String asset = fontFile['asset'] as String;
if (asset == null) {
- printError('Warning: Missing asset in fonts for $familyName', emphasis: true);
+ globals.printError('Warning: Missing asset in fonts for $familyName', emphasis: true);
continue;
}
@@ -307,14 +307,14 @@
@visibleForTesting
String buildSchemaDir(FileSystem fs) {
- return fs.path.join(
- fs.path.absolute(Cache.flutterRoot), 'packages', 'flutter_tools', 'schema',
+ return globals.fs.path.join(
+ globals.fs.path.absolute(Cache.flutterRoot), 'packages', 'flutter_tools', 'schema',
);
}
@visibleForTesting
String buildSchemaPath(FileSystem fs) {
- return fs.path.join(
+ return globals.fs.path.join(
buildSchemaDir(fs),
'pubspec_yaml.json',
);
@@ -352,8 +352,8 @@
}
if (errors.isNotEmpty) {
- printStatus('Error detected in pubspec.yaml:', emphasis: true);
- printError(errors.join('\n'));
+ globals.printStatus('Error detected in pubspec.yaml:', emphasis: true);
+ globals.printError(errors.join('\n'));
return false;
}
diff --git a/packages/flutter_tools/lib/src/fuchsia/application_package.dart b/packages/flutter_tools/lib/src/fuchsia/application_package.dart
index f7571b2..4626cc0 100644
--- a/packages/flutter_tools/lib/src/fuchsia/application_package.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/application_package.dart
@@ -7,7 +7,7 @@
import '../application_package.dart';
import '../base/file_system.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
abstract class FuchsiaApp extends ApplicationPackage {
@@ -29,9 +29,9 @@
///
/// [applicationBinary] is the path to the .far archive.
factory FuchsiaApp.fromPrebuiltApp(FileSystemEntity applicationBinary) {
- final FileSystemEntityType entityType = fs.typeSync(applicationBinary.path);
+ final FileSystemEntityType entityType = globals.fs.typeSync(applicationBinary.path);
if (entityType != FileSystemEntityType.file) {
- printError('File "${applicationBinary.path}" does not exist or is not a .far file. Use far archive.');
+ globals.printError('File "${applicationBinary.path}" does not exist or is not a .far file. Use far archive.');
return null;
}
return PrebuiltFuchsiaApp(
@@ -56,7 +56,7 @@
final String _farArchive;
@override
- File farArchive(BuildMode buildMode) => fs.file(_farArchive);
+ File farArchive(BuildMode buildMode) => globals.fs.file(_farArchive);
@override
String get name => _farArchive;
@@ -72,9 +72,9 @@
File farArchive(BuildMode buildMode) {
// TODO(zra): Distinguish among build modes.
final String outDir = getFuchsiaBuildDirectory();
- final String pkgDir = fs.path.join(outDir, 'pkg');
+ final String pkgDir = globals.fs.path.join(outDir, 'pkg');
final String appName = project.project.manifest.appName;
- return fs.file(fs.path.join(pkgDir, '$appName-0.far'));
+ return globals.fs.file(globals.fs.path.join(pkgDir, '$appName-0.far'));
}
@override
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
index 3e8f6f0..24f1419 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
@@ -18,7 +18,7 @@
import '../bundle.dart';
import '../convert.dart';
import '../devfs.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
@@ -28,14 +28,14 @@
Future<void> _timedBuildStep(String name, Future<void> Function() action) async {
final Stopwatch sw = Stopwatch()..start();
await action();
- printTrace('$name: ${sw.elapsedMilliseconds} ms.');
+ globals.printTrace('$name: ${sw.elapsedMilliseconds} ms.');
flutterUsage.sendTiming('build', name, Duration(milliseconds: sw.elapsedMilliseconds));
}
Future<void> _validateCmxFile(FuchsiaProject fuchsiaProject) async {
final String appName = fuchsiaProject.project.manifest.appName;
- final String cmxPath = fs.path.join(fuchsiaProject.meta.path, '$appName.cmx');
- final File cmxFile = fs.file(cmxPath);
+ final String cmxPath = globals.fs.path.join(fuchsiaProject.meta.path, '$appName.cmx');
+ final File cmxFile = globals.fs.file(cmxPath);
if (!await cmxFile.exists()) {
throwToolExit('The Fuchsia build requires a .cmx file at $cmxPath for the app: $appName.');
}
@@ -55,7 +55,7 @@
String runnerPackageSource = FuchsiaPackageServer.toolHost,
}) async {
await _validateCmxFile(fuchsiaProject);
- final Directory outDir = fs.directory(getFuchsiaBuildDirectory());
+ final Directory outDir = globals.fs.directory(getFuchsiaBuildDirectory());
if (!outDir.existsSync()) {
outDir.createSync(recursive: true);
}
@@ -83,14 +83,14 @@
) async {
final String outDir = getFuchsiaBuildDirectory();
final String appName = fuchsiaProject.project.manifest.appName;
- final String dilPath = fs.path.join(outDir, '$appName.dil');
+ final String dilPath = globals.fs.path.join(outDir, '$appName.dil');
- final String vmSnapshotData = fs.path.join(outDir, 'vm_data.aotsnapshot');
- final String vmSnapshotInstructions = fs.path.join(outDir, 'vm_instructions.aotsnapshot');
- final String snapshotData = fs.path.join(outDir, 'data.aotsnapshot');
- final String snapshotInstructions = fs.path.join(outDir, 'instructions.aotsnapshot');
+ final String vmSnapshotData = globals.fs.path.join(outDir, 'vm_data.aotsnapshot');
+ final String vmSnapshotInstructions = globals.fs.path.join(outDir, 'vm_instructions.aotsnapshot');
+ final String snapshotData = globals.fs.path.join(outDir, 'data.aotsnapshot');
+ final String snapshotInstructions = globals.fs.path.join(outDir, 'instructions.aotsnapshot');
- final String genSnapshot = artifacts.getArtifactPath(
+ final String genSnapshot = globals.artifacts.getArtifactPath(
Artifact.genSnapshot,
platform: targetPlatform,
mode: buildInfo.mode,
@@ -109,7 +109,7 @@
dilPath,
];
int result;
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Compiling Fuchsia application to native code...',
timeout: null,
);
@@ -138,13 +138,13 @@
final Map<String, DevFSContent> assetEntries =
Map<String, DevFSContent>.from(assets.entries);
- await writeBundle(fs.directory(assetDir), assetEntries);
+ await writeBundle(globals.fs.directory(assetDir), assetEntries);
final String appName = fuchsiaProject.project.manifest.appName;
final String outDir = getFuchsiaBuildDirectory();
- final String assetManifest = fs.path.join(outDir, '${appName}_pkgassets');
+ final String assetManifest = globals.fs.path.join(outDir, '${appName}_pkgassets');
- final File destFile = fs.file(assetManifest);
+ final File destFile = globals.fs.file(assetManifest);
await destFile.create(recursive: true);
final IOSink outFile = destFile.openWrite();
@@ -193,29 +193,29 @@
String runnerPackageSource,
) async {
final String outDir = getFuchsiaBuildDirectory();
- final String pkgDir = fs.path.join(outDir, 'pkg');
+ final String pkgDir = globals.fs.path.join(outDir, 'pkg');
final String appName = fuchsiaProject.project.manifest.appName;
- final String pkgassets = fs.path.join(outDir, '${appName}_pkgassets');
- final String packageManifest = fs.path.join(pkgDir, 'package_manifest');
- final String devKeyPath = fs.path.join(pkgDir, 'development.key');
+ final String pkgassets = globals.fs.path.join(outDir, '${appName}_pkgassets');
+ final String packageManifest = globals.fs.path.join(pkgDir, 'package_manifest');
+ final String devKeyPath = globals.fs.path.join(pkgDir, 'development.key');
- final Directory pkg = fs.directory(pkgDir);
+ final Directory pkg = globals.fs.directory(pkgDir);
if (!pkg.existsSync()) {
pkg.createSync(recursive: true);
}
final File srcCmx =
- fs.file(fs.path.join(fuchsiaProject.meta.path, '$appName.cmx'));
- final File dstCmx = fs.file(fs.path.join(outDir, '$appName.cmx'));
+ globals.fs.file(globals.fs.path.join(fuchsiaProject.meta.path, '$appName.cmx'));
+ final File dstCmx = globals.fs.file(globals.fs.path.join(outDir, '$appName.cmx'));
_rewriteCmx(buildInfo.mode, runnerPackageSource, srcCmx, dstCmx);
- final File manifestFile = fs.file(packageManifest);
+ final File manifestFile = globals.fs.file(packageManifest);
if (buildInfo.usesAot) {
- final String vmSnapshotData = fs.path.join(outDir, 'vm_data.aotsnapshot');
- final String vmSnapshotInstructions = fs.path.join(outDir, 'vm_instructions.aotsnapshot');
- final String snapshotData = fs.path.join(outDir, 'data.aotsnapshot');
- final String snapshotInstructions = fs.path.join(outDir, 'instructions.aotsnapshot');
+ final String vmSnapshotData = globals.fs.path.join(outDir, 'vm_data.aotsnapshot');
+ final String vmSnapshotInstructions = globals.fs.path.join(outDir, 'vm_instructions.aotsnapshot');
+ final String snapshotData = globals.fs.path.join(outDir, 'data.aotsnapshot');
+ final String snapshotInstructions = globals.fs.path.join(outDir, 'instructions.aotsnapshot');
manifestFile.writeAsStringSync(
'data/$appName/vm_snapshot_data.bin=$vmSnapshotData\n');
manifestFile.writeAsStringSync(
@@ -228,11 +228,11 @@
'data/$appName/isolate_snapshot_instructions.bin=$snapshotInstructions\n',
mode: FileMode.append);
} else {
- final String dilpmanifest = fs.path.join(outDir, '$appName.dilpmanifest');
- manifestFile.writeAsStringSync(fs.file(dilpmanifest).readAsStringSync());
+ final String dilpmanifest = globals.fs.path.join(outDir, '$appName.dilpmanifest');
+ manifestFile.writeAsStringSync(globals.fs.file(dilpmanifest).readAsStringSync());
}
- manifestFile.writeAsStringSync(fs.file(pkgassets).readAsStringSync(),
+ manifestFile.writeAsStringSync(globals.fs.file(pkgassets).readAsStringSync(),
mode: FileMode.append);
manifestFile.writeAsStringSync('meta/$appName.cmx=${dstCmx.path}\n',
mode: FileMode.append);
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart
index 292edf8..0c1e825 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart
@@ -4,7 +4,7 @@
import '../base/common.dart';
import '../base/process.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'fuchsia_sdk.dart';
// Usage: dev_finder <flags> <subcommand> <subcommand args>
@@ -34,7 +34,7 @@
];
final RunResult result = await processUtils.run(command);
if (result.exitCode != 0) {
- printError('dev_finder failed: ${result.stderr}');
+ globals.printError('dev_finder failed: ${result.stderr}');
return null;
}
return result.stdout.split('\n');
@@ -61,7 +61,7 @@
];
final RunResult result = await processUtils.run(command);
if (result.exitCode != 0) {
- printError('dev_finder failed: ${result.stderr}');
+ globals.printError('dev_finder failed: ${result.stderr}');
return null;
}
return result.stdout.trim();
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
index 204bdde..5ae5a89 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
@@ -14,13 +14,11 @@
import '../base/io.dart';
import '../base/logger.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/time.dart';
import '../build_info.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../vmservice.dart';
@@ -141,7 +139,7 @@
FuchsiaDevices() : super('Fuchsia devices');
@override
- bool get supportsPlatform => platform.isLinux || platform.isMacOS;
+ bool get supportsPlatform => globals.platform.isLinux || globals.platform.isMacOS;
@override
bool get canListAnything => fuchsiaWorkflow.canListDevices;
@@ -248,32 +246,32 @@
local: true,
);
if (host == null) {
- printError('Failed to resolve host for Fuchsia device');
+ globals.printError('Failed to resolve host for Fuchsia device');
return LaunchResult.failed();
}
final int port = await os.findFreePort();
if (port == 0) {
- printError('Failed to find a free port');
+ globals.printError('Failed to find a free port');
return LaunchResult.failed();
}
// Try Start with a fresh package repo in case one was left over from a
// previous run.
final Directory packageRepo =
- fs.directory(fs.path.join(getFuchsiaBuildDirectory(), '.pkg-repo'));
+ globals.fs.directory(globals.fs.path.join(getFuchsiaBuildDirectory(), '.pkg-repo'));
try {
if (packageRepo.existsSync()) {
packageRepo.deleteSync(recursive: true);
}
packageRepo.createSync(recursive: true);
} catch (e) {
- printError('Failed to create Fuchisa package repo directory '
+ globals.printError('Failed to create Fuchisa package repo directory '
'at ${packageRepo.path}: $e');
return LaunchResult.failed();
}
final String appName = FlutterProject.current().manifest.appName;
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Starting Fuchsia application $appName...',
timeout: null,
);
@@ -284,11 +282,11 @@
// package server. This is to avoid relying on amber correctly using
// multiple package servers, support for which is in flux.
if (!await fuchsiaDeviceTools.amberCtl.getUp(this, 'tiles')) {
- printError('Failed to get amber to prefetch tiles');
+ globals.printError('Failed to get amber to prefetch tiles');
return LaunchResult.failed();
}
if (!await fuchsiaDeviceTools.amberCtl.getUp(this, 'tiles_ctl')) {
- printError('Failed to get amber to prefetch tiles_ctl');
+ globals.printError('Failed to get amber to prefetch tiles_ctl');
return LaunchResult.failed();
}
@@ -297,7 +295,7 @@
fuchsiaPackageServer = FuchsiaPackageServer(
packageRepo.path, packageServerName, host, port);
if (!await fuchsiaPackageServer.start()) {
- printError('Failed to start the Fuchsia package server');
+ globals.printError('Failed to start the Fuchsia package server');
return LaunchResult.failed();
}
@@ -305,24 +303,24 @@
final File farArchive = package.farArchive(
debuggingOptions.buildInfo.mode);
if (!await fuchsiaPackageServer.addPackage(farArchive)) {
- printError('Failed to add package to the package server');
+ globals.printError('Failed to add package to the package server');
return LaunchResult.failed();
}
// Serve the flutter_runner.
- final File flutterRunnerArchive = fs.file(artifacts.getArtifactPath(
+ final File flutterRunnerArchive = globals.fs.file(globals.artifacts.getArtifactPath(
Artifact.fuchsiaFlutterRunner,
platform: await targetPlatform,
mode: debuggingOptions.buildInfo.mode,
));
if (!await fuchsiaPackageServer.addPackage(flutterRunnerArchive)) {
- printError('Failed to add flutter_runner package to the package server');
+ globals.printError('Failed to add flutter_runner package to the package server');
return LaunchResult.failed();
}
// Teach the package controller about the package server.
if (!await fuchsiaDeviceTools.amberCtl.addRepoCfg(this, fuchsiaPackageServer)) {
- printError('Failed to teach amber about the package server');
+ globals.printError('Failed to teach amber about the package server');
return LaunchResult.failed();
}
serverRegistered = true;
@@ -344,27 +342,27 @@
}
if (!await fuchsiaDeviceTools.amberCtl.pkgCtlResolve(
this, fuchsiaPackageServer, flutterRunnerName)) {
- printError('Failed to get pkgctl to prefetch the flutter_runner');
+ globals.printError('Failed to get pkgctl to prefetch the flutter_runner');
return LaunchResult.failed();
}
// Tell the package controller to prefetch the app.
if (!await fuchsiaDeviceTools.amberCtl.pkgCtlResolve(
this, fuchsiaPackageServer, appName)) {
- printError('Failed to get pkgctl to prefetch the package');
+ globals.printError('Failed to get pkgctl to prefetch the package');
return LaunchResult.failed();
}
// Ensure tiles_ctl is started, and start the app.
if (!await FuchsiaTilesCtl.ensureStarted(this)) {
- printError('Failed to ensure that tiles is started on the device');
+ globals.printError('Failed to ensure that tiles is started on the device');
return LaunchResult.failed();
}
// Instruct tiles_ctl to start the app.
final String fuchsiaUrl = 'fuchsia-pkg://$packageServerName/$appName#meta/$appName.cmx';
if (!await fuchsiaDeviceTools.tilesCtl.add(this, fuchsiaUrl, <String>[])) {
- printError('Failed to add the app to tiles');
+ globals.printError('Failed to add the app to tiles');
return LaunchResult.failed();
}
} finally {
@@ -374,23 +372,23 @@
await fuchsiaDeviceTools.amberCtl.pkgCtlRepoRemove(this, fuchsiaPackageServer);
}
// Shutdown the package server and delete the package repo;
- printTrace('Shutting down the tool\'s package server.');
+ globals.printTrace('Shutting down the tool\'s package server.');
fuchsiaPackageServer?.stop();
- printTrace('Removing the tool\'s package repo: at ${packageRepo.path}');
+ globals.printTrace('Removing the tool\'s package repo: at ${packageRepo.path}');
try {
packageRepo.deleteSync(recursive: true);
} catch (e) {
- printError('Failed to remove Fuchsia package repo directory '
+ globals.printError('Failed to remove Fuchsia package repo directory '
'at ${packageRepo.path}: $e.');
}
status.cancel();
}
if (debuggingOptions.buildInfo.mode.isRelease) {
- printTrace('App succesfully started in a release mode.');
+ globals.printTrace('App succesfully started in a release mode.');
return LaunchResult.succeeded();
}
- printTrace('App started in a non-release mode. Setting up vmservice connection.');
+ globals.printTrace('App started in a non-release mode. Setting up vmservice connection.');
// In a debug or profile build, try to find the observatory uri.
final FuchsiaIsolateDiscoveryProtocol discovery =
@@ -408,7 +406,7 @@
final int appKey = await FuchsiaTilesCtl.findAppKey(this, app.id);
if (appKey != -1) {
if (!await fuchsiaDeviceTools.tilesCtl.remove(this, appKey)) {
- printError('tiles_ctl remove on ${app.id} failed.');
+ globals.printError('tiles_ctl remove on ${app.id} failed.');
return false;
}
}
@@ -420,7 +418,7 @@
Future<TargetPlatform> _queryTargetPlatform() async {
final RunResult result = await shell('uname -m');
if (result.exitCode != 0) {
- printError('Could not determine Fuchsia target platform type:\n$result\n'
+ globals.printError('Could not determine Fuchsia target platform type:\n$result\n'
'Defaulting to arm64.');
return TargetPlatform.fuchsia_arm64;
}
@@ -431,7 +429,7 @@
case 'x86_64':
return TargetPlatform.fuchsia_x64;
default:
- printError('Unknown Fuchsia target platform "$machine". '
+ globals.printError('Unknown Fuchsia target platform "$machine". '
'Defaulting to arm64.');
return TargetPlatform.fuchsia_arm64;
}
@@ -445,12 +443,12 @@
const String versionPath = '/pkgfs/packages/build-info/0/data/version';
final RunResult catResult = await shell('cat $versionPath');
if (catResult.exitCode != 0) {
- printTrace('Failed to cat $versionPath: ${catResult.stderr}');
+ globals.printTrace('Failed to cat $versionPath: ${catResult.stderr}');
return 'Fuchsia';
}
final String version = catResult.stdout.trim();
if (version.isEmpty) {
- printTrace('$versionPath was empty');
+ globals.printTrace('$versionPath was empty');
return 'Fuchsia';
}
return 'Fuchsia $version';
@@ -579,7 +577,7 @@
}
}
} on SocketException catch (err) {
- printTrace('Failed to connect to $port: $err');
+ globals.printTrace('Failed to connect to $port: $err');
}
}
throwToolExit('No ports found running $isolateName');
@@ -624,7 +622,7 @@
if (_uri != null) {
return _uri;
}
- _status ??= logger.startProgress(
+ _status ??= globals.logger.startProgress(
'Waiting for a connection from $_isolateName on ${_device.name}...',
timeout: null, // could take an arbitrary amount of time
);
@@ -660,7 +658,7 @@
service = await _vmServiceConnector(uri);
_ports[port] = service;
} on SocketException catch (err) {
- printTrace('Failed to connect to $localPort: $err');
+ globals.printTrace('Failed to connect to $localPort: $err');
continue;
}
}
@@ -716,7 +714,7 @@
await device._resolvedIp,
'true',
];
- final Process process = await processManager.start(command);
+ final Process process = await globals.processManager.start(command);
unawaited(process.exitCode.then((int exitCode) {
if (exitCode != 0) {
throwToolExit('Failed to forward port:$devicePort');
@@ -747,7 +745,7 @@
'${forwardedPort.hostPort}:$_ipv4Loopback:${forwardedPort.devicePort}',
await device._resolvedIp,
];
- final ProcessResult result = await processManager.run(command);
+ final ProcessResult result = await globals.processManager.run(command);
if (result.exitCode != 0) {
throwToolExit('Unforward command failed: $result');
}
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart
index dfa7f77..8e76ec0 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart
@@ -6,11 +6,10 @@
import '../artifacts.dart';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
/// This is a simple wrapper around the custom kernel compiler from the Fuchsia
@@ -31,22 +30,22 @@
final String outDir = getFuchsiaBuildDirectory();
final String appName = fuchsiaProject.project.manifest.appName;
final String fsRoot = fuchsiaProject.project.directory.path;
- final String relativePackagesFile = fs.path.relative(packagesFile, from: fsRoot);
- final String manifestPath = fs.path.join(outDir, '$appName.dilpmanifest');
- final String kernelCompiler = artifacts.getArtifactPath(
+ final String relativePackagesFile = globals.fs.path.relative(packagesFile, from: fsRoot);
+ final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest');
+ final String kernelCompiler = globals.artifacts.getArtifactPath(
Artifact.fuchsiaKernelCompiler,
platform: TargetPlatform.fuchsia_arm64, // This file is not arch-specific.
mode: buildInfo.mode,
);
- if (!fs.isFileSync(kernelCompiler)) {
+ if (!globals.fs.isFileSync(kernelCompiler)) {
throwToolExit('Fuchisa kernel compiler not found at "$kernelCompiler"');
}
- final String platformDill = artifacts.getArtifactPath(
+ final String platformDill = globals.artifacts.getArtifactPath(
Artifact.platformKernelDill,
platform: TargetPlatform.fuchsia_arm64, // This file is not arch-specific.
mode: buildInfo.mode,
);
- if (!fs.isFileSync(platformDill)) {
+ if (!globals.fs.isFileSync(platformDill)) {
throwToolExit('Fuchisa platform file not found at "$platformDill"');
}
List<String> flags = <String>[
@@ -55,7 +54,7 @@
'--filesystem-scheme', 'main-root',
'--filesystem-root', fsRoot,
'--packages', '$multiRootScheme:///$relativePackagesFile',
- '--output', fs.path.join(outDir, '$appName.dil'),
+ '--output', globals.fs.path.join(outDir, '$appName.dil'),
'--component-name', appName,
// AOT/JIT:
@@ -85,11 +84,11 @@
];
final List<String> command = <String>[
- artifacts.getArtifactPath(Artifact.engineDartBinary),
+ globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
kernelCompiler,
...flags,
];
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Building Fuchsia application...',
timeout: null,
);
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
index 0a18b4b..9400470 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
@@ -7,7 +7,7 @@
import '../base/io.dart';
import '../base/process.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'fuchsia_sdk.dart';
@@ -121,11 +121,11 @@
process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
- .listen(printTrace);
+ .listen(globals.printTrace);
process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
- .listen(printError);
+ .listen(globals.printError);
return process;
}
@@ -200,12 +200,12 @@
/// be spawned, and true otherwise.
Future<bool> start() async {
if (_process != null) {
- printError('$this already started!');
+ globals.printError('$this already started!');
return false;
}
// initialize a new repo.
if (!await fuchsiaSdk.fuchsiaPM.newrepo(_repo)) {
- printError('Failed to create a new package server repo');
+ globals.printError('Failed to create a new package server repo');
return false;
}
_process = await fuchsiaSdk.fuchsiaPM.serve(_repo, _host, _port);
@@ -213,7 +213,7 @@
unawaited(_process.exitCode.whenComplete(() {
// If _process is null, then the server was stopped deliberately.
if (_process != null) {
- printError('Error running Fuchsia pm tool "serve" command');
+ globals.printError('Error running Fuchsia pm tool "serve" command');
}
}));
return true;
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
index f916660..ba91b5f 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
@@ -7,11 +7,8 @@
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
-import '../cache.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'fuchsia_dev_finder.dart';
import 'fuchsia_kernel_compiler.dart';
@@ -66,8 +63,8 @@
});
if (fuchsiaArtifacts.sshConfig == null ||
!fuchsiaArtifacts.sshConfig.existsSync()) {
- printError('Cannot read device logs: No ssh config.');
- printError('Have you set FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR?');
+ globals.printError('Cannot read device logs: No ssh config.');
+ globals.printError('Have you set FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR?');
return null;
}
const String remoteCommand = 'log_listener --clock Local';
@@ -78,7 +75,7 @@
id,
remoteCommand,
];
- processManager.start(cmd).then((Process newProcess) {
+ globals.processManager.start(cmd).then((Process newProcess) {
if (controller.isClosed) {
return;
}
@@ -90,7 +87,7 @@
});
return controller.stream;
} catch (exception) {
- printTrace('$exception');
+ globals.printTrace('$exception');
}
return const Stream<String>.empty();
}
@@ -112,7 +109,7 @@
/// FUCHSIA_SSH_CONFIG) to find the ssh configuration needed to talk to
/// a device.
factory FuchsiaArtifacts.find() {
- if (!platform.isLinux && !platform.isMacOS) {
+ if (!globals.platform.isLinux && !globals.platform.isMacOS) {
// Don't try to find the artifacts on platforms that are not supported.
return FuchsiaArtifacts();
}
@@ -120,17 +117,17 @@
// relative to it. Next, if FUCHSIA_SSH_CONFIG is defined, then use it.
// TODO(zra): Consider passing the ssh config path in with a flag.
File sshConfig;
- if (platform.environment.containsKey(_kFuchsiaBuildDir)) {
- sshConfig = fs.file(fs.path.join(
- platform.environment[_kFuchsiaBuildDir], 'ssh-keys', 'ssh_config'));
- } else if (platform.environment.containsKey(_kFuchsiaSshConfig)) {
- sshConfig = fs.file(platform.environment[_kFuchsiaSshConfig]);
+ if (globals.platform.environment.containsKey(_kFuchsiaBuildDir)) {
+ sshConfig = globals.fs.file(globals.fs.path.join(
+ globals.platform.environment[_kFuchsiaBuildDir], 'ssh-keys', 'ssh_config'));
+ } else if (globals.platform.environment.containsKey(_kFuchsiaSshConfig)) {
+ sshConfig = globals.fs.file(globals.platform.environment[_kFuchsiaSshConfig]);
}
- final String fuchsia = Cache.instance.getArtifactDirectory('fuchsia').path;
- final String tools = fs.path.join(fuchsia, 'tools');
- final File devFinder = fs.file(fs.path.join(tools, 'dev_finder'));
- final File pm = fs.file(fs.path.join(tools, 'pm'));
+ final String fuchsia = globals.cache.getArtifactDirectory('fuchsia').path;
+ final String tools = globals.fs.path.join(fuchsia, 'tools');
+ final File devFinder = globals.fs.file(globals.fs.path.join(tools, 'dev_finder'));
+ final File pm = globals.fs.file(globals.fs.path.join(tools, 'pm'));
return FuchsiaArtifacts(
sshConfig: sshConfig,
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart
index e6759d9..61edab9 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart
@@ -3,8 +3,8 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/platform.dart';
import '../doctor.dart';
+import '../globals.dart' as globals;
import 'fuchsia_sdk.dart';
/// The [FuchsiaWorkflow] instance.
@@ -17,7 +17,7 @@
class FuchsiaWorkflow implements Workflow {
@override
- bool get appliesToHostPlatform => platform.isLinux || platform.isMacOS;
+ bool get appliesToHostPlatform => globals.platform.isLinux || globals.platform.isMacOS;
@override
bool get canListDevices {
diff --git a/packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart b/packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
index 73f9009..5357a9f 100644
--- a/packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import '../base/process.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'fuchsia_device.dart';
@@ -23,7 +23,7 @@
final FuchsiaTilesCtl tilesCtl = fuchsiaDeviceTools.tilesCtl;
final Map<int, String> runningApps = await tilesCtl.list(device);
if (runningApps == null) {
- printTrace('tiles_ctl is not running');
+ globals.printTrace('tiles_ctl is not running');
return -1;
}
for (MapEntry<int, String> entry in runningApps.entries) {
diff --git a/packages/flutter_tools/lib/src/globals.dart b/packages/flutter_tools/lib/src/globals.dart
index 51f95dc..777b844 100644
--- a/packages/flutter_tools/lib/src/globals.dart
+++ b/packages/flutter_tools/lib/src/globals.dart
@@ -2,17 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:platform/platform.dart';
+import 'package:process/process.dart';
+
import 'artifacts.dart';
import 'base/config.dart';
import 'base/context.dart';
+import 'base/error_handling_file_system.dart';
+import 'base/file_system.dart';
import 'base/logger.dart';
import 'base/terminal.dart';
import 'cache.dart';
Logger get logger => context.get<Logger>();
-Cache get cache => Cache.instance;
-Config get config => Config.instance;
-Artifacts get artifacts => Artifacts.instance;
+Cache get cache => context.get<Cache>();
+Config get config => context.get<Config>();
+Artifacts get artifacts => context.get<Artifacts>();
+
+const FileSystem _kLocalFs = LocalFileSystem();
+
+/// Currently active implementation of the file system.
+///
+/// By default it uses local disk-based implementation. Override this in tests
+/// with [MemoryFileSystem].
+FileSystem get fs => ErrorHandlingFileSystem(
+ context.get<FileSystem>() ?? _kLocalFs,
+);
+
+
+const ProcessManager _kLocalProcessManager = LocalProcessManager();
+
+/// The active process manager.
+ProcessManager get processManager => context.get<ProcessManager>() ?? _kLocalProcessManager;
+
+const Platform _kLocalPlatform = LocalPlatform();
+
+Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
+
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
@@ -72,3 +98,9 @@
/// Use this for verbose tracing output. Users can turn this output on in order
/// to help diagnose issues with the toolchain or with their setup.
void printTrace(String message) => logger.printTrace(message);
+
+AnsiTerminal get terminal {
+ return context?.get<AnsiTerminal>() ?? _defaultAnsiTerminal;
+}
+
+final AnsiTerminal _defaultAnsiTerminal = AnsiTerminal();
diff --git a/packages/flutter_tools/lib/src/intellij/intellij.dart b/packages/flutter_tools/lib/src/intellij/intellij.dart
index 5d17917..aa2fd20 100644
--- a/packages/flutter_tools/lib/src/intellij/intellij.dart
+++ b/packages/flutter_tools/lib/src/intellij/intellij.dart
@@ -4,10 +4,10 @@
import 'package:archive/archive.dart';
-import '../base/file_system.dart';
import '../base/version.dart';
import '../convert.dart';
import '../doctor.dart';
+import '../globals.dart' as globals;
class IntelliJPlugins {
IntelliJPlugins(this.pluginsPath);
@@ -45,22 +45,22 @@
}
bool _hasPackage(String packageName) {
- final String packagePath = fs.path.join(pluginsPath, packageName);
+ final String packagePath = globals.fs.path.join(pluginsPath, packageName);
if (packageName.endsWith('.jar')) {
- return fs.isFileSync(packagePath);
+ return globals.fs.isFileSync(packagePath);
}
- return fs.isDirectorySync(packagePath);
+ return globals.fs.isDirectorySync(packagePath);
}
String _readPackageVersion(String packageName) {
final String jarPath = packageName.endsWith('.jar')
- ? fs.path.join(pluginsPath, packageName)
- : fs.path.join(pluginsPath, packageName, 'lib', '$packageName.jar');
+ ? globals.fs.path.join(pluginsPath, packageName)
+ : globals.fs.path.join(pluginsPath, packageName, 'lib', '$packageName.jar');
// TODO(danrubel): look for a better way to extract a single 2K file from the zip
// rather than reading the entire file into memory.
try {
final Archive archive =
- ZipDecoder().decodeBytes(fs.file(jarPath).readAsBytesSync());
+ ZipDecoder().decodeBytes(globals.fs.file(jarPath).readAsBytesSync());
final ArchiveFile file = archive.findFile('META-INF/plugin.xml');
final String content = utf8.decode(file.content as List<int>);
const String versionStartTag = '<version>';
diff --git a/packages/flutter_tools/lib/src/ios/bitcode.dart b/packages/flutter_tools/lib/src/ios/bitcode.dart
index 135c094..2ec0f48 100644
--- a/packages/flutter_tools/lib/src/ios/bitcode.dart
+++ b/packages/flutter_tools/lib/src/ios/bitcode.dart
@@ -5,23 +5,23 @@
import '../artifacts.dart';
import '../base/common.dart';
import '../base/context.dart';
-import '../base/file_system.dart';
import '../base/process.dart';
import '../base/version.dart';
import '../build_info.dart';
+import '../globals.dart' as globals;
import '../ios/plist_parser.dart';
import '../macos/xcode.dart';
const bool kBitcodeEnabledDefault = false;
Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform) async {
- final Artifacts artifacts = Artifacts.instance;
- final String flutterFrameworkPath = artifacts.getArtifactPath(
+ final Artifacts localArtifacts = globals.artifacts;
+ final String flutterFrameworkPath = localArtifacts.getArtifactPath(
Artifact.flutterFramework,
mode: buildMode,
platform: targetPlatform,
);
- if (!fs.isDirectorySync(flutterFrameworkPath)) {
+ if (!globals.fs.isDirectorySync(flutterFrameworkPath)) {
throwToolExit('Flutter.framework not found at $flutterFrameworkPath');
}
final Xcode xcode = context.get<Xcode>();
@@ -29,7 +29,7 @@
final RunResult clangResult = await xcode.clang(<String>['--version']);
final String clangVersion = clangResult.stdout.split('\n').first;
final String engineClangVersion = PlistParser.instance.getValueFromFile(
- fs.path.join(flutterFrameworkPath, 'Info.plist'),
+ globals.fs.path.join(flutterFrameworkPath, 'Info.plist'),
'ClangVersion',
);
final Version engineClangSemVer = _parseVersionFromClang(engineClangVersion);
diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart
index 0826400..fe375d4 100644
--- a/packages/flutter_tools/lib/src/ios/code_signing.dart
+++ b/packages/flutter_tools/lib/src/ios/code_signing.dart
@@ -10,9 +10,8 @@
import '../base/common.dart';
import '../base/io.dart';
import '../base/process.dart';
-import '../base/terminal.dart';
import '../convert.dart' show utf8;
-import '../globals.dart';
+import '../globals.dart' as globals;
/// User message when no development certificates are found in the keychain.
///
@@ -106,7 +105,7 @@
// If the user already has it set in the project build settings itself,
// continue with that.
if (isNotEmpty(buildSettings['DEVELOPMENT_TEAM'])) {
- printStatus(
+ globals.printStatus(
'Automatically signing iOS for device deployment using specified development '
'team in Xcode project: ${buildSettings['DEVELOPMENT_TEAM']}'
);
@@ -134,7 +133,7 @@
throwOnError: true,
)).stdout.trim();
} on ProcessException catch (error) {
- printTrace('Unexpected failure from find-identity: $error.');
+ globals.printTrace('Unexpected failure from find-identity: $error.');
return null;
}
@@ -156,7 +155,7 @@
return null;
}
- printStatus('Signing iOS app for device deployment using developer identity: "$signingIdentity"');
+ globals.printStatus('Signing iOS app for device deployment using developer identity: "$signingIdentity"');
final String signingCertificateId =
_securityFindIdentityCertificateCnExtractionPattern
@@ -175,7 +174,7 @@
throwOnError: true,
)).stdout.trim();
} on ProcessException catch (error) {
- printTrace('Couldn\'t find the certificate: $error.');
+ globals.printTrace('Couldn\'t find the certificate: $error.');
return null;
}
@@ -202,7 +201,7 @@
Future<String> _chooseSigningIdentity(List<String> validCodeSigningIdentities) async {
// The user has no valid code signing identities.
if (validCodeSigningIdentities.isEmpty) {
- printError(noCertificatesInstruction, emphasis: true);
+ globals.printError(noCertificatesInstruction, emphasis: true);
throwToolExit('No development certificates available to code sign app for device deployment');
}
@@ -211,34 +210,34 @@
}
if (validCodeSigningIdentities.length > 1) {
- final String savedCertChoice = config.getValue('ios-signing-cert') as String;
+ final String savedCertChoice = globals.config.getValue('ios-signing-cert') as String;
if (savedCertChoice != null) {
if (validCodeSigningIdentities.contains(savedCertChoice)) {
- printStatus('Found saved certificate choice "$savedCertChoice". To clear, use "flutter config".');
+ globals.printStatus('Found saved certificate choice "$savedCertChoice". To clear, use "flutter config".');
return savedCertChoice;
} else {
- printError('Saved signing certificate "$savedCertChoice" is not a valid development certificate');
+ globals.printError('Saved signing certificate "$savedCertChoice" is not a valid development certificate');
}
}
// If terminal UI can't be used, just attempt with the first valid certificate
// since we can't ask the user.
- if (!terminal.usesTerminalUi) {
+ if (!globals.terminal.usesTerminalUi) {
return validCodeSigningIdentities.first;
}
final int count = validCodeSigningIdentities.length;
- printStatus(
+ globals.printStatus(
'Multiple valid development certificates available (your choice will be saved):',
emphasis: true,
);
for (int i=0; i<count; i++) {
- printStatus(' ${i+1}) ${validCodeSigningIdentities[i]}', emphasis: true);
+ globals.printStatus(' ${i+1}) ${validCodeSigningIdentities[i]}', emphasis: true);
}
- printStatus(' a) Abort', emphasis: true);
+ globals.printStatus(' a) Abort', emphasis: true);
- final String choice = await terminal.promptForCharInput(
+ final String choice = await globals.terminal.promptForCharInput(
List<String>.generate(count, (int number) => '${number + 1}')
..add('a'),
prompt: 'Please select a certificate for code signing',
@@ -250,8 +249,8 @@
throwToolExit('Aborted. Code signing is required to build a deployable iOS app.');
} else {
final String selectedCert = validCodeSigningIdentities[int.parse(choice) - 1];
- printStatus('Certificate choice "$selectedCert" saved');
- config.setValue('ios-signing-cert', selectedCert);
+ globals.printStatus('Certificate choice "$selectedCert" saved');
+ globals.config.setValue('ios-signing-cert', selectedCert);
return selectedCert;
}
}
diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart
index 7361c17..5b5fd27 100644
--- a/packages/flutter_tools/lib/src/ios/devices.dart
+++ b/packages/flutter_tools/lib/src/ios/devices.dart
@@ -13,12 +13,11 @@
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../convert.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../mdns_discovery.dart';
import '../project.dart';
import '../protocol_discovery.dart';
@@ -40,7 +39,7 @@
@required String bundlePath,
@required List<String> launchArguments,
}) async {
- final String iosDeployPath = artifacts.getArtifactPath(Artifact.iosDeploy, platform: TargetPlatform.ios);
+ final String iosDeployPath = globals.artifacts.getArtifactPath(Artifact.iosDeploy, platform: TargetPlatform.ios);
final List<String> launchCommand = <String>[
iosDeployPath,
'--id',
@@ -62,9 +61,9 @@
// python at the front of the path, which may not include package 'six'.
// Ensure that we pick up the system install of python, which does include
// it.
- final Map<String, String> iosDeployEnv = Map<String, String>.from(platform.environment);
+ final Map<String, String> iosDeployEnv = Map<String, String>.from(globals.platform.environment);
iosDeployEnv['PATH'] = '/usr/bin:${iosDeployEnv['PATH']}';
- iosDeployEnv.addEntries(<MapEntry<String, String>>[cache.dyLdLibEntry]);
+ iosDeployEnv.addEntries(<MapEntry<String, String>>[globals.cache.dyLdLibEntry]);
return await processUtils.stream(
launchCommand,
@@ -78,17 +77,17 @@
String _monitorInstallationFailure(String stdout) {
// Installation issues.
if (stdout.contains('Error 0xe8008015') || stdout.contains('Error 0xe8000067')) {
- printError(noProvisioningProfileInstruction, emphasis: true);
+ globals.printError(noProvisioningProfileInstruction, emphasis: true);
// Launch issues.
} else if (stdout.contains('e80000e2')) {
- printError('''
+ globals.printError('''
═══════════════════════════════════════════════════════════════════════════════════
Your device is locked. Unlock your device first before running.
═══════════════════════════════════════════════════════════════════════════════════''',
emphasis: true);
} else if (stdout.contains('Error 0xe8000022')) {
- printError('''
+ globals.printError('''
═══════════════════════════════════════════════════════════════════════════════════
Error launching app. Try launching from within Xcode via:
open ios/Runner.xcworkspace
@@ -106,7 +105,7 @@
IOSDevices() : super('iOS devices');
@override
- bool get supportsPlatform => platform.isMacOS;
+ bool get supportsPlatform => globals.platform.isMacOS;
@override
bool get canListAnything => iosWorkflow.canListDevices;
@@ -124,15 +123,15 @@
platformType: PlatformType.ios,
ephemeral: true,
) {
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
assert(false, 'Control of iOS devices or simulators only supported on Mac OS.');
return;
}
- _installerPath = artifacts.getArtifactPath(
+ _installerPath = globals.artifacts.getArtifactPath(
Artifact.ideviceinstaller,
platform: TargetPlatform.ios,
);
- _iproxyPath = artifacts.getArtifactPath(
+ _iproxyPath = globals.artifacts.getArtifactPath(
Artifact.iproxy,
platform: TargetPlatform.ios,
);
@@ -172,7 +171,7 @@
bool get supportsStartPaused => false;
static Future<List<IOSDevice>> getAttachedDevices() async {
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
throw UnsupportedError('Control of iOS devices or simulators only supported on Mac OS.');
}
if (!iMobileDevice.isInstalled) {
@@ -192,9 +191,9 @@
devices.add(IOSDevice(id, name: deviceName, sdkVersion: sdkVersion));
} on IOSDeviceNotFoundError catch (error) {
// Unable to find device with given udid. Possibly a network device.
- printTrace('Error getting attached iOS device: $error');
+ globals.printTrace('Error getting attached iOS device: $error');
} on IOSDeviceNotTrustedError catch (error) {
- printTrace('Error getting attached iOS device information: $error');
+ globals.printTrace('Error getting attached iOS device information: $error');
UsageEvent('device', 'ios-trust-failure').send();
}
}
@@ -209,7 +208,7 @@
<String>[_installerPath, '--list-apps'],
throwOnError: true,
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry],
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry],
),
);
} on ProcessException {
@@ -223,9 +222,9 @@
@override
Future<bool> installApp(IOSApp app) async {
- final Directory bundle = fs.directory(app.deviceBundlePath);
+ final Directory bundle = globals.fs.directory(app.deviceBundlePath);
if (!bundle.existsSync()) {
- printError('Could not find application bundle at ${bundle.path}; have you run "flutter build ios"?');
+ globals.printError('Could not find application bundle at ${bundle.path}; have you run "flutter build ios"?');
return false;
}
@@ -234,12 +233,12 @@
<String>[_installerPath, '-i', app.deviceBundlePath],
throwOnError: true,
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry],
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry],
),
);
return true;
} on ProcessException catch (error) {
- printError(error.message);
+ globals.printError(error.message);
return false;
}
}
@@ -251,12 +250,12 @@
<String>[_installerPath, '-U', app.id],
throwOnError: true,
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry],
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry],
),
);
return true;
} on ProcessException catch (error) {
- printError(error.message);
+ globals.printError(error.message);
return false;
}
}
@@ -279,14 +278,14 @@
if (!prebuiltApplication) {
// TODO(chinmaygarde): Use mainPath, route.
- printTrace('Building ${package.name} for $id');
+ globals.printTrace('Building ${package.name} for $id');
String cpuArchitecture;
try {
cpuArchitecture = await iMobileDevice.getInfoForDevice(id, 'CPUArchitecture');
} on IOSDeviceNotFoundError catch (e) {
- printError(e.message);
+ globals.printError(e.message);
return LaunchResult.failed();
}
@@ -301,9 +300,9 @@
activeArch: iosArch,
);
if (!buildResult.success) {
- printError('Could not build the precompiled application for the device.');
+ globals.printError('Could not build the precompiled application for the device.');
await diagnoseXcodeBuildFailure(buildResult);
- printError('');
+ globals.printError('');
return LaunchResult.failed();
}
packageId = buildResult.xcodeBuildExecution?.buildSettings['PRODUCT_BUNDLE_IDENTIFIER'];
@@ -316,9 +315,9 @@
packageId ??= package.id;
// Step 2: Check that the application exists at the specified path.
- final Directory bundle = fs.directory(package.deviceBundlePath);
+ final Directory bundle = globals.fs.directory(package.deviceBundlePath);
if (!bundle.existsSync()) {
- printError('Could not find the built application bundle at ${bundle.path}.');
+ globals.printError('Could not find the built application bundle at ${bundle.path}.');
return LaunchResult.failed();
}
@@ -335,7 +334,7 @@
// "system_debug_ios" integration test in the CI, which simulates a
// home-screen launch.
if (debuggingOptions.debuggingEnabled &&
- platform.environment['FLUTTER_TOOLS_DEBUG_WITHOUT_CHECKED_MODE'] != 'true') ...<String>[
+ globals.platform.environment['FLUTTER_TOOLS_DEBUG_WITHOUT_CHECKED_MODE'] != 'true') ...<String>[
'--enable-checked-mode',
'--verify-entry-points',
],
@@ -350,14 +349,14 @@
if (platformArgs['trace-startup'] as bool ?? false) '--trace-startup',
];
- final Status installStatus = logger.startProgress(
+ final Status installStatus = globals.logger.startProgress(
'Installing and launching...',
timeout: timeoutConfiguration.slowOperation);
try {
ProtocolDiscovery observatoryDiscovery;
if (debuggingOptions.debuggingEnabled) {
// Debugging is enabled, look for the observatory server port post launch.
- printTrace('Debugging is enabled, connecting to observatory');
+ globals.printTrace('Debugging is enabled, connecting to observatory');
// TODO(danrubel): The Android device class does something similar to this code below.
// The various Device subclasses should be refactored and common code moved into the superclass.
@@ -375,10 +374,10 @@
launchArguments: launchArguments,
);
if (installationResult != 0) {
- printError('Could not install ${bundle.path} on $id.');
- printError('Try launching Xcode and selecting "Product > Run" to fix the problem:');
- printError(' open ios/Runner.xcworkspace');
- printError('');
+ globals.printError('Could not install ${bundle.path} on $id.');
+ globals.printError('Try launching Xcode and selecting "Product > Run" to fix the problem:');
+ globals.printError(' open ios/Runner.xcworkspace');
+ globals.printError('');
return LaunchResult.failed();
}
@@ -388,7 +387,7 @@
Uri localUri;
try {
- printTrace('Application launched on the device. Waiting for observatory port.');
+ globals.printTrace('Application launched on the device. Waiting for observatory port.');
localUri = await MDnsObservatoryDiscovery.instance.getObservatoryUri(
packageId,
this,
@@ -400,21 +399,21 @@
return LaunchResult.succeeded(observatoryUri: localUri);
}
} catch (error) {
- printError('Failed to establish a debug connection with $id using mdns: $error');
+ globals.printError('Failed to establish a debug connection with $id using mdns: $error');
}
// Fallback to manual protocol discovery.
UsageEvent('ios-mdns', 'failure').send();
- printTrace('mDNS lookup failed, attempting fallback to reading device log.');
+ globals.printTrace('mDNS lookup failed, attempting fallback to reading device log.');
try {
- printTrace('Waiting for observatory port.');
+ globals.printTrace('Waiting for observatory port.');
localUri = await observatoryDiscovery.uri;
if (localUri != null) {
UsageEvent('ios-mdns', 'fallback-success').send();
return LaunchResult.succeeded(observatoryUri: localUri);
}
} catch (error) {
- printError('Failed to establish a debug connection with $id using logs: $error');
+ globals.printError('Failed to establish a debug connection with $id using logs: $error');
} finally {
await observatoryDiscovery?.cancel();
}
@@ -697,7 +696,7 @@
bool connected = false;
while (!connected) {
- printTrace('Attempting to forward device port $devicePort to host port $hostPort');
+ globals.printTrace('Attempting to forward device port $devicePort to host port $hostPort');
// Usage: iproxy LOCAL_TCP_PORT DEVICE_TCP_PORT UDID
process = await processUtils.start(
<String>[
@@ -707,7 +706,7 @@
device.id,
],
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry],
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry],
),
);
// TODO(ianh): This is a flakey race condition, https://github.com/libimobiledevice/libimobiledevice/issues/674
@@ -730,7 +729,7 @@
final ForwardedPort forwardedPort = ForwardedPort.withContext(
hostPort, devicePort, process,
);
- printTrace('Forwarded port $forwardedPort');
+ globals.printTrace('Forwarded port $forwardedPort');
_forwardedPorts.add(forwardedPort);
return hostPort;
}
@@ -742,7 +741,7 @@
return;
}
- printTrace('Unforwarding port $forwardedPort');
+ globals.printTrace('Unforwarding port $forwardedPort');
forwardedPort.dispose();
}
diff --git a/packages/flutter_tools/lib/src/ios/ios_emulators.dart b/packages/flutter_tools/lib/src/ios/ios_emulators.dart
index 96bc865..0ac58ab 100644
--- a/packages/flutter_tools/lib/src/ios/ios_emulators.dart
+++ b/packages/flutter_tools/lib/src/ios/ios_emulators.dart
@@ -4,18 +4,17 @@
import 'dart:async';
-import '../base/platform.dart';
import '../base/process.dart';
import '../device.dart';
import '../emulator.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../macos/xcode.dart';
import 'ios_workflow.dart';
import 'simulators.dart';
class IOSEmulators extends EmulatorDiscovery {
@override
- bool get supportsPlatform => platform.isMacOS;
+ bool get supportsPlatform => globals.platform.isMacOS;
@override
bool get canListAnything => iosWorkflow.canListEmulators;
@@ -51,7 +50,7 @@
final RunResult launchResult = await processUtils.run(args);
if (launchResult.exitCode != 0) {
- printError('$launchResult');
+ globals.printError('$launchResult');
return false;
}
return true;
diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
index 155a08e..d49a111 100644
--- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart
+++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart
@@ -3,8 +3,8 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/platform.dart';
import '../doctor.dart';
+import '../globals.dart' as globals;
import '../macos/xcode.dart';
IOSWorkflow get iosWorkflow => context.get<IOSWorkflow>();
@@ -13,7 +13,7 @@
const IOSWorkflow();
@override
- bool get appliesToHostPlatform => platform.isMacOS;
+ bool get appliesToHostPlatform => globals.platform.isMacOS;
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
@override
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart
index 3ac2ecb..7974313 100644
--- a/packages/flutter_tools/lib/src/ios/mac.dart
+++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -14,13 +14,11 @@
import '../base/io.dart';
import '../base/logger.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../flutter_manifest.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../macos/cocoapod_utils.dart';
import '../macos/xcode.dart';
import '../project.dart';
@@ -93,11 +91,11 @@
class IMobileDevice {
IMobileDevice()
- : _ideviceIdPath = artifacts.getArtifactPath(Artifact.ideviceId, platform: TargetPlatform.ios),
- _ideviceinfoPath = artifacts.getArtifactPath(Artifact.ideviceinfo, platform: TargetPlatform.ios),
- _idevicenamePath = artifacts.getArtifactPath(Artifact.idevicename, platform: TargetPlatform.ios),
- _idevicesyslogPath = artifacts.getArtifactPath(Artifact.idevicesyslog, platform: TargetPlatform.ios),
- _idevicescreenshotPath = artifacts.getArtifactPath(Artifact.idevicescreenshot, platform: TargetPlatform.ios);
+ : _ideviceIdPath = globals.artifacts.getArtifactPath(Artifact.ideviceId, platform: TargetPlatform.ios),
+ _ideviceinfoPath = globals.artifacts.getArtifactPath(Artifact.ideviceinfo, platform: TargetPlatform.ios),
+ _idevicenamePath = globals.artifacts.getArtifactPath(Artifact.idevicename, platform: TargetPlatform.ios),
+ _idevicesyslogPath = globals.artifacts.getArtifactPath(Artifact.idevicesyslog, platform: TargetPlatform.ios),
+ _idevicescreenshotPath = globals.artifacts.getArtifactPath(Artifact.idevicescreenshot, platform: TargetPlatform.ios);
final String _ideviceIdPath;
final String _ideviceinfoPath;
@@ -112,7 +110,7 @@
'-h',
],
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry]
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry]
),
);
return _isInstalled;
@@ -133,7 +131,7 @@
// If usage info is printed in a hyphenated id, we need to update.
const String fakeIphoneId = '00008020-001C2D903C42002E';
final Map<String, String> executionEnv = Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry]
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry]
);
final ProcessResult ideviceResult = (await processUtils.run(
<String>[
@@ -171,13 +169,13 @@
Future<String> getAvailableDeviceIDs() async {
try {
- final ProcessResult result = await processManager.run(
+ final ProcessResult result = await globals.processManager.run(
<String>[
_ideviceIdPath,
'-l',
],
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry]
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry]
),
);
if (result.exitCode != 0) {
@@ -191,7 +189,7 @@
Future<String> getInfoForDevice(String deviceID, String key) async {
try {
- final ProcessResult result = await processManager.run(
+ final ProcessResult result = await globals.processManager.run(
<String>[
_ideviceinfoPath,
'-u',
@@ -200,7 +198,7 @@
key,
],
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry]
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry]
),
);
final String stdout = result.stdout as String;
@@ -240,7 +238,7 @@
deviceID,
],
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry]
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry]
),
);
}
@@ -254,7 +252,7 @@
],
throwOnError: true,
environment: Map<String, String>.fromEntries(
- <MapEntry<String, String>>[cache.dyLdLibEntry]
+ <MapEntry<String, String>>[globals.cache.dyLdLibEntry]
),
);
}
@@ -280,47 +278,47 @@
final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(app.project.hostAppRoot.path);
if (!projectInfo.targets.contains('Runner')) {
- printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.');
- printError('Open Xcode to fix the problem:');
- printError(' open ios/Runner.xcworkspace');
+ globals.printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.');
+ globals.printError('Open Xcode to fix the problem:');
+ globals.printError(' open ios/Runner.xcworkspace');
return XcodeBuildResult(success: false);
}
final String scheme = projectInfo.schemeFor(buildInfo);
if (scheme == null) {
- printError('');
+ globals.printError('');
if (projectInfo.definesCustomSchemes) {
- printError('The Xcode project defines schemes: ${projectInfo.schemes.join(', ')}');
- printError('You must specify a --flavor option to select one of them.');
+ globals.printError('The Xcode project defines schemes: ${projectInfo.schemes.join(', ')}');
+ globals.printError('You must specify a --flavor option to select one of them.');
} else {
- printError('The Xcode project does not define custom schemes.');
- printError('You cannot use the --flavor option.');
+ globals.printError('The Xcode project does not define custom schemes.');
+ globals.printError('You cannot use the --flavor option.');
}
return XcodeBuildResult(success: false);
}
final String configuration = projectInfo.buildConfigurationFor(buildInfo, scheme);
if (configuration == null) {
- printError('');
- printError('The Xcode project defines build configurations: ${projectInfo.buildConfigurations.join(', ')}');
- printError('Flutter expects a build configuration named ${XcodeProjectInfo.expectedBuildConfigurationFor(buildInfo, scheme)} or similar.');
- printError('Open Xcode to fix the problem:');
- printError(' open ios/Runner.xcworkspace');
- printError('1. Click on "Runner" in the project navigator.');
- printError('2. Ensure the Runner PROJECT is selected, not the Runner TARGET.');
+ globals.printError('');
+ globals.printError('The Xcode project defines build configurations: ${projectInfo.buildConfigurations.join(', ')}');
+ globals.printError('Flutter expects a build configuration named ${XcodeProjectInfo.expectedBuildConfigurationFor(buildInfo, scheme)} or similar.');
+ globals.printError('Open Xcode to fix the problem:');
+ globals.printError(' open ios/Runner.xcworkspace');
+ globals.printError('1. Click on "Runner" in the project navigator.');
+ globals.printError('2. Ensure the Runner PROJECT is selected, not the Runner TARGET.');
if (buildInfo.isDebug) {
- printError('3. Click the Editor->Add Configuration->Duplicate "Debug" Configuration.');
+ globals.printError('3. Click the Editor->Add Configuration->Duplicate "Debug" Configuration.');
} else {
- printError('3. Click the Editor->Add Configuration->Duplicate "Release" Configuration.');
+ globals.printError('3. Click the Editor->Add Configuration->Duplicate "Release" Configuration.');
}
- printError('');
- printError(' If this option is disabled, it is likely you have the target selected instead');
- printError(' of the project; see:');
- printError(' https://stackoverflow.com/questions/19842746/adding-a-build-configuration-in-xcode');
- printError('');
- printError(' If you have created a completely custom set of build configurations,');
- printError(' you can set the FLUTTER_BUILD_MODE=${buildInfo.modeName.toLowerCase()}');
- printError(' in the .xcconfig file for that configuration and run from Xcode.');
- printError('');
- printError('4. If you are not using completely custom build configurations, name the newly created configuration ${buildInfo.modeName}.');
+ globals.printError('');
+ globals.printError(' If this option is disabled, it is likely you have the target selected instead');
+ globals.printError(' of the project; see:');
+ globals.printError(' https://stackoverflow.com/questions/19842746/adding-a-build-configuration-in-xcode');
+ globals.printError('');
+ globals.printError(' If you have created a completely custom set of build configurations,');
+ globals.printError(' you can set the FLUTTER_BUILD_MODE=${buildInfo.modeName.toLowerCase()}');
+ globals.printError(' in the .xcconfig file for that configuration and run from Xcode.');
+ globals.printError('');
+ globals.printError('4. If you are not using completely custom build configurations, name the newly created configuration ${buildInfo.modeName}.');
return XcodeBuildResult(success: false);
}
@@ -329,17 +327,17 @@
final bool buildNameIsMissing = buildName == null || buildName.isEmpty;
if (buildNameIsMissing) {
- printStatus('Warning: Missing build name (CFBundleShortVersionString).');
+ globals.printStatus('Warning: Missing build name (CFBundleShortVersionString).');
}
final String buildNumber = parsedBuildNumber(manifest: manifest, buildInfo: buildInfo);
final bool buildNumberIsMissing = buildNumber == null || buildNumber.isEmpty;
if (buildNumberIsMissing) {
- printStatus('Warning: Missing build number (CFBundleVersion).');
+ globals.printStatus('Warning: Missing build number (CFBundleVersion).');
}
if (buildNameIsMissing || buildNumberIsMissing) {
- printError('Action Required: You must set a build name and number in the pubspec.yaml '
+ globals.printError('Action Required: You must set a build name and number in the pubspec.yaml '
'file version field before submitting to the App Store.');
}
@@ -363,7 +361,7 @@
'-configuration', configuration,
];
- if (logger.isVerbose) {
+ if (globals.logger.isVerbose) {
// An environment variable to be passed to xcode_backend.sh determining
// whether to echo back executed commands.
buildCommands.add('VERBOSE_SCRIPT_LOGGING=YES');
@@ -382,11 +380,11 @@
final List<FileSystemEntity> contents = app.project.hostAppRoot.listSync();
for (FileSystemEntity entity in contents) {
- if (fs.path.extension(entity.path) == '.xcworkspace') {
+ if (globals.fs.path.extension(entity.path) == '.xcworkspace') {
buildCommands.addAll(<String>[
- '-workspace', fs.path.basename(entity.path),
+ '-workspace', globals.fs.path.basename(entity.path),
'-scheme', scheme,
- 'BUILD_DIR=${fs.path.absolute(getIosBuildDirectory())}',
+ 'BUILD_DIR=${globals.fs.path.absolute(getIosBuildDirectory())}',
]);
break;
}
@@ -421,8 +419,8 @@
Directory tempDir;
File scriptOutputPipeFile;
- if (logger.hasTerminal) {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_build_log_pipe.');
+ if (globals.logger.hasTerminal) {
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_build_log_pipe.');
scriptOutputPipeFile = tempDir.childFile('pipe_to_stdout');
os.makePipe(scriptOutputPipeFile.path);
@@ -440,7 +438,7 @@
} else {
initialBuildStatus?.cancel();
initialBuildStatus = null;
- buildSubStatus = logger.startProgress(
+ buildSubStatus = globals.logger.startProgress(
line,
timeout: timeoutConfiguration.slowOperation,
progressIndicatorPadding: kDefaultStatusPadding - 7,
@@ -463,7 +461,7 @@
buildCommands.addAll(environmentVariablesAsXcodeBuildSettings());
final Stopwatch sw = Stopwatch()..start();
- initialBuildStatus = logger.startProgress('Running Xcode build...', timeout: timeoutConfiguration.fastOperation);
+ initialBuildStatus = globals.logger.startProgress('Running Xcode build...', timeout: timeoutConfiguration.fastOperation);
final RunResult buildResult = await _runBuildWithRetries(buildCommands, app);
@@ -473,7 +471,7 @@
buildSubStatus = null;
initialBuildStatus?.cancel();
initialBuildStatus = null;
- printStatus(
+ globals.printStatus(
'Xcode build done.'.padRight(kDefaultStatusPadding + 1)
+ '${getElapsedAsSeconds(sw.elapsed).padLeft(5)}',
);
@@ -517,14 +515,14 @@
}
if (buildResult.exitCode != 0) {
- printStatus('Failed to build iOS app');
+ globals.printStatus('Failed to build iOS app');
if (buildResult.stderr.isNotEmpty) {
- printStatus('Error output from Xcode build:\n↳');
- printStatus(buildResult.stderr, indent: 4);
+ globals.printStatus('Error output from Xcode build:\n↳');
+ globals.printStatus(buildResult.stderr, indent: 4);
}
if (buildResult.stdout.isNotEmpty) {
- printStatus('Xcode\'s output:\n↳');
- printStatus(buildResult.stdout, indent: 4);
+ globals.printStatus('Xcode\'s output:\n↳');
+ globals.printStatus(buildResult.stdout, indent: 4);
}
return XcodeBuildResult(
success: false,
@@ -538,24 +536,24 @@
),
);
} else {
- final String expectedOutputDirectory = fs.path.join(
+ final String expectedOutputDirectory = globals.fs.path.join(
buildSettings['TARGET_BUILD_DIR'],
buildSettings['WRAPPER_NAME'],
);
String outputDir;
- if (fs.isDirectorySync(expectedOutputDirectory)) {
+ if (globals.fs.isDirectorySync(expectedOutputDirectory)) {
// Copy app folder to a place where other tools can find it without knowing
// the BuildInfo.
outputDir = expectedOutputDirectory.replaceFirst('/$configuration-', '/');
- if (fs.isDirectorySync(outputDir)) {
+ if (globals.fs.isDirectorySync(outputDir)) {
// Previous output directory might have incompatible artifacts
// (for example, kernel binary files produced from previous run).
- fs.directory(outputDir).deleteSync(recursive: true);
+ globals.fs.directory(outputDir).deleteSync(recursive: true);
}
- copyDirectorySync(fs.directory(expectedOutputDirectory), fs.directory(outputDir));
+ copyDirectorySync(globals.fs.directory(expectedOutputDirectory), globals.fs.directory(outputDir));
} else {
- printError('Build succeeded but the expected app at $expectedOutputDirectory not found');
+ globals.printError('Build succeeded but the expected app at $expectedOutputDirectory not found');
}
return XcodeBuildResult(
success: true,
@@ -592,11 +590,11 @@
}
if (remainingTries > 0) {
- printStatus('Xcode build failed due to concurrent builds, '
+ globals.printStatus('Xcode build failed due to concurrent builds, '
'will retry in $buildRetryDelaySeconds seconds.');
await Future<void>.delayed(Duration(seconds: buildRetryDelaySeconds));
} else {
- printStatus(
+ globals.printStatus(
'Xcode build failed too many times due to concurrent builds, '
'giving up.');
break;
@@ -615,8 +613,8 @@
String readGeneratedXcconfig(String appPath) {
final String generatedXcconfigPath =
- fs.path.join(fs.currentDirectory.path, appPath, 'Flutter', 'Generated.xcconfig');
- final File generatedXcconfigFile = fs.file(generatedXcconfigPath);
+ globals.fs.path.join(globals.fs.currentDirectory.path, appPath, 'Flutter', 'Generated.xcconfig');
+ final File generatedXcconfigFile = globals.fs.file(generatedXcconfigPath);
if (!generatedXcconfigFile.existsSync()) {
return null;
}
@@ -638,7 +636,7 @@
result.stdout?.contains('BCEROR') == true &&
// May need updating if Xcode changes its outputs.
result.stdout?.contains('Xcode couldn\'t find a provisioning profile matching') == true) {
- printError(noProvisioningProfileInstruction, emphasis: true);
+ globals.printError(noProvisioningProfileInstruction, emphasis: true);
return;
}
// Make sure the user has specified one of:
@@ -648,26 +646,26 @@
result.xcodeBuildExecution.buildForPhysicalDevice &&
!<String>['DEVELOPMENT_TEAM', 'PROVISIONING_PROFILE'].any(
result.xcodeBuildExecution.buildSettings.containsKey)) {
- printError(noDevelopmentTeamInstruction, emphasis: true);
+ globals.printError(noDevelopmentTeamInstruction, emphasis: true);
return;
}
if (result.xcodeBuildExecution != null &&
result.xcodeBuildExecution.buildForPhysicalDevice &&
result.xcodeBuildExecution.buildSettings['PRODUCT_BUNDLE_IDENTIFIER']?.contains('com.example') == true) {
- printError('');
- printError('It appears that your application still contains the default signing identifier.');
- printError("Try replacing 'com.example' with your signing id in Xcode:");
- printError(' open ios/Runner.xcworkspace');
+ globals.printError('');
+ globals.printError('It appears that your application still contains the default signing identifier.');
+ globals.printError("Try replacing 'com.example' with your signing id in Xcode:");
+ globals.printError(' open ios/Runner.xcworkspace');
return;
}
if (result.stdout?.contains('Code Sign error') == true) {
- printError('');
- printError('It appears that there was a problem signing your application prior to installation on the device.');
- printError('');
- printError('Verify that the Bundle Identifier in your project is your signing id in Xcode');
- printError(' open ios/Runner.xcworkspace');
- printError('');
- printError("Also try selecting 'Product > Build' to fix the problem:");
+ globals.printError('');
+ globals.printError('It appears that there was a problem signing your application prior to installation on the device.');
+ globals.printError('');
+ globals.printError('Verify that the Bundle Identifier in your project is your signing id in Xcode');
+ globals.printError(' open ios/Runner.xcworkspace');
+ globals.printError('');
+ globals.printError("Also try selecting 'Product > Build' to fix the problem:");
return;
}
}
@@ -709,15 +707,15 @@
const String _xcodeRequirement = 'Xcode $kXcodeRequiredVersionMajor.$kXcodeRequiredVersionMinor or greater is required to develop for iOS.';
bool _checkXcodeVersion() {
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
return false;
}
if (!xcodeProjectInterpreter.isInstalled) {
- printError('Cannot find "xcodebuild". $_xcodeRequirement');
+ globals.printError('Cannot find "xcodebuild". $_xcodeRequirement');
return false;
}
if (!xcode.isVersionSatisfactory) {
- printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement');
+ globals.printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement');
return false;
}
return true;
@@ -736,7 +734,7 @@
final Match match = oldAssets.firstMatch(line);
if (match != null) {
if (printedStatuses.add(match.group(1))) {
- printStatus('Removing obsolete reference to ${match.group(1)} from ${project.hostAppBundleName}');
+ globals.printStatus('Removing obsolete reference to ${match.group(1)} from ${project.hostAppBundleName}');
}
} else {
buffer.writeln(line);
diff --git a/packages/flutter_tools/lib/src/ios/plist_parser.dart b/packages/flutter_tools/lib/src/ios/plist_parser.dart
index 40d6d1e..8a2bcf3 100644
--- a/packages/flutter_tools/lib/src/ios/plist_parser.dart
+++ b/packages/flutter_tools/lib/src/ios/plist_parser.dart
@@ -8,7 +8,7 @@
import '../base/process.dart';
import '../base/utils.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
class PlistParser {
const PlistParser();
@@ -29,14 +29,14 @@
Map<String, dynamic> parseFile(String plistFilePath) {
assert(plistFilePath != null);
const String executable = '/usr/bin/plutil';
- if (!fs.isFileSync(executable)) {
+ if (!globals.fs.isFileSync(executable)) {
throw const FileNotFoundException(executable);
}
- if (!fs.isFileSync(plistFilePath)) {
+ if (!globals.fs.isFileSync(plistFilePath)) {
return const <String, dynamic>{};
}
- final String normalizedPlistPath = fs.path.absolute(plistFilePath);
+ final String normalizedPlistPath = globals.fs.path.absolute(plistFilePath);
try {
final List<String> args = <String>[
@@ -48,7 +48,7 @@
).stdout.trim();
return castStringKeyedMap(json.decode(jsonContent));
} on ProcessException catch (error) {
- printTrace('$error');
+ globals.printTrace('$error');
return const <String, dynamic>{};
}
}
diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart
index 7f24d01..748d1dc 100644
--- a/packages/flutter_tools/lib/src/ios/simulators.dart
+++ b/packages/flutter_tools/lib/src/ios/simulators.dart
@@ -12,15 +12,13 @@
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../convert.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../macos/xcode.dart';
import '../project.dart';
import '../protocol_discovery.dart';
@@ -35,7 +33,7 @@
IOSSimulators() : super('iOS simulators');
@override
- bool get supportsPlatform => platform.isMacOS;
+ bool get supportsPlatform => globals.platform.isMacOS;
@override
bool get canListAnything => iosWorkflow.canListDevices;
@@ -86,10 +84,10 @@
// "pairs": { ... },
final List<String> command = <String>[_xcrunPath, 'simctl', 'list', '--json', section.name];
- printTrace(command.join(' '));
- final ProcessResult results = await processManager.run(command);
+ globals.printTrace(command.join(' '));
+ final ProcessResult results = await globals.processManager.run(command);
if (results.exitCode != 0) {
- printError('Error executing simctl: ${results.exitCode}\n${results.stderr}');
+ globals.printError('Error executing simctl: ${results.exitCode}\n${results.stderr}');
return <String, Map<String, dynamic>>{};
}
try {
@@ -97,13 +95,13 @@
if (decodeResult is Map<String, dynamic>) {
return decodeResult;
}
- printError('simctl returned unexpected JSON response: ${results.stdout}');
+ globals.printError('simctl returned unexpected JSON response: ${results.stdout}');
return <String, dynamic>{};
} on FormatException {
// We failed to parse the simctl output, or it returned junk.
// One known message is "Install Started" isn't valid JSON but is
// returned sometimes.
- printError('simctl returned non-JSON response: ${results.stdout}');
+ globals.printError('simctl returned non-JSON response: ${results.stdout}');
return <String, dynamic>{};
}
}
@@ -278,7 +276,7 @@
Map<ApplicationPackage, _IOSSimulatorLogReader> _logReaders;
_IOSSimulatorDevicePortForwarder _portForwarder;
- String get xcrunPath => fs.path.join('/usr', 'bin', 'xcrun');
+ String get xcrunPath => globals.fs.path.join('/usr', 'bin', 'xcrun');
@override
Future<bool> isAppInstalled(ApplicationPackage app) {
@@ -311,7 +309,7 @@
@override
bool isSupported() {
- if (!platform.isMacOS) {
+ if (!globals.platform.isMacOS) {
_supportMessage = 'iOS devices require a Mac host machine.';
return false;
}
@@ -348,12 +346,12 @@
bool ipv6 = false,
}) async {
if (!prebuiltApplication && package is BuildableIOSApp) {
- printTrace('Building ${package.name} for $id.');
+ globals.printTrace('Building ${package.name} for $id.');
try {
await _setupUpdatedApplicationBundle(package, debuggingOptions.buildInfo, mainPath);
} on ToolExit catch (e) {
- printError(e.message);
+ globals.printError(e.message);
return LaunchResult.failed();
}
} else {
@@ -394,12 +392,12 @@
// which should always yield the correct value and does not require
// parsing the xcodeproj or configuration files.
// See https://github.com/flutter/flutter/issues/31037 for more information.
- final String plistPath = fs.path.join(package.simulatorBundlePath, 'Info.plist');
+ final String plistPath = globals.fs.path.join(package.simulatorBundlePath, 'Info.plist');
final String bundleIdentifier = PlistParser.instance.getValueFromFile(plistPath, PlistParser.kCFBundleIdentifierKey);
await SimControl.instance.launch(id, bundleIdentifier, args);
} catch (error) {
- printError('$error');
+ globals.printError('$error');
return LaunchResult.failed();
}
@@ -409,13 +407,13 @@
// Wait for the service protocol port here. This will complete once the
// device has printed "Observatory is listening on..."
- printTrace('Waiting for observatory port to be available...');
+ globals.printTrace('Waiting for observatory port to be available...');
try {
final Uri deviceUri = await observatoryDiscovery.uri;
return LaunchResult.succeeded(observatoryUri: deviceUri);
} catch (error) {
- printError('Error waiting for a debug connection: $error');
+ globals.printError('Error waiting for a debug connection: $error');
return LaunchResult.failed();
} finally {
await observatoryDiscovery.cancel();
@@ -444,14 +442,14 @@
}
// Step 2: Assert that the Xcode project was successfully built.
- final Directory bundle = fs.directory(app.simulatorBundlePath);
+ final Directory bundle = globals.fs.directory(app.simulatorBundlePath);
final bool bundleExists = bundle.existsSync();
if (!bundleExists) {
throwToolExit('Could not find the built application bundle at ${bundle.path}.');
}
// Step 3: Install the updated bundle to the simulator.
- await SimControl.instance.install(id, fs.path.absolute(bundle.path));
+ await SimControl.instance.install(id, globals.fs.path.absolute(bundle.path));
}
@visibleForTesting
@@ -473,9 +471,9 @@
}
String get logFilePath {
- return platform.environment.containsKey('IOS_SIMULATOR_LOG_FILE_PATH')
- ? platform.environment['IOS_SIMULATOR_LOG_FILE_PATH'].replaceAll('%{id}', id)
- : fs.path.join(homeDirPath, 'Library', 'Logs', 'CoreSimulator', id, 'system.log');
+ return globals.platform.environment.containsKey('IOS_SIMULATOR_LOG_FILE_PATH')
+ ? globals.platform.environment['IOS_SIMULATOR_LOG_FILE_PATH'].replaceAll('%{id}', id)
+ : globals.fs.path.join(homeDirPath, 'Library', 'Logs', 'CoreSimulator', id, 'system.log');
}
@override
@@ -503,7 +501,7 @@
@override
void clearLogs() {
- final File logFile = fs.file(logFilePath);
+ final File logFile = globals.fs.file(logFilePath);
if (logFile.existsSync()) {
final RandomAccessFile randomFile = logFile.openSync(mode: FileMode.write);
randomFile.truncateSync(0);
@@ -513,7 +511,7 @@
Future<void> ensureLogsExists() async {
if (await sdkMajorVersion < 11) {
- final File logFile = fs.file(logFilePath);
+ final File logFile = globals.fs.file(logFilePath);
if (!logFile.existsSync()) {
logFile.writeAsBytesSync(<int>[]);
}
@@ -689,7 +687,7 @@
String _lastLine;
void _onDeviceLine(String line) {
- printTrace('[DEVICE LOG] $line');
+ globals.printTrace('[DEVICE LOG] $line');
final Match multi = _lastMessageMultipleRegex.matchAsPrefix(line);
if (multi != null) {
@@ -714,7 +712,7 @@
}
void _onSystemLine(String line) {
- printTrace('[SYS LOG] $line');
+ globals.printTrace('[SYS LOG] $line');
if (!_flutterRunnerRegex.hasMatch(line)) {
return;
}
diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
index 37907ba..ff966cb 100644
--- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart
+++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
@@ -13,13 +13,12 @@
import '../base/io.dart';
import '../base/logger.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../cache.dart';
import '../flutter_manifest.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
@@ -27,12 +26,12 @@
final RegExp _varExpr = RegExp(r'\$\(([^)]*)\)');
String flutterFrameworkDir(BuildMode mode) {
- return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(
+ return globals.fs.path.normalize(globals.fs.path.dirname(globals.artifacts.getArtifactPath(
Artifact.flutterFramework, platform: TargetPlatform.ios, mode: mode)));
}
String flutterMacOSFrameworkDir(BuildMode mode) {
- return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(
+ return globals.fs.path.normalize(globals.fs.path.dirname(globals.artifacts.getArtifactPath(
Artifact.flutterMacOSFramework, platform: TargetPlatform.darwin_x64, mode: mode)));
}
@@ -155,11 +154,11 @@
}) {
final List<String> xcodeBuildSettings = <String>[];
- final String flutterRoot = fs.path.normalize(Cache.flutterRoot);
+ final String flutterRoot = globals.fs.path.normalize(Cache.flutterRoot);
xcodeBuildSettings.add('FLUTTER_ROOT=$flutterRoot');
// This holds because requiresProjectRoot is true for this command
- xcodeBuildSettings.add('FLUTTER_APPLICATION_PATH=${fs.path.normalize(project.directory.path)}');
+ xcodeBuildSettings.add('FLUTTER_APPLICATION_PATH=${globals.fs.path.normalize(project.directory.path)}');
// Relative to FLUTTER_APPLICATION_PATH, which is [Directory.current].
if (targetOverride != null) {
@@ -191,11 +190,11 @@
final String buildNumber = parsedBuildNumber(manifest: project.manifest, buildInfo: buildInfo) ?? '1';
xcodeBuildSettings.add('FLUTTER_BUILD_NUMBER=$buildNumber');
- if (artifacts is LocalEngineArtifacts) {
- final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
+ if (globals.artifacts is LocalEngineArtifacts) {
+ final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath;
- xcodeBuildSettings.add('FLUTTER_ENGINE=${fs.path.dirname(fs.path.dirname(engineOutPath))}');
- xcodeBuildSettings.add('LOCAL_ENGINE=${fs.path.basename(engineOutPath)}');
+ xcodeBuildSettings.add('FLUTTER_ENGINE=${globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath))}');
+ xcodeBuildSettings.add('LOCAL_ENGINE=${globals.fs.path.basename(engineOutPath)}');
// Tell Xcode not to build universal binaries for local engines, which are
// single-architecture.
@@ -226,7 +225,7 @@
static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+)');
void _updateVersion() {
- if (!platform.isMacOS || !fs.file(_executable).existsSync()) {
+ if (!globals.platform.isMacOS || !globals.fs.file(_executable).existsSync()) {
return;
}
try {
@@ -289,7 +288,7 @@
final List<String> showBuildSettingsCommand = <String>[
_executable,
'-project',
- fs.path.absolute(projectPath),
+ globals.fs.path.absolute(projectPath),
'-target',
target,
'-showBuildSettings',
@@ -314,7 +313,7 @@
command: showBuildSettingsCommand.join(' '),
).send();
}
- printTrace('Unexpected failure to get the build settings: $error.');
+ globals.printTrace('Unexpected failure to get the build settings: $error.');
return const <String, String>{};
} finally {
status.stop();
@@ -331,7 +330,7 @@
'-quiet',
'clean',
...environmentVariablesAsXcodeBuildSettings()
- ], workingDirectory: fs.currentDirectory.path);
+ ], workingDirectory: globals.fs.currentDirectory.path);
}
Future<XcodeProjectInfo> getInfo(String projectPath, {String projectFilename}) async {
@@ -362,7 +361,7 @@
/// environment without requiring settings changes in the Xcode project.
List<String> environmentVariablesAsXcodeBuildSettings() {
const String xcodeBuildSettingPrefix = 'FLUTTER_XCODE_';
- return platform.environment.entries.where((MapEntry<String, String> mapEntry) {
+ return globals.platform.environment.entries.where((MapEntry<String, String> mapEntry) {
return mapEntry.key.startsWith(xcodeBuildSettingPrefix);
}).expand<String>((MapEntry<String, String> mapEntry) {
// Remove FLUTTER_XCODE_ prefix from the environment variable to get the build setting.
diff --git a/packages/flutter_tools/lib/src/linux/application_package.dart b/packages/flutter_tools/lib/src/linux/application_package.dart
index 398836b..13568eb 100644
--- a/packages/flutter_tools/lib/src/linux/application_package.dart
+++ b/packages/flutter_tools/lib/src/linux/application_package.dart
@@ -7,6 +7,7 @@
import '../application_package.dart';
import '../base/file_system.dart';
import '../build_info.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import 'makefile.dart';
@@ -58,7 +59,7 @@
@override
String executable(BuildMode buildMode) {
final String binaryName = makefileExecutableName(project);
- return fs.path.join(getLinuxBuildDirectory(), getNameForBuildMode(buildMode), binaryName);
+ return globals.fs.path.join(getLinuxBuildDirectory(), getNameForBuildMode(buildMode), binaryName);
}
@override
diff --git a/packages/flutter_tools/lib/src/linux/build_linux.dart b/packages/flutter_tools/lib/src/linux/build_linux.dart
index 817c4e6..92e896a 100644
--- a/packages/flutter_tools/lib/src/linux/build_linux.dart
+++ b/packages/flutter_tools/lib/src/linux/build_linux.dart
@@ -4,12 +4,11 @@
import '../artifacts.dart';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
@@ -22,11 +21,11 @@
export FLUTTER_TARGET=$target
export PROJECT_DIR=${linuxProject.project.directory.path}
''');
- if (artifacts is LocalEngineArtifacts) {
- final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
+ if (globals.artifacts is LocalEngineArtifacts) {
+ final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath;
- buffer.writeln('export FLUTTER_ENGINE=${fs.path.dirname(fs.path.dirname(engineOutPath))}');
- buffer.writeln('export LOCAL_ENGINE=${fs.path.basename(engineOutPath)}');
+ buffer.writeln('export FLUTTER_ENGINE=${globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath))}');
+ buffer.writeln('export LOCAL_ENGINE=${globals.fs.path.basename(engineOutPath)}');
}
/// Cache flutter configuration files in the linux directory.
@@ -36,17 +35,17 @@
if (!buildInfo.isDebug) {
const String warning = '🚧 ';
- printStatus(warning * 20);
- printStatus('Warning: Only debug is currently implemented for Linux. This is effectively a debug build.');
- printStatus('See https://github.com/flutter/flutter/issues/38478 for details and updates.');
- printStatus(warning * 20);
- printStatus('');
+ globals.printStatus(warning * 20);
+ globals.printStatus('Warning: Only debug is currently implemented for Linux. This is effectively a debug build.');
+ globals.printStatus('See https://github.com/flutter/flutter/issues/38478 for details and updates.');
+ globals.printStatus(warning * 20);
+ globals.printStatus('');
}
// Invoke make.
final String buildFlag = getNameForBuildMode(buildInfo.mode ?? BuildMode.release);
final Stopwatch sw = Stopwatch()..start();
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Building Linux application...',
timeout: null,
);
diff --git a/packages/flutter_tools/lib/src/linux/linux_device.dart b/packages/flutter_tools/lib/src/linux/linux_device.dart
index 97a899e..2ab1b61 100644
--- a/packages/flutter_tools/lib/src/linux/linux_device.dart
+++ b/packages/flutter_tools/lib/src/linux/linux_device.dart
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import '../base/platform.dart';
import '../build_info.dart';
import '../desktop_device.dart';
import '../device.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import 'application_package.dart';
import 'build_linux.dart';
@@ -56,7 +56,7 @@
LinuxDevices() : super('linux devices');
@override
- bool get supportsPlatform => platform.isLinux;
+ bool get supportsPlatform => globals.platform.isLinux;
@override
bool get canListAnything => linuxWorkflow.canListDevices;
diff --git a/packages/flutter_tools/lib/src/linux/linux_doctor.dart b/packages/flutter_tools/lib/src/linux/linux_doctor.dart
index 6f45a93..2d5665b 100644
--- a/packages/flutter_tools/lib/src/linux/linux_doctor.dart
+++ b/packages/flutter_tools/lib/src/linux/linux_doctor.dart
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import '../base/io.dart';
-import '../base/process_manager.dart';
import '../base/version.dart';
import '../doctor.dart';
+import '../globals.dart' as globals;
/// A validator that checks for Clang and Make build dependencies
class LinuxDoctorValidator extends DoctorValidator {
@@ -21,7 +21,7 @@
/// Check for a minimum version of Clang.
ProcessResult clangResult;
try {
- clangResult = await processManager.run(const <String>[
+ clangResult = await globals.processManager.run(const <String>[
'clang++',
'--version',
]);
@@ -48,7 +48,7 @@
// a better idea about what is supported.
ProcessResult makeResult;
try {
- makeResult = await processManager.run(const <String>[
+ makeResult = await globals.processManager.run(const <String>[
'make',
'--version',
]);
diff --git a/packages/flutter_tools/lib/src/linux/linux_workflow.dart b/packages/flutter_tools/lib/src/linux/linux_workflow.dart
index 964263b..11423d3 100644
--- a/packages/flutter_tools/lib/src/linux/linux_workflow.dart
+++ b/packages/flutter_tools/lib/src/linux/linux_workflow.dart
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/platform.dart';
import '../doctor.dart';
import '../features.dart';
+import '../globals.dart' as globals;
/// The [WindowsWorkflow] instance.
LinuxWorkflow get linuxWorkflow => context.get<LinuxWorkflow>();
@@ -18,13 +18,13 @@
const LinuxWorkflow();
@override
- bool get appliesToHostPlatform => platform.isLinux && featureFlags.isLinuxEnabled;
+ bool get appliesToHostPlatform => globals.platform.isLinux && featureFlags.isLinuxEnabled;
@override
- bool get canLaunchDevices => platform.isLinux && featureFlags.isLinuxEnabled;
+ bool get canLaunchDevices => globals.platform.isLinux && featureFlags.isLinuxEnabled;
@override
- bool get canListDevices => platform.isLinux && featureFlags.isLinuxEnabled;
+ bool get canListDevices => globals.platform.isLinux && featureFlags.isLinuxEnabled;
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/lib/src/macos/application_package.dart b/packages/flutter_tools/lib/src/macos/application_package.dart
index 5727363..5b820fd 100644
--- a/packages/flutter_tools/lib/src/macos/application_package.dart
+++ b/packages/flutter_tools/lib/src/macos/application_package.dart
@@ -8,7 +8,7 @@
import '../base/file_system.dart';
import '../base/utils.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/plist_parser.dart';
import '../project.dart';
@@ -33,7 +33,7 @@
/// port over stdout.
factory MacOSApp.fromPrebuiltApp(FileSystemEntity applicationBinary) {
final _ExecutableAndId executableAndId = _executableFromBundle(applicationBinary);
- final Directory applicationBundle = fs.directory(applicationBinary);
+ final Directory applicationBundle = globals.fs.directory(applicationBinary);
return PrebuiltMacOSApp(
bundleDir: applicationBundle,
bundleName: applicationBundle.path,
@@ -44,38 +44,38 @@
/// Look up the executable name for a macOS application bundle.
static _ExecutableAndId _executableFromBundle(FileSystemEntity applicationBundle) {
- final FileSystemEntityType entityType = fs.typeSync(applicationBundle.path);
+ final FileSystemEntityType entityType = globals.fs.typeSync(applicationBundle.path);
if (entityType == FileSystemEntityType.notFound) {
- printError('File "${applicationBundle.path}" does not exist.');
+ globals.printError('File "${applicationBundle.path}" does not exist.');
return null;
}
Directory bundleDir;
if (entityType == FileSystemEntityType.directory) {
- final Directory directory = fs.directory(applicationBundle);
+ final Directory directory = globals.fs.directory(applicationBundle);
if (!_isBundleDirectory(directory)) {
- printError('Folder "${applicationBundle.path}" is not an app bundle.');
+ globals.printError('Folder "${applicationBundle.path}" is not an app bundle.');
return null;
}
- bundleDir = fs.directory(applicationBundle);
+ bundleDir = globals.fs.directory(applicationBundle);
} else {
- printError('Folder "${applicationBundle.path}" is not an app bundle.');
+ globals.printError('Folder "${applicationBundle.path}" is not an app bundle.');
return null;
}
- final String plistPath = fs.path.join(bundleDir.path, 'Contents', 'Info.plist');
- if (!fs.file(plistPath).existsSync()) {
- printError('Invalid prebuilt macOS app. Does not contain Info.plist.');
+ final String plistPath = globals.fs.path.join(bundleDir.path, 'Contents', 'Info.plist');
+ if (!globals.fs.file(plistPath).existsSync()) {
+ globals.printError('Invalid prebuilt macOS app. Does not contain Info.plist.');
return null;
}
final Map<String, dynamic> propertyValues = PlistParser.instance.parseFile(plistPath);
final String id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String;
final String executableName = propertyValues[PlistParser.kCFBundleExecutable] as String;
if (id == null) {
- printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier');
+ globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier');
return null;
}
- final String executable = fs.path.join(bundleDir.path, 'Contents', 'MacOS', executableName);
- if (!fs.file(executable).existsSync()) {
- printError('Could not find macOS binary at $executable');
+ final String executable = globals.fs.path.join(bundleDir.path, 'Contents', 'MacOS', executableName);
+ if (!globals.fs.file(executable).existsSync()) {
+ globals.printError('Could not find macOS binary at $executable');
}
return _ExecutableAndId(executable, id);
}
@@ -125,10 +125,10 @@
String applicationBundle(BuildMode buildMode) {
final File appBundleNameFile = project.nameFile;
if (!appBundleNameFile.existsSync()) {
- printError('Unable to find app name. ${appBundleNameFile.path} does not exist');
+ globals.printError('Unable to find app name. ${appBundleNameFile.path} does not exist');
return null;
}
- return fs.path.join(
+ return globals.fs.path.join(
getMacOSBuildDirectory(),
'Build',
'Products',
@@ -142,7 +142,7 @@
if (directory == null) {
return null;
}
- final _ExecutableAndId executableAndId = MacOSApp._executableFromBundle(fs.directory(directory));
+ final _ExecutableAndId executableAndId = MacOSApp._executableFromBundle(globals.fs.directory(directory));
return executableAndId?.executable;
}
}
diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart
index 40e3f99..da6de5e 100644
--- a/packages/flutter_tools/lib/src/macos/build_macos.dart
+++ b/packages/flutter_tools/lib/src/macos/build_macos.dart
@@ -7,7 +7,7 @@
import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/xcodeproj.dart';
import '../project.dart';
import '../reporting/reporting.dart';
@@ -20,7 +20,7 @@
BuildInfo buildInfo,
String targetOverride,
}) async {
- final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory());
+ final Directory flutterBuildDir = globals.fs.directory(getMacOSBuildDirectory());
if (!flutterBuildDir.existsSync()) {
flutterBuildDir.createSync(recursive: true);
}
@@ -62,7 +62,7 @@
// Run the Xcode build.
final Stopwatch sw = Stopwatch()..start();
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Building macOS application...',
timeout: null,
);
@@ -76,8 +76,8 @@
'-configuration', '$configuration',
'-scheme', 'Runner',
'-derivedDataPath', flutterBuildDir.absolute.path,
- 'OBJROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
- 'SYMROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
+ 'OBJROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
+ 'SYMROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
'COMPILER_INDEX_STORE_ENABLE=NO',
...environmentVariablesAsXcodeBuildSettings()
], trace: true);
diff --git a/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart b/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
index 5c673d6..8fc4169 100644
--- a/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
+++ b/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
@@ -4,9 +4,9 @@
import 'dart:async';
-import '../base/file_system.dart';
import '../base/fingerprint.dart';
import '../build_info.dart';
+import '../globals.dart' as globals;
import '../ios/xcodeproj.dart';
import '../plugins.dart';
import '../project.dart';
@@ -24,7 +24,7 @@
// If the Xcode project, Podfile, or generated xcconfig have changed since
// last run, pods should be updated.
final Fingerprinter fingerprinter = Fingerprinter(
- fingerprintPath: fs.path.join(buildDirectory, 'pod_inputs.fingerprint'),
+ fingerprintPath: globals.fs.path.join(buildDirectory, 'pod_inputs.fingerprint'),
paths: <String>[
xcodeProject.xcodeProjectInfoFile.path,
xcodeProject.podfile.path,
diff --git a/packages/flutter_tools/lib/src/macos/cocoapods.dart b/packages/flutter_tools/lib/src/macos/cocoapods.dart
index ca29dee..e0ba702 100644
--- a/packages/flutter_tools/lib/src/macos/cocoapods.dart
+++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart
@@ -12,12 +12,10 @@
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
-import '../base/platform.dart';
import '../base/process.dart';
-import '../base/process_manager.dart';
import '../base/version.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../ios/xcodeproj.dart';
import '../project.dart';
@@ -130,8 +128,9 @@
if (installedVersion != null && installedVersion >= Version.parse('1.8.0')) {
return true;
}
- final String cocoapodsReposDir = platform.environment['CP_REPOS_DIR'] ?? fs.path.join(homeDirPath, '.cocoapods', 'repos');
- return fs.isDirectory(fs.path.join(cocoapodsReposDir, 'master'));
+ final String cocoapodsReposDir = globals.platform.environment['CP_REPOS_DIR']
+ ?? globals.fs.path.join(homeDirPath, '.cocoapods', 'repos');
+ return globals.fs.isDirectory(globals.fs.path.join(cocoapodsReposDir, 'master'));
}
Future<bool> processPods({
@@ -159,7 +158,7 @@
final CocoaPodsStatus installation = await evaluateCocoaPodsInstallation;
switch (installation) {
case CocoaPodsStatus.notInstalled:
- printError(
+ globals.printError(
'Warning: CocoaPods not installed. Skipping pod install.\n'
'$noCocoaPodsConsequence\n'
'To install:\n'
@@ -168,7 +167,7 @@
);
return false;
case CocoaPodsStatus.unknownVersion:
- printError(
+ globals.printError(
'Warning: Unknown CocoaPods version installed.\n'
'$unknownCocoaPodsConsequence\n'
'To upgrade:\n'
@@ -177,7 +176,7 @@
);
break;
case CocoaPodsStatus.belowMinimumVersion:
- printError(
+ globals.printError(
'Warning: CocoaPods minimum required version $cocoaPodsMinimumVersion or greater not installed. Skipping pod install.\n'
'$noCocoaPodsConsequence\n'
'To upgrade:\n'
@@ -186,7 +185,7 @@
);
return false;
case CocoaPodsStatus.belowRecommendedVersion:
- printError(
+ globals.printError(
'Warning: CocoaPods recommended version $cocoaPodsRecommendedVersion or greater not installed.\n'
'Pods handling may fail on some projects involving plugins.\n'
'To upgrade:\n'
@@ -198,7 +197,7 @@
break;
}
if (!await isCocoaPodsInitialized) {
- printError(
+ globals.printError(
'Warning: CocoaPods installed but not initialized. Skipping pod install.\n'
'$noCocoaPodsConsequence\n'
'To initialize CocoaPods, run:\n'
@@ -239,7 +238,7 @@
)).containsKey('SWIFT_VERSION');
podfileTemplateName = isSwift ? 'Podfile-ios-swift' : 'Podfile-ios-objc';
}
- final File podfileTemplate = fs.file(fs.path.join(
+ final File podfileTemplate = globals.fs.file(globals.fs.path.join(
Cache.flutterRoot,
'packages',
'flutter_tools',
@@ -300,10 +299,10 @@
}
Future<void> _runPodInstall(XcodeBasedProject xcodeProject, String engineDirectory) async {
- final Status status = logger.startProgress('Running pod install...', timeout: timeoutConfiguration.slowOperation);
- final ProcessResult result = await processManager.run(
+ final Status status = globals.logger.startProgress('Running pod install...', timeout: timeoutConfiguration.slowOperation);
+ final ProcessResult result = await globals.processManager.run(
<String>['pod', 'install', '--verbose'],
- workingDirectory: fs.path.dirname(xcodeProject.podfile.path),
+ workingDirectory: globals.fs.path.dirname(xcodeProject.podfile.path),
environment: <String, String>{
'FLUTTER_FRAMEWORK_DIR': engineDirectory,
// See https://github.com/flutter/flutter/issues/10873.
@@ -313,16 +312,16 @@
},
);
status.stop();
- if (logger.isVerbose || result.exitCode != 0) {
+ if (globals.logger.isVerbose || result.exitCode != 0) {
final String stdout = result.stdout as String;
if (stdout.isNotEmpty) {
- printStatus('CocoaPods\' output:\n↳');
- printStatus(stdout, indent: 4);
+ globals.printStatus('CocoaPods\' output:\n↳');
+ globals.printStatus(stdout, indent: 4);
}
final String stderr = result.stderr as String;
if (stderr.isNotEmpty) {
- printStatus('Error output from CocoaPods:\n↳');
- printStatus(stderr, indent: 4);
+ globals.printStatus('Error output from CocoaPods:\n↳');
+ globals.printStatus(stderr, indent: 4);
}
}
if (result.exitCode != 0) {
@@ -335,7 +334,7 @@
void _diagnosePodInstallFailure(ProcessResult result) {
final dynamic stdout = result.stdout;
if (stdout is String && stdout.contains('out-of-date source repos')) {
- printError(
+ globals.printError(
"Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.\n"
'To update the CocoaPods specs, run:\n'
' pod repo update\n',
@@ -355,12 +354,12 @@
if (xcodeProject is! IosProject) {
return;
}
- final Link flutterSymlink = fs.link(fs.path.join(
+ final Link flutterSymlink = globals.fs.link(globals.fs.path.join(
xcodeProject.symlinks.path,
'flutter',
));
if (flutterSymlink.existsSync()) {
- printError(
+ globals.printError(
'Warning: Podfile is out of date\n'
'$outOfDatePodfileConsequence\n'
'To regenerate the Podfile, run:\n'
diff --git a/packages/flutter_tools/lib/src/macos/macos_device.dart b/packages/flutter_tools/lib/src/macos/macos_device.dart
index bbdceaa..d0448d2 100644
--- a/packages/flutter_tools/lib/src/macos/macos_device.dart
+++ b/packages/flutter_tools/lib/src/macos/macos_device.dart
@@ -3,11 +3,10 @@
// found in the LICENSE file.
import '../base/io.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
import '../build_info.dart';
import '../desktop_device.dart';
import '../device.dart';
+import '../globals.dart' as globals;
import '../macos/application_package.dart';
import '../project.dart';
import 'build_macos.dart';
@@ -59,7 +58,7 @@
// than post-attach, since this won't run for release builds, but there's
// no general-purpose way of knowing when a process is far enoug along in
// the launch process for 'open' to foreground it.
- processManager.run(<String>[
+ globals.processManager.run(<String>[
'open', package.applicationBundle(buildMode),
]).then((ProcessResult result) {
if (result.exitCode != 0) {
@@ -73,7 +72,7 @@
MacOSDevices() : super('macOS devices');
@override
- bool get supportsPlatform => platform.isMacOS;
+ bool get supportsPlatform => globals.platform.isMacOS;
@override
bool get canListAnything => macOSWorkflow.canListDevices;
diff --git a/packages/flutter_tools/lib/src/macos/macos_workflow.dart b/packages/flutter_tools/lib/src/macos/macos_workflow.dart
index 2d5d4a5..0ae1ae4 100644
--- a/packages/flutter_tools/lib/src/macos/macos_workflow.dart
+++ b/packages/flutter_tools/lib/src/macos/macos_workflow.dart
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/platform.dart';
import '../doctor.dart';
import '../features.dart';
+import '../globals.dart' as globals;
/// The [MacOSWorkflow] instance.
MacOSWorkflow get macOSWorkflow => context.get<MacOSWorkflow>();
@@ -18,13 +18,13 @@
const MacOSWorkflow();
@override
- bool get appliesToHostPlatform => platform.isMacOS && featureFlags.isMacOSEnabled;
+ bool get appliesToHostPlatform => globals.platform.isMacOS && featureFlags.isMacOSEnabled;
@override
- bool get canLaunchDevices => platform.isMacOS && featureFlags.isMacOSEnabled;
+ bool get canLaunchDevices => globals.platform.isMacOS && featureFlags.isMacOSEnabled;
@override
- bool get canListDevices => platform.isMacOS && featureFlags.isMacOSEnabled;
+ bool get canListDevices => globals.platform.isMacOS && featureFlags.isMacOSEnabled;
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/lib/src/macos/xcode.dart b/packages/flutter_tools/lib/src/macos/xcode.dart
index 6c40ce8..51c9f71 100644
--- a/packages/flutter_tools/lib/src/macos/xcode.dart
+++ b/packages/flutter_tools/lib/src/macos/xcode.dart
@@ -6,10 +6,9 @@
import '../base/common.dart';
import '../base/context.dart';
-import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
import '../base/process.dart';
+import '../globals.dart' as globals;
import '../ios/xcodeproj.dart';
const int kXcodeRequiredVersionMajor = 10;
@@ -43,7 +42,7 @@
}
class Xcode {
- bool get isInstalledAndMeetsVersionCheck => platform.isMacOS && isInstalled && isVersionSatisfactory;
+ bool get isInstalledAndMeetsVersionCheck => globals.platform.isMacOS && isInstalled && isVersionSatisfactory;
String _xcodeSelectPath;
String get xcodeSelectPath {
@@ -159,10 +158,10 @@
return null;
}
final List<String> searchPaths = <String>[
- fs.path.join(xcodeSelectPath, 'Applications', 'Simulator.app'),
+ globals.fs.path.join(xcodeSelectPath, 'Applications', 'Simulator.app'),
];
return searchPaths.where((String p) => p != null).firstWhere(
- (String p) => fs.directory(p).existsSync(),
+ (String p) => globals.fs.directory(p).existsSync(),
orElse: () => null,
);
}
diff --git a/packages/flutter_tools/lib/src/mdns_discovery.dart b/packages/flutter_tools/lib/src/mdns_discovery.dart
index 3ee58c7..033e097 100644
--- a/packages/flutter_tools/lib/src/mdns_discovery.dart
+++ b/packages/flutter_tools/lib/src/mdns_discovery.dart
@@ -12,7 +12,7 @@
import 'base/io.dart';
import 'build_info.dart';
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'reporting/reporting.dart';
/// A wrapper around [MDnsClient] to find a Dart observatory instance.
@@ -54,7 +54,7 @@
/// the Observatory instance is for.
// TODO(jonahwilliams): use `deviceVmservicePort` to filter mdns results.
Future<MDnsObservatoryDiscoveryResult> query({String applicationId, int deviceVmservicePort}) async {
- printTrace('Checking for advertised Dart observatories...');
+ globals.printTrace('Checking for advertised Dart observatories...');
try {
await client.start();
final List<PtrResourceRecord> pointerRecords = await client
@@ -63,7 +63,7 @@
)
.toList();
if (pointerRecords.isEmpty) {
- printTrace('No pointer records found.');
+ globals. printTrace('No pointer records found.');
return null;
}
// We have no guarantee that we won't get multiple hits from the same
@@ -96,7 +96,7 @@
} else {
domainName = pointerRecords[0].domainName;
}
- printTrace('Checking for available port on $domainName');
+ globals.printTrace('Checking for available port on $domainName');
// Here, if we get more than one, it should just be a duplicate.
final List<SrvResourceRecord> srv = await client
.lookup<SrvResourceRecord>(
@@ -107,10 +107,10 @@
return null;
}
if (srv.length > 1) {
- printError('Unexpectedly found more than one observatory report for $domainName '
+ globals.printError('Unexpectedly found more than one observatory report for $domainName '
'- using first one (${srv.first.port}).');
}
- printTrace('Checking for authentication code for $domainName');
+ globals.printTrace('Checking for authentication code for $domainName');
final List<TxtResourceRecord> txt = await client
.lookup<TxtResourceRecord>(
ResourceRecordQuery.text(domainName),
@@ -168,14 +168,14 @@
// If there's not an ipv4 link local address in `NetworkInterfaces.list`,
// then request user interventions with a `printError()` if possible.
Future<void> _checkForIPv4LinkLocal(Device device) async {
- printTrace(
+ globals.printTrace(
'mDNS query failed. Checking for an interface with a ipv4 link local address.'
);
final List<NetworkInterface> interfaces = await listNetworkInterfaces(
includeLinkLocal: true,
type: InternetAddressType.IPv4,
);
- if (logger.isVerbose) {
+ if (globals.logger.isVerbose) {
_logInterfaces(interfaces);
}
final bool hasIPv4LinkLocal = interfaces.any(
@@ -184,14 +184,14 @@
),
);
if (hasIPv4LinkLocal) {
- printTrace('An interface with an ipv4 link local address was found.');
+ globals.printTrace('An interface with an ipv4 link local address was found.');
return;
}
final TargetPlatform targetPlatform = await device.targetPlatform;
switch (targetPlatform) {
case TargetPlatform.ios:
UsageEvent('ios-mdns', 'no-ipv4-link-local').send();
- printError(
+ globals.printError(
'The mDNS query for an attached iOS device failed. It may '
'be necessary to disable the "Personal Hotspot" on the device, and '
'to ensure that the "Disable unless needed" setting is unchecked '
@@ -200,18 +200,18 @@
);
break;
default:
- printTrace('No interface with an ipv4 link local address was found.');
+ globals.printTrace('No interface with an ipv4 link local address was found.');
break;
}
}
void _logInterfaces(List<NetworkInterface> interfaces) {
for (NetworkInterface interface in interfaces) {
- if (logger.isVerbose) {
- printTrace('Found interface "${interface.name}":');
+ if (globals.logger.isVerbose) {
+ globals.printTrace('Found interface "${interface.name}":');
for (InternetAddress address in interface.addresses) {
final String linkLocal = address.isLinkLocal ? 'link local' : '';
- printTrace('\tBound address: "${address.address}" $linkLocal');
+ globals.printTrace('\tBound address: "${address.address}" $linkLocal');
}
}
}
diff --git a/packages/flutter_tools/lib/src/persistent_tool_state.dart b/packages/flutter_tools/lib/src/persistent_tool_state.dart
index dd1c463..181131d 100644
--- a/packages/flutter_tools/lib/src/persistent_tool_state.dart
+++ b/packages/flutter_tools/lib/src/persistent_tool_state.dart
@@ -5,6 +5,7 @@
import 'base/config.dart';
import 'base/context.dart';
import 'base/file_system.dart';
+import 'globals.dart' as globals;
PersistentToolState get persistentToolState => PersistentToolState.instance;
@@ -24,7 +25,7 @@
class _DefaultPersistentToolState implements PersistentToolState {
_DefaultPersistentToolState([File configFile]) :
- _config = Config(configFile ?? fs.file(fs.path.join(userHomePath(), _kFileName)));
+ _config = Config(configFile ?? globals.fs.file(globals.fs.path.join(userHomePath(), _kFileName)));
static const String _kFileName = '.flutter_tool_state';
static const String _kRedisplayWelcomeMessage = 'redisplay-welcome-message';
diff --git a/packages/flutter_tools/lib/src/platform_plugins.dart b/packages/flutter_tools/lib/src/platform_plugins.dart
index fd8aeaf..f791c1d 100644
--- a/packages/flutter_tools/lib/src/platform_plugins.dart
+++ b/packages/flutter_tools/lib/src/platform_plugins.dart
@@ -7,6 +7,7 @@
import 'base/common.dart';
import 'base/file_system.dart';
+import 'globals.dart' as globals;
/// Marker interface for all platform specific plugin config impls.
abstract class PluginPlatform {
@@ -78,28 +79,28 @@
Set<String> _getSupportedEmbeddings() {
assert(pluginPath != null);
final Set<String> supportedEmbeddings = <String>{};
- final String baseMainPath = fs.path.join(
+ final String baseMainPath = globals.fs.path.join(
pluginPath,
'android',
'src',
'main',
);
- File mainPluginClass = fs.file(
- fs.path.join(
+ File mainPluginClass = globals.fs.file(
+ globals.fs.path.join(
baseMainPath,
'java',
- package.replaceAll('.', fs.path.separator),
+ package.replaceAll('.', globals.fs.path.separator),
'$pluginClass.java',
)
);
// Check if the plugin is implemented in Kotlin since the plugin's pubspec.yaml
// doesn't include this information.
if (!mainPluginClass.existsSync()) {
- mainPluginClass = fs.file(
- fs.path.join(
+ mainPluginClass = globals.fs.file(
+ globals.fs.path.join(
baseMainPath,
'kotlin',
- package.replaceAll('.', fs.path.separator),
+ package.replaceAll('.', globals.fs.path.separator),
'$pluginClass.kt',
)
);
diff --git a/packages/flutter_tools/lib/src/plugins.dart b/packages/flutter_tools/lib/src/plugins.dart
index 8d5ed93..22f506b 100644
--- a/packages/flutter_tools/lib/src/plugins.dart
+++ b/packages/flutter_tools/lib/src/plugins.dart
@@ -14,7 +14,7 @@
import 'convert.dart';
import 'dart/package_map.dart';
import 'features.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'macos/cocoapods.dart';
import 'platform_plugins.dart';
import 'project.dart';
@@ -22,7 +22,7 @@
void _renderTemplateToFile(String template, dynamic context, String filePath) {
final String renderedTemplate =
mustache.Template(template, htmlEscapeValues: false).renderString(context);
- final File file = fs.file(filePath);
+ final File file = globals.fs.file(filePath);
file.createSync(recursive: true);
file.writeAsStringSync(renderedTemplate);
}
@@ -264,11 +264,11 @@
}
Plugin _pluginFromPubspec(String name, Uri packageRoot) {
- final String pubspecPath = fs.path.fromUri(packageRoot.resolve('pubspec.yaml'));
- if (!fs.isFileSync(pubspecPath)) {
+ final String pubspecPath = globals.fs.path.fromUri(packageRoot.resolve('pubspec.yaml'));
+ if (!globals.fs.isFileSync(pubspecPath)) {
return null;
}
- final dynamic pubspec = loadYaml(fs.file(pubspecPath).readAsStringSync());
+ final dynamic pubspec = loadYaml(globals.fs.file(pubspecPath).readAsStringSync());
if (pubspec == null) {
return null;
}
@@ -276,9 +276,9 @@
if (flutterConfig == null || !(flutterConfig.containsKey('plugin') as bool)) {
return null;
}
- final String packageRootPath = fs.path.fromUri(packageRoot);
+ final String packageRootPath = globals.fs.path.fromUri(packageRoot);
final YamlMap dependencies = pubspec['dependencies'] as YamlMap;
- printTrace('Found plugin $name at $packageRootPath');
+ globals.printTrace('Found plugin $name at $packageRootPath');
return Plugin.fromYaml(
name,
packageRootPath,
@@ -291,13 +291,13 @@
final List<Plugin> plugins = <Plugin>[];
Map<String, Uri> packages;
try {
- final String packagesFile = fs.path.join(
+ final String packagesFile = globals.fs.path.join(
project.directory.path,
PackageMap.globalPackagesPath,
);
packages = PackageMap(packagesFile).map;
} on FormatException catch (e) {
- printTrace('Invalid .packages file: $e');
+ globals.printTrace('Invalid .packages file: $e');
return plugins;
}
packages.forEach((String name, Uri uri) {
@@ -464,13 +464,13 @@
'plugins': androidPlugins,
'androidX': isAppUsingAndroidX(project.android.hostAppGradleRoot),
};
- final String javaSourcePath = fs.path.join(
+ final String javaSourcePath = globals.fs.path.join(
project.android.pluginRegistrantHost.path,
'src',
'main',
'java',
);
- final String registryPath = fs.path.join(
+ final String registryPath = globals.fs.path.join(
javaSourcePath,
'io',
'flutter',
@@ -488,7 +488,7 @@
if (plugin['supportsEmbeddingV1'] as bool && !(plugin['supportsEmbeddingV2'] as bool)) {
templateContext['needsShim'] = true;
if (project.isModule) {
- printStatus(
+ globals.printStatus(
'The plugin `${plugin['name']}` is built using an older version '
"of the Android plugin API which assumes that it's running in a "
'full-Flutter environment. It may have undefined behaviors when '
@@ -516,7 +516,7 @@
templateContent = _androidPluginRegistryTemplateOldEmbedding;
break;
}
- printTrace('Generating $registryPath');
+ globals.printTrace('Generating $registryPath');
_renderTemplateToFile(
templateContent,
templateContext,
@@ -678,32 +678,32 @@
};
final String registryDirectory = project.ios.pluginRegistrantHost.path;
if (project.isModule) {
- final String registryClassesDirectory = fs.path.join(registryDirectory, 'Classes');
+ final String registryClassesDirectory = globals.fs.path.join(registryDirectory, 'Classes');
_renderTemplateToFile(
_pluginRegistrantPodspecTemplate,
context,
- fs.path.join(registryDirectory, 'FlutterPluginRegistrant.podspec'),
+ globals.fs.path.join(registryDirectory, 'FlutterPluginRegistrant.podspec'),
);
_renderTemplateToFile(
_objcPluginRegistryHeaderTemplate,
context,
- fs.path.join(registryClassesDirectory, 'GeneratedPluginRegistrant.h'),
+ globals.fs.path.join(registryClassesDirectory, 'GeneratedPluginRegistrant.h'),
);
_renderTemplateToFile(
_objcPluginRegistryImplementationTemplate,
context,
- fs.path.join(registryClassesDirectory, 'GeneratedPluginRegistrant.m'),
+ globals.fs.path.join(registryClassesDirectory, 'GeneratedPluginRegistrant.m'),
);
} else {
_renderTemplateToFile(
_objcPluginRegistryHeaderTemplate,
context,
- fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.h'),
+ globals.fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.h'),
);
_renderTemplateToFile(
_objcPluginRegistryImplementationTemplate,
context,
- fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.m'),
+ globals.fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.m'),
);
}
}
@@ -727,7 +727,7 @@
_renderTemplateToFile(
_swiftPluginRegistryTemplate,
context,
- fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.swift'),
+ globals.fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.swift'),
);
}
@@ -744,12 +744,12 @@
_renderTemplateToFile(
_cppPluginRegistryHeaderTemplate,
templateContext,
- fs.path.join(registryDirectory, 'generated_plugin_registrant.h'),
+ globals.fs.path.join(registryDirectory, 'generated_plugin_registrant.h'),
);
_renderTemplateToFile(
_cppPluginRegistryImplementationTemplate,
templateContext,
- fs.path.join(registryDirectory, 'generated_plugin_registrant.cc'),
+ globals.fs.path.join(registryDirectory, 'generated_plugin_registrant.cc'),
);
}
@@ -759,9 +759,9 @@
'plugins': webPlugins,
};
final String registryDirectory = project.web.libDirectory.path;
- final String filePath = fs.path.join(registryDirectory, 'generated_plugin_registrant.dart');
+ final String filePath = globals.fs.path.join(registryDirectory, 'generated_plugin_registrant.dart');
if (webPlugins.isEmpty) {
- final File file = fs.file(filePath);
+ final File file = globals.fs.file(filePath);
if (file.existsSync()) {
file.deleteSync();
}
diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index 04d2850..234a266 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -15,10 +15,9 @@
import 'base/file_system.dart';
import 'build_info.dart';
import 'bundle.dart' as bundle;
-import 'cache.dart';
import 'features.dart';
import 'flutter_manifest.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'ios/plist_parser.dart';
import 'ios/xcodeproj.dart' as xcode;
import 'plugins.dart';
@@ -73,11 +72,11 @@
/// Returns a [FlutterProject] view of the current directory or a ToolExit error,
/// if `pubspec.yaml` or `example/pubspec.yaml` is invalid.
- static FlutterProject current() => fromDirectory(fs.currentDirectory);
+ static FlutterProject current() => fromDirectory(globals.fs.currentDirectory);
/// Returns a [FlutterProject] view of the given directory or a ToolExit error,
/// if `pubspec.yaml` or `example/pubspec.yaml` is invalid.
- static FlutterProject fromPath(String path) => fromDirectory(fs.directory(path));
+ static FlutterProject fromPath(String path) => fromDirectory(globals.fs.directory(path));
/// The location of this project.
final Directory directory;
@@ -192,8 +191,8 @@
try {
manifest = FlutterManifest.createFromPath(path);
} on YamlException catch (e) {
- printStatus('Error detected in pubspec.yaml:', emphasis: true);
- printError('$e');
+ globals.printStatus('Error detected in pubspec.yaml:', emphasis: true);
+ globals.printError('$e');
}
if (manifest == null) {
throwToolExit('Please correct the pubspec.yaml file at $path');
@@ -455,7 +454,7 @@
}
Future<void> _updateGeneratedXcodeConfigIfNeeded() async {
- if (Cache.instance.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
+ if (globals.cache.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
await xcode.updateGeneratedXcodeProperties(
project: parent,
buildInfo: BuildInfo.debug,
@@ -469,7 +468,7 @@
return;
}
final bool pubspecChanged = isOlderThanReference(entity: ephemeralDirectory, referenceFile: parent.pubspecFile);
- final bool toolingChanged = Cache.instance.isOlderThanToolsStamp(ephemeralDirectory);
+ final bool toolingChanged = globals.cache.isOlderThanToolsStamp(ephemeralDirectory);
if (!pubspecChanged && !toolingChanged) {
return;
}
@@ -479,18 +478,18 @@
.childDirectory('engine');
_deleteIfExistsSync(ephemeralDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'library'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'library'), ephemeralDirectory);
// Add ephemeral host app, if a editable host app does not already exist.
if (!_editableDirectory.existsSync()) {
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'host_app_ephemeral'), ephemeralDirectory);
if (hasPlugins(parent)) {
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral_cocoapods'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'host_app_ephemeral_cocoapods'), ephemeralDirectory);
}
// Copy podspec and framework from engine cache. The actual build mode
// doesn't actually matter as it will be overwritten by xcode_backend.sh.
// However, cocoapods will run before that script and requires something
// to be in this location.
- final Directory framework = fs.directory(artifacts.getArtifactPath(Artifact.flutterFramework,
+ final Directory framework = globals.fs.directory(globals.artifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: BuildMode.debug));
if (framework.existsSync()) {
final File podspec = framework.parent.childFile('Flutter.podspec');
@@ -506,10 +505,10 @@
throwToolExit('iOS host app is already editable. To start fresh, delete the ios/ folder.');
}
_deleteIfExistsSync(ephemeralDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'library'), ephemeralDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral'), _editableDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral_cocoapods'), _editableDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_editable_cocoapods'), _editableDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'library'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'host_app_ephemeral'), _editableDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'host_app_ephemeral_cocoapods'), _editableDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'ios', 'host_app_editable_cocoapods'), _editableDirectory);
await _updateGeneratedXcodeConfigIfNeeded();
await injectPlugins(parent);
}
@@ -583,14 +582,14 @@
File get appManifestFile {
return isUsingGradle
- ? fs.file(fs.path.join(hostAppGradleRoot.path, 'app', 'src', 'main', 'AndroidManifest.xml'))
+ ? globals.fs.file(globals.fs.path.join(hostAppGradleRoot.path, 'app', 'src', 'main', 'AndroidManifest.xml'))
: hostAppGradleRoot.childFile('AndroidManifest.xml');
}
File get gradleAppOutV1File => gradleAppOutV1Directory.childFile('app-debug.apk');
Directory get gradleAppOutV1Directory {
- return fs.directory(fs.path.join(hostAppGradleRoot.path, 'app', 'build', 'outputs', 'apk'));
+ return globals.fs.directory(globals.fs.path.join(hostAppGradleRoot.path, 'app', 'build', 'outputs', 'apk'));
}
/// Whether the current flutter project has an Android sub-project.
@@ -622,8 +621,8 @@
_regenerateLibrary();
// Add ephemeral host app, if an editable host app does not already exist.
if (!_editableHostAppDirectory.existsSync()) {
- _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), ephemeralDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_ephemeral'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'android', 'host_app_common'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'android', 'host_app_ephemeral'), ephemeralDirectory);
}
}
if (!hostAppGradleRoot.existsSync()) {
@@ -634,7 +633,7 @@
bool _shouldRegenerateFromTemplate() {
return isOlderThanReference(entity: ephemeralDirectory, referenceFile: parent.pubspecFile)
- || Cache.instance.isOlderThanToolsStamp(ephemeralDirectory);
+ || globals.cache.isOlderThanToolsStamp(ephemeralDirectory);
}
Future<void> makeHostAppEditable() async {
@@ -643,9 +642,9 @@
throwToolExit('Android host app is already editable. To start fresh, delete the android/ folder.');
}
_regenerateLibrary();
- _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _editableHostAppDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_editable'), _editableHostAppDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'android', 'gradle'), _editableHostAppDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'android', 'host_app_common'), _editableHostAppDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'android', 'host_app_editable'), _editableHostAppDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'android', 'gradle'), _editableHostAppDirectory);
gradle.gradleUtils.injectGradleWrapperIfNeeded(_editableHostAppDirectory);
gradle.writeLocalProperties(_editableHostAppDirectory.childFile('local.properties'));
await injectPlugins(parent);
@@ -657,12 +656,12 @@
void _regenerateLibrary() {
_deleteIfExistsSync(ephemeralDirectory);
- _overwriteFromTemplate(fs.path.join(
+ _overwriteFromTemplate(globals.fs.path.join(
'module',
'android',
featureFlags.isAndroidEmbeddingV2Enabled ? 'library_new_embedding' : 'library',
), ephemeralDirectory);
- _overwriteFromTemplate(fs.path.join('module', 'android', 'gradle'), ephemeralDirectory);
+ _overwriteFromTemplate(globals.fs.path.join('module', 'android', 'gradle'), ephemeralDirectory);
gradle.gradleUtils.injectGradleWrapperIfNeeded(ephemeralDirectory);
}
@@ -848,7 +847,7 @@
}
Future<void> _updateGeneratedXcodeConfigIfNeeded() async {
- if (Cache.instance.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
+ if (globals.cache.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
await xcode.updateGeneratedXcodeProperties(
project: parent,
buildInfo: BuildInfo.debug,
diff --git a/packages/flutter_tools/lib/src/protocol_discovery.dart b/packages/flutter_tools/lib/src/protocol_discovery.dart
index bc6dd11..6133048 100644
--- a/packages/flutter_tools/lib/src/protocol_discovery.dart
+++ b/packages/flutter_tools/lib/src/protocol_discovery.dart
@@ -8,7 +8,7 @@
import 'base/io.dart';
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
/// Discovers a specific service protocol on a device, and forwards the service
/// protocol device port to the host.
@@ -117,20 +117,20 @@
return;
}
if (devicePort != null && uri.port != devicePort) {
- printTrace('skipping potential observatory $uri due to device port mismatch');
+ globals.printTrace('skipping potential observatory $uri due to device port mismatch');
return;
}
_uriStreamController.add(uri);
}
Future<Uri> _forwardPort(Uri deviceUri) async {
- printTrace('$serviceName URL on device: $deviceUri');
+ globals.printTrace('$serviceName URL on device: $deviceUri');
Uri hostUri = deviceUri;
if (portForwarder != null) {
final int actualDevicePort = deviceUri.port;
final int actualHostPort = await portForwarder.forward(actualDevicePort, hostPort: hostPort);
- printTrace('Forwarded host port $actualHostPort to device port $actualDevicePort for $serviceName');
+ globals.printTrace('Forwarded host port $actualHostPort to device port $actualDevicePort for $serviceName');
hostUri = deviceUri.replace(port: actualHostPort);
}
diff --git a/packages/flutter_tools/lib/src/proxy_validator.dart b/packages/flutter_tools/lib/src/proxy_validator.dart
index b8be1cf..3a8931e 100644
--- a/packages/flutter_tools/lib/src/proxy_validator.dart
+++ b/packages/flutter_tools/lib/src/proxy_validator.dart
@@ -4,8 +4,8 @@
import 'dart:async';
-import 'base/platform.dart';
import 'doctor.dart';
+import 'globals.dart' as globals;
class ProxyValidator extends DoctorValidator {
ProxyValidator() : super('Proxy Configuration');
@@ -19,8 +19,8 @@
/// an empty string will be returned. Checks for the lowercase version of the
/// environment variable first, then uppercase to match Dart's HTTP implementation.
static String _getEnv(String key) =>
- platform.environment[key.toLowerCase()]?.trim() ??
- platform.environment[key.toUpperCase()]?.trim() ??
+ globals.platform.environment[key.toLowerCase()]?.trim() ??
+ globals.platform.environment[key.toUpperCase()]?.trim() ??
'';
@override
diff --git a/packages/flutter_tools/lib/src/reporting/crash_reporting.dart b/packages/flutter_tools/lib/src/reporting/crash_reporting.dart
index abf57c5..9c54a9b 100644
--- a/packages/flutter_tools/lib/src/reporting/crash_reporting.dart
+++ b/packages/flutter_tools/lib/src/reporting/crash_reporting.dart
@@ -56,7 +56,7 @@
final Usage _usage = Usage.instance;
Uri get _baseUrl {
- final String overrideUrl = platform.environment['FLUTTER_CRASH_SERVER_BASE_URL'];
+ final String overrideUrl = globals.platform.environment['FLUTTER_CRASH_SERVER_BASE_URL'];
if (overrideUrl != null) {
return Uri.parse(overrideUrl);
@@ -90,7 +90,7 @@
return;
}
- printTrace('Sending crash report to Google.');
+ globals.printTrace('Sending crash report to Google.');
final Uri uri = _baseUrl.replace(
queryParameters: <String, String>{
@@ -103,7 +103,7 @@
req.fields['uuid'] = _usage.clientId;
req.fields['product'] = _kProductId;
req.fields['version'] = flutterVersion;
- req.fields['osName'] = platform.operatingSystem;
+ req.fields['osName'] = globals.platform.operatingSystem;
req.fields['osVersion'] = os.name; // this actually includes version
req.fields['type'] = _kDartTypeId;
req.fields['error_runtime_type'] = '${error.runtimeType}';
@@ -121,17 +121,17 @@
if (resp.statusCode == 200) {
final String reportId = await http.ByteStream(resp.stream)
.bytesToString();
- printTrace('Crash report sent (report ID: $reportId)');
+ globals.printTrace('Crash report sent (report ID: $reportId)');
_crashReportSent = true;
} else {
- printError('Failed to send crash report. Server responded with HTTP status code ${resp.statusCode}');
+ globals.printError('Failed to send crash report. Server responded with HTTP status code ${resp.statusCode}');
}
} catch (sendError, sendStackTrace) {
if (sendError is SocketException || sendError is HttpException) {
- printError('Failed to send crash report due to a network error: $sendError');
+ globals.printError('Failed to send crash report due to a network error: $sendError');
} else {
// If the sender itself crashes, just print. We did our best.
- printError('Crash report sender itself crashed: $sendError\n$sendStackTrace');
+ globals.printError('Crash report sender itself crashed: $sendError\n$sendStackTrace');
}
}
}
diff --git a/packages/flutter_tools/lib/src/reporting/events.dart b/packages/flutter_tools/lib/src/reporting/events.dart
index 10c4e7a..3ed3480 100644
--- a/packages/flutter_tools/lib/src/reporting/events.dart
+++ b/packages/flutter_tools/lib/src/reporting/events.dart
@@ -195,7 +195,7 @@
);
} catch (error) {
// If grabbing the maxRss fails for some reason, just don't send an event.
- printTrace('Querying maxRss failed with error: $error');
+ globals.printTrace('Querying maxRss failed with error: $error');
}
}
}
diff --git a/packages/flutter_tools/lib/src/reporting/github_template.dart b/packages/flutter_tools/lib/src/reporting/github_template.dart
index 922f260..367232e 100644
--- a/packages/flutter_tools/lib/src/reporting/github_template.dart
+++ b/packages/flutter_tools/lib/src/reporting/github_template.dart
@@ -12,7 +12,7 @@
import '../base/net.dart';
import '../convert.dart';
import '../flutter_manifest.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
/// Provide suggested GitHub issue templates to user when Flutter encounters an error.
@@ -106,7 +106,7 @@
}
// Write the last part of the path, which includes the plugin name and version.
// Example: camera-0.5.7+2
- final List<String> pathParts = fs.path.split(pluginParts[1]);
+ final List<String> pathParts = globals.fs.path.split(pluginParts[1]);
description.writeln(pathParts.isEmpty ? pluginParts.first : pathParts.last);
}
}
@@ -123,7 +123,7 @@
Future<String> _shortURL(String fullURL) async {
String url;
try {
- printTrace('Attempting git.io shortener: $fullURL');
+ globals.printTrace('Attempting git.io shortener: $fullURL');
final List<int> bodyBytes = utf8.encode('url=${Uri.encodeQueryComponent(fullURL)}');
final HttpClientRequest request = await _client.postUrl(Uri.parse('https://git.io'));
request.headers.set(HttpHeaders.contentLengthHeader, bodyBytes.length.toString());
@@ -133,10 +133,10 @@
if (response.statusCode == 201) {
url = response.headers[HttpHeaders.locationHeader]?.first;
} else {
- printTrace('Failed to shorten GitHub template URL. Server responded with HTTP status code ${response.statusCode}');
+ globals.printTrace('Failed to shorten GitHub template URL. Server responded with HTTP status code ${response.statusCode}');
}
} catch (sendError) {
- printTrace('Failed to shorten GitHub template URL: $sendError');
+ globals.printTrace('Failed to shorten GitHub template URL: $sendError');
}
return url ?? fullURL;
diff --git a/packages/flutter_tools/lib/src/reporting/reporting.dart b/packages/flutter_tools/lib/src/reporting/reporting.dart
index bae3839..c811303 100644
--- a/packages/flutter_tools/lib/src/reporting/reporting.dart
+++ b/packages/flutter_tools/lib/src/reporting/reporting.dart
@@ -10,17 +10,15 @@
import 'package:meta/meta.dart';
import 'package:usage/usage_io.dart';
-import '../base/config.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/time.dart';
import '../base/utils.dart';
import '../doctor.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../persistent_tool_state.dart';
import '../runner/flutter_command.dart';
import '../version.dart';
diff --git a/packages/flutter_tools/lib/src/reporting/usage.dart b/packages/flutter_tools/lib/src/reporting/usage.dart
index cdb9dd5..b8ceebe 100644
--- a/packages/flutter_tools/lib/src/reporting/usage.dart
+++ b/packages/flutter_tools/lib/src/reporting/usage.dart
@@ -164,8 +164,8 @@
}) {
final FlutterVersion flutterVersion = FlutterVersion.instance;
final String version = versionOverride ?? flutterVersion.getVersionString(redactUnknownBranches: true);
- final bool suppressEnvFlag = platform.environment['FLUTTER_SUPPRESS_ANALYTICS'] == 'true';
- final String logFilePath = logFile ?? platform.environment['FLUTTER_ANALYTICS_LOG_FILE'];
+ final bool suppressEnvFlag = globals.platform.environment['FLUTTER_SUPPRESS_ANALYTICS'] == 'true';
+ final String logFilePath = logFile ?? globals.platform.environment['FLUTTER_ANALYTICS_LOG_FILE'];
final bool usingLogFile = logFilePath != null && logFilePath.isNotEmpty;
if (// To support testing, only allow other signals to supress analytics
@@ -194,7 +194,7 @@
settingsName,
version,
documentDirectory:
- configDirOverride != null ? fs.directory(configDirOverride) : null,
+ configDirOverride != null ? globals.fs.directory(configDirOverride) : null,
);
}
assert(_analytics != null);
@@ -209,15 +209,15 @@
final String enabledFeatures = allFeatures
.where((Feature feature) {
return feature.configSetting != null &&
- Config.instance.getValue(feature.configSetting) == true;
+ globals.config.getValue(feature.configSetting) == true;
})
.map((Feature feature) => feature.configSetting)
.join(',');
_analytics.setSessionValue(cdKey(CustomDimensions.enabledFlutterFeatures), enabledFeatures);
// Record the host as the application installer ID - the context that flutter_tools is running in.
- if (platform.environment.containsKey('FLUTTER_HOST')) {
- _analytics.setSessionValue('aiid', platform.environment['FLUTTER_HOST']);
+ if (globals.platform.environment.containsKey('FLUTTER_HOST')) {
+ _analytics.setSessionValue('aiid', globals.platform.environment['FLUTTER_HOST']);
}
_analytics.analyticsOpt = AnalyticsOpt.optOut;
}
@@ -326,8 +326,8 @@
}
void _printWelcome() {
- printStatus('');
- printStatus('''
+ globals.printStatus('');
+ globals.printStatus('''
╔════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - https://flutter.dev ║
║ ║
@@ -381,7 +381,7 @@
// xcode_backend.sh etc manipulates them.
class LogToFileAnalytics extends AnalyticsMock {
LogToFileAnalytics(String logFilePath) :
- logFile = fs.file(logFilePath)..createSync(recursive: true),
+ logFile = globals.fs.file(logFilePath)..createSync(recursive: true),
super(true);
final File logFile;
diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart
index aaadc55..15e4b03 100644
--- a/packages/flutter_tools/lib/src/resident_runner.dart
+++ b/packages/flutter_tools/lib/src/resident_runner.dart
@@ -14,7 +14,6 @@
import 'base/io.dart' as io;
import 'base/logger.dart';
import 'base/signals.dart';
-import 'base/terminal.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'codegen.dart';
@@ -23,7 +22,7 @@
import 'devfs.dart';
import 'device.dart';
import 'features.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'project.dart';
import 'run_cold.dart';
import 'run_hot.dart';
@@ -44,7 +43,7 @@
List<String> dartDefines,
}) : assert(trackWidgetCreation != null),
generator = generator ?? ResidentCompiler(
- artifacts.getArtifactPath(
+ globals.artifacts.getArtifactPath(
Artifact.flutterPatchedSdkPath,
platform: targetPlatform,
mode: buildMode,
@@ -81,14 +80,14 @@
if (featureFlags.isWebIncrementalCompilerEnabled &&
targetPlatform == TargetPlatform.web_javascript) {
generator = ResidentCompiler(
- artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: buildMode),
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: buildMode),
buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme,
targetModel: TargetModel.dartdevc,
experimentalFlags: experimentalFlags,
- platformDill: fs.file(artifacts
+ platformDill: globals.fs.file(globals.artifacts
.getArtifactPath(Artifact.webPlatformKernelDill, mode: buildMode))
.absolute.uri.toString(),
dartDefines: dartDefines,
@@ -102,7 +101,7 @@
);
} else {
generator = ResidentCompiler(
- artifacts.getArtifactPath(
+ globals.artifacts.getArtifactPath(
Artifact.flutterPatchedSdkPath,
platform: targetPlatform,
mode: buildMode,
@@ -168,7 +167,7 @@
subscription = observatoryUris.listen((Uri observatoryUri) async {
// FYI, this message is used as a sentinel in tests.
- printTrace('Connecting to service protocol: $observatoryUri');
+ globals.printTrace('Connecting to service protocol: $observatoryUri');
isWaitingForVm = true;
VMService service;
@@ -182,7 +181,7 @@
device: device,
);
} on Exception catch (exception) {
- printTrace('Fail to connect to service protocol: $observatoryUri: $exception');
+ globals.printTrace('Fail to connect to service protocol: $observatoryUri: $exception');
if (!completer.isCompleted && !_isListeningForObservatoryUri) {
completer.completeError('failed to connect to $observatoryUri');
}
@@ -191,14 +190,14 @@
if (completer.isCompleted) {
return;
}
- printTrace('Successfully connected to service protocol: $observatoryUri');
+ globals.printTrace('Successfully connected to service protocol: $observatoryUri');
vmService = service;
device.getLogReader(app: package).connectedVMService = vmService;
completer.complete();
await subscription.cancel();
}, onError: (dynamic error) {
- printTrace('Fail to handle observatory URI: $error');
+ globals.printTrace('Fail to handle observatory URI: $error');
}, onDone: () {
_isListeningForObservatoryUri = false;
if (!completer.isCompleted && !isWaitingForVm) {
@@ -281,7 +280,7 @@
String entryPath, {
bool pause = false,
}) {
- final Uri deviceEntryUri = devFS.baseUri.resolveUri(fs.path.toUri(entryPath));
+ final Uri deviceEntryUri = devFS.baseUri.resolveUri(globals.fs.path.toUri(entryPath));
final Uri devicePackagesUri = devFS.baseUri.resolve('.packages');
return <Future<Map<String, dynamic>>>[
for (FlutterView view in views)
@@ -295,7 +294,7 @@
Future<void> resetAssetDirectory() async {
final Uri deviceAssetsDirectoryUri = devFS.baseUri.resolveUri(
- fs.path.toUri(getAssetBuildDirectory()));
+ globals.fs.path.toUri(getAssetBuildDirectory()));
assert(deviceAssetsDirectoryUri != null);
await Future.wait<void>(views.map<Future<void>>(
(FlutterView view) => view.setAssetDirectory(deviceAssetsDirectoryUri)
@@ -376,12 +375,12 @@
}
final Stream<String> logStream = device.getLogReader(app: package).logLines;
if (logStream == null) {
- printError('Failed to read device log stream');
+ globals.printError('Failed to read device log stream');
return;
}
_loggingSubscription = logStream.listen((String line) {
if (!line.contains('Observatory listening on http')) {
- printStatus(line, wrap: false);
+ globals.printStatus(line, wrap: false);
}
});
}
@@ -404,7 +403,7 @@
}) async {
final bool prebuiltMode = hotRunner.applicationBinary != null;
final String modeName = hotRunner.debuggingOptions.buildInfo.friendlyModeName;
- printStatus('Launching ${getDisplayPath(hotRunner.mainPath)} on ${device.name} in $modeName mode...');
+ globals.printStatus('Launching ${getDisplayPath(hotRunner.mainPath)} on ${device.name} in $modeName mode...');
final TargetPlatform targetPlatform = await device.targetPlatform;
package = await ApplicationPackageFactory.instance.getPackageForPlatform(
@@ -418,7 +417,7 @@
if (hint != null) {
message += '\n$hint';
}
- printError(message);
+ globals.printError(message);
return 1;
}
@@ -440,7 +439,7 @@
final LaunchResult result = await futureResult;
if (!result.started) {
- printError('Error launching application on ${device.name}.');
+ globals.printError('Error launching application on ${device.name}.');
await stopEchoingDeviceLog();
return 2;
}
@@ -471,9 +470,9 @@
final bool prebuiltMode = coldRunner.applicationBinary != null;
if (coldRunner.mainPath == null) {
assert(prebuiltMode);
- printStatus('Launching ${package.displayName} on ${device.name} in $modeName mode...');
+ globals.printStatus('Launching ${package.displayName} on ${device.name} in $modeName mode...');
} else {
- printStatus('Launching ${getDisplayPath(coldRunner.mainPath)} on ${device.name} in $modeName mode...');
+ globals.printStatus('Launching ${getDisplayPath(coldRunner.mainPath)} on ${device.name} in $modeName mode...');
}
if (package == null) {
@@ -482,7 +481,7 @@
if (hint != null) {
message += '\n$hint';
}
- printError(message);
+ globals.printError(message);
return 1;
}
@@ -504,7 +503,7 @@
);
if (!result.started) {
- printError('Error running application on ${device.name}.');
+ globals.printError('Error running application on ${device.name}.');
await stopEchoingDeviceLog();
return 2;
}
@@ -533,7 +532,7 @@
@required String dillOutputPath,
@required List<Uri> invalidatedFiles,
}) async {
- final Status devFSStatus = logger.startProgress(
+ final Status devFSStatus = globals.logger.startProgress(
'Syncing files to device ${device.name}...',
timeout: timeoutConfiguration.fastOperation,
);
@@ -558,7 +557,7 @@
return UpdateFSReport(success: false);
}
devFSStatus.stop();
- printTrace('Synced ${getSizeAsMB(report.syncedBytes)}.');
+ globals.printTrace('Synced ${getSizeAsMB(report.syncedBytes)}.');
return report;
}
@@ -601,12 +600,12 @@
this.hotMode = true,
String dillOutputPath,
}) : mainPath = findMainDartFile(target),
- projectRootPath = projectRootPath ?? fs.currentDirectory.path,
- packagesFilePath = packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath),
+ projectRootPath = projectRootPath ?? globals.fs.currentDirectory.path,
+ packagesFilePath = packagesFilePath ?? globals.fs.path.absolute(PackageMap.globalPackagesPath),
_dillOutputPath = dillOutputPath,
artifactDirectory = dillOutputPath == null
- ? fs.systemTempDirectory.createTempSync('flutter_tool.')
- : fs.file(dillOutputPath).parent,
+ ? globals.fs.systemTempDirectory.createTempSync('flutter_tool.')
+ : globals.fs.file(dillOutputPath).parent,
assetBundle = AssetBundleFactory.instance.createBundle() {
if (!artifactDirectory.existsSync()) {
artifactDirectory.createSync(recursive: true);
@@ -616,9 +615,9 @@
// better way to determine where the appropriate dill file is, as this
// doesn't work for Android or macOS builds.}
if (dillOutputPath == null) {
- final File existingDill = fs.file(fs.path.join('build', 'app.dill'));
+ final File existingDill = globals.fs.file(globals.fs.path.join('build', 'app.dill'));
if (existingDill.existsSync()) {
- existingDill.copySync(fs.path.join(artifactDirectory.path, 'app.dill'));
+ existingDill.copySync(globals.fs.path.join(artifactDirectory.path, 'app.dill'));
}
}
}
@@ -651,7 +650,7 @@
});
}
- String get dillOutputPath => _dillOutputPath ?? fs.path.join(artifactDirectory.path, 'app.dill');
+ String get dillOutputPath => _dillOutputPath ?? globals.fs.path.join(artifactDirectory.path, 'app.dill');
String getReloadPath({ bool fullRestart }) => mainPath + (fullRestart ? '' : '.incremental') + '.dill';
bool get debuggingEnabled => debuggingOptions.debuggingEnabled;
@@ -732,11 +731,11 @@
if (debuggingOptions.vmserviceOutFile != null) {
try {
final String address = flutterDevices.first.vmService.wsAddress.toString();
- final File vmserviceOutFile = fs.file(debuggingOptions.vmserviceOutFile);
+ final File vmserviceOutFile = globals.fs.file(debuggingOptions.vmserviceOutFile);
vmserviceOutFile.createSync(recursive: true);
vmserviceOutFile.writeAsStringSync(address);
} on FileSystemException {
- printError('Failed to write vmservice-out-file at ${debuggingOptions.vmserviceOutFile}');
+ globals.printError('Failed to write vmservice-out-file at ${debuggingOptions.vmserviceOutFile}');
}
}
}
@@ -840,8 +839,8 @@
Future<void> screenshot(FlutterDevice device) async {
assert(device.device.supportsScreenshot);
- final Status status = logger.startProgress('Taking screenshot for ${device.device.name}...', timeout: timeoutConfiguration.fastOperation);
- final File outputFile = getUniqueFile(fs.currentDirectory, 'flutter', 'png');
+ final Status status = globals.logger.startProgress('Taking screenshot for ${device.device.name}...', timeout: timeoutConfiguration.fastOperation);
+ final File outputFile = getUniqueFile(globals.fs.currentDirectory, 'flutter', 'png');
try {
if (supportsServiceProtocol && isRunningDebug) {
await device.refreshViews();
@@ -851,7 +850,7 @@
}
} catch (error) {
status.cancel();
- printError('Error communicating with Flutter on the device: $error');
+ globals.printError('Error communicating with Flutter on the device: $error');
return;
}
}
@@ -865,17 +864,17 @@
}
} catch (error) {
status.cancel();
- printError('Error communicating with Flutter on the device: $error');
+ globals.printError('Error communicating with Flutter on the device: $error');
return;
}
}
}
final int sizeKB = outputFile.lengthSync() ~/ 1024;
status.stop();
- printStatus('Screenshot written to ${fs.path.relative(outputFile.path)} (${sizeKB}kB).');
+ globals.printStatus('Screenshot written to ${globals.fs.path.relative(outputFile.path)} (${sizeKB}kB).');
} catch (error) {
status.cancel();
- printError('Error taking screenshot: $error');
+ globals.printError('Error taking screenshot: $error');
}
}
@@ -886,7 +885,7 @@
for (FlutterDevice device in flutterDevices) {
to = await device.togglePlatform(from: from);
}
- printStatus('Switched operating system to $to');
+ globals.printStatus('Switched operating system to $to');
}
Future<void> stopEchoingDeviceLog() async {
@@ -948,12 +947,12 @@
}
Future<void> _serviceProtocolDone(dynamic object) {
- printTrace('Service protocol connection closed.');
+ globals.printTrace('Service protocol connection closed.');
return Future<void>.value(object);
}
Future<void> _serviceProtocolError(dynamic error, StackTrace stack) {
- printTrace('Service protocol connection closed with an error: $error\n$stack');
+ globals.printTrace('Service protocol connection closed with an error: $error\n$stack');
return Future<void>.error(error, stack);
}
@@ -965,7 +964,7 @@
if (_finished.isCompleted) {
return;
}
- printStatus('Lost connection to device.');
+ globals.printStatus('Lost connection to device.');
_finished.complete(0);
}
@@ -973,7 +972,7 @@
if (_finished.isCompleted) {
return;
}
- printStatus('Application finished.');
+ globals.printStatus('Application finished.');
_finished.complete(0);
}
@@ -1005,22 +1004,22 @@
void printHelpDetails() {
if (supportsServiceProtocol) {
- printStatus('You can dump the widget hierarchy of the app (debugDumpApp) by pressing "w".');
- printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
+ globals.printStatus('You can dump the widget hierarchy of the app (debugDumpApp) by pressing "w".');
+ globals.printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
if (isRunningDebug) {
- printStatus('For layers (debugDumpLayerTree), use "L"; for accessibility (debugDumpSemantics), use "S" (for traversal order) or "U" (for inverse hit test order).');
- printStatus('To toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride), press "i".');
- printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
- printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".');
- printStatus('To toggle the elevation checker, press "z".');
+ globals.printStatus('For layers (debugDumpLayerTree), use "L"; for accessibility (debugDumpSemantics), use "S" (for traversal order) or "U" (for inverse hit test order).');
+ globals.printStatus('To toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride), press "i".');
+ globals.printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
+ globals.printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".');
+ globals.printStatus('To toggle the elevation checker, press "z".');
} else {
- printStatus('To dump the accessibility tree (debugDumpSemantics), press "S" (for traversal order) or "U" (for inverse hit test order).');
+ globals.printStatus('To dump the accessibility tree (debugDumpSemantics), press "S" (for traversal order) or "U" (for inverse hit test order).');
}
- printStatus('To display the performance overlay (WidgetsApp.showPerformanceOverlay), press "P".');
- printStatus('To enable timeline events for all widget build methods, (debugProfileWidgetBuilds), press "a"');
+ globals.printStatus('To display the performance overlay (WidgetsApp.showPerformanceOverlay), press "P".');
+ globals.printStatus('To enable timeline events for all widget build methods, (debugProfileWidgetBuilds), press "a"');
}
if (flutterDevices.any((FlutterDevice d) => d.device.supportsScreenshot)) {
- printStatus('To save a screenshot to flutter.png, press "s".');
+ globals.printStatus('To save a screenshot to flutter.png, press "s".');
}
}
@@ -1052,9 +1051,9 @@
/// where the app's main function should be.
String findMainDartFile([ String target ]) {
target ??= '';
- final String targetPath = fs.path.absolute(target);
- if (fs.isDirectorySync(targetPath)) {
- return fs.path.join(targetPath, 'lib', 'main.dart');
+ final String targetPath = globals.fs.path.absolute(target);
+ if (globals.fs.isDirectorySync(targetPath)) {
+ return globals.fs.path.join(targetPath, 'lib', 'main.dart');
}
return targetPath;
}
@@ -1066,7 +1065,7 @@
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
final FlutterProject project = FlutterProject.current();
- final String manifestPath = fs.path.relative(project.android.appManifestFile.path);
+ final String manifestPath = globals.fs.path.relative(project.android.appManifestFile.path);
return 'Is your project missing an $manifestPath?\nConsider running "flutter create ." to create one.';
case TargetPlatform.ios:
return 'Is your project missing an ios/Runner/Info.plist?\nConsider running "flutter create ." to create one.';
@@ -1087,12 +1086,12 @@
String lastReceivedCommand;
void setupTerminal() {
- if (!logger.quiet) {
- printStatus('');
+ if (!globals.logger.quiet) {
+ globals.printStatus('');
residentRunner.printHelp(details: false);
}
- terminal.singleCharMode = true;
- subscription = terminal.keystrokes.listen(processTerminalInput);
+ globals.terminal.singleCharMode = true;
+ subscription = globals.terminal.keystrokes.listen(processTerminalInput);
}
@@ -1126,7 +1125,7 @@
/// Returns [true] if the input has been handled by this function.
Future<bool> _commonTerminalInputHandler(String character) async {
- printStatus(''); // the key the user tapped might be on this line
+ globals.printStatus(''); // the key the user tapped might be on this line
switch(character) {
case 'a':
if (residentRunner.supportsServiceProtocol) {
@@ -1154,9 +1153,9 @@
case 'l':
final List<FlutterView> views = residentRunner.flutterDevices
.expand((FlutterDevice d) => d.views).toList();
- printStatus('Connected ${pluralize('view', views.length)}:');
+ globals.printStatus('Connected ${pluralize('view', views.length)}:');
for (FlutterView v in views) {
- printStatus('${v.uiIsolate.name} (${v.uiIsolate.id})', indent: 2);
+ globals.printStatus('${v.uiIsolate.name} (${v.uiIsolate.id})', indent: 2);
}
return true;
case 'L':
@@ -1205,7 +1204,7 @@
throwToolExit(result.message);
}
if (!result.isOk) {
- printStatus('Try again after fixing the above error(s).', emphasis: true);
+ globals.printStatus('Try again after fixing the above error(s).', emphasis: true);
}
return true;
case 'R':
@@ -1218,7 +1217,7 @@
throwToolExit(result.message);
}
if (!result.isOk) {
- printStatus('Try again after fixing the above error(s).', emphasis: true);
+ globals.printStatus('Try again after fixing the above error(s).', emphasis: true);
}
return true;
case 'S':
@@ -1259,7 +1258,7 @@
// When terminal doesn't support line mode, '\n' can sneak into the input.
command = command.trim();
if (_processingUserRequest) {
- printTrace('Ignoring terminal input: "$command" because we are busy.');
+ globals.printTrace('Ignoring terminal input: "$command" because we are busy.');
return;
}
_processingUserRequest = true;
@@ -1269,7 +1268,7 @@
} catch (error, st) {
// Don't print stack traces for known error types.
if (error is! ToolExit) {
- printError('$error\n$st');
+ globals.printError('$error\n$st');
}
await _cleanUp(null);
rethrow;
@@ -1280,7 +1279,7 @@
Future<void> _handleSignal(io.ProcessSignal signal) async {
if (_processingUserRequest) {
- printTrace('Ignoring signal: "$signal" because we are busy.');
+ globals.printTrace('Ignoring signal: "$signal" because we are busy.');
return;
}
_processingUserRequest = true;
@@ -1295,7 +1294,7 @@
}
Future<void> _cleanUp(io.ProcessSignal signal) async {
- terminal.singleCharMode = false;
+ globals.terminal.singleCharMode = false;
await subscription?.cancel();
await residentRunner.cleanupAfterSignal();
}
diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart
index b03d19b..02f95ae 100644
--- a/packages/flutter_tools/lib/src/run_cold.dart
+++ b/packages/flutter_tools/lib/src/run_cold.dart
@@ -8,7 +8,7 @@
import 'base/file_system.dart';
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'resident_runner.dart';
import 'tracing.dart';
import 'vmservice.dart';
@@ -50,12 +50,12 @@
}) async {
final bool prebuiltMode = applicationBinary != null;
if (!prebuiltMode) {
- if (!fs.isFileSync(mainPath)) {
+ if (!globals.fs.isFileSync(mainPath)) {
String message = 'Tried to run $mainPath, but that file does not exist.';
if (target == null) {
message += '\nConsider using the -t option to specify the Dart file to start.';
}
- printError(message);
+ globals.printError(message);
return 1;
}
}
@@ -75,7 +75,7 @@
try {
await connectToServiceProtocol();
} on String catch (message) {
- printError(message);
+ globals.printError(message);
return 2;
}
}
@@ -88,7 +88,7 @@
));
}
- printTrace('Application running.');
+ globals.printTrace('Application running.');
for (FlutterDevice device in flutterDevices) {
if (device.vmService == null) {
@@ -96,14 +96,14 @@
}
device.initLogReader();
await device.refreshViews();
- printTrace('Connected to ${device.device.name}');
+ globals.printTrace('Connected to ${device.device.name}');
}
if (traceStartup) {
// Only trace startup for the first device.
final FlutterDevice device = flutterDevices.first;
if (device.vmService != null) {
- printStatus('Tracing startup on ${device.device.name}.');
+ globals.printStatus('Tracing startup on ${device.device.name}.');
await downloadStartupTrace(
device.vmService,
awaitFirstFrame: awaitFirstFrameWhenTracing,
@@ -132,13 +132,13 @@
try {
await connectToServiceProtocol();
} catch (error) {
- printError('Error connecting to the service protocol: $error');
+ globals.printError('Error connecting to the service protocol: $error');
// https://github.com/flutter/flutter/issues/33050
// TODO(blasten): Remove this check once https://issuetracker.google.com/issues/132325318 has been fixed.
if (await hasDeviceRunningAndroidQ(flutterDevices) &&
error.toString().contains(kAndroidQHttpConnectionClosedExp)) {
- printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.');
- printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318');
+ globals.printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.');
+ globals.printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318');
}
return 2;
}
@@ -148,7 +148,7 @@
await refreshViews();
for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) {
- printTrace('Connected to $view.');
+ globals.printTrace('Connected to $view.');
}
}
appStartedCompleter?.complete();
@@ -184,7 +184,7 @@
for (FlutterDevice device in flutterDevices) {
final String dname = device.device.name;
if (device.vmService != null) {
- printStatus('An Observatory debugger and profiler on $dname is '
+ globals.printStatus('An Observatory debugger and profiler on $dname is '
'available at: ${device.vmService .httpAddress}');
}
}
@@ -199,11 +199,11 @@
? 'To detach, press "d"; to quit, press "q".'
: 'To quit, press "q".';
if (haveDetails && !details) {
- printStatus('For a more detailed help message, press "h". $quitMessage');
+ globals.printStatus('For a more detailed help message, press "h". $quitMessage');
} else if (haveAnything) {
- printStatus('To repeat this help message, press "h". $quitMessage');
+ globals.printStatus('To repeat this help message, press "h". $quitMessage');
} else {
- printStatus(quitMessage);
+ globals.printStatus(quitMessage);
}
}
diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart
index 26a1e36..e8d9337 100644
--- a/packages/flutter_tools/lib/src/run_hot.dart
+++ b/packages/flutter_tools/lib/src/run_hot.dart
@@ -4,6 +4,7 @@
import 'dart:async';
+import 'package:platform/platform.dart';
import 'package:json_rpc_2/error_code.dart' as rpc_error_code;
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart';
@@ -13,7 +14,6 @@
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/logger.dart';
-import 'base/platform.dart';
import 'base/terminal.dart';
import 'base/utils.dart';
import 'build_info.dart';
@@ -21,16 +21,16 @@
import 'convert.dart';
import 'devfs.dart';
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'reporting/reporting.dart';
import 'resident_runner.dart';
import 'vmservice.dart';
ProjectFileInvalidator get projectFileInvalidator => context.get<ProjectFileInvalidator>() ?? _defaultInvalidator;
final ProjectFileInvalidator _defaultInvalidator = ProjectFileInvalidator(
- fileSystem: fs,
- platform: platform,
- logger: logger,
+ fileSystem: globals.fs,
+ platform: globals.platform,
+ logger: globals.logger,
);
HotRunnerConfig get hotRunnerConfig => context.get<HotRunnerConfig>();
@@ -143,7 +143,7 @@
await device.generator.compileExpression(expression, definitions,
typeDefinitions, libraryUri, klass, isStatic);
if (compilerOutput != null && compilerOutput.outputFilename != null) {
- return base64.encode(fs.file(compilerOutput.outputFilename).readAsBytesSync());
+ return base64.encode(globals.fs.file(compilerOutput.outputFilename).readAsBytesSync());
}
}
}
@@ -174,7 +174,7 @@
return OperationResult(1, 'Failed to compile');
}
try {
- final String entryPath = fs.path.relative(
+ final String entryPath = globals.fs.path.relative(
getReloadPath(fullRestart: false),
from: projectRootPath,
);
@@ -196,7 +196,7 @@
}
}
- printStatus('reloadMethod took ${stopwatch.elapsedMilliseconds}');
+ globals.printStatus('reloadMethod took ${stopwatch.elapsedMilliseconds}');
flutterUsage.sendTiming('hot', 'ui', stopwatch.elapsed);
return OperationResult.ok;
}
@@ -216,13 +216,13 @@
reloadMethod: reloadMethod,
);
} catch (error) {
- printError('Error connecting to the service protocol: $error');
+ globals.printError('Error connecting to the service protocol: $error');
// https://github.com/flutter/flutter/issues/33050
// TODO(blasten): Remove this check once https://issuetracker.google.com/issues/132325318 has been fixed.
if (await hasDeviceRunningAndroidQ(flutterDevices) &&
error.toString().contains(kAndroidQHttpConnectionClosedExp)) {
- printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.');
- printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318.');
+ globals.printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.');
+ globals.printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318.');
}
return 2;
}
@@ -243,7 +243,7 @@
);
}
} catch (error) {
- printError('Error initializing DevFS: $error');
+ globals.printError('Error initializing DevFS: $error');
return 3;
}
final Stopwatch initialUpdateDevFSsTimer = Stopwatch()..start();
@@ -264,7 +264,7 @@
device.generator.accept();
}
for (FlutterView view in device.views) {
- printTrace('Connected to $view.');
+ globals.printTrace('Connected to $view.');
}
}
@@ -284,22 +284,22 @@
if (benchmarkMode) {
// We are running in benchmark mode.
- printStatus('Running in benchmark mode.');
+ globals.printStatus('Running in benchmark mode.');
// Measure time to perform a hot restart.
- printStatus('Benchmarking hot restart');
+ globals.printStatus('Benchmarking hot restart');
await restart(fullRestart: true, benchmarkMode: true);
- printStatus('Benchmarking hot reload');
+ globals.printStatus('Benchmarking hot reload');
// Measure time to perform a hot reload.
await restart(fullRestart: false);
if (stayResident) {
await waitForAppToFinish();
} else {
- printStatus('Benchmark completed. Exiting application.');
+ globals.printStatus('Benchmark completed. Exiting application.');
await _cleanupDevFS();
await stopEchoingDeviceLog();
await exitApp();
}
- final File benchmarkOutput = fs.file('hot_benchmark.json');
+ final File benchmarkOutput = globals.fs.file('hot_benchmark.json');
benchmarkOutput.writeAsStringSync(toPrettyJson(benchmarkData));
return 0;
}
@@ -319,12 +319,12 @@
Completer<void> appStartedCompleter,
String route,
}) async {
- if (!fs.isFileSync(mainPath)) {
+ if (!globals.fs.isFileSync(mainPath)) {
String message = 'Tried to run $mainPath, but that file does not exist.';
if (target == null) {
message += '\nConsider using the -t option to specify the Dart file to start.';
}
- printError(message);
+ globals.printError(message);
return 1;
}
@@ -347,12 +347,12 @@
}
Future<List<Uri>> _initDevFS() async {
- final String fsName = fs.path.basename(projectRootPath);
+ final String fsName = globals.fs.path.basename(projectRootPath);
return <Uri>[
for (FlutterDevice device in flutterDevices)
await device.setupDevFS(
fsName,
- fs.directory(projectRootPath),
+ globals.fs.directory(projectRootPath),
packagesFilePath: packagesFilePath,
),
];
@@ -362,7 +362,7 @@
final bool isFirstUpload = !assetBundle.wasBuiltOnce();
final bool rebuildBundle = assetBundle.needsBuild();
if (rebuildBundle) {
- printTrace('Updating assets');
+ globals.printTrace('Updating assets');
final int result = await assetBundle.build();
if (result != 0) {
return UpdateFSReport(success: false);
@@ -411,7 +411,7 @@
futures.add(device.devFS.destroy()
.timeout(const Duration(milliseconds: 250))
.catchError((dynamic error) {
- printTrace('Ignored error while cleaning up DevFS: $error');
+ globals.printTrace('Ignored error while cleaning up DevFS: $error');
}));
}
device.devFS = null;
@@ -432,14 +432,14 @@
}
Future<void> _launchFromDevFS(String mainScript) async {
- final String entryUri = fs.path.relative(mainScript, from: projectRootPath);
+ final String entryUri = globals.fs.path.relative(mainScript, from: projectRootPath);
final List<Future<void>> futures = <Future<void>>[];
for (FlutterDevice device in flutterDevices) {
final Uri deviceEntryUri = device.devFS.baseUri.resolveUri(
- fs.path.toUri(entryUri));
+ globals.fs.path.toUri(entryUri));
final Uri devicePackagesUri = device.devFS.baseUri.resolve('.packages');
final Uri deviceAssetsDirectoryUri = device.devFS.baseUri.resolveUri(
- fs.path.toUri(getAssetBuildDirectory()));
+ globals.fs.path.toUri(getAssetBuildDirectory()));
futures.add(_launchInView(device,
deviceEntryUri,
devicePackagesUri,
@@ -462,7 +462,7 @@
bool benchmarkMode = false,
}) async {
if (!_isPaused()) {
- printTrace('Refreshing active FlutterViews before restarting.');
+ globals.printTrace('Refreshing active FlutterViews before restarting.');
await refreshViews();
}
@@ -510,7 +510,7 @@
_runningFromSnapshot = false;
await _launchFromDevFS(mainPath + '.dill');
restartTimer.stop();
- printTrace('Hot restart performed in ${getElapsedAsMilliseconds(restartTimer.elapsed)}.');
+ globals.printTrace('Hot restart performed in ${getElapsedAsMilliseconds(restartTimer.elapsed)}.');
// We are now running from sources.
_runningFromSnapshot = false;
_addBenchmarkData('hotRestartMillisecondsToFrame',
@@ -550,7 +550,7 @@
}) {
if (reloadReport == null) {
if (printErrors) {
- printError('Hot reload did not receive reload report.');
+ globals.printError('Hot reload did not receive reload report.');
}
return false;
}
@@ -568,15 +568,15 @@
)
)) {
if (printErrors) {
- printError('Hot reload received invalid response: $reloadReport');
+ globals.printError('Hot reload received invalid response: $reloadReport');
}
return false;
}
if (!(reloadReport['success'] as bool)) {
if (printErrors) {
- printError('Hot reload was rejected:');
+ globals.printError('Hot reload was rejected:');
for (Map<String, dynamic> notice in reloadReport['details']['notices']) {
- printError('${notice['message']}');
+ globals.printError('${notice['message']}');
}
}
return false;
@@ -623,7 +623,7 @@
silent: silent,
);
if (!silent) {
- printStatus('Restarted application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
+ globals.printStatus('Restarted application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
}
return result;
}
@@ -637,7 +637,7 @@
if (result.isOk) {
final String elapsed = getElapsedAsMilliseconds(timer.elapsed);
if (!silent) {
- printStatus('${result.message} in $elapsed.');
+ globals.printStatus('${result.message} in $elapsed.');
}
}
return result;
@@ -656,7 +656,7 @@
}
Status status;
if (!silent) {
- status = logger.startProgress(
+ status = globals.logger.startProgress(
'Performing hot restart...',
timeout: timeoutConfiguration.fastOperation,
progressId: 'hot.restart',
@@ -703,7 +703,7 @@
}) async {
final bool reloadOnTopOfSnapshot = _runningFromSnapshot;
final String progressPrefix = reloadOnTopOfSnapshot ? 'Initializing' : 'Performing';
- Status status = logger.startProgress(
+ Status status = globals.logger.startProgress(
'$progressPrefix hot reload...',
timeout: timeoutConfiguration.fastOperation,
progressId: 'hot.reload',
@@ -718,7 +718,7 @@
pause: pause,
onSlow: (String message) {
status?.cancel();
- status = logger.startProgress(
+ status = globals.logger.startProgress(
message,
timeout: timeoutConfiguration.slowOperation,
progressId: 'hot.reload',
@@ -765,7 +765,7 @@
final Stopwatch reloadTimer = Stopwatch()..start();
if (!_isPaused()) {
- printTrace('Refreshing active FlutterViews before reloading.');
+ globals.printTrace('Refreshing active FlutterViews before reloading.');
await refreshViews();
}
@@ -780,7 +780,7 @@
final Stopwatch vmReloadTimer = Stopwatch()..start();
Map<String, dynamic> firstReloadDetails;
try {
- final String entryPath = fs.path.relative(
+ final String entryPath = globals.fs.path.relative(
getReloadPath(fullRestart: false),
from: projectRootPath,
);
@@ -828,11 +828,11 @@
firstReloadDetails ??= castStringKeyedMap(reloadReport['details']);
final int loadedLibraryCount = reloadReport['details']['loadedLibraryCount'] as int;
final int finalLibraryCount = reloadReport['details']['finalLibraryCount'] as int;
- printTrace('reloaded $loadedLibraryCount of $finalLibraryCount libraries');
+ globals.printTrace('reloaded $loadedLibraryCount of $finalLibraryCount libraries');
reloadMessage = 'Reloaded $loadedLibraryCount of $finalLibraryCount libraries';
}
} on Map<String, dynamic> catch (error, stackTrace) {
- printTrace('Hot reload failed: $error\n$stackTrace');
+ globals.printTrace('Hot reload failed: $error\n$stackTrace');
final int errorCode = error['code'] as int;
String errorMessage = error['message'] as String;
if (errorCode == Isolate.kIsolateReloadBarred) {
@@ -851,7 +851,7 @@
}
return OperationResult(errorCode, '$errorMessage (error code: $errorCode)');
} catch (error, stackTrace) {
- printTrace('Hot reload failed: $error\n$stackTrace');
+ globals.printTrace('Hot reload failed: $error\n$stackTrace');
return OperationResult(1, '$error');
}
// Record time it took for the VM to reload the sources.
@@ -860,10 +860,10 @@
// Reload the isolate.
final List<Future<void>> allDevices = <Future<void>>[];
for (FlutterDevice device in flutterDevices) {
- printTrace('Sending reload events to ${device.device.name}');
+ globals.printTrace('Sending reload events to ${device.device.name}');
final List<Future<ServiceObject>> futuresViews = <Future<ServiceObject>>[];
for (FlutterView view in device.views) {
- printTrace('Sending reload event to "${view.uiIsolate.name}"');
+ globals.printTrace('Sending reload event to "${view.uiIsolate.name}"');
futuresViews.add(view.uiIsolate.reload());
}
allDevices.add(Future.wait(futuresViews).whenComplete(() {
@@ -900,14 +900,14 @@
onSlow('${_describePausedIsolates(pausedIsolatesFound, serviceEventKind)}; interface might not update.');
}
if (reassembleViews.isEmpty) {
- printTrace('Skipping reassemble because all isolates are paused.');
+ globals.printTrace('Skipping reassemble because all isolates are paused.');
return OperationResult(OperationResult.ok.code, reloadMessage);
}
}
- printTrace('Evicting dirty assets');
+ globals.printTrace('Evicting dirty assets');
await _evictDirtyAssets();
assert(reassembleViews.isNotEmpty);
- printTrace('Reassembling application');
+ globals.printTrace('Reassembling application');
bool failedReassemble = false;
final List<Future<void>> futures = <Future<void>>[
for (FlutterView view in reassembleViews)
@@ -916,7 +916,7 @@
await view.uiIsolate.flutterReassemble();
} catch (error) {
failedReassemble = true;
- printError('Reassembling ${view.uiIsolate.name} failed: $error');
+ globals.printError('Reassembling ${view.uiIsolate.name} failed: $error');
return;
}
}(),
@@ -930,7 +930,7 @@
return; // probably no point waiting, they're probably deadlocked and we've already warned.
}
// Check if any isolate is newly paused.
- printTrace('This is taking a long time; will now check for paused isolates.');
+ globals.printTrace('This is taking a long time; will now check for paused isolates.');
int postReloadPausedIsolatesFound = 0;
String serviceEventKind;
for (FlutterView view in reassembleViews) {
@@ -945,7 +945,7 @@
}
}
}
- printTrace('Found $postReloadPausedIsolatesFound newly paused isolate(s).');
+ globals.printTrace('Found $postReloadPausedIsolatesFound newly paused isolate(s).');
if (postReloadPausedIsolatesFound == 0) {
await reassembleFuture; // must just be taking a long time... keep waiting!
return;
@@ -985,7 +985,7 @@
).send();
if (shouldReportReloadTime) {
- printTrace('Hot reload performed in ${getElapsedAsMilliseconds(reloadDuration)}.');
+ globals.printTrace('Hot reload performed in ${getElapsedAsMilliseconds(reloadDuration)}.');
// Record complete time it took for the reload.
_addBenchmarkData('hotReloadMillisecondsToFrame', reloadInMs);
}
@@ -1050,14 +1050,14 @@
if (canHotRestart) {
rawMessage += 'To hot restart (and rebuild state), press "R".';
}
- final String message = terminal.color(
- fire + terminal.bolden(rawMessage),
+ final String message = globals.terminal.color(
+ fire + globals.terminal.bolden(rawMessage),
TerminalColor.red,
);
- printStatus(message);
+ globals.printStatus(message);
for (FlutterDevice device in flutterDevices) {
final String dname = device.device.name;
- printStatus('An Observatory debugger and profiler on $dname is '
+ globals.printStatus('An Observatory debugger and profiler on $dname is '
'available at: ${device.vmService.httpAddress}');
}
final String quitMessage = _didAttach
@@ -1065,9 +1065,9 @@
: 'To quit, press "q".';
if (details) {
printHelpDetails();
- printStatus('To repeat this help message, press "h". $quitMessage');
+ globals.printStatus('To repeat this help message, press "h". $quitMessage');
} else {
- printStatus('For a more detailed help message, press "h". $quitMessage');
+ globals.printStatus('For a more detailed help message, press "h". $quitMessage');
}
}
@@ -1078,7 +1078,7 @@
continue;
}
if (device.views.first.uiIsolate == null) {
- printError('Application isolate not found for $device');
+ globals.printError('Application isolate not found for $device');
continue;
}
for (String assetPath in device.devFS.assetPathsToEvict) {
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index b9a6d91..a04e402 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -12,7 +12,6 @@
import '../application_package.dart';
import '../base/common.dart';
import '../base/context.dart';
-import '../base/file_system.dart';
import '../base/io.dart' as io;
import '../base/signals.dart';
import '../base/terminal.dart';
@@ -27,7 +26,7 @@
import '../device.dart';
import '../doctor.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'flutter_command_runner.dart';
@@ -525,7 +524,7 @@
rethrow;
} finally {
final DateTime endTime = systemClock.now();
- printTrace(userMessages.flutterElapsedTime(name, getElapsedAsMilliseconds(endTime.difference(startTime))));
+ globals.printTrace(userMessages.flutterElapsedTime(name, getElapsedAsMilliseconds(endTime.difference(startTime))));
_sendPostUsage(commandPath, commandResult, startTime, endTime);
}
},
@@ -599,9 +598,9 @@
if (shouldUpdateCache) {
// First always update universal artifacts, as some of these (e.g.
// idevice_id on macOS) are required to determine `requiredArtifacts`.
- await cache.updateAll(<DevelopmentArtifact>{DevelopmentArtifact.universal});
+ await globals.cache.updateAll(<DevelopmentArtifact>{DevelopmentArtifact.universal});
- await cache.updateAll(await requiredArtifacts);
+ await globals.cache.updateAll(await requiredArtifacts);
}
await validateCommand();
@@ -643,29 +642,29 @@
/// then print an error message and return null.
Future<List<Device>> findAllTargetDevices() async {
if (!doctor.canLaunchAnything) {
- printError(userMessages.flutterNoDevelopmentDevice);
+ globals.printError(userMessages.flutterNoDevelopmentDevice);
return null;
}
List<Device> devices = await deviceManager.findTargetDevices(FlutterProject.current());
if (devices.isEmpty && deviceManager.hasSpecifiedDeviceId) {
- printStatus(userMessages.flutterNoMatchingDevice(deviceManager.specifiedDeviceId));
+ globals.printStatus(userMessages.flutterNoMatchingDevice(deviceManager.specifiedDeviceId));
return null;
} else if (devices.isEmpty && deviceManager.hasSpecifiedAllDevices) {
- printStatus(userMessages.flutterNoDevicesFound);
+ globals.printStatus(userMessages.flutterNoDevicesFound);
return null;
} else if (devices.isEmpty) {
- printStatus(userMessages.flutterNoSupportedDevices);
+ globals.printStatus(userMessages.flutterNoSupportedDevices);
return null;
} else if (devices.length > 1 && !deviceManager.hasSpecifiedAllDevices) {
if (deviceManager.hasSpecifiedDeviceId) {
- printStatus(userMessages.flutterFoundSpecifiedDevices(devices.length, deviceManager.specifiedDeviceId));
+ globals.printStatus(userMessages.flutterFoundSpecifiedDevices(devices.length, deviceManager.specifiedDeviceId));
} else {
- printStatus(userMessages.flutterSpecifyDeviceWithAllOption);
+ globals.printStatus(userMessages.flutterSpecifyDeviceWithAllOption);
devices = await deviceManager.getAllConnectedDevices().toList();
}
- printStatus('');
+ globals.printStatus('');
await Device.printDevices(devices);
return null;
}
@@ -682,9 +681,9 @@
return null;
}
if (deviceList.length > 1) {
- printStatus(userMessages.flutterSpecifyDevice);
+ globals.printStatus(userMessages.flutterSpecifyDevice);
deviceList = await deviceManager.getAllConnectedDevices().toList();
- printStatus('');
+ globals.printStatus('');
await Device.printDevices(deviceList);
return null;
}
@@ -696,7 +695,7 @@
Future<void> validateCommand() async {
if (_requiresPubspecYaml && !PackageMap.isUsingCustomPackagesPath) {
// Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path.
- if (!fs.isFileSync('pubspec.yaml')) {
+ if (!globals.fs.isFileSync('pubspec.yaml')) {
throw ToolExit(userMessages.flutterNoPubspec);
}
@@ -711,7 +710,7 @@
if (_usesTargetOption) {
final String targetPath = targetFile;
- if (!fs.isFileSync(targetPath)) {
+ if (!globals.fs.isFileSync(targetPath)) {
throw ToolExit(userMessages.flutterTargetFileMissing(targetPath));
}
}
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
index 1a2c0fa..ca6d672 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
@@ -15,7 +15,6 @@
import '../base/file_system.dart';
import '../base/io.dart' as io;
import '../base/logger.dart';
-import '../base/platform.dart';
import '../base/terminal.dart';
import '../base/user_messages.dart';
import '../base/utils.dart';
@@ -23,7 +22,7 @@
import '../convert.dart';
import '../dart/package_map.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../reporting/reporting.dart';
import '../tester/flutter_tester.dart';
import '../version.dart';
@@ -93,7 +92,7 @@
String packagesHelp;
bool showPackagesCommand;
- if (fs.isFileSync(kPackagesFileName)) {
+ if (globals.fs.isFileSync(kPackagesFileName)) {
packagesHelp = '(defaults to "$kPackagesFileName")';
showPackagesCommand = verboseHelp;
} else {
@@ -157,25 +156,25 @@
}
static String get defaultFlutterRoot {
- if (platform.environment.containsKey(kFlutterRootEnvironmentVariableName)) {
- return platform.environment[kFlutterRootEnvironmentVariableName];
+ if (globals.platform.environment.containsKey(kFlutterRootEnvironmentVariableName)) {
+ return globals.platform.environment[kFlutterRootEnvironmentVariableName];
}
try {
- if (platform.script.scheme == 'data') {
+ if (globals.platform.script.scheme == 'data') {
return '../..'; // we're running as a test
}
- if (platform.script.scheme == 'package') {
- final String packageConfigPath = Uri.parse(platform.packageConfig).toFilePath();
- return fs.path.dirname(fs.path.dirname(fs.path.dirname(packageConfigPath)));
+ if (globals.platform.script.scheme == 'package') {
+ final String packageConfigPath = Uri.parse(globals.platform.packageConfig).toFilePath();
+ return globals.fs.path.dirname(globals.fs.path.dirname(globals.fs.path.dirname(packageConfigPath)));
}
- final String script = platform.script.toFilePath();
- if (fs.path.basename(script) == kSnapshotFileName) {
- return fs.path.dirname(fs.path.dirname(fs.path.dirname(script)));
+ final String script = globals.platform.script.toFilePath();
+ if (globals.fs.path.basename(script) == kSnapshotFileName) {
+ return globals.fs.path.dirname(globals.fs.path.dirname(globals.fs.path.dirname(script)));
}
- if (fs.path.basename(script) == kFlutterToolsScriptFileName) {
- return fs.path.dirname(fs.path.dirname(fs.path.dirname(fs.path.dirname(script))));
+ if (globals.fs.path.basename(script) == kFlutterToolsScriptFileName) {
+ return globals.fs.path.dirname(globals.fs.path.dirname(globals.fs.path.dirname(globals.fs.path.dirname(script))));
}
// If run from a bare script within the repo.
@@ -234,7 +233,7 @@
// Check for verbose.
if (topLevelResults['verbose'] as bool) {
// Override the logger.
- contextOverrides[Logger] = VerboseLogger(logger);
+ contextOverrides[Logger] = VerboseLogger(globals.logger);
}
// Don't set wrapColumns unless the user said to: if it's set, then all
@@ -271,7 +270,7 @@
// We must set Cache.flutterRoot early because other features use it (e.g.
// enginePath's initializer uses it).
final String flutterRoot = topLevelResults['flutter-root'] as String ?? defaultFlutterRoot;
- Cache.flutterRoot = fs.path.normalize(fs.path.absolute(flutterRoot));
+ Cache.flutterRoot = globals.fs.path.normalize(globals.fs.path.absolute(flutterRoot));
// Set up the tooling configuration.
final String enginePath = _findEnginePath(topLevelResults);
@@ -286,9 +285,9 @@
return MapEntry<Type, Generator>(type, () => value);
}),
body: () async {
- logger.quiet = topLevelResults['quiet'] as bool;
+ globals.logger.quiet = topLevelResults['quiet'] as bool;
- if (platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') {
+ if (globals.platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') {
await Cache.lock();
}
@@ -300,8 +299,8 @@
try {
await FlutterVersion.instance.ensureVersionFile();
} on FileSystemException catch (e) {
- printError('Failed to write the version file to the artifact cache: "$e".');
- printError('Please ensure you have permissions in the artifact cache directory.');
+ globals.printError('Failed to write the version file to the artifact cache: "$e".');
+ globals.printError('Please ensure you have permissions in the artifact cache directory.');
throwToolExit('Failed to write the version file');
}
if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool) {
@@ -309,7 +308,7 @@
}
if (topLevelResults.wasParsed('packages')) {
- PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(topLevelResults['packages'] as String));
+ PackageMap.globalPackagesPath = globals.fs.path.normalize(globals.fs.path.absolute(topLevelResults['packages'] as String));
}
// See if the user specified a specific device.
@@ -323,7 +322,7 @@
} else {
status = FlutterVersion.instance.toString();
}
- printStatus(status);
+ globals.printStatus(status);
return;
}
@@ -336,27 +335,28 @@
}
String _tryEnginePath(String enginePath) {
- if (fs.isDirectorySync(fs.path.join(enginePath, 'out'))) {
+ if (globals.fs.isDirectorySync(globals.fs.path.join(enginePath, 'out'))) {
return enginePath;
}
return null;
}
String _findEnginePath(ArgResults globalResults) {
- String engineSourcePath = globalResults['local-engine-src-path'] as String ?? platform.environment[kFlutterEngineEnvironmentVariableName];
+ String engineSourcePath = globalResults['local-engine-src-path'] as String
+ ?? globals.platform.environment[kFlutterEngineEnvironmentVariableName];
if (engineSourcePath == null && globalResults['local-engine'] != null) {
try {
Uri engineUri = PackageMap(PackageMap.globalPackagesPath).map[kFlutterEnginePackageName];
// Skip if sky_engine is the self-contained one.
- if (engineUri != null && fs.identicalSync(fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'pkg', kFlutterEnginePackageName, 'lib'), engineUri.path)) {
+ if (engineUri != null && globals.fs.identicalSync(globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'pkg', kFlutterEnginePackageName, 'lib'), engineUri.path)) {
engineUri = null;
}
// If sky_engine is specified and the engineSourcePath not set, try to determine the engineSourcePath by sky_engine setting.
// A typical engineUri looks like: file://flutter-engine-local-path/src/out/host_debug_unopt/gen/dart-pkg/sky_engine/lib/
if (engineUri?.path != null) {
- engineSourcePath = fs.directory(engineUri.path)?.parent?.parent?.parent?.parent?.parent?.parent?.path;
- if (engineSourcePath != null && (engineSourcePath == fs.path.dirname(engineSourcePath) || engineSourcePath.isEmpty)) {
+ engineSourcePath = globals.fs.directory(engineUri.path)?.parent?.parent?.parent?.parent?.parent?.parent?.path;
+ if (engineSourcePath != null && (engineSourcePath == globals.fs.path.dirname(engineSourcePath) || engineSourcePath.isEmpty)) {
engineSourcePath = null;
throwToolExit(userMessages.runnerNoEngineSrcDir(kFlutterEnginePackageName, kFlutterEngineEnvironmentVariableName),
exitCode: 2);
@@ -368,7 +368,7 @@
engineSourcePath = null;
}
// If engineSourcePath is still not set, try to determine it by flutter root.
- engineSourcePath ??= _tryEnginePath(fs.path.join(fs.directory(Cache.flutterRoot).parent.path, 'engine', 'src'));
+ engineSourcePath ??= _tryEnginePath(globals.fs.path.join(globals.fs.directory(Cache.flutterRoot).parent.path, 'engine', 'src'));
}
if (engineSourcePath != null && _tryEnginePath(engineSourcePath) == null) {
@@ -400,15 +400,15 @@
throwToolExit(userMessages.runnerLocalEngineRequired, exitCode: 2);
}
- final String engineBuildPath = fs.path.normalize(fs.path.join(enginePath, 'out', localEngine));
- if (!fs.isDirectorySync(engineBuildPath)) {
+ final String engineBuildPath = globals.fs.path.normalize(globals.fs.path.join(enginePath, 'out', localEngine));
+ if (!globals.fs.isDirectorySync(engineBuildPath)) {
throwToolExit(userMessages.runnerNoEngineBuild(engineBuildPath), exitCode: 2);
}
- final String basename = fs.path.basename(engineBuildPath);
+ final String basename = globals.fs.path.basename(engineBuildPath);
final String hostBasename = _getHostEngineBasename(basename);
- final String engineHostBuildPath = fs.path.normalize(fs.path.join(fs.path.dirname(engineBuildPath), hostBasename));
- if (!fs.isDirectorySync(engineHostBuildPath)) {
+ final String engineHostBuildPath = globals.fs.path.normalize(globals.fs.path.join(globals.fs.path.dirname(engineBuildPath), hostBasename));
+ if (!globals.fs.isDirectorySync(engineHostBuildPath)) {
throwToolExit(userMessages.runnerNoEngineBuild(engineHostBuildPath), exitCode: 2);
}
@@ -421,10 +421,10 @@
/// Get the root directories of the repo - the directories containing Dart packages.
List<String> getRepoRoots() {
- final String root = fs.path.absolute(Cache.flutterRoot);
+ final String root = globals.fs.path.absolute(Cache.flutterRoot);
// not bin, and not the root
return <String>['dev', 'examples', 'packages'].map<String>((String item) {
- return fs.path.join(root, item);
+ return globals.fs.path.join(root, item);
}).toList();
}
@@ -432,27 +432,27 @@
List<Directory> getRepoPackages() {
return getRepoRoots()
.expand<String>((String root) => _gatherProjectPaths(root))
- .map<Directory>((String dir) => fs.directory(dir))
+ .map<Directory>((String dir) => globals.fs.directory(dir))
.toList();
}
static List<String> _gatherProjectPaths(String rootPath) {
- if (fs.isFileSync(fs.path.join(rootPath, '.dartignore'))) {
+ if (globals.fs.isFileSync(globals.fs.path.join(rootPath, '.dartignore'))) {
return <String>[];
}
- final List<String> projectPaths = fs.directory(rootPath)
+ final List<String> projectPaths = globals.fs.directory(rootPath)
.listSync(followLinks: false)
.expand((FileSystemEntity entity) {
- if (entity is Directory && !fs.path.split(entity.path).contains('.dart_tool')) {
+ if (entity is Directory && !globals.fs.path.split(entity.path).contains('.dart_tool')) {
return _gatherProjectPaths(entity.path);
}
return <String>[];
})
.toList();
- if (fs.isFileSync(fs.path.join(rootPath, 'pubspec.yaml'))) {
+ if (globals.fs.isFileSync(globals.fs.path.join(rootPath, 'pubspec.yaml'))) {
projectPaths.add(rootPath);
}
@@ -462,19 +462,19 @@
void _checkFlutterCopy() {
// If the current directory is contained by a flutter repo, check that it's
// the same flutter that is currently running.
- String directory = fs.path.normalize(fs.path.absolute(fs.currentDirectory.path));
+ String directory = globals.fs.path.normalize(globals.fs.path.absolute(globals.fs.currentDirectory.path));
// Check if the cwd is a flutter dir.
while (directory.isNotEmpty) {
if (_isDirectoryFlutterRepo(directory)) {
if (!_compareResolvedPaths(directory, Cache.flutterRoot)) {
- printError(userMessages.runnerWrongFlutterInstance(Cache.flutterRoot, directory));
+ globals.printError(userMessages.runnerWrongFlutterInstance(Cache.flutterRoot, directory));
}
break;
}
- final String parent = fs.path.dirname(directory);
+ final String parent = globals.fs.path.dirname(directory);
if (parent == directory) {
break;
}
@@ -482,7 +482,7 @@
}
// Check that the flutter running is that same as the one referenced in the pubspec.
- if (fs.isFileSync(kPackagesFileName)) {
+ if (globals.fs.isFileSync(kPackagesFileName)) {
final PackageMap packageMap = PackageMap(kPackagesFileName);
Uri flutterUri;
try {
@@ -491,19 +491,19 @@
// We're not quite sure why this can happen, perhaps the user
// accidentally edited the .packages file. Re-running pub should
// fix the issue, and we definitely shouldn't crash here.
- printTrace('Failed to parse .packages file to check flutter dependency.');
+ globals.printTrace('Failed to parse .packages file to check flutter dependency.');
return;
}
if (flutterUri != null && (flutterUri.scheme == 'file' || flutterUri.scheme == '')) {
// .../flutter/packages/flutter/lib
final Uri rootUri = flutterUri.resolve('../../..');
- final String flutterPath = fs.path.normalize(fs.file(rootUri).absolute.path);
+ final String flutterPath = globals.fs.path.normalize(globals.fs.file(rootUri).absolute.path);
- if (!fs.isDirectorySync(flutterPath)) {
- printError(userMessages.runnerRemovedFlutterRepo(Cache.flutterRoot, flutterPath));
+ if (!globals.fs.isDirectorySync(flutterPath)) {
+ globals.printError(userMessages.runnerRemovedFlutterRepo(Cache.flutterRoot, flutterPath));
} else if (!_compareResolvedPaths(flutterPath, Cache.flutterRoot)) {
- printError(userMessages.runnerChangedFlutterRepo(Cache.flutterRoot, flutterPath));
+ globals.printError(userMessages.runnerChangedFlutterRepo(Cache.flutterRoot, flutterPath));
}
}
}
@@ -512,14 +512,14 @@
// Check if `bin/flutter` and `bin/cache/engine.stamp` exist.
bool _isDirectoryFlutterRepo(String directory) {
return
- fs.isFileSync(fs.path.join(directory, 'bin/flutter')) &&
- fs.isFileSync(fs.path.join(directory, 'bin/cache/engine.stamp'));
+ globals.fs.isFileSync(globals.fs.path.join(directory, 'bin/flutter')) &&
+ globals.fs.isFileSync(globals.fs.path.join(directory, 'bin/cache/engine.stamp'));
}
}
bool _compareResolvedPaths(String path1, String path2) {
- path1 = fs.directory(fs.path.absolute(path1)).resolveSymbolicLinksSync();
- path2 = fs.directory(fs.path.absolute(path2)).resolveSymbolicLinksSync();
+ path1 = globals.fs.directory(globals.fs.path.absolute(path1)).resolveSymbolicLinksSync();
+ path2 = globals.fs.directory(globals.fs.path.absolute(path2)).resolveSymbolicLinksSync();
return path1 == path2;
}
diff --git a/packages/flutter_tools/lib/src/template.dart b/packages/flutter_tools/lib/src/template.dart
index e622960..f47f450 100644
--- a/packages/flutter_tools/lib/src/template.dart
+++ b/packages/flutter_tools/lib/src/template.dart
@@ -7,7 +7,7 @@
import 'base/common.dart';
import 'base/file_system.dart';
import 'cache.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
/// Expands templates in a directory to a destination. All files that must
/// undergo template expansion should end with the '.tmpl' extension. All other
@@ -39,14 +39,14 @@
continue;
}
- final String relativePath = fs.path.relative(entity.path,
+ final String relativePath = globals.fs.path.relative(entity.path,
from: baseDir.absolute.path);
if (relativePath.contains(templateExtension)) {
// If '.tmpl' appears anywhere within the path of this entity, it is
// is a candidate for rendering. This catches cases where the folder
// itself is a template.
- _templateFilePaths[relativePath] = fs.path.absolute(entity.path);
+ _templateFilePaths[relativePath] = globals.fs.path.absolute(entity.path);
}
}
}
@@ -75,7 +75,7 @@
try {
destination.createSync(recursive: true);
} on FileSystemException catch (err) {
- printError(err.toString());
+ globals.printError(err.toString());
throwToolExit('Failed to flutter create at ${destination.path}.');
return 0;
}
@@ -110,8 +110,8 @@
final String androidIdentifier = context['androidIdentifier'] as String;
final String pluginClass = context['pluginClass'] as String;
final String destinationDirPath = destination.absolute.path;
- final String pathSeparator = fs.path.separator;
- String finalDestinationPath = fs.path
+ final String pathSeparator = globals.fs.path.separator;
+ String finalDestinationPath = globals.fs.path
.join(destinationDirPath, relativeDestinationPath)
.replaceAll(copyTemplateExtension, '')
.replaceAll(templateExtension, '');
@@ -139,8 +139,8 @@
if (finalDestinationPath == null) {
return;
}
- final File finalDestinationFile = fs.file(finalDestinationPath);
- final String relativePathForLogging = fs.path.relative(finalDestinationFile.path);
+ final File finalDestinationFile = globals.fs.file(finalDestinationPath);
+ final String relativePathForLogging = globals.fs.path.relative(finalDestinationFile.path);
// Step 1: Check if the file needs to be overwritten.
@@ -148,25 +148,25 @@
if (overwriteExisting) {
finalDestinationFile.deleteSync(recursive: true);
if (printStatusWhenWriting) {
- printStatus(' $relativePathForLogging (overwritten)');
+ globals.printStatus(' $relativePathForLogging (overwritten)');
}
} else {
// The file exists but we cannot overwrite it, move on.
if (printStatusWhenWriting) {
- printTrace(' $relativePathForLogging (existing - skipped)');
+ globals.printTrace(' $relativePathForLogging (existing - skipped)');
}
return;
}
} else {
if (printStatusWhenWriting) {
- printStatus(' $relativePathForLogging (created)');
+ globals.printStatus(' $relativePathForLogging (created)');
}
}
fileCount++;
finalDestinationFile.createSync(recursive: true);
- final File sourceFile = fs.file(absoluteSourcePath);
+ final File sourceFile = globals.fs.file(absoluteSourcePath);
// Step 2: If the absolute paths ends with a '.copy.tmpl', this file does
// not need mustache rendering but needs to be directly copied.
@@ -200,7 +200,7 @@
}
Directory templateDirectoryInPackage(String name) {
- final String templatesDir = fs.path.join(Cache.flutterRoot,
+ final String templatesDir = globals.fs.path.join(Cache.flutterRoot,
'packages', 'flutter_tools', 'templates');
- return fs.directory(fs.path.join(templatesDir, name));
+ return globals.fs.directory(globals.fs.path.join(templatesDir, name));
}
diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart
index af590dd..b9dad72 100644
--- a/packages/flutter_tools/lib/src/test/coverage_collector.dart
+++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart
@@ -10,11 +10,10 @@
import '../base/io.dart';
import '../base/logger.dart';
import '../base/os.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../base/utils.dart';
import '../dart/package_map.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../vmservice.dart';
import 'watcher.dart';
@@ -28,7 +27,7 @@
@override
Future<void> handleFinishedTest(ProcessEvent event) async {
- printTrace('test ${event.childIndex}: collecting coverage');
+ globals.printTrace('test ${event.childIndex}: collecting coverage');
await collectCoverage(event.process, event.observatoryUri);
}
@@ -70,7 +69,7 @@
assert(process != null);
assert(observatoryUri != null);
final int pid = process.pid;
- printTrace('pid $pid: collecting coverage data from $observatoryUri...');
+ globals.printTrace('pid $pid: collecting coverage data from $observatoryUri...');
Map<String, dynamic> data;
final Future<void> processComplete = process.exitCode
@@ -87,9 +86,9 @@
await Future.any<void>(<Future<void>>[ processComplete, collectionComplete ]);
assert(data != null);
- printTrace('pid $pid ($observatoryUri): collected coverage data; merging...');
+ globals.printTrace('pid $pid ($observatoryUri): collected coverage data; merging...');
_addHitmap(coverage.createHitmap(data['coverage'] as List<dynamic>));
- printTrace('pid $pid ($observatoryUri): done merging coverage data into global coverage map.');
+ globals.printTrace('pid $pid ($observatoryUri): done merging coverage data into global coverage map.');
}
/// Returns a future that will complete with the formatted coverage data
@@ -106,9 +105,9 @@
}
if (formatter == null) {
final coverage.Resolver resolver = coverage.Resolver(packagesPath: PackageMap.globalPackagesPath);
- final String packagePath = fs.currentDirectory.path;
+ final String packagePath = globals.fs.currentDirectory.path;
final List<String> reportOn = coverageDirectory == null
- ? <String>[fs.path.join(packagePath, 'lib')]
+ ? <String>[globals.fs.path.join(packagePath, 'lib')]
: <String>[coverageDirectory.path];
formatter = coverage.LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath);
}
@@ -118,42 +117,42 @@
}
Future<bool> collectCoverageData(String coveragePath, { bool mergeCoverageData = false, Directory coverageDirectory }) async {
- final Status status = logger.startProgress('Collecting coverage information...', timeout: timeoutConfiguration.fastOperation);
+ final Status status = globals.logger.startProgress('Collecting coverage information...', timeout: timeoutConfiguration.fastOperation);
final String coverageData = await finalizeCoverage(
coverageDirectory: coverageDirectory,
);
status.stop();
- printTrace('coverage information collection complete');
+ globals.printTrace('coverage information collection complete');
if (coverageData == null) {
return false;
}
- final File coverageFile = fs.file(coveragePath)
+ final File coverageFile = globals.fs.file(coveragePath)
..createSync(recursive: true)
..writeAsStringSync(coverageData, flush: true);
- printTrace('wrote coverage data to $coveragePath (size=${coverageData.length})');
+ globals.printTrace('wrote coverage data to $coveragePath (size=${coverageData.length})');
const String baseCoverageData = 'coverage/lcov.base.info';
if (mergeCoverageData) {
- if (!fs.isFileSync(baseCoverageData)) {
- printError('Missing "$baseCoverageData". Unable to merge coverage data.');
+ if (!globals.fs.isFileSync(baseCoverageData)) {
+ globals.printError('Missing "$baseCoverageData". Unable to merge coverage data.');
return false;
}
if (os.which('lcov') == null) {
String installMessage = 'Please install lcov.';
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
installMessage = 'Consider running "sudo apt-get install lcov".';
- } else if (platform.isMacOS) {
+ } else if (globals.platform.isMacOS) {
installMessage = 'Consider running "brew install lcov".';
}
- printError('Missing "lcov" tool. Unable to merge coverage data.\n$installMessage');
+ globals.printError('Missing "lcov" tool. Unable to merge coverage data.\n$installMessage');
return false;
}
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_test_coverage.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_test_coverage.');
try {
- final File sourceFile = coverageFile.copySync(fs.path.join(tempDir.path, 'lcov.source.info'));
+ final File sourceFile = coverageFile.copySync(globals.fs.path.join(tempDir.path, 'lcov.source.info'));
final RunResult result = processUtils.runSync(<String>[
'lcov',
'--add-tracefile', baseCoverageData,
diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart
index be1e878..8b73b57 100644
--- a/packages/flutter_tools/lib/src/test/flutter_platform.dart
+++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart
@@ -16,13 +16,11 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
import '../build_info.dart';
import '../compile.dart';
import '../convert.dart';
import '../dart/package_map.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../test/test_wrapper.dart';
import '../vmservice.dart';
@@ -378,7 +376,7 @@
await compiler.compiler.compileExpression(expression, definitions,
typeDefinitions, libraryUri, klass, isStatic);
if (compilerOutput != null && compilerOutput.outputFilename != null) {
- return base64.encode(fs.file(compilerOutput.outputFilename).readAsBytesSync());
+ return base64.encode(globals.fs.file(compilerOutput.outputFilename).readAsBytesSync());
}
throw 'Failed to compile $expression';
}
@@ -395,7 +393,7 @@
StreamChannel<dynamic> controller,
int ourTestCount,
) async {
- printTrace('test $ourTestCount: starting test $testPath');
+ globals.printTrace('test $ourTestCount: starting test $testPath');
_AsyncError outOfBandError; // error that we couldn't send to the harness that we need to send via our future
@@ -411,7 +409,7 @@
// Prepare our WebSocket server to talk to the engine subproces.
final HttpServer server = await bind(host, port);
finalizers.add(() async {
- printTrace('test $ourTestCount: shutting down test harness socket server');
+ globals.printTrace('test $ourTestCount: shutting down test harness socket server');
await server.close(force: true);
});
final Completer<WebSocket> webSocket = Completer<WebSocket>();
@@ -423,18 +421,18 @@
},
onError: (dynamic error, StackTrace stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well.
- printTrace('test $ourTestCount: test harness socket server experienced an unexpected error: $error');
+ globals.printTrace('test $ourTestCount: test harness socket server experienced an unexpected error: $error');
if (!controllerSinkClosed) {
controller.sink.addError(error, stack);
controller.sink.close();
} else {
- printError('unexpected error from test harness socket server: $error');
+ globals.printError('unexpected error from test harness socket server: $error');
}
},
cancelOnError: true,
);
- printTrace('test $ourTestCount: starting shell process');
+ globals.printTrace('test $ourTestCount: starting shell process');
// If a kernel file is given, then use that to launch the test.
// If mapping is provided, look kernel file from mapping.
@@ -471,7 +469,7 @@
subprocessActive = true;
finalizers.add(() async {
if (subprocessActive) {
- printTrace('test $ourTestCount: ensuring end-of-process for shell');
+ globals.printTrace('test $ourTestCount: ensuring end-of-process for shell');
process.kill();
final int exitCode = await process.exitCode;
subprocessActive = false;
@@ -504,20 +502,20 @@
assert(explicitObservatoryPort == null ||
explicitObservatoryPort == detectedUri.port);
if (startPaused && !machine) {
- printStatus('The test process has been started.');
- printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
- printStatus(' $detectedUri');
- printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
+ globals.printStatus('The test process has been started.');
+ globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
+ globals.printStatus(' $detectedUri');
+ globals.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
} else {
- printTrace('test $ourTestCount: using observatory uri $detectedUri from pid ${process.pid}');
+ globals.printTrace('test $ourTestCount: using observatory uri $detectedUri from pid ${process.pid}');
}
processObservatoryUri = detectedUri;
{
- printTrace('Connecting to service protocol: $processObservatoryUri');
+ globals.printTrace('Connecting to service protocol: $processObservatoryUri');
final Future<VMService> localVmService = VMService.connect(processObservatoryUri,
compileExpression: _compileExpressionService);
localVmService.then((VMService vmservice) {
- printTrace('Successfully connected to service protocol: $processObservatoryUri');
+ globals.printTrace('Successfully connected to service protocol: $processObservatoryUri');
});
}
gotProcessObservatoryUri.complete();
@@ -534,7 +532,7 @@
// The engine could crash, in which case process.exitCode will complete.
// The engine could connect to us, in which case webSocket.future will complete.
// The local test harness could get bored of us.
- printTrace('test $ourTestCount: awaiting initial result for pid ${process.pid}');
+ globals.printTrace('test $ourTestCount: awaiting initial result for pid ${process.pid}');
final InitialResult initialResult = await Future.any<InitialResult>(<Future<InitialResult>>[
process.exitCode.then<InitialResult>((int exitCode) => InitialResult.crashed),
timeout.future.then<InitialResult>((void value) => InitialResult.timedOut),
@@ -548,7 +546,7 @@
switch (initialResult) {
case InitialResult.crashed:
- printTrace('test $ourTestCount: process with pid ${process.pid} crashed before connecting to test harness');
+ globals.printTrace('test $ourTestCount: process with pid ${process.pid} crashed before connecting to test harness');
final int exitCode = await process.exitCode;
subprocessActive = false;
final String message = _getErrorMessage(
@@ -559,7 +557,7 @@
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
unawaited(controller.sink.close());
- printTrace('test $ourTestCount: waiting for controller sink to close');
+ globals.printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
await watcher?.handleTestCrashed(ProcessEvent(ourTestCount, process));
break;
@@ -567,18 +565,18 @@
// Could happen either if the process takes a long time starting
// (_kTestProcessTimeout), or if once Dart code starts running, it takes a
// long time to open the WebSocket connection (_kTestStartupTimeout).
- printTrace('test $ourTestCount: timed out waiting for process with pid ${process.pid} to connect to test harness');
+ globals.printTrace('test $ourTestCount: timed out waiting for process with pid ${process.pid} to connect to test harness');
final String message = _getErrorMessage('Test never connected to test harness.', testPath, shellPath);
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
unawaited(controller.sink.close());
- printTrace('test $ourTestCount: waiting for controller sink to close');
+ globals.printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
await watcher
?.handleTestTimedOut(ProcessEvent(ourTestCount, process));
break;
case InitialResult.connected:
- printTrace('test $ourTestCount: process with pid ${process.pid} connected to test harness');
+ globals.printTrace('test $ourTestCount: process with pid ${process.pid} connected to test harness');
final WebSocket testSocket = await webSocket.future;
final Completer<void> harnessDone = Completer<void>();
@@ -590,12 +588,12 @@
onDone: harnessDone.complete,
onError: (dynamic error, StackTrace stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well.
- printError('test harness controller stream experienced an unexpected error\ntest: $testPath\nerror: $error');
+ globals.printError('test harness controller stream experienced an unexpected error\ntest: $testPath\nerror: $error');
if (!controllerSinkClosed) {
controller.sink.addError(error, stack);
controller.sink.close();
} else {
- printError('unexpected error from test harness controller stream: $error');
+ globals.printError('unexpected error from test harness controller stream: $error');
}
},
cancelOnError: true,
@@ -610,18 +608,18 @@
onDone: testDone.complete,
onError: (dynamic error, StackTrace stack) {
// If you reach here, it's unlikely we're going to be able to really handle this well.
- printError('test socket stream experienced an unexpected error\ntest: $testPath\nerror: $error');
+ globals.printError('test socket stream experienced an unexpected error\ntest: $testPath\nerror: $error');
if (!controllerSinkClosed) {
controller.sink.addError(error, stack);
controller.sink.close();
} else {
- printError('unexpected error from test socket stream: $error');
+ globals.printError('unexpected error from test socket stream: $error');
}
},
cancelOnError: true,
);
- printTrace('test $ourTestCount: awaiting test result for pid ${process.pid}');
+ globals.printTrace('test $ourTestCount: awaiting test result for pid ${process.pid}');
final TestResult testResult = await Future.any<TestResult>(<Future<TestResult>>[
process.exitCode.then<TestResult>((int exitCode) {
return TestResult.crashed;
@@ -641,7 +639,7 @@
switch (testResult) {
case TestResult.crashed:
- printTrace('test $ourTestCount: process with pid ${process.pid} crashed');
+ globals.printTrace('test $ourTestCount: process with pid ${process.pid} crashed');
final int exitCode = await process.exitCode;
subprocessActive = false;
final String message = _getErrorMessage(
@@ -652,16 +650,16 @@
controller.sink.addError(message);
// Awaited for with 'sink.done' below.
unawaited(controller.sink.close());
- printTrace('test $ourTestCount: waiting for controller sink to close');
+ globals.printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
break;
case TestResult.harnessBailed:
case TestResult.testBailed:
if (testResult == TestResult.harnessBailed) {
- printTrace('test $ourTestCount: process with pid ${process.pid} no longer needed by test harness');
+ globals.printTrace('test $ourTestCount: process with pid ${process.pid} no longer needed by test harness');
} else {
assert(testResult == TestResult.testBailed);
- printTrace('test $ourTestCount: process with pid ${process.pid} no longer needs test harness');
+ globals.printTrace('test $ourTestCount: process with pid ${process.pid} no longer needs test harness');
}
await watcher?.handleFinishedTest(
ProcessEvent(ourTestCount, process, processObservatoryUri));
@@ -670,25 +668,25 @@
break;
}
} catch (error, stack) {
- printTrace('test $ourTestCount: error caught during test; ${controllerSinkClosed ? "reporting to console" : "sending to test framework"}');
+ globals.printTrace('test $ourTestCount: error caught during test; ${controllerSinkClosed ? "reporting to console" : "sending to test framework"}');
if (!controllerSinkClosed) {
controller.sink.addError(error, stack);
} else {
- printError('unhandled error during test:\n$testPath\n$error\n$stack');
+ globals.printError('unhandled error during test:\n$testPath\n$error\n$stack');
outOfBandError ??= _AsyncError(error, stack);
}
} finally {
- printTrace('test $ourTestCount: cleaning up...');
+ globals.printTrace('test $ourTestCount: cleaning up...');
// Finalizers are treated like a stack; run them in reverse order.
for (Finalizer finalizer in finalizers.reversed) {
try {
await finalizer();
} catch (error, stack) {
- printTrace('test $ourTestCount: error while cleaning up; ${controllerSinkClosed ? "reporting to console" : "sending to test framework"}');
+ globals.printTrace('test $ourTestCount: error while cleaning up; ${controllerSinkClosed ? "reporting to console" : "sending to test framework"}');
if (!controllerSinkClosed) {
controller.sink.addError(error, stack);
} else {
- printError('unhandled error during finalization of test:\n$testPath\n$error\n$stack');
+ globals.printError('unhandled error during finalization of test:\n$testPath\n$error\n$stack');
outOfBandError ??= _AsyncError(error, stack);
}
}
@@ -696,16 +694,16 @@
if (!controllerSinkClosed) {
// Waiting below with await.
unawaited(controller.sink.close());
- printTrace('test $ourTestCount: waiting for controller sink to close');
+ globals.printTrace('test $ourTestCount: waiting for controller sink to close');
await controller.sink.done;
}
}
assert(!subprocessActive);
assert(controllerSinkClosed);
if (outOfBandError != null) {
- printTrace('test $ourTestCount: finished with out-of-band failure');
+ globals.printTrace('test $ourTestCount: finished with out-of-band failure');
} else {
- printTrace('test $ourTestCount: finished');
+ globals.printTrace('test $ourTestCount: finished');
}
return outOfBandError;
}
@@ -717,17 +715,17 @@
HttpServer server,
) {
// Prepare a temporary directory to store the Dart file that will talk to us.
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_test_listener.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_test_listener.');
finalizers.add(() async {
- printTrace('test $ourTestCount: deleting temporary directory');
+ globals.printTrace('test $ourTestCount: deleting temporary directory');
tempDir.deleteSync(recursive: true);
});
// Prepare the Dart file that will talk to us and start the test.
- final File listenerFile = fs.file('${tempDir.path}/listener.dart');
+ final File listenerFile = globals.fs.file('${tempDir.path}/listener.dart');
listenerFile.createSync();
listenerFile.writeAsStringSync(_generateTestMain(
- testUrl: fs.path.toUri(fs.path.absolute(testPath)),
+ testUrl: globals.fs.path.toUri(globals.fs.path.absolute(testPath)),
));
return listenerFile.path;
}
@@ -738,7 +736,7 @@
assert(testUrl.scheme == 'file');
return generateTestBootstrap(
testUrl: testUrl,
- testConfigFile: findTestConfigFile(fs.file(testUrl)),
+ testConfigFile: findTestConfigFile(globals.fs.file(testUrl)),
host: host,
updateGoldens: updateGoldens,
);
@@ -753,7 +751,7 @@
compiler = null;
}
if (fontsDirectory != null) {
- printTrace('Deleting ${fontsDirectory.path}...');
+ globals.printTrace('Deleting ${fontsDirectory.path}...');
fontsDirectory.deleteSync(recursive: true);
fontsDirectory = null;
}
@@ -768,16 +766,16 @@
final StringBuffer sb = StringBuffer();
sb.writeln('<fontconfig>');
- sb.writeln(' <dir>${cache.getCacheArtifacts().path}</dir>');
+ sb.writeln(' <dir>${globals.cache.getCacheArtifacts().path}</dir>');
sb.writeln(' <cachedir>/var/cache/fontconfig</cachedir>');
sb.writeln('</fontconfig>');
if (fontsDirectory == null) {
- fontsDirectory = fs.systemTempDirectory.createTempSync('flutter_test_fonts.');
- printTrace('Using this directory for fonts configuration: ${fontsDirectory.path}');
+ fontsDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_test_fonts.');
+ globals.printTrace('Using this directory for fonts configuration: ${fontsDirectory.path}');
}
- _cachedFontConfig = fs.file('${fontsDirectory.path}/fonts.conf');
+ _cachedFontConfig = globals.fs.file('${fontsDirectory.path}/fonts.conf');
_cachedFontConfig.createSync();
_cachedFontConfig.writeAsStringSync(sb.toString());
return _cachedFontConfig;
@@ -826,14 +824,14 @@
testPath,
];
- printTrace(command.join(' '));
+ globals.printTrace(command.join(' '));
// If the FLUTTER_TEST environment variable has been set, then pass it on
// for package:flutter_test to handle the value.
//
// If FLUTTER_TEST has not been set, assume from this context that this
// call was invoked by the command 'flutter test'.
- final String flutterTest = platform.environment.containsKey('FLUTTER_TEST')
- ? platform.environment['FLUTTER_TEST']
+ final String flutterTest = globals.platform.environment.containsKey('FLUTTER_TEST')
+ ? globals.platform.environment['FLUTTER_TEST']
: 'true';
final Map<String, String> environment = <String, String>{
'FLUTTER_TEST': flutterTest,
@@ -841,9 +839,9 @@
'SERVER_PORT': serverPort.toString(),
'APP_NAME': flutterProject?.manifest?.appName ?? '',
if (buildTestAssets)
- 'UNIT_TEST_ASSETS': fs.path.join(flutterProject?.directory?.path ?? '', 'build', 'unit_test_assets'),
+ 'UNIT_TEST_ASSETS': globals.fs.path.join(flutterProject?.directory?.path ?? '', 'build', 'unit_test_assets'),
};
- return processManager.start(command, environment: environment);
+ return globals.processManager.start(command, environment: environment);
}
void _pipeStandardStreamsToConsole(
@@ -866,24 +864,24 @@
startTimeoutTimer();
}
} else if (line.startsWith('error: Unable to read Dart source \'package:test/')) {
- printTrace('Shell: $line');
- printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n');
+ globals.printTrace('Shell: $line');
+ globals.printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n');
} else if (line.startsWith(observatoryString)) {
- printTrace('Shell: $line');
+ globals.printTrace('Shell: $line');
try {
final Uri uri = Uri.parse(line.substring(observatoryString.length));
if (reportObservatoryUri != null) {
reportObservatoryUri(uri);
}
} catch (error) {
- printError('Could not parse shell observatory port message: $error');
+ globals.printError('Could not parse shell observatory port message: $error');
}
} else if (line != null) {
- printStatus('Shell: $line');
+ globals.printStatus('Shell: $line');
}
},
onError: (dynamic error) {
- printError('shell console stream for process pid ${process.pid} experienced an unexpected error: $error');
+ globals. printError('shell console stream for process pid ${process.pid} experienced an unexpected error: $error');
},
cancelOnError: true,
);
diff --git a/packages/flutter_tools/lib/src/test/flutter_web_platform.dart b/packages/flutter_tools/lib/src/test/flutter_web_platform.dart
index 2323e0a..7aa705b 100644
--- a/packages/flutter_tools/lib/src/test/flutter_web_platform.dart
+++ b/packages/flutter_tools/lib/src/test/flutter_web_platform.dart
@@ -33,12 +33,11 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/process_manager.dart';
import '../build_info.dart';
import '../cache.dart';
import '../convert.dart';
import '../dart/package_map.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../web/chrome.dart';
@@ -52,7 +51,7 @@
this.updateGoldens,
}) {
// Look up the location of the testing resources.
- final Map<String, Uri> packageMap = PackageMap(fs.path.join(
+ final Map<String, Uri> packageMap = PackageMap(globals.fs.path.join(
Cache.flutterRoot,
'packages',
'flutter_tools',
@@ -64,7 +63,7 @@
.add(packagesDirHandler())
.add(_jsHandler.handler)
.add(createStaticHandler(
- fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools'),
+ globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools'),
serveFilesOutsidePath: true,
))
.add(createStaticHandler(_config.suiteDefaults.precompiledPath,
@@ -109,7 +108,7 @@
Uri get url => _server.url;
/// The ahem text file.
- File get ahem => fs.file(fs.path.join(
+ File get ahem => globals.fs.file(globals.fs.path.join(
Cache.flutterRoot,
'packages',
'flutter_tools',
@@ -118,8 +117,8 @@
));
/// The require js binary.
- File get requireJs => fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.engineDartSdkPath),
+ File get requireJs => globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath),
'lib',
'dev_compiler',
'kernel',
@@ -128,8 +127,8 @@
));
/// The ddc to dart stack trace mapper.
- File get stackTraceMapper => fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.engineDartSdkPath),
+ File get stackTraceMapper => globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath),
'lib',
'dev_compiler',
'web',
@@ -137,20 +136,20 @@
));
/// The precompiled dart sdk.
- File get dartSdk => fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.flutterWebSdk),
+ File get dartSdk => globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
'amd',
'dart_sdk.js',
));
/// The precompiled test javascript.
- File get testDartJs => fs.file(fs.path.join(
+ File get testDartJs => globals.fs.file(globals.fs.path.join(
testUri.toFilePath(),
'dart.js',
));
- File get testHostDartJs => fs.file(fs.path.join(
+ File get testHostDartJs => globals.fs.file(globals.fs.path.join(
testUri.toFilePath(),
'src',
'runner',
@@ -228,10 +227,10 @@
});
bytes = base64.decode(response.result['data'] as String);
} on WipError catch (ex) {
- printError('Caught WIPError: $ex');
+ globals.printError('Caught WIPError: $ex');
return shelf.Response.ok('WIP error: $ex');
} on FormatException catch (ex) {
- printError('Caught FormatException: $ex');
+ globals.printError('Caught FormatException: $ex');
return shelf.Response.ok('Caught exception: $ex');
}
@@ -263,10 +262,10 @@
// A handler that serves wrapper files used to bootstrap tests.
shelf.Response _wrapperHandler(shelf.Request request) {
- final String path = fs.path.fromUri(request.url);
+ final String path = globals.fs.path.fromUri(request.url);
if (path.endsWith('.html')) {
- final String test = fs.path.withoutExtension(path) + '.dart';
- final String scriptBase = htmlEscape.convert(fs.path.basename(test));
+ final String test = globals.fs.path.withoutExtension(path) + '.dart';
+ final String scriptBase = htmlEscape.convert(globals.fs.path.basename(test));
final String link = '<link rel="x-dart-test" href="$scriptBase">';
return shelf.Response.ok('''
<!DOCTYPE html>
@@ -279,7 +278,7 @@
</html>
''', headers: <String, String>{'Content-Type': 'text/html'});
}
- printTrace('Did not find anything for request: ${request.url}');
+ globals.printTrace('Did not find anything for request: ${request.url}');
return shelf.Response.notFound('Not found.');
}
@@ -299,8 +298,8 @@
return null;
}
- final Uri suiteUrl = url.resolveUri(fs.path.toUri(fs.path.withoutExtension(
- fs.path.relative(path, from: fs.path.join(_root, 'test'))) +
+ final Uri suiteUrl = url.resolveUri(globals.fs.path.toUri(globals.fs.path.withoutExtension(
+ globals.fs.path.relative(path, from: globals.fs.path.join(_root, 'test'))) +
'.html'));
final RunnerSuite suite = await browserManager
.load(path, suiteUrl, suiteConfig, message, mapper: _mappers[path]);
@@ -334,7 +333,7 @@
'debug': _config.pauseAfterLoad.toString(),
});
- printTrace('Serving tests at $hostUrl');
+ globals.printTrace('Serving tests at $hostUrl');
final Future<BrowserManager> future = BrowserManager.start(
browser,
@@ -793,7 +792,7 @@
class TestGoldenComparator {
/// Creates a [TestGoldenComparator] instance.
TestGoldenComparator(this.shellPath, this.compilerFactory)
- : tempDir = fs.systemTempDirectory.createTempSync('flutter_web_platform.');
+ : tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_web_platform.');
final String shellPath;
final Directory tempDir;
@@ -845,7 +844,7 @@
// Chrome is the only supported browser currently.
'FLUTTER_TEST_BROWSER': 'chrome',
};
- return processManager.start(command, environment: environment);
+ return globals.processManager.start(command, environment: environment);
}
Future<String> compareGoldens(Uri testUri, Uint8List bytes, Uri goldenKey, bool updateGoldens) async {
@@ -876,7 +875,7 @@
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
.where((String line) {
- printTrace('<<< $line');
+ globals.printTrace('<<< $line');
return line.isNotEmpty && line[0] == '{';
})
.map<dynamic>(jsonDecode)
@@ -886,7 +885,7 @@
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
.forEach((String line) {
- printError('<<< $line');
+ globals.printError('<<< $line');
});
}
@@ -904,7 +903,7 @@
'key': goldenKey.toString(),
'update': updateGoldens,
});
- printTrace('Preparing to send command: $command');
+ globals.printTrace('Preparing to send command: $command');
process.stdin.writeln(command);
}
@@ -915,7 +914,7 @@
}
static String generateBootstrap(Uri testUri) {
- final File testConfigFile = findTestConfigFile(fs.file(testUri));
+ final File testConfigFile = findTestConfigFile(globals.fs.file(testUri));
// Generate comparator process for the file.
return '''
import 'dart:convert'; // ignore: dart_convert_import
diff --git a/packages/flutter_tools/lib/src/test/runner.dart b/packages/flutter_tools/lib/src/test/runner.dart
index 527584d..593603d 100644
--- a/packages/flutter_tools/lib/src/test/runner.dart
+++ b/packages/flutter_tools/lib/src/test/runner.dart
@@ -10,11 +10,9 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/process_manager.dart';
-import '../base/terminal.dart';
import '../build_info.dart';
import '../dart/package_map.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../web/compile.dart';
import 'flutter_platform.dart' as loader;
@@ -49,14 +47,14 @@
String randomSeed = '0',
}) async {
// Configure package:test to use the Flutter engine for child processes.
- final String shellPath = artifacts.getArtifactPath(Artifact.flutterTester);
- if (!processManager.canRun(shellPath)) {
+ final String shellPath = globals.artifacts.getArtifactPath(Artifact.flutterTester);
+ if (!globals.processManager.canRun(shellPath)) {
throwToolExit('Cannot execute Flutter tester at $shellPath');
}
// Compute the command-line arguments for package:test.
final List<String> testArgs = <String>[
- if (!terminal.supportsColor)
+ if (!globals.terminal.supportsColor)
'--no-color',
if (machine)
...<String>['-r', 'json']
@@ -70,7 +68,7 @@
'--test-randomize-ordering-seed=$randomSeed',
];
if (web) {
- final String tempBuildDir = fs.systemTempDirectory
+ final String tempBuildDir = globals.fs.systemTempDirectory
.createTempSync('flutter_test.')
.absolute
.uri
@@ -127,7 +125,7 @@
trackWidgetCreation: trackWidgetCreation,
updateGoldens: updateGoldens,
buildTestAssets: buildTestAssets,
- projectRootDirectory: fs.currentDirectory.uri,
+ projectRootDirectory: globals.fs.currentDirectory.uri,
flutterProject: flutterProject,
icudtlPath: icudtlPath,
);
@@ -135,25 +133,25 @@
// Make the global packages path absolute.
// (Makes sure it still works after we change the current directory.)
PackageMap.globalPackagesPath =
- fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
+ globals.fs.path.normalize(globals.fs.path.absolute(PackageMap.globalPackagesPath));
// Call package:test's main method in the appropriate directory.
- final Directory saved = fs.currentDirectory;
+ final Directory saved = globals.fs.currentDirectory;
try {
if (workDir != null) {
- printTrace('switching to directory $workDir to run tests');
- fs.currentDirectory = workDir;
+ globals.printTrace('switching to directory $workDir to run tests');
+ globals.fs.currentDirectory = workDir;
}
- printTrace('running test package with arguments: $testArgs');
+ globals.printTrace('running test package with arguments: $testArgs');
await testWrapper.main(testArgs);
// test.main() sets dart:io's exitCode global.
- printTrace('test package returned with exit code $exitCode');
+ globals.printTrace('test package returned with exit code $exitCode');
return exitCode;
} finally {
- fs.currentDirectory = saved;
+ globals.fs.currentDirectory = saved;
await platform.close();
}
}
diff --git a/packages/flutter_tools/lib/src/test/test_compiler.dart b/packages/flutter_tools/lib/src/test/test_compiler.dart
index 27dda02..7d434dc 100644
--- a/packages/flutter_tools/lib/src/test/test_compiler.dart
+++ b/packages/flutter_tools/lib/src/test/test_compiler.dart
@@ -14,7 +14,7 @@
import '../codegen.dart';
import '../compile.dart';
import '../dart/package_map.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
/// A request to the [TestCompiler] for recompilation.
@@ -41,18 +41,18 @@
this.trackWidgetCreation,
this.flutterProject,
) : testFilePath = getKernelPathForTransformerOptions(
- fs.path.join(flutterProject.directory.path, getBuildDirectory(), 'testfile.dill'),
+ globals.fs.path.join(flutterProject.directory.path, getBuildDirectory(), 'testfile.dill'),
trackWidgetCreation: trackWidgetCreation,
) {
// Compiler maintains and updates single incremental dill file.
// Incremental compilation requests done for each test copy that file away
// for independent execution.
- final Directory outputDillDirectory = fs.systemTempDirectory.createTempSync('flutter_test_compiler.');
+ final Directory outputDillDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_test_compiler.');
outputDill = outputDillDirectory.childFile('output.dill');
- printTrace('Compiler will use the following file as its incremental dill file: ${outputDill.path}');
- printTrace('Listening to compiler controller...');
+ globals.printTrace('Compiler will use the following file as its incremental dill file: ${outputDill.path}');
+ globals.printTrace('Listening to compiler controller...');
compilerController.stream.listen(_onCompilationRequest, onDone: () {
- printTrace('Deleting ${outputDillDirectory.path}...');
+ globals.printTrace('Deleting ${outputDillDirectory.path}...');
outputDillDirectory.deleteSync(recursive: true);
});
}
@@ -107,7 +107,7 @@
);
}
return ResidentCompiler(
- artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
+ globals.artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
packagesPath: PackageMap.globalPackagesPath,
buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation,
@@ -130,7 +130,7 @@
}
while (compilationQueue.isNotEmpty) {
final _CompilationRequest request = compilationQueue.first;
- printTrace('Compiling ${request.path}');
+ globals.printTrace('Compiling ${request.path}');
final Stopwatch compilerTime = Stopwatch()..start();
bool firstCompile = false;
if (compiler == null) {
@@ -153,9 +153,9 @@
request.result.complete(null);
await _shutdown();
} else {
- final File outputFile = fs.file(outputPath);
+ final File outputFile = globals.fs.file(outputPath);
final File kernelReadyToRun = await outputFile.copy('${request.path}.dill');
- final File testCache = fs.file(testFilePath);
+ final File testCache = globals.fs.file(testFilePath);
if (firstCompile || !testCache.existsSync() || (testCache.lengthSync() < outputFile.lengthSync())) {
// The idea is to keep the cache file up-to-date and include as
// much as possible in an effort to re-use as many packages as
@@ -167,7 +167,7 @@
compiler.accept();
compiler.reset();
}
- printTrace('Compiling ${request.path} took ${compilerTime.elapsedMilliseconds}ms');
+ globals.printTrace('Compiling ${request.path} took ${compilerTime.elapsedMilliseconds}ms');
// Only remove now when we finished processing the element
compilationQueue.removeAt(0);
}
@@ -178,14 +178,14 @@
return;
}
if (message.startsWith('Error: Could not resolve the package \'flutter_test\'')) {
- printTrace(message);
- printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n',
+ globals.printTrace(message);
+ globals.printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n',
emphasis: emphasis,
color: color,
);
_suppressOutput = true;
return;
}
- printError('$message');
+ globals.printError('$message');
}
}
diff --git a/packages/flutter_tools/lib/src/test/test_config.dart b/packages/flutter_tools/lib/src/test/test_config.dart
index 1d65774..ded1010 100644
--- a/packages/flutter_tools/lib/src/test/test_config.dart
+++ b/packages/flutter_tools/lib/src/test/test_config.dart
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import '../base/file_system.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
/// The name of the test configuration file that will be discovered by the
/// test harness if it exists in the project directory hierarchy.
@@ -20,12 +20,12 @@
while (directory.path != directory.parent.path) {
final File configFile = directory.childFile(_kTestConfigFileName);
if (configFile.existsSync()) {
- printTrace('Discovered $_kTestConfigFileName in ${directory.path}');
+ globals.printTrace('Discovered $_kTestConfigFileName in ${directory.path}');
testConfigFile = configFile;
break;
}
if (directory.childFile(_kProjectRootSentinel).existsSync()) {
- printTrace('Stopping scan for $_kTestConfigFileName; '
+ globals.printTrace('Stopping scan for $_kTestConfigFileName; '
'found project root at ${directory.path}');
break;
}
diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart
index 077830d..57e08c6 100644
--- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart
+++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart
@@ -11,20 +11,19 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/process_manager.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../convert.dart';
import '../dart/package_map.dart';
import '../device.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../protocol_discovery.dart';
import '../version.dart';
class FlutterTesterApp extends ApplicationPackage {
factory FlutterTesterApp.fromCurrentDirectory() {
- return FlutterTesterApp._(fs.currentDirectory);
+ return FlutterTesterApp._(globals.fs.currentDirectory);
}
FlutterTesterApp._(Directory directory)
@@ -110,12 +109,12 @@
final BuildInfo buildInfo = debuggingOptions.buildInfo;
if (!buildInfo.isDebug) {
- printError('This device only supports debug mode.');
+ globals.printError('This device only supports debug mode.');
return LaunchResult.failed();
}
- final String shellPath = artifacts.getArtifactPath(Artifact.flutterTester);
- if (!fs.isFileSync(shellPath)) {
+ final String shellPath = globals.artifacts.getArtifactPath(Artifact.flutterTester);
+ if (!globals.fs.isFileSync(shellPath)) {
throwToolExit('Cannot find Flutter shell at $shellPath');
}
@@ -141,7 +140,7 @@
// Build assets and perform initial compilation.
final String assetDirPath = getAssetBuildDirectory();
final String applicationKernelFilePath = getKernelPathForTransformerOptions(
- fs.path.join(getBuildDirectory(), 'flutter-tester-app.dill'),
+ globals.fs.path.join(getBuildDirectory(), 'flutter-tester-app.dill'),
trackWidgetCreation: buildInfo.trackWidgetCreation,
);
await BundleBuilder().build(
@@ -158,10 +157,10 @@
command.add(applicationKernelFilePath);
try {
- printTrace(command.join(' '));
+ globals.printTrace(command.join(' '));
_isRunning = true;
- _process = await processManager.start(command,
+ _process = await globals.processManager.start(command,
environment: <String, String>{
'FLUTTER_TEST': 'true',
},
@@ -195,7 +194,7 @@
final Uri observatoryUri = await observatoryDiscovery.uri;
return LaunchResult.succeeded(observatoryUri: observatoryUri);
} catch (error) {
- printError('Failed to launch $package: $error');
+ globals.printError('Failed to launch $package: $error');
return LaunchResult.failed();
}
}
diff --git a/packages/flutter_tools/lib/src/tracing.dart b/packages/flutter_tools/lib/src/tracing.dart
index 95c0dc0..623a10d 100644
--- a/packages/flutter_tools/lib/src/tracing.dart
+++ b/packages/flutter_tools/lib/src/tracing.dart
@@ -8,7 +8,7 @@
import 'base/logger.dart';
import 'base/utils.dart';
import 'build_info.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'vmservice.dart';
// Names of some of the Timeline events we care about.
@@ -39,7 +39,7 @@
bool awaitFirstFrame = false,
}) async {
if (awaitFirstFrame) {
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Waiting for application to render first frame...',
timeout: timeoutConfiguration.fastOperation,
);
@@ -75,8 +75,8 @@
/// Download the startup trace information from the given observatory client and
/// store it to build/start_up_info.json.
Future<void> downloadStartupTrace(VMService observatory, { bool awaitFirstFrame = true }) async {
- final String traceInfoFilePath = fs.path.join(getBuildDirectory(), 'start_up_info.json');
- final File traceInfoFile = fs.file(traceInfoFilePath);
+ final String traceInfoFilePath = globals.fs.path.join(getBuildDirectory(), 'start_up_info.json');
+ final File traceInfoFile = globals.fs.file(traceInfoFilePath);
// Delete old startup data, if any.
if (traceInfoFile.existsSync()) {
@@ -109,7 +109,7 @@
final int frameworkInitTimestampMicros = extractInstantEventTimestamp(kFrameworkInitEventName);
if (engineEnterTimestampMicros == null) {
- printTrace('Engine start event is missing in the timeline: $timeline');
+ globals.printTrace('Engine start event is missing in the timeline: $timeline');
throw 'Engine start event is missing in the timeline. Cannot compute startup time.';
}
@@ -127,7 +127,7 @@
final int firstFrameBuiltTimestampMicros = extractInstantEventTimestamp(kFirstFrameBuiltEventName);
final int firstFrameRasterizedTimestampMicros = extractInstantEventTimestamp(kFirstFrameRasterizedEventName);
if (firstFrameBuiltTimestampMicros == null || firstFrameRasterizedTimestampMicros == null) {
- printTrace('First frame events are missing in the timeline: $timeline');
+ globals.printTrace('First frame events are missing in the timeline: $timeline');
throw 'First frame events are missing in the timeline. Cannot compute startup time.';
}
@@ -146,6 +146,6 @@
traceInfoFile.writeAsStringSync(toPrettyJson(traceInfo));
- printStatus(message);
- printStatus('Saved startup trace info in ${traceInfoFile.path}.');
+ globals.printStatus(message);
+ globals.printStatus('Saved startup trace info in ${traceInfoFile.path}.');
}
diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart
index 738015f..d6dc8c8 100644
--- a/packages/flutter_tools/lib/src/version.dart
+++ b/packages/flutter_tools/lib/src/version.dart
@@ -11,11 +11,10 @@
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/process.dart';
-import 'base/process_manager.dart';
import 'base/time.dart';
import 'cache.dart';
import 'convert.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
class FlutterVersion {
FlutterVersion([this._clock = const SystemClock()]) {
@@ -97,13 +96,13 @@
String get frameworkDate => frameworkCommitDate;
- String get dartSdkVersion => Cache.instance.dartSdkVersion;
+ String get dartSdkVersion => globals.cache.dartSdkVersion;
- String get engineRevision => Cache.instance.engineRevision;
+ String get engineRevision => globals.cache.engineRevision;
String get engineRevisionShort => _shortGitRevision(engineRevision);
Future<void> ensureVersionFile() {
- fs.file(fs.path.join(Cache.flutterRoot, 'version')).writeAsStringSync(_frameworkVersion);
+ globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'version')).writeAsStringSync(_frameworkVersion);
return Future<void>.value();
}
@@ -161,7 +160,7 @@
} on VersionCheckError catch (e) {
if (lenient) {
final DateTime dummyDate = DateTime.fromMillisecondsSinceEpoch(0);
- printError('Failed to find the latest git commit date: $e\n'
+ globals.printError('Failed to find the latest git commit date: $e\n'
'Returning $dummyDate instead.');
// Return something that DateTime.parse() can parse.
return dummyDate.toString();
@@ -249,7 +248,7 @@
String tentativeDescendantRevision,
String tentativeAncestorRevision,
}) {
- final ProcessResult result = processManager.runSync(
+ final ProcessResult result = globals.processManager.runSync(
<String>[
'git',
'merge-base',
@@ -309,7 +308,7 @@
/// channel doesn't linger.
static Future<void> resetFlutterVersionFreshnessCheck() async {
try {
- await Cache.instance.getStampFileFor(
+ await globals.cache.getStampFileFor(
VersionCheckStamp.flutterVersionCheckStampFile,
).delete();
} on FileSystemException {
@@ -368,7 +367,7 @@
remoteVersionStatus == VersionCheckResult.newVersionAvailable
? newVersionAvailableMessage()
: versionOutOfDateMessage(frameworkAge);
- printStatus(updateMessage, emphasis: true);
+ globals.printStatus(updateMessage, emphasis: true);
await Future.wait<void>(<Future<void>>[
stamp.store(
newTimeWarningWasPrinted: _clock.now(),
@@ -448,7 +447,7 @@
// This happens when any of the git commands fails, which can happen when
// there's no Internet connectivity. Remote version check is best effort
// only. We do not prevent the command from running when it fails.
- printTrace('Failed to check Flutter version in the remote repository: $error');
+ globals.printTrace('Failed to check Flutter version in the remote repository: $error');
// Still update the timestamp to avoid us hitting the server on every single
// command if for some reason we cannot connect (eg. we may be offline).
await versionCheckStamp.store(
@@ -477,7 +476,7 @@
static const String flutterVersionCheckStampFile = 'flutter_version_check';
static Future<VersionCheckStamp> load() async {
- final String versionCheckStamp = Cache.instance.getStampFor(flutterVersionCheckStampFile);
+ final String versionCheckStamp = globals.cache.getStampFor(flutterVersionCheckStampFile);
if (versionCheckStamp != null) {
// Attempt to parse stamp JSON.
@@ -486,11 +485,11 @@
if (jsonObject is Map<String, dynamic>) {
return fromJson(jsonObject);
} else {
- printTrace('Warning: expected version stamp to be a Map but found: $jsonObject');
+ globals.printTrace('Warning: expected version stamp to be a Map but found: $jsonObject');
}
} catch (error, stackTrace) {
// Do not crash if JSON is malformed.
- printTrace('${error.runtimeType}: $error\n$stackTrace');
+ globals.printTrace('${error.runtimeType}: $error\n$stackTrace');
}
}
@@ -532,7 +531,7 @@
}
const JsonEncoder prettyJsonEncoder = JsonEncoder.withIndent(' ');
- Cache.instance.setStampFor(flutterVersionCheckStampFile, prettyJsonEncoder.convert(jsonData));
+ globals.cache.setStampFor(flutterVersionCheckStampFile, prettyJsonEncoder.convert(jsonData));
}
Map<String, String> toJson({
@@ -582,7 +581,7 @@
/// If [lenient] is true and the command fails, returns an empty string.
/// Otherwise, throws a [ToolExit] exception.
String _runSync(List<String> command, { bool lenient = true }) {
- final ProcessResult results = processManager.runSync(
+ final ProcessResult results = globals.processManager.runSync(
command,
workingDirectory: Cache.flutterRoot,
);
@@ -614,7 +613,7 @@
///
/// If the command fails, throws a [ToolExit] exception.
Future<String> _run(List<String> command) async {
- final ProcessResult results = await processManager.run(command, workingDirectory: Cache.flutterRoot);
+ final ProcessResult results = await globals.processManager.run(command, workingDirectory: Cache.flutterRoot);
if (results.exitCode == 0) {
return (results.stdout as String).trim();
@@ -669,7 +668,7 @@
final RegExp versionPattern = RegExp(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:\+hotfix\.([0-9]+))?-([0-9]+)-g([a-f0-9]+)$');
final List<String> parts = versionPattern.matchAsPrefix(version)?.groups(<int>[1, 2, 3, 4, 5, 6]);
if (parts == null) {
- printTrace('Could not interpret results of "git describe": $version');
+ globals.printTrace('Could not interpret results of "git describe": $version');
return const GitTagVersion.unknown();
}
final List<int> parsedParts = parts.take(5).map<int>((String source) => source == null ? null : int.tryParse(source)).toList();
diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart
index 928cf2a..9d0450e 100644
--- a/packages/flutter_tools/lib/src/vmservice.dart
+++ b/packages/flutter_tools/lib/src/vmservice.dart
@@ -14,12 +14,11 @@
import 'base/common.dart';
import 'base/context.dart';
-import 'base/file_system.dart';
import 'base/io.dart' as io;
import 'base/utils.dart';
import 'convert.dart' show base64, utf8;
import 'device.dart';
-import 'globals.dart';
+import 'globals.dart' as globals;
import 'version.dart';
/// Override `WebSocketConnector` in [context] to use a different constructor
@@ -71,11 +70,11 @@
io.WebSocket socket;
Future<void> handleError(dynamic e) async {
- printTrace('Exception attempting to connect to Observatory: $e');
- printTrace('This was attempt #$attempts. Will retry in $delay.');
+ globals.printTrace('Exception attempting to connect to Observatory: $e');
+ globals.printTrace('This was attempt #$attempts. Will retry in $delay.');
if (attempts == 10) {
- printStatus('This is taking longer than expected...');
+ globals.printStatus('This is taking longer than expected...');
}
// Delay next attempt.
@@ -180,7 +179,7 @@
throw rpc.RpcException.invalidParams('Invalid \'classId\': $classId');
}
- printTrace('reloadMethod not yet supported, falling back to hot reload');
+ globals.printTrace('reloadMethod not yet supported, falling back to hot reload');
try {
await reloadMethod(
@@ -291,7 +290,7 @@
}
static void _unhandledError(dynamic error, dynamic stack) {
- logger.printTrace('Error in internal implementation of JSON RPC.\n$error\n$stack');
+ globals.logger.printTrace('Error in internal implementation of JSON RPC.\n$error\n$stack');
assert(false);
}
@@ -332,7 +331,7 @@
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
Device device,
}) async {
- final Uri wsUri = httpUri.replace(scheme: 'ws', path: fs.path.join(httpUri.path, 'ws'));
+ final Uri wsUri = httpUri.replace(scheme: 'ws', path: globals.fs.path.join(httpUri.path, 'ws'));
final StreamChannel<String> channel = await _openChannel(wsUri, compression: compression);
final rpc.Peer peer = rpc.Peer.withoutJson(jsonDocument.bind(channel), onUnhandledError: _unhandledError);
final VMService service = VMService(
@@ -420,7 +419,7 @@
final Map<String, dynamic> eventIsolate = castStringKeyedMap(eventData['isolate']);
// Log event information.
- printTrace('Notification from VM: $data');
+ globals.printTrace('Notification from VM: $data');
ServiceEvent event;
if (eventIsolate != null) {
@@ -898,7 +897,7 @@
// Eagerly load the isolate.
isolate.load().catchError((dynamic e, StackTrace stack) {
- printTrace('Eagerly loading an isolate failed: $e\n$stack');
+ globals.printTrace('Eagerly loading an isolate failed: $e\n$stack');
});
} else {
// Existing isolate, update data.
@@ -948,20 +947,20 @@
Map<String, dynamic> params = const <String, dynamic>{},
bool truncateLogs = true,
}) async {
- printTrace('Sending to VM service: $method($params)');
+ globals.printTrace('Sending to VM service: $method($params)');
assert(params != null);
try {
final Map<String, dynamic> result = await _vmService._sendRequest(method, params);
final String resultString =
truncateLogs ? _truncate(result.toString(), 250, '...') : result.toString();
- printTrace('Result: $resultString');
+ globals.printTrace('Result: $resultString');
return result;
} on WebSocketChannelException catch (error) {
throwToolExit('Error connecting to observatory: $error');
return null;
} on rpc.RpcException catch (error) {
- printError('Error ${error.code} received from application: ${error.message}');
- printTrace('${error.data}');
+ globals.printError('Error ${error.code} received from application: ${error.message}');
+ globals.printTrace('${error.data}');
rethrow;
}
}
@@ -1087,7 +1086,7 @@
}
failCount += 1;
if (failCount == 5) { // waited 200ms
- printStatus('Flutter is taking longer than expected to report its views. Still trying...');
+ globals.printStatus('Flutter is taking longer than expected to report its views. Still trying...');
}
await Future<void>.delayed(const Duration(milliseconds: 50));
await reload();
@@ -1501,7 +1500,7 @@
// TODO(johnmccutchan): Listen to the debug stream and catch initial
// launch errors.
if (event.kind == ServiceEvent.kIsolateRunnable) {
- printTrace('Isolate is runnable.');
+ globals.printTrace('Isolate is runnable.');
if (!completer.isCompleted) {
completer.complete();
}
diff --git a/packages/flutter_tools/lib/src/vscode/vscode.dart b/packages/flutter_tools/lib/src/vscode/vscode.dart
index 4a810b8..6410493 100644
--- a/packages/flutter_tools/lib/src/vscode/vscode.dart
+++ b/packages/flutter_tools/lib/src/vscode/vscode.dart
@@ -4,12 +4,11 @@
import '../base/common.dart';
import '../base/file_system.dart';
-import '../base/platform.dart';
import '../base/utils.dart';
import '../base/version.dart';
import '../convert.dart';
import '../doctor.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
// Include VS Code insiders (useful for debugging).
const bool _includeInsiders = false;
@@ -23,7 +22,7 @@
VsCode._(this.directory, this.extensionDirectory, { Version version, this.edition })
: version = version ?? Version.unknown {
- if (!fs.isDirectorySync(directory)) {
+ if (!globals.fs.isDirectorySync(directory)) {
_validationMessages.add(ValidationMessage.error('VS Code not found at $directory'));
return;
} else {
@@ -34,14 +33,14 @@
// below will fail, so just bail out early.
final ValidationMessage notInstalledMessage = ValidationMessage.error(
'Flutter extension not installed; install from\n$extensionMarketplaceUrl');
- if (!fs.isDirectorySync(extensionDirectory)) {
+ if (!globals.fs.isDirectorySync(extensionDirectory)) {
_validationMessages.add(notInstalledMessage);
return;
}
// Check for presence of extension.
final String extensionIdentifierLower = extensionIdentifier.toLowerCase();
- final Iterable<FileSystemEntity> extensionDirs = fs
+ final Iterable<FileSystemEntity> extensionDirs = globals.fs
.directory(extensionDirectory)
.listSync()
.whereType<Directory>()
@@ -65,7 +64,7 @@
String edition,
}) {
final String packageJsonPath =
- fs.path.join(installPath, 'resources', 'app', 'package.json');
+ globals.fs.path.join(installPath, 'resources', 'app', 'package.json');
final String versionString = _getVersionFromPackageJson(packageJsonPath);
Version version;
if (versionString != null) {
@@ -89,13 +88,13 @@
Iterable<ValidationMessage> get validationMessages => _validationMessages;
static List<VsCode> allInstalled() {
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
return _installedMacOS();
}
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
return _installedWindows();
}
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
return _installedLinux();
}
// VS Code isn't supported on the other platforms.
@@ -113,20 +112,20 @@
static List<VsCode> _installedMacOS() {
return _findInstalled(<_VsCodeInstallLocation>[
_VsCodeInstallLocation(
- fs.path.join('/Applications', 'Visual Studio Code.app', 'Contents'),
+ globals.fs.path.join('/Applications', 'Visual Studio Code.app', 'Contents'),
'.vscode',
),
_VsCodeInstallLocation(
- fs.path.join(homeDirPath, 'Applications', 'Visual Studio Code.app', 'Contents'),
+ globals.fs.path.join(homeDirPath, 'Applications', 'Visual Studio Code.app', 'Contents'),
'.vscode',
),
_VsCodeInstallLocation(
- fs.path.join('/Applications', 'Visual Studio Code - Insiders.app', 'Contents'),
+ globals.fs.path.join('/Applications', 'Visual Studio Code - Insiders.app', 'Contents'),
'.vscode-insiders',
isInsiders: true,
),
_VsCodeInstallLocation(
- fs.path.join(homeDirPath, 'Applications', 'Visual Studio Code - Insiders.app', 'Contents'),
+ globals.fs.path.join(homeDirPath, 'Applications', 'Visual Studio Code - Insiders.app', 'Contents'),
'.vscode-insiders',
isInsiders: true,
),
@@ -146,37 +145,37 @@
// $HOME/.vscode/extensions
// $HOME/.vscode-insiders/extensions
static List<VsCode> _installedWindows() {
- final String progFiles86 = platform.environment['programfiles(x86)'];
- final String progFiles = platform.environment['programfiles'];
- final String localAppData = platform.environment['localappdata'];
+ final String progFiles86 = globals.platform.environment['programfiles(x86)'];
+ final String progFiles = globals.platform.environment['programfiles'];
+ final String localAppData = globals.platform.environment['localappdata'];
final List<_VsCodeInstallLocation> searchLocations =
<_VsCodeInstallLocation>[];
if (localAppData != null) {
searchLocations.add(_VsCodeInstallLocation(
- fs.path.join(localAppData, 'Programs\\Microsoft VS Code'),
+ globals.fs.path.join(localAppData, 'Programs\\Microsoft VS Code'),
'.vscode'));
}
searchLocations.add(_VsCodeInstallLocation(
- fs.path.join(progFiles86, 'Microsoft VS Code'), '.vscode',
+ globals.fs.path.join(progFiles86, 'Microsoft VS Code'), '.vscode',
edition: '32-bit edition'));
searchLocations.add(_VsCodeInstallLocation(
- fs.path.join(progFiles, 'Microsoft VS Code'), '.vscode',
+ globals.fs.path.join(progFiles, 'Microsoft VS Code'), '.vscode',
edition: '64-bit edition'));
if (localAppData != null) {
searchLocations.add(_VsCodeInstallLocation(
- fs.path.join(localAppData, 'Programs\\Microsoft VS Code Insiders'),
+ globals.fs.path.join(localAppData, 'Programs\\Microsoft VS Code Insiders'),
'.vscode-insiders',
isInsiders: true));
}
searchLocations.add(_VsCodeInstallLocation(
- fs.path.join(progFiles86, 'Microsoft VS Code Insiders'),
+ globals.fs.path.join(progFiles86, 'Microsoft VS Code Insiders'),
'.vscode-insiders',
edition: '32-bit edition',
isInsiders: true));
searchLocations.add(_VsCodeInstallLocation(
- fs.path.join(progFiles, 'Microsoft VS Code Insiders'),
+ globals.fs.path.join(progFiles, 'Microsoft VS Code Insiders'),
'.vscode-insiders',
edition: '64-bit edition',
isInsiders: true));
@@ -206,9 +205,9 @@
final List<VsCode> results = <VsCode>[];
for (_VsCodeInstallLocation searchLocation in searchLocations) {
- if (fs.isDirectorySync(searchLocation.installPath)) {
+ if (globals.fs.isDirectorySync(searchLocation.installPath)) {
final String extensionDirectory =
- fs.path.join(homeDirPath, searchLocation.extensionsFolder, 'extensions');
+ globals.fs.path.join(homeDirPath, searchLocation.extensionsFolder, 'extensions');
results.add(VsCode.fromDirectory(searchLocation.installPath, extensionDirectory, edition: searchLocation.edition));
}
}
@@ -221,15 +220,15 @@
'VS Code ($version)${_extensionVersion != Version.unknown ? ', Flutter ($_extensionVersion)' : ''}';
static String _getVersionFromPackageJson(String packageJsonPath) {
- if (!fs.isFileSync(packageJsonPath)) {
+ if (!globals.fs.isFileSync(packageJsonPath)) {
return null;
}
- final String jsonString = fs.file(packageJsonPath).readAsStringSync();
+ final String jsonString = globals.fs.file(packageJsonPath).readAsStringSync();
try {
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(jsonString));
return jsonObject['version'] as String;
} on FormatException catch (err) {
- printTrace('Error parsing VSCode $packageJsonPath:\n$err');
+ globals.printTrace('Error parsing VSCode $packageJsonPath:\n$err');
return null;
}
}
diff --git a/packages/flutter_tools/lib/src/web/chrome.dart b/packages/flutter_tools/lib/src/web/chrome.dart
index f1e926d..e03b9aa 100644
--- a/packages/flutter_tools/lib/src/web/chrome.dart
+++ b/packages/flutter_tools/lib/src/web/chrome.dart
@@ -12,9 +12,8 @@
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
import '../convert.dart';
+import '../globals.dart' as globals;
/// The [ChromeLauncher] instance.
ChromeLauncher get chromeLauncher => context.get<ChromeLauncher>();
@@ -34,35 +33,35 @@
/// The possible locations where the chrome executable can be located on windows.
final List<String> kWindowsPrefixes = <String>[
- platform.environment['LOCALAPPDATA'],
- platform.environment['PROGRAMFILES'],
- platform.environment['PROGRAMFILES(X86)'],
+ globals.platform.environment['LOCALAPPDATA'],
+ globals.platform.environment['PROGRAMFILES'],
+ globals.platform.environment['PROGRAMFILES(X86)'],
];
/// Find the chrome executable on the current platform.
///
/// Does not verify whether the executable exists.
String findChromeExecutable() {
- if (platform.environment.containsKey(kChromeEnvironment)) {
- return platform.environment[kChromeEnvironment];
+ if (globals.platform.environment.containsKey(kChromeEnvironment)) {
+ return globals.platform.environment[kChromeEnvironment];
}
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
return kLinuxExecutable;
}
- if (platform.isMacOS) {
+ if (globals.platform.isMacOS) {
return kMacOSExecutable;
}
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
final String windowsPrefix = kWindowsPrefixes.firstWhere((String prefix) {
if (prefix == null) {
return false;
}
- final String path = fs.path.join(prefix, kWindowsExecutable);
- return fs.file(path).existsSync();
+ final String path = globals.fs.path.join(prefix, kWindowsExecutable);
+ return globals.fs.file(path).existsSync();
}, orElse: () => '.');
- return fs.path.join(windowsPrefix, kWindowsExecutable);
+ return globals.fs.path.join(windowsPrefix, kWindowsExecutable);
}
- throwToolExit('Platform ${platform.operatingSystem} is not supported.');
+ throwToolExit('Platform ${globals.platform.operatingSystem} is not supported.');
return null;
}
@@ -88,7 +87,7 @@
bool canFindChrome() {
final String chrome = findChromeExecutable();
try {
- return processManager.canRun(chrome);
+ return globals.processManager.canRun(chrome);
} on ArgumentError {
return false;
}
@@ -104,14 +103,14 @@
// This is a JSON file which contains configuration from the
// browser session, such as window position. It is located
// under the Chrome data-dir folder.
- final String preferencesPath = fs.path.join('Default', 'preferences');
+ final String preferencesPath = globals.fs.path.join('Default', 'preferences');
final String chromeExecutable = findChromeExecutable();
- final Directory activeDataDir = fs.systemTempDirectory.createTempSync('flutter_tool.');
+ final Directory activeDataDir = globals.fs.systemTempDirectory.createTempSync('flutter_tool.');
// Seed data dir with previous state.
- final File savedPreferencesFile = fs.file(fs.path.join(dataDir?.path ?? '', preferencesPath));
- final File destinationFile = fs.file(fs.path.join(activeDataDir.path, preferencesPath));
+ final File savedPreferencesFile = globals.fs.file(globals.fs.path.join(dataDir?.path ?? '', preferencesPath));
+ final File destinationFile = globals.fs.file(globals.fs.path.join(activeDataDir.path, preferencesPath));
if (dataDir != null) {
if (savedPreferencesFile.existsSync()) {
destinationFile.parent.createSync(recursive: true);
@@ -143,7 +142,7 @@
url,
];
- final Process process = await processManager.start(args);
+ final Process process = await globals.processManager.start(args);
// When the process exits, copy the user settings back to the provided
// data-dir.
diff --git a/packages/flutter_tools/lib/src/web/compile.dart b/packages/flutter_tools/lib/src/web/compile.dart
index 7185c7d..8f024d2 100644
--- a/packages/flutter_tools/lib/src/web/compile.dart
+++ b/packages/flutter_tools/lib/src/web/compile.dart
@@ -13,7 +13,7 @@
import '../build_system/targets/dart.dart';
import '../build_system/targets/web.dart';
import '../convert.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../platform_plugins.dart';
import '../plugins.dart';
import '../project.dart';
@@ -35,12 +35,12 @@
final bool hasWebPlugins = findPlugins(flutterProject)
.any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
await injectPlugins(flutterProject, checkProjects: true);
- final Status status = logger.startProgress('Compiling $target for the Web...', timeout: null);
+ final Status status = globals.logger.startProgress('Compiling $target for the Web...', timeout: null);
final Stopwatch sw = Stopwatch()..start();
try {
final BuildResult result = await buildSystem.build(const WebReleaseBundle(), Environment(
- outputDir: fs.directory(getWebBuildDirectory()),
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.directory(getWebBuildDirectory()),
+ projectDir: globals.fs.currentDirectory,
buildDir: flutterProject.directory
.childDirectory('.dart_tool')
.childDirectory('flutter_build'),
@@ -54,7 +54,7 @@
));
if (!result.success) {
for (ExceptionMeasurement measurement in result.exceptions.values) {
- printError('Target ${measurement.target} failed: ${measurement.exception}',
+ globals.printError('Target ${measurement.target} failed: ${measurement.exception}',
stackTrace: measurement.fatal
? measurement.stackTrace
: null,
diff --git a/packages/flutter_tools/lib/src/web/devfs_web.dart b/packages/flutter_tools/lib/src/web/devfs_web.dart
index 6a5db70..c28815b 100644
--- a/packages/flutter_tools/lib/src/web/devfs_web.dart
+++ b/packages/flutter_tools/lib/src/web/devfs_web.dart
@@ -12,14 +12,13 @@
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../compile.dart';
import '../convert.dart';
import '../devfs.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import 'bootstrap.dart';
/// A web server which handles serving JavaScript and assets.
@@ -69,7 +68,7 @@
final HttpResponse response = request.response;
// If the response is `/`, then we are requesting the index file.
if (request.uri.path == '/') {
- final File indexFile = fs.currentDirectory
+ final File indexFile = globals.fs.currentDirectory
.childDirectory('web')
.childFile('index.html');
if (indexFile.existsSync()) {
@@ -116,25 +115,25 @@
// likely coming from a source map request. Attempt to look in the
// local filesystem for it, and return a 404 if it is not found. The tool
// doesn't currently consider the case of Dart files as assets.
- File file = fs.file(Uri.base.resolve(request.uri.path));
+ File file = globals.fs.file(Uri.base.resolve(request.uri.path));
// If both of the lookups above failed, the file might have been an asset.
// Try and resolve the path relative to the built asset directory.
if (!file.existsSync()) {
final String assetPath = request.uri.path.replaceFirst('/assets/', '');
- file = fs.file(fs.path.join(getAssetBuildDirectory(), fs.path.relative(assetPath)));
+ file = globals.fs.file(globals.fs.path.join(getAssetBuildDirectory(), globals.fs.path.relative(assetPath)));
}
// If it isn't a project source or an asset, it must be a dart SDK source.
// or a flutter web SDK source.
if (!file.existsSync()) {
- final Directory dartSdkParent = fs.directory(artifacts.getArtifactPath(Artifact.engineDartSdkPath)).parent;
- file = fs.file(fs.path.joinAll(<String>[dartSdkParent.path, ...request.uri.pathSegments]));
+ final Directory dartSdkParent = globals.fs.directory(globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath)).parent;
+ file = globals.fs.file(globals.fs.path.joinAll(<String>[dartSdkParent.path, ...request.uri.pathSegments]));
}
if (!file.existsSync()) {
- final String flutterWebSdk = artifacts.getArtifactPath(Artifact.flutterWebSdk);
- file = fs.file(fs.path.joinAll(<String>[flutterWebSdk, ...request.uri.pathSegments]));
+ final String flutterWebSdk = globals.artifacts.getArtifactPath(Artifact.flutterWebSdk);
+ file = globals.fs.file(globals.fs.path.joinAll(<String>[flutterWebSdk, ...request.uri.pathSegments]));
}
if (!file.existsSync()) {
@@ -180,21 +179,21 @@
final Map<String, dynamic> manifest = castStringKeyedMap(json.decode(manifestFile.readAsStringSync()));
for (String filePath in manifest.keys) {
if (filePath == null) {
- printTrace('Invalid manfiest file: $filePath');
+ globals.printTrace('Invalid manfiest file: $filePath');
continue;
}
final Map<String, dynamic> offsets = castStringKeyedMap(manifest[filePath]);
final List<int> codeOffsets = (offsets['code'] as List<dynamic>).cast<int>();
final List<int> sourcemapOffsets = (offsets['sourcemap'] as List<dynamic>).cast<int>();
if (codeOffsets.length != 2 || sourcemapOffsets.length != 2) {
- printTrace('Invalid manifest byte offsets: $offsets');
+ globals.printTrace('Invalid manifest byte offsets: $offsets');
continue;
}
final int codeStart = codeOffsets[0];
final int codeEnd = codeOffsets[1];
if (codeStart < 0 || codeEnd > codeBytes.lengthInBytes) {
- printTrace('Invalid byte index: [$codeStart, $codeEnd]');
+ globals.printTrace('Invalid byte index: [$codeStart, $codeEnd]');
continue;
}
final Uint8List byteView = Uint8List.view(
@@ -207,7 +206,7 @@
final int sourcemapStart = sourcemapOffsets[0];
final int sourcemapEnd = sourcemapOffsets[1];
if (sourcemapStart < 0 || sourcemapEnd > sourcemapBytes.lengthInBytes) {
- printTrace('Invalid byte index: [$sourcemapStart, $sourcemapEnd]');
+ globals.printTrace('Invalid byte index: [$sourcemapStart, $sourcemapEnd]');
continue;
}
final Uint8List sourcemapView = Uint8List.view(
@@ -285,28 +284,28 @@
assert(trackWidgetCreation != null);
assert(generator != null);
if (bundleFirstUpload) {
- final File requireJS = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.engineDartSdkPath),
+ final File requireJS = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath),
'lib',
'dev_compiler',
'kernel',
'amd',
'require.js',
));
- final File dartSdk = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.flutterWebSdk),
+ final File dartSdk = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
'amd',
'dart_sdk.js',
));
- final File dartSdkSourcemap = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.flutterWebSdk),
+ final File dartSdkSourcemap = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
'amd',
'dart_sdk.js.map',
));
- final File stackTraceMapper = fs.file(fs.path.join(
- artifacts.getArtifactPath(Artifact.engineDartSdkPath),
+ final File stackTraceMapper = globals.fs.file(globals.fs.path.join(
+ globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath),
'lib',
'dev_compiler',
'web',
@@ -324,7 +323,7 @@
_webAssetServer.writeFile('/dart_sdk.js.map', dartSdkSourcemap.readAsStringSync());
// TODO(jonahwilliams): refactor the asset code in this and the regular devfs to
// be shared.
- await writeBundle(fs.directory(getAssetBuildDirectory()), bundle.entries);
+ await writeBundle(globals.fs.directory(getAssetBuildDirectory()), bundle.entries);
}
final DateTime candidateCompileTime = DateTime.now();
if (fullRestart) {
@@ -348,9 +347,9 @@
File sourcemapFile;
List<String> modules;
try {
- codeFile = fs.file('${compilerOutput.outputFilename}.sources');
- manifestFile = fs.file('${compilerOutput.outputFilename}.json');
- sourcemapFile = fs.file('${compilerOutput.outputFilename}.map');
+ codeFile = globals.fs.file('${compilerOutput.outputFilename}.sources');
+ manifestFile = globals.fs.file('${compilerOutput.outputFilename}.json');
+ sourcemapFile = globals.fs.file('${compilerOutput.outputFilename}.map');
modules = _webAssetServer.write(codeFile, manifestFile, sourcemapFile);
} on FileSystemException catch (err) {
throwToolExit('Failed to load recompiled sources:\n$err');
@@ -362,9 +361,9 @@
}
String _filePathToUriFragment(String path) {
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
final bool startWithSlash = path.startsWith('/');
- final String partial = fs.path
+ final String partial = globals.fs.path
.split(path)
.skip(startWithSlash ? 2 : 1).join('/');
if (partial.startsWith('/')) {
diff --git a/packages/flutter_tools/lib/src/web/web_device.dart b/packages/flutter_tools/lib/src/web/web_device.dart
index bc25b83..628a640 100644
--- a/packages/flutter_tools/lib/src/web/web_device.dart
+++ b/packages/flutter_tools/lib/src/web/web_device.dart
@@ -7,12 +7,10 @@
import '../application_package.dart';
import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
-import '../base/process_manager.dart';
import '../build_info.dart';
import '../device.dart';
import '../features.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import 'chrome.dart';
@@ -100,8 +98,8 @@
}
// See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
String version = 'unknown';
- if (platform.isWindows) {
- final ProcessResult result = await processManager.run(<String>[
+ if (globals.platform.isWindows) {
+ final ProcessResult result = await globals.processManager.run(<String>[
r'reg', 'query', 'HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon', '/v', 'version',
]);
if (result.exitCode == 0) {
@@ -112,7 +110,7 @@
}
} else {
final String chrome = findChromeExecutable();
- final ProcessResult result = await processManager.run(<String>[
+ final ProcessResult result = await globals.processManager.run(<String>[
chrome,
'--version',
]);
@@ -137,11 +135,11 @@
// for the web initialization and server logic.
final String url = platformArgs['uri'] as String;
_chrome = await chromeLauncher.launch(url,
- dataDir: fs.currentDirectory
+ dataDir: globals.fs.currentDirectory
.childDirectory('.dart_tool')
.childDirectory('chrome-device'));
- logger.sendEvent('app.webLaunchUrl', <String, dynamic>{'url': url, 'launched': true});
+ globals.logger.sendEvent('app.webLaunchUrl', <String, dynamic>{'url': url, 'launched': true});
return LaunchResult.succeeded(observatoryUri: null);
}
@@ -261,11 +259,11 @@
}) async {
final String url = platformArgs['uri'] as String;
if (debuggingOptions.startPaused) {
- printStatus('Waiting for connection from Dart debug extension at $url', emphasis: true);
+ globals.printStatus('Waiting for connection from Dart debug extension at $url', emphasis: true);
} else {
- printStatus('$mainPath is being served at $url', emphasis: true);
+ globals.printStatus('$mainPath is being served at $url', emphasis: true);
}
- logger.sendEvent('app.webLaunchUrl', <String, dynamic>{'url': url, 'launched': false});
+ globals.logger.sendEvent('app.webLaunchUrl', <String, dynamic>{'url': url, 'launched': false});
return LaunchResult.succeeded(observatoryUri: null);
}
diff --git a/packages/flutter_tools/lib/src/web/web_validator.dart b/packages/flutter_tools/lib/src/web/web_validator.dart
index e8873e6..b96ae3e 100644
--- a/packages/flutter_tools/lib/src/web/web_validator.dart
+++ b/packages/flutter_tools/lib/src/web/web_validator.dart
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import '../base/platform.dart';
import '../doctor.dart';
+import '../globals.dart' as globals;
import 'chrome.dart';
/// A validator that checks whether chrome is installed and can run.
@@ -15,7 +15,7 @@
final String chrome = findChromeExecutable();
final bool canRunChrome = chromeLauncher.canFindChrome();
final List<ValidationMessage> messages = <ValidationMessage>[
- if (platform.environment.containsKey(kChromeEnvironment))
+ if (globals.platform.environment.containsKey(kChromeEnvironment))
if (!canRunChrome)
ValidationMessage.hint('$chrome is not executable.')
else
diff --git a/packages/flutter_tools/lib/src/web/workflow.dart b/packages/flutter_tools/lib/src/web/workflow.dart
index 1e5f591..55d602e 100644
--- a/packages/flutter_tools/lib/src/web/workflow.dart
+++ b/packages/flutter_tools/lib/src/web/workflow.dart
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/platform.dart';
import '../doctor.dart';
import '../features.dart';
+import '../globals.dart' as globals;
/// The web workflow instance.
WebWorkflow get webWorkflow => context.get<WebWorkflow>();
@@ -14,7 +14,7 @@
const WebWorkflow();
@override
- bool get appliesToHostPlatform => featureFlags.isWebEnabled && (platform.isWindows || platform.isMacOS || platform.isLinux);
+ bool get appliesToHostPlatform => featureFlags.isWebEnabled && (globals.platform.isWindows || globals.platform.isMacOS || globals.platform.isLinux);
@override
bool get canLaunchDevices => featureFlags.isWebEnabled;
diff --git a/packages/flutter_tools/lib/src/windows/application_package.dart b/packages/flutter_tools/lib/src/windows/application_package.dart
index 44b39e3..bd93c80 100644
--- a/packages/flutter_tools/lib/src/windows/application_package.dart
+++ b/packages/flutter_tools/lib/src/windows/application_package.dart
@@ -9,6 +9,7 @@
import '../base/file_system.dart';
import '../base/utils.dart';
import '../build_info.dart';
+import '../globals.dart' as globals;
import '../project.dart';
abstract class WindowsApp extends ApplicationPackage {
@@ -64,7 +65,7 @@
if (!exeNameFile.existsSync()) {
throwToolExit('Failed to find Windows executable name');
}
- return fs.path.join(
+ return globals.fs.path.join(
getWindowsBuildDirectory(),
'x64',
toTitleCase(getNameForBuildMode(buildMode)),
diff --git a/packages/flutter_tools/lib/src/windows/build_windows.dart b/packages/flutter_tools/lib/src/windows/build_windows.dart
index 2f0644f..55e4b77 100644
--- a/packages/flutter_tools/lib/src/windows/build_windows.dart
+++ b/packages/flutter_tools/lib/src/windows/build_windows.dart
@@ -4,12 +4,11 @@
import '../artifacts.dart';
import '../base/common.dart';
-import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../cache.dart';
-import '../globals.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'msbuild_utils.dart';
@@ -26,11 +25,11 @@
if (target != null) {
environment['FLUTTER_TARGET'] = target;
}
- if (artifacts is LocalEngineArtifacts) {
- final LocalEngineArtifacts localEngineArtifacts = artifacts as LocalEngineArtifacts;
+ if (globals.artifacts is LocalEngineArtifacts) {
+ final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath;
- environment['FLUTTER_ENGINE'] = fs.path.dirname(fs.path.dirname(engineOutPath));
- environment['LOCAL_ENGINE'] = fs.path.basename(engineOutPath);
+ environment['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
+ environment['LOCAL_ENGINE'] = globals.fs.path.basename(engineOutPath);
}
writePropertySheet(windowsProject.generatedPropertySheetFile, environment);
@@ -42,14 +41,14 @@
if (!buildInfo.isDebug) {
const String warning = '🚧 ';
- printStatus(warning * 20);
- printStatus('Warning: Only debug is currently implemented for Windows. This is effectively a debug build.');
- printStatus('See https://github.com/flutter/flutter/issues/38477 for details and updates.');
- printStatus(warning * 20);
- printStatus('');
+ globals.printStatus(warning * 20);
+ globals.printStatus('Warning: Only debug is currently implemented for Windows. This is effectively a debug build.');
+ globals.printStatus('See https://github.com/flutter/flutter/issues/38477 for details and updates.');
+ globals.printStatus(warning * 20);
+ globals.printStatus('');
}
- final String buildScript = fs.path.join(
+ final String buildScript = globals.fs.path.join(
Cache.flutterRoot,
'packages',
'flutter_tools',
@@ -60,7 +59,7 @@
final String configuration = buildInfo.isDebug ? 'Debug' : 'Release';
final String solutionPath = windowsProject.solutionFile.path;
final Stopwatch sw = Stopwatch()..start();
- final Status status = logger.startProgress(
+ final Status status = globals.logger.startProgress(
'Building Windows application...',
timeout: null,
);
@@ -72,9 +71,9 @@
result = await processUtils.stream(<String>[
buildScript,
vcvarsScript,
- fs.path.basename(solutionPath),
+ globals.fs.path.basename(solutionPath),
configuration,
- ], workingDirectory: fs.path.dirname(solutionPath), trace: true);
+ ], workingDirectory: globals.fs.path.dirname(solutionPath), trace: true);
} finally {
status.cancel();
}
diff --git a/packages/flutter_tools/lib/src/windows/visual_studio.dart b/packages/flutter_tools/lib/src/windows/visual_studio.dart
index 2d8620d..da1079b 100644
--- a/packages/flutter_tools/lib/src/windows/visual_studio.dart
+++ b/packages/flutter_tools/lib/src/windows/visual_studio.dart
@@ -3,11 +3,10 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/file_system.dart';
import '../base/io.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../convert.dart';
+import '../globals.dart' as globals;
VisualStudio get visualStudio => context.get<VisualStudio>();
@@ -96,7 +95,7 @@
if (details.isEmpty) {
return null;
}
- return fs.path.join(
+ return globals.fs.path.join(
_usableVisualStudioDetails[_installationPathKey] as String,
'VC',
'Auxiliary',
@@ -111,8 +110,8 @@
/// present then there isn't a new enough installation of VS. This path is
/// not user-controllable, unlike the install location of Visual Studio
/// itself.
- final String _vswherePath = fs.path.join(
- platform.environment['PROGRAMFILES(X86)'],
+ final String _vswherePath = globals.fs.path.join(
+ globals.platform.environment['PROGRAMFILES(X86)'],
'Microsoft Visual Studio',
'Installer',
'vswhere.exe',
diff --git a/packages/flutter_tools/lib/src/windows/windows_device.dart b/packages/flutter_tools/lib/src/windows/windows_device.dart
index 4c4d4e2..1161d6d 100644
--- a/packages/flutter_tools/lib/src/windows/windows_device.dart
+++ b/packages/flutter_tools/lib/src/windows/windows_device.dart
@@ -5,11 +5,11 @@
import 'package:meta/meta.dart';
import '../base/io.dart';
-import '../base/platform.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../desktop_device.dart';
import '../device.dart';
+import '../globals.dart' as globals;
import '../project.dart';
import 'application_package.dart';
import 'build_windows.dart';
@@ -60,7 +60,7 @@
WindowsDevices() : super('windows devices');
@override
- bool get supportsPlatform => platform.isWindows;
+ bool get supportsPlatform => globals.platform.isWindows;
@override
bool get canListAnything => windowsWorkflow.canListDevices;
diff --git a/packages/flutter_tools/lib/src/windows/windows_workflow.dart b/packages/flutter_tools/lib/src/windows/windows_workflow.dart
index 74be049..72dddea 100644
--- a/packages/flutter_tools/lib/src/windows/windows_workflow.dart
+++ b/packages/flutter_tools/lib/src/windows/windows_workflow.dart
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import '../base/context.dart';
-import '../base/platform.dart';
import '../doctor.dart';
import '../features.dart';
+import '../globals.dart' as globals;
/// The [WindowsWorkflow] instance.
WindowsWorkflow get windowsWorkflow => context.get<WindowsWorkflow>();
@@ -18,13 +18,13 @@
const WindowsWorkflow();
@override
- bool get appliesToHostPlatform => platform.isWindows && featureFlags.isWindowsEnabled;
+ bool get appliesToHostPlatform => globals.platform.isWindows && featureFlags.isWindowsEnabled;
@override
- bool get canLaunchDevices => platform.isWindows && featureFlags.isWindowsEnabled;
+ bool get canLaunchDevices => globals.platform.isWindows && featureFlags.isWindowsEnabled;
@override
- bool get canListDevices => platform.isWindows && featureFlags.isWindowsEnabled;
+ bool get canListDevices => globals.platform.isWindows && featureFlags.isWindowsEnabled;
@override
bool get canListEmulators => false;
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
index 6ccca56..cc94e54 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
@@ -10,6 +10,7 @@
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -20,7 +21,7 @@
setUp(() {
FlutterCommandRunner.initFlutterRoot();
- tempDir = fs.systemTempDirectory.createTempSync('flutter_analysis_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analysis_test.');
});
tearDown(() {
@@ -92,12 +93,12 @@
}
void _createSampleProject(Directory directory, { bool brokenCode = false }) {
- final File pubspecFile = fs.file(fs.path.join(directory.path, 'pubspec.yaml'));
+ final File pubspecFile = globals.fs.file(globals.fs.path.join(directory.path, 'pubspec.yaml'));
pubspecFile.writeAsStringSync('''
name: foo_project
''');
- final File dartFile = fs.file(fs.path.join(directory.path, 'lib', 'main.dart'));
+ final File dartFile = globals.fs.file(globals.fs.path.join(directory.path, 'lib', 'main.dart'));
dartFile.parent.createSync();
dartFile.writeAsStringSync('''
void main() {
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart
index 8e5fb42..a2c11be 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart
@@ -6,6 +6,7 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/analyze_base.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -31,15 +32,15 @@
testUsingContext('inRepo', () {
// Absolute paths
expect(inRepo(<String>[tempDir.path]), isFalse);
- expect(inRepo(<String>[fs.path.join(tempDir.path, 'foo')]), isFalse);
+ expect(inRepo(<String>[globals.fs.path.join(tempDir.path, 'foo')]), isFalse);
expect(inRepo(<String>[Cache.flutterRoot]), isTrue);
- expect(inRepo(<String>[fs.path.join(Cache.flutterRoot, 'foo')]), isTrue);
+ expect(inRepo(<String>[globals.fs.path.join(Cache.flutterRoot, 'foo')]), isTrue);
// Relative paths
- fs.currentDirectory = Cache.flutterRoot;
+ globals.fs.currentDirectory = Cache.flutterRoot;
expect(inRepo(<String>['.']), isTrue);
expect(inRepo(<String>['foo']), isTrue);
- fs.currentDirectory = tempDir.path;
+ globals.fs.currentDirectory = tempDir.path;
expect(inRepo(<String>['.']), isFalse);
expect(inRepo(<String>['foo']), isFalse);
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart
index fd7e09d..3eeef20 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart
@@ -9,6 +9,7 @@
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/assemble.dart';
import 'package:mockito/mockito.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -87,8 +88,8 @@
.thenAnswer((Invocation invocation) async {
return BuildResult(
success: true,
- inputFiles: <File>[fs.file('foo')..createSync()],
- outputFiles: <File>[fs.file('bar')..createSync()],
+ inputFiles: <File>[globals.fs.file('foo')..createSync()],
+ outputFiles: <File>[globals.fs.file('bar')..createSync()],
);
});
@@ -101,8 +102,8 @@
'debug_macos_bundle_flutter_assets',
]);
- final File inputs = fs.file('inputs');
- final File outputs = fs.file('outputs');
+ final File inputs = globals.fs.file('inputs');
+ final File outputs = globals.fs.file('outputs');
expect(inputs.readAsStringSync(), contains('foo'));
expect(outputs.readAsStringSync(), contains('bar'));
@@ -124,8 +125,8 @@
.thenAnswer((Invocation invocation) async {
return BuildResult(
success: true,
- inputFiles: <File>[fs.file('foo'), fs.file('fizz')..createSync()],
- outputFiles: <File>[fs.file('bar'), fs.file(fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]);
+ inputFiles: <File>[globals.fs.file('foo'), globals.fs.file('fizz')..createSync()],
+ outputFiles: <File>[globals.fs.file('bar'), globals.fs.file(globals.fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]);
});
await commandRunner.run(<String>[
'assemble',
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
index ccb7249..7c1dec7 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
@@ -10,7 +10,7 @@
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/net.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/attach.dart';
@@ -26,6 +26,7 @@
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:quiver/testing/async.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -41,7 +42,7 @@
Cache.disableLocking();
logger = StreamLogger();
testFileSystem = MemoryFileSystem(
- style: platform.isWindows
+ style: globals.platform.isWindows
? FileSystemStyle.windows
: FileSystemStyle.posix,
);
@@ -403,11 +404,11 @@
'Observatory listening on http://127.0.0.1:$devicePort');
return mockLogReader;
});
- final File foo = fs.file('lib/foo.dart')
+ final File foo = globals.fs.file('lib/foo.dart')
..createSync();
// Delete the main.dart file to be sure that attach works without it.
- fs.file(fs.path.join('lib', 'main.dart')).deleteSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).deleteSync();
final AttachCommand command = AttachCommand(hotRunnerFactory: mockHotRunnerFactory);
await createTestCommandRunner(command).run(<String>['attach', '-t', foo.path, '-v']);
@@ -456,10 +457,10 @@
testDeviceManager.addDevice(device);
- final File foo = fs.file('lib/foo.dart')..createSync();
+ final File foo = globals.fs.file('lib/foo.dart')..createSync();
// Delete the main.dart file to be sure that attach works without it.
- fs.file(fs.path.join('lib', 'main.dart')).deleteSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).deleteSync();
final AttachCommand command = AttachCommand(hotRunnerFactory: mockHotRunnerFactory);
await createTestCommandRunner(command).run(<String>['attach', '-t', foo.path, '-v']);
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart
index d5e5e98..c52fdaa 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
import 'package:mockito/mockito.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/mocks.dart';
@@ -31,9 +31,9 @@
});
test('invokes assemble for android aot build.', () => testbed.run(() async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
@@ -49,7 +49,7 @@
final Environment environment = verify(buildSystem.build(any, captureAny)).captured.single as Environment;
expect(environment.defines, <String, String>{
- kTargetFile: fs.path.absolute(fs.path.join('lib', 'main.dart')),
+ kTargetFile: globals.fs.path.absolute(globals.fs.path.join('lib', 'main.dart')),
kBuildMode: 'release',
kTargetPlatform: 'android-arm',
});
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart
index c95035e..404ab86 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart
@@ -3,9 +3,10 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
@@ -16,6 +17,7 @@
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -58,9 +60,9 @@
testUsingContext('there is no cmx file', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.directory('fuchsia').createSync(recursive: true);
- fs.file('.packages').createSync();
- fs.file('pubspec.yaml').createSync();
+ globals.fs.directory('fuchsia').createSync(recursive: true);
+ globals.fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
expect(
createTestCommandRunner(command)
@@ -76,12 +78,12 @@
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
const String appName = 'app_name';
- fs
- .file(fs.path.join('fuchsia', 'meta', '$appName.cmx'))
+ globals.fs
+ .file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx'))
..createSync(recursive: true)
..writeAsStringSync('{}');
- fs.file('.packages').createSync();
- final File pubspecFile = fs.file('pubspec.yaml')..createSync();
+ globals.fs.file('.packages').createSync();
+ final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
expect(
@@ -98,13 +100,13 @@
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
const String appName = 'app_name';
- fs
- .file(fs.path.join('fuchsia', 'meta', '$appName.cmx'))
+ globals.fs
+ .file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx'))
..createSync(recursive: true)
..writeAsStringSync('{}');
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
- final File pubspecFile = fs.file('pubspec.yaml')..createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
expect(
createTestCommandRunner(command)
@@ -121,20 +123,20 @@
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
const String appName = 'app_name';
- fs
- .file(fs.path.join('fuchsia', 'meta', '$appName.cmx'))
+ globals.fs
+ .file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx'))
..createSync(recursive: true)
..writeAsStringSync('{}');
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
- final File pubspecFile = fs.file('pubspec.yaml')..createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
await createTestCommandRunner(command)
.run(const <String>['build', 'fuchsia']);
final String farPath =
- fs.path.join(getFuchsiaBuildDirectory(), 'pkg', 'app_name-0.far');
- expect(fs.file(farPath).existsSync(), isTrue);
+ globals.fs.path.join(getFuchsiaBuildDirectory(), 'pkg', 'app_name-0.far');
+ expect(globals.fs.file(farPath).existsSync(), isTrue);
}, overrides: <Type, Generator>{
Platform: () => linuxPlatform,
FileSystem: () => MemoryFileSystem(),
@@ -155,11 +157,11 @@
@override
Future<bool> init(String buildPath, String appName) async {
- if (!fs.directory(buildPath).existsSync()) {
+ if (!globals.fs.directory(buildPath).existsSync()) {
return false;
}
- fs
- .file(fs.path.join(buildPath, 'meta', 'package'))
+ globals.fs
+ .file(globals.fs.path.join(buildPath, 'meta', 'package'))
.createSync(recursive: true);
_appName = appName;
return true;
@@ -167,36 +169,36 @@
@override
Future<bool> genkey(String buildPath, String outKeyPath) async {
- if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync()) {
+ if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync()) {
return false;
}
- fs.file(outKeyPath).createSync(recursive: true);
+ globals.fs.file(outKeyPath).createSync(recursive: true);
return true;
}
@override
Future<bool> build(String buildPath, String keyPath, String manifestPath) async {
- if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
- !fs.file(keyPath).existsSync() ||
- !fs.file(manifestPath).existsSync()) {
+ if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
+ !globals.fs.file(keyPath).existsSync() ||
+ !globals.fs.file(manifestPath).existsSync()) {
return false;
}
- fs.file(fs.path.join(buildPath, 'meta.far')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(buildPath, 'meta.far')).createSync(recursive: true);
return true;
}
@override
Future<bool> archive(String buildPath, String keyPath, String manifestPath) async {
- if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
- !fs.file(keyPath).existsSync() ||
- !fs.file(manifestPath).existsSync()) {
+ if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
+ !globals.fs.file(keyPath).existsSync() ||
+ !globals.fs.file(manifestPath).existsSync()) {
return false;
}
if (_appName == null) {
return false;
}
- fs
- .file(fs.path.join(buildPath, '$_appName-0.far'))
+ globals.fs
+ .file(globals.fs.path.join(buildPath, '$_appName-0.far'))
.createSync(recursive: true);
return true;
}
@@ -211,8 +213,8 @@
}) async {
final String outDir = getFuchsiaBuildDirectory();
final String appName = fuchsiaProject.project.manifest.appName;
- final String manifestPath = fs.path.join(outDir, '$appName.dilpmanifest');
- fs.file(manifestPath).createSync(recursive: true);
+ final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest');
+ globals.fs.file(manifestPath).createSync(recursive: true);
}
}
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart
index 3c9a557..77fe437 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart
@@ -10,6 +10,7 @@
import 'package:flutter_tools/src/commands/build_ios_framework.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
@@ -34,7 +35,7 @@
mockCache = MockCache();
when(mockFlutterVersion.gitTagVersion).thenReturn(mockGitTagVersion);
- outputDirectory = fs.systemTempDirectory
+ outputDirectory = globals.fs.systemTempDirectory
.createTempSync('flutter_build_ios_framework_test_output.')
.childDirectory('Debug')
..createSync();
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart
index 88f0c4d..d2d9354 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart
@@ -4,10 +4,13 @@
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+import 'package:mockito/mockito.dart';
+import 'package:process/process.dart';
+
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_linux.dart';
@@ -15,8 +18,7 @@
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/linux/makefile.dart';
import 'package:flutter_tools/src/project.dart';
-import 'package:mockito/mockito.dart';
-import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -55,10 +57,10 @@
// Creates the mock files necessary to run a build.
void setUpMockProjectFilesForBuild() {
- fs.file('linux/build.sh').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('linux/build.sh').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
}
// Sets up mock expectation for running 'make'.
@@ -110,7 +112,7 @@
await createTestCommandRunner(command).run(
const <String>['build', 'linux']
);
- expect(fs.file('linux/flutter/ephemeral/generated_config.mk').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/generated_config.mk').existsSync(), true);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
@@ -190,15 +192,15 @@
});
testUsingContext('linux can extract binary name from Makefile', () async {
- fs.file('linux/Makefile')
+ globals.fs.file('linux/Makefile')
..createSync(recursive: true)
..writeAsStringSync(r'''
# Comment
SOMETHING_ELSE=FOO
BINARY_NAME=fizz_bar
''');
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(makefileExecutableName(flutterProject.linux), 'fizz_bar');
@@ -236,7 +238,7 @@
});
testUsingContext('hidden when not enabled on Linux host', () {
- when(platform.isLinux).thenReturn(true);
+ when(globals.platform.isLinux).thenReturn(true);
expect(BuildLinuxCommand().hidden, true);
}, overrides: <Type, Generator>{
@@ -245,7 +247,7 @@
});
testUsingContext('Not hidden when enabled and on Linux host', () {
- when(platform.isLinux).thenReturn(true);
+ when(globals.platform.isLinux).thenReturn(true);
expect(BuildLinuxCommand().hidden, false);
}, overrides: <Type, Generator>{
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 6d0ca8c..7f6d74f 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
@@ -4,10 +4,11 @@
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
@@ -18,6 +19,7 @@
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -67,17 +69,17 @@
// Sets up the minimal mock project files necessary for macOS builds to succeed.
void createMinimalMockProjectFiles() {
- fs.directory('macos').createSync();
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.directory('macos').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
}
// Mocks the process manager to handle an xcodebuild call to build the app
// in the given configuration.
void setUpMockXcodeBuildHandler(String configuration) {
- final FlutterProject flutterProject = FlutterProject.fromDirectory(fs.currentDirectory);
- final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory());
+ final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.currentDirectory);
+ final Directory flutterBuildDir = globals.fs.directory(getMacOSBuildDirectory());
when(mockProcessManager.start(<String>[
'/usr/bin/env',
'xcrun',
@@ -86,11 +88,11 @@
'-configuration', configuration,
'-scheme', 'Runner',
'-derivedDataPath', flutterBuildDir.absolute.path,
- 'OBJROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
- 'SYMROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
+ 'OBJROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
+ 'SYMROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
'COMPILER_INDEX_STORE_ENABLE=NO',
])).thenAnswer((Invocation invocation) async {
- fs.file(fs.path.join('macos', 'Flutter', 'ephemeral', '.app_filename'))
+ globals.fs.file(globals.fs.path.join('macos', 'Flutter', 'ephemeral', '.app_filename'))
..createSync(recursive: true)
..writeAsStringSync('example.app');
return mockProcess;
@@ -111,9 +113,9 @@
testUsingContext('macOS build fails on non-macOS platform', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
expect(createTestCommandRunner(command).run(
const <String>['build', 'macos']
@@ -202,7 +204,7 @@
});
testUsingContext('hidden when not enabled on macOS host', () {
- when(platform.isMacOS).thenReturn(true);
+ when(globals.platform.isMacOS).thenReturn(true);
expect(BuildMacosCommand().hidden, true);
}, overrides: <Type, Generator>{
@@ -211,7 +213,7 @@
});
testUsingContext('Not hidden when enabled and on macOS host', () {
- when(platform.isMacOS).thenReturn(true);
+ when(globals.platform.isMacOS).thenReturn(true);
expect(BuildMacosCommand().hidden, false);
}, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
index 00b693d..52922ca 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import 'package:args/command_runner.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/common.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
@@ -19,6 +19,7 @@
import 'package:flutter_tools/src/version.dart';
import 'package:flutter_tools/src/web/compile.dart';
import 'package:mockito/mockito.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/mocks.dart';
@@ -35,12 +36,12 @@
setUp(() {
testbed = Testbed(setup: () {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync('name: foo\n');
- fs.file('.packages').createSync();
- fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true);
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
}, overrides: <Type, Generator>{
Platform: () => mockPlatform,
FlutterVersion: () => MockFlutterVersion(),
@@ -50,11 +51,11 @@
});
test('Refuses to build for web when missing index.html', () => testbed.run(() async {
- fs.file(fs.path.join('web', 'index.html')).deleteSync();
+ globals.fs.file(globals.fs.path.join('web', 'index.html')).deleteSync();
expect(buildWeb(
FlutterProject.current(),
- fs.path.join('lib', 'main.dart'),
+ globals.fs.path.join('lib', 'main.dart'),
BuildInfo.debug,
false,
const <String>[],
@@ -62,7 +63,7 @@
}));
test('Refuses to build using runner when missing index.html', () => testbed.run(() async {
- fs.file(fs.path.join('web', 'index.html')).deleteSync();
+ globals.fs.file(globals.fs.path.join('web', 'index.html')).deleteSync();
final ResidentWebRunner runner = DwdsWebRunnerFactory().createWebRunner(
null,
@@ -99,23 +100,23 @@
applyMocksToCommand(buildCommand);
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
final List<String> dependencies = <String>[
- fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'),
- fs.path.join('bin', 'cache', 'flutter_web_sdk'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk '),
+ globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'),
+ globals.fs.path.join('bin', 'cache', 'flutter_web_sdk'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk '),
];
for (String dependency in dependencies) {
- fs.file(dependency).createSync(recursive: true);
+ globals.fs.file(dependency).createSync(recursive: true);
}
// Project files.
- fs.file('.packages')
+ globals.fs.file('.packages')
..writeAsStringSync('''
foo:lib/
fizz:bar/lib/
''');
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..writeAsStringSync('''
name: foo
@@ -126,7 +127,7 @@
path:
bar/
''');
- fs.file(fs.path.join('bar', 'pubspec.yaml'))
+ globals.fs.file(globals.fs.path.join('bar', 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync('''
name: bar
@@ -138,12 +139,12 @@
pluginClass: UrlLauncherPlugin
fileName: url_launcher_web.dart
''');
- fs.file(fs.path.join('bar', 'lib', 'url_launcher_web.dart'))
+ globals.fs.file(globals.fs.path.join('bar', 'lib', 'url_launcher_web.dart'))
..createSync(recursive: true)
..writeAsStringSync('''
class UrlLauncherPlugin {}
''');
- fs.file(fs.path.join('lib', 'main.dart'))
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
..writeAsStringSync('void main() { }');
// Process calls. We're not testing that these invocations are correct because
@@ -153,7 +154,7 @@
});
await runner.run(<String>['build', 'web']);
- expect(fs.file(fs.path.join('lib', 'generated_plugin_registrant.dart')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('lib', 'generated_plugin_registrant.dart')).existsSync(), true);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
BuildSystem: () => MockBuildSystem(),
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart
index a78a908..9a81864 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart
@@ -3,10 +3,11 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_windows.dart';
@@ -16,6 +17,7 @@
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:xml/xml.dart' as xml;
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -59,7 +61,7 @@
testUsingContext('Windows build fails when there is no vcvars64.bat', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.file(solutionPath).createSync(recursive: true);
+ globals.fs.file(solutionPath).createSync(recursive: true);
expect(createTestCommandRunner(command).run(
const <String>['build', 'windows']
), throwsA(isInstanceOf<ToolExit>()));
@@ -89,11 +91,11 @@
testUsingContext('Windows build fails on non windows platform', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.file(solutionPath).createSync(recursive: true);
+ globals.fs.file(solutionPath).createSync(recursive: true);
when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
expect(createTestCommandRunner(command).run(
const <String>['build', 'windows']
@@ -109,18 +111,18 @@
testUsingContext('Windows build does not spew stdout to status logger', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.file(solutionPath).createSync(recursive: true);
+ globals.fs.file(solutionPath).createSync(recursive: true);
when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
when(mockProcessManager.start(<String>[
r'C:\packages\flutter_tools\bin\vs_build.bat',
vcvarsPath,
- fs.path.basename(solutionPath),
+ globals.fs.path.basename(solutionPath),
'Release',
- ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
+ ], workingDirectory: globals.fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
return mockProcess;
});
@@ -140,18 +142,18 @@
testUsingContext('Windows build invokes msbuild and writes generated files', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.file(solutionPath).createSync(recursive: true);
+ globals.fs.file(solutionPath).createSync(recursive: true);
when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
when(mockProcessManager.start(<String>[
r'C:\packages\flutter_tools\bin\vs_build.bat',
vcvarsPath,
- fs.path.basename(solutionPath),
+ globals.fs.path.basename(solutionPath),
'Release',
- ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
+ ], workingDirectory: globals.fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
return mockProcess;
});
@@ -160,7 +162,7 @@
);
// Spot-check important elements from the properties file.
- final File propsFile = fs.file(r'C:\windows\flutter\ephemeral\Generated.props');
+ final File propsFile = globals.fs.file(r'C:\windows\flutter\ephemeral\Generated.props');
expect(propsFile.existsSync(), true);
final xml.XmlDocument props = xml.parse(propsFile.readAsStringSync());
expect(props.findAllElements('PropertyGroup').first.getAttribute('Label'), 'UserMacros');
@@ -177,18 +179,18 @@
testUsingContext('Release build prints an under-construction warning', () async {
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
- fs.file(solutionPath).createSync(recursive: true);
+ globals.fs.file(solutionPath).createSync(recursive: true);
when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
when(mockProcessManager.start(<String>[
r'C:\packages\flutter_tools\bin\vs_build.bat',
vcvarsPath,
- fs.path.basename(solutionPath),
+ globals.fs.path.basename(solutionPath),
'Release',
- ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
+ ], workingDirectory: globals.fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
return mockProcess;
});
@@ -206,7 +208,7 @@
});
testUsingContext('hidden when not enabled on Windows host', () {
- when(platform.isWindows).thenReturn(true);
+ when(globals.platform.isWindows).thenReturn(true);
expect(BuildWindowsCommand().hidden, true);
}, overrides: <Type, Generator>{
@@ -215,7 +217,7 @@
});
testUsingContext('Not hidden when enabled and on Windows host', () {
- when(platform.isWindows).thenReturn(true);
+ when(globals.platform.isWindows).thenReturn(true);
expect(BuildWindowsCommand().hidden, false);
}, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart
index fef7c1c..7145de8 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart
@@ -3,10 +3,11 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/commands/clean.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart
index 475b4bc..608c400 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart
@@ -8,11 +8,11 @@
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/base/common.dart';
-import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/config.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
@@ -120,19 +120,19 @@
'--enable-macos-desktop',
]);
- expect(Config.instance.getValue('enable-web'), true);
- expect(Config.instance.getValue('enable-linux-desktop'), true);
- expect(Config.instance.getValue('enable-windows-desktop'), true);
- expect(Config.instance.getValue('enable-macos-desktop'), true);
+ expect(globals.config.getValue('enable-web'), true);
+ expect(globals.config.getValue('enable-linux-desktop'), true);
+ expect(globals.config.getValue('enable-windows-desktop'), true);
+ expect(globals.config.getValue('enable-macos-desktop'), true);
await commandRunner.run(<String>[
'config', '--clear-features',
]);
- expect(Config.instance.getValue('enable-web'), null);
- expect(Config.instance.getValue('enable-linux-desktop'), null);
- expect(Config.instance.getValue('enable-windows-desktop'), null);
- expect(Config.instance.getValue('enable-macos-desktop'), null);
+ expect(globals.config.getValue('enable-web'), null);
+ expect(globals.config.getValue('enable-linux-desktop'), null);
+ expect(globals.config.getValue('enable-windows-desktop'), null);
+ expect(globals.config.getValue('enable-macos-desktop'), null);
await commandRunner.run(<String>[
'config',
@@ -142,10 +142,10 @@
'--no-enable-macos-desktop',
]);
- expect(Config.instance.getValue('enable-web'), false);
- expect(Config.instance.getValue('enable-linux-desktop'), false);
- expect(Config.instance.getValue('enable-windows-desktop'), false);
- expect(Config.instance.getValue('enable-macos-desktop'), false);
+ expect(globals.config.getValue('enable-web'), false);
+ expect(globals.config.getValue('enable-linux-desktop'), false);
+ expect(globals.config.getValue('enable-windows-desktop'), false);
+ expect(globals.config.getValue('enable-macos-desktop'), false);
verifyNoAnalytics();
}, overrides: <Type, Generator>{
AndroidStudio: () => mockAndroidStudio,
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart
index 943422b..dc77557 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart
@@ -3,11 +3,11 @@
// found in the LICENSE file.
import 'package:args/command_runner.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -24,15 +24,15 @@
setUp(() {
testbed = Testbed(setup: () {
final List<String> paths = <String>[
- fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'),
- fs.path.join('flutter', 'packages', 'flutter_driver', 'pubspec.yaml'),
- fs.path.join('flutter', 'packages', 'flutter_test', 'pubspec.yaml'),
- fs.path.join('flutter', 'bin', 'cache', 'artifacts', 'gradle_wrapper', 'wrapper'),
- fs.path.join('usr', 'local', 'bin', 'adb'),
- fs.path.join('Android', 'platform-tools', 'adb.exe'),
+ globals.fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'),
+ globals.fs.path.join('flutter', 'packages', 'flutter_driver', 'pubspec.yaml'),
+ globals.fs.path.join('flutter', 'packages', 'flutter_test', 'pubspec.yaml'),
+ globals.fs.path.join('flutter', 'bin', 'cache', 'artifacts', 'gradle_wrapper', 'wrapper'),
+ globals.fs.path.join('usr', 'local', 'bin', 'adb'),
+ globals.fs.path.join('Android', 'platform-tools', 'adb.exe'),
];
for (String path in paths) {
- fs.file(path).createSync(recursive: true);
+ globals.fs.file(path).createSync(recursive: true);
}
}, overrides: <Type, Generator>{
DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart
index fd4f51a79..ba5053b 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart
@@ -10,7 +10,7 @@
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/commands/daemon.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/ios_workflow.dart';
import 'package:flutter_tools/src/resident_runner.dart';
@@ -61,7 +61,7 @@
notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
);
- printError('daemon.logMessage test');
+ globals.printError('daemon.logMessage test');
final Map<String, dynamic> response = await responses.stream.firstWhere((Map<String, dynamic> map) {
return map['event'] == 'daemon.logMessage' && map['params']['level'] == 'error';
});
@@ -89,7 +89,7 @@
logToStdout: true,
dartDefines: const <String>[],
);
- printStatus('daemon.logMessage test');
+ globals.printStatus('daemon.logMessage test');
// Service the event loop.
await Future<void>.value();
}, zoneSpecification: ZoneSpecification(print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
index d0e28b9..5b3e077 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
@@ -6,15 +6,13 @@
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/common.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
-import 'package:flutter_tools/src/base/process_manager.dart';
+
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/features.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/proxy_validator.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/vscode/vscode.dart';
@@ -24,6 +22,7 @@
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:quiver/testing/async.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -493,7 +492,7 @@
testUsingContext('gen_snapshot does not work', () async {
when(mockProcessManager.runSync(
- <String>[artifacts.getArtifactPath(Artifact.genSnapshot)],
+ <String>[globals.artifacts.getArtifactPath(Artifact.genSnapshot)],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(101, 1, '', ''));
@@ -503,7 +502,7 @@
for (String msg in userMessages.flutterBinariesDoNotRun.split('\n')) {
expect(statusLines, contains(contains(msg)));
}
- if (platform.isLinux) {
+ if (globals.platform.isLinux) {
for (String msg in userMessages.flutterBinariesLinuxRepairCommands.split('\n')) {
expect(statusLines, contains(contains(msg)));
}
@@ -522,7 +521,7 @@
when(mockFlutterVersion.frameworkDate).thenThrow(versionCheckError);
when(mockProcessManager.runSync(
- <String>[artifacts.getArtifactPath(Artifact.genSnapshot)],
+ <String>[globals.artifacts.getArtifactPath(Artifact.genSnapshot)],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(101, 255, '', ''));
@@ -705,7 +704,7 @@
});
testUsingContext('WebWorkflow is a part of validator workflows if enabled', () async {
- when(processManager.canRun(any)).thenReturn(true);
+ when(globals.processManager.canRun(any)).thenReturn(true);
expect(DoctorValidatorsProvider.defaultInstance.workflows.contains(webWorkflow), true);
}, overrides: <Type, Generator>{
@@ -720,7 +719,7 @@
IntelliJValidatorTestTarget(String title, String installPath) : super(title, installPath);
@override
- String get pluginsPath => fs.path.join('test', 'data', 'intellij', 'plugins');
+ String get pluginsPath => globals.fs.path.join('test', 'data', 'intellij', 'plugins');
@override
String get version => 'test.test.test';
@@ -1046,9 +1045,9 @@
static VsCodeValidatorTestTargets get installedWithoutExtension =>
VsCodeValidatorTestTargets._(validInstall, missingExtensions);
- static final String validInstall = fs.path.join('test', 'data', 'vscode', 'application');
- static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions');
- static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions');
+ static final String validInstall = globals.fs.path.join('test', 'data', 'vscode', 'application');
+ static final String validExtensions = globals.fs.path.join('test', 'data', 'vscode', 'extensions');
+ static final String missingExtensions = globals.fs.path.join('test', 'data', 'vscode', 'notExtensions');
}
class MockProcessManager extends Mock implements ProcessManager {}
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
index 3e17f8f..43cb66b 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
@@ -5,16 +5,18 @@
import 'dart:async';
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/drive.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:mockito/mockito.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -66,9 +68,9 @@
testUsingContext('returns 1 when test file is not found', () async {
testDeviceManager.addDevice(MockDevice());
- final String testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart');
- final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
- fs.file(testApp).createSync(recursive: true);
+ final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
+ final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
+ globals.fs.file(testApp).createSync(recursive: true);
final List<String> args = <String>[
'drive',
@@ -91,8 +93,8 @@
testDeviceManager.addDevice(MockDevice());
appStarter = expectAsync1((DriveCommand command) async => null);
- final String testApp = fs.path.join(tempDir.path, 'test_driver', 'e2e.dart');
- final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
+ final String testApp = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e.dart');
+ final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
final MemoryFileSystem memFs = fs;
await memFs.file(testApp).writeAsString('main() { }');
@@ -116,8 +118,8 @@
});
testUsingContext('returns 1 when app file is outside package', () async {
- final String appFile = fs.path.join(tempDir.dirname, 'other_app', 'app.dart');
- fs.file(appFile).createSync(recursive: true);
+ final String appFile = globals.fs.path.join(tempDir.dirname, 'other_app', 'app.dart');
+ globals.fs.file(appFile).createSync(recursive: true);
final List<String> args = <String>[
'--no-wrap',
'drive',
@@ -139,8 +141,8 @@
});
testUsingContext('returns 1 when app file is in the root dir', () async {
- final String appFile = fs.path.join(tempDir.path, 'main.dart');
- fs.file(appFile).createSync(recursive: true);
+ final String appFile = globals.fs.path.join(tempDir.path, 'main.dart');
+ globals.fs.file(appFile).createSync(recursive: true);
final List<String> args = <String>[
'--no-wrap',
'drive',
@@ -165,8 +167,8 @@
testUsingContext('returns 0 when test ends successfully', () async {
testDeviceManager.addDevice(MockDevice());
- final String testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart');
- final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
+ final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
+ final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
appStarter = expectAsync1((DriveCommand command) async {
return LaunchResult.succeeded();
@@ -210,8 +212,8 @@
testUsingContext('returns exitCode set by test runner', () async {
testDeviceManager.addDevice(MockDevice());
- final String testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart');
- final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
+ final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
+ final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
appStarter = expectAsync1((DriveCommand command) async {
return LaunchResult.succeeded();
@@ -370,8 +372,8 @@
)).thenAnswer((_) => Future<LaunchResult>.value(mockLaunchResult));
when(mockDevice.isAppInstalled(any)).thenAnswer((_) => Future<bool>.value(false));
- testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart');
- testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
+ testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
+ testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
testRunner = (List<String> testArgs, Map<String, String> environment) async {
throwToolExit(null, exitCode: 123);
@@ -503,8 +505,8 @@
when(mockDevice.isAppInstalled(any))
.thenAnswer((_) => Future<bool>.value(false));
- testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart');
- testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
+ testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
+ testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
testRunner = (List<String> testArgs, Map<String, String> environment) async {
throwToolExit(null, exitCode: 123);
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart
index 68e3223..334d5af 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/codegen.dart';
import 'package:flutter_tools/src/commands/generate.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -47,10 +47,10 @@
test('Outputs error information from flutter generate', () => testbed.run(() async {
final GenerateCommand command = GenerateCommand();
applyMocksToCommand(command);
- fs.file(fs.path.join('lib', 'main.dart'))
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
..createSync(recursive: true);
- fs.currentDirectory
+ globals.fs.currentDirectory
.childDirectory('.dart_tool')
.childDirectory('build')
.childDirectory('abcdefg')
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart
index 9aec064..3e22868 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart
@@ -9,6 +9,7 @@
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/template.dart';
import 'package:flutter_tools/src/commands/ide_config.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -24,33 +25,33 @@
final String tempPath = tempDir.absolute.path;
final List<String> paths =
(root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) {
- final String relativePath = fs.path.relative(entity.path, from: tempPath);
+ final String relativePath = globals.fs.path.relative(entity.path, from: tempPath);
return relativePath;
}).toList();
final Map<String, String> contents = <String, String>{};
for (String path in paths) {
- final String absPath = fs.path.join(tempPath, path);
- if (fs.isDirectorySync(absPath)) {
+ final String absPath = globals.fs.path.join(tempPath, path);
+ if (globals.fs.isDirectorySync(absPath)) {
contents[path] = 'dir';
- } else if (fs.isFileSync(absPath)) {
- contents[path] = fs.file(absPath).readAsStringSync();
+ } else if (globals.fs.isFileSync(absPath)) {
+ contents[path] = globals.fs.file(absPath).readAsStringSync();
}
}
return contents;
}
Map<String, String> _getManifest(Directory base, String marker, { bool isTemplate = false }) {
- final String basePath = fs.path.relative(base.path, from: tempDir.absolute.path);
+ final String basePath = globals.fs.path.relative(base.path, from: tempDir.absolute.path);
final String suffix = isTemplate ? Template.copyTemplateExtension : '';
return <String, String>{
- fs.path.join(basePath, '.idea'): 'dir',
- fs.path.join(basePath, '.idea', 'modules.xml$suffix'): 'modules $marker',
- fs.path.join(basePath, '.idea', 'vcs.xml$suffix'): 'vcs $marker',
- fs.path.join(basePath, '.idea', '.name$suffix'): 'codeStyleSettings $marker',
- fs.path.join(basePath, '.idea', 'runConfigurations'): 'dir',
- fs.path.join(basePath, '.idea', 'runConfigurations', 'hello_world.xml$suffix'): 'hello_world $marker',
- fs.path.join(basePath, 'flutter.iml$suffix'): 'flutter $marker',
- fs.path.join(basePath, 'packages', 'new', 'deep.iml$suffix'): 'deep $marker',
+ globals.fs.path.join(basePath, '.idea'): 'dir',
+ globals.fs.path.join(basePath, '.idea', 'modules.xml$suffix'): 'modules $marker',
+ globals.fs.path.join(basePath, '.idea', 'vcs.xml$suffix'): 'vcs $marker',
+ globals.fs.path.join(basePath, '.idea', '.name$suffix'): 'codeStyleSettings $marker',
+ globals.fs.path.join(basePath, '.idea', 'runConfigurations'): 'dir',
+ globals.fs.path.join(basePath, '.idea', 'runConfigurations', 'hello_world.xml$suffix'): 'hello_world $marker',
+ globals.fs.path.join(basePath, 'flutter.iml$suffix'): 'flutter $marker',
+ globals.fs.path.join(basePath, 'packages', 'new', 'deep.iml$suffix'): 'deep $marker',
};
}
@@ -70,8 +71,8 @@
}
bool _fileOrDirectoryExists(String path) {
- final String absPath = fs.path.join(tempDir.absolute.path, path);
- return fs.file(absPath).existsSync() || fs.directory(absPath).existsSync();
+ final String absPath = globals.fs.path.join(tempDir.absolute.path, path);
+ return globals.fs.file(absPath).existsSync() || globals.fs.directory(absPath).existsSync();
}
Future<void> _updateIdeConfig({
@@ -90,16 +91,16 @@
]);
for (String path in expectedContents.keys) {
- final String absPath = fs.path.join(tempDir.absolute.path, path);
- expect(_fileOrDirectoryExists(fs.path.join(dir.path, path)), true,
+ final String absPath = globals.fs.path.join(tempDir.absolute.path, path);
+ expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), true,
reason: "$path doesn't exist");
- if (fs.file(absPath).existsSync()) {
- expect(fs.file(absPath).readAsStringSync(), equals(expectedContents[path]),
+ if (globals.fs.file(absPath).existsSync()) {
+ expect(globals.fs.file(absPath).readAsStringSync(), equals(expectedContents[path]),
reason: "$path contents don't match");
}
}
for (String path in unexpectedPaths) {
- expect(_fileOrDirectoryExists(fs.path.join(dir.path, path)), false, reason: '$path exists');
+ expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), false, reason: '$path exists');
}
}
@@ -108,7 +109,7 @@
});
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_ide_config_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_ide_config_test.');
final Directory packagesDir = tempDir.childDirectory('packages')..createSync(recursive: true);
toolsDir = packagesDir.childDirectory('flutter_tools')..createSync();
templateDir = toolsDir.childDirectory('ide_templates')..createSync();
@@ -189,7 +190,7 @@
'template',
isTemplate: true,
);
- final String flutterIml = fs.path.join(
+ final String flutterIml = globals.fs.path.join(
'packages',
'flutter_tools',
'ide_templates',
@@ -259,7 +260,7 @@
'existing',
isTemplate: true,
);
- final String flutterIml = fs.path.join(
+ final String flutterIml = globals.fs.path.join(
'packages',
'flutter_tools',
'ide_templates',
@@ -288,25 +289,25 @@
tempDir,
'existing',
);
- flutterManifest.remove(fs.path.join('packages', 'new', 'deep.iml'));
+ flutterManifest.remove(globals.fs.path.join('packages', 'new', 'deep.iml'));
_populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest(
intellijDir,
'existing',
isTemplate: true,
);
- String deepIml = fs.path.join(
+ String deepIml = globals.fs.path.join(
'packages',
'flutter_tools',
'ide_templates',
'intellij');
// Remove the all the dir entries too.
updatedTemplates.remove(deepIml);
- deepIml = fs.path.join(deepIml, 'packages');
+ deepIml = globals.fs.path.join(deepIml, 'packages');
updatedTemplates.remove(deepIml);
- deepIml = fs.path.join(deepIml, 'new');
+ deepIml = globals.fs.path.join(deepIml, 'new');
updatedTemplates.remove(deepIml);
- deepIml = fs.path.join(deepIml, 'deep.iml');
+ deepIml = globals.fs.path.join(deepIml, 'deep.iml');
updatedTemplates.remove(deepIml);
final Map<String, String> expectedContents = <String, String>{
...flutterManifest,
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
index 9fb909c..466f4c8 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
@@ -20,7 +20,7 @@
import 'package:flutter_tools/src/commands/run.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/features.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/resident_runner.dart';
@@ -61,9 +61,9 @@
});
testUsingContext('does not support "--use-application-binary" and "--fast-start"', () async {
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final RunCommand command = RunCommand();
applyMocksToCommand(command);
@@ -97,9 +97,9 @@
when(deviceManager.getDevices()).thenAnswer((Invocation invocation) {
return Stream<Device>.value(mockDevice);
});
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final RunCommand command = RunCommand();
applyMocksToCommand(command);
@@ -114,7 +114,7 @@
expect(e, isInstanceOf<ToolExit>());
}
- final BufferLogger bufferLogger = logger as BufferLogger;
+ final BufferLogger bufferLogger = globals.logger as BufferLogger;
expect(bufferLogger.statusText, contains(
'Using --fast-start option with device mockdevice, but this device '
'does not support it. Overriding the setting to false.'
@@ -263,14 +263,14 @@
(Invocation invocation) => Future<List<Device>>.value(<Device>[mockDevice])
);
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.');
tempDir.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true);
tempDir.childFile('.packages').createSync();
tempDir.childDirectory('lib').childFile('main.dart').createSync(recursive: true);
tempDir.childFile('pubspec.yaml')
..createSync()
..writeAsStringSync('# Hello, World');
- fs.currentDirectory = tempDir;
+ globals.fs.currentDirectory = tempDir;
try {
await createTestCommandRunner(command).run(<String>[
@@ -482,8 +482,8 @@
});
testUsingContext('populates the environment', () async {
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.');
- fs.currentDirectory = tempDir;
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.');
+ globals.fs.currentDirectory = tempDir;
final Directory libDir = tempDir.childDirectory('lib');
libDir.createSync();
@@ -509,8 +509,8 @@
});
testUsingContext('populates dartDefines in --machine mode', () async {
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.');
- fs.currentDirectory = tempDir;
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.');
+ globals.fs.currentDirectory = tempDir;
final Directory libDir = tempDir.childDirectory('lib');
libDir.createSync();
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart
index ac21ec7..d9bb0a4 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart
@@ -10,6 +10,7 @@
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/shell_completion.dart';
import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -48,8 +49,8 @@
await createTestCommandRunner(command).run(
<String>['bash-completion', outputFile],
);
- expect(fs.isFileSync(outputFile), isTrue);
- expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion'));
+ expect(globals.fs.isFileSync(outputFile), isTrue);
+ expect(globals.fs.file(outputFile).readAsStringSync(), contains('__flutter_completion'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -59,7 +60,7 @@
testUsingContext("won't overwrite existing output file ", () async {
final ShellCompletionCommand command = ShellCompletionCommand();
const String outputFile = 'bash-setup.sh';
- fs.file(outputFile).createSync();
+ globals.fs.file(outputFile).createSync();
try {
await createTestCommandRunner(command).run(
<String>['bash-completion', outputFile],
@@ -69,8 +70,8 @@
expect(error.exitCode ?? 1, 1);
expect(error.message, contains('Use --overwrite'));
}
- expect(fs.isFileSync(outputFile), isTrue);
- expect(fs.file(outputFile).readAsStringSync(), isEmpty);
+ expect(globals.fs.isFileSync(outputFile), isTrue);
+ expect(globals.fs.file(outputFile).readAsStringSync(), isEmpty);
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -80,12 +81,12 @@
testUsingContext('will overwrite existing output file if given --overwrite', () async {
final ShellCompletionCommand command = ShellCompletionCommand();
const String outputFile = 'bash-setup.sh';
- fs.file(outputFile).createSync();
+ globals.fs.file(outputFile).createSync();
await createTestCommandRunner(command).run(
<String>['bash-completion', '--overwrite', outputFile],
);
- expect(fs.isFileSync(outputFile), isTrue);
- expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion'));
+ expect(globals.fs.isFileSync(outputFile), isTrue);
+ expect(globals.fs.file(outputFile).readAsStringSync(), contains('__flutter_completion'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
diff --git a/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart b/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart
index 5933d47..7d06528 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart
@@ -4,14 +4,16 @@
import 'dart:async';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/analyze.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -22,7 +24,7 @@
};
void main() {
- final String analyzerSeparator = platform.isWindows ? '-' : '•';
+ final String analyzerSeparator = globals.platform.isWindows ? '-' : '•';
group('analyze once', () {
Directory tempDir;
@@ -31,9 +33,9 @@
setUpAll(() {
Cache.disableLocking();
- tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_1.').absolute;
- projectPath = fs.path.join(tempDir.path, 'flutter_project');
- libMain = fs.file(fs.path.join(projectPath, 'lib', 'main.dart'));
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_1.').absolute;
+ projectPath = globals.fs.path.join(tempDir.path, 'flutter_project');
+ libMain = globals.fs.file(globals.fs.path.join(projectPath, 'lib', 'main.dart'));
});
tearDownAll(() {
@@ -47,7 +49,7 @@
arguments: <String>['--no-wrap', 'create', projectPath],
statusTextContains: <String>[
'All done!',
- 'Your application code is in ${fs.path.normalize(fs.path.join(fs.path.relative(projectPath), 'lib', 'main.dart'))}',
+ 'Your application code is in ${globals.fs.path.normalize(globals.fs.path.join(globals.fs.path.relative(projectPath), 'lib', 'main.dart'))}',
],
);
expect(libMain.existsSync(), isTrue);
@@ -58,7 +60,7 @@
// Analyze in the current directory - no arguments
testUsingContext('working directory', () async {
await runCommand(
- command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)),
+ command: AnalyzeCommand(workingDirectory: globals.fs.directory(projectPath)),
arguments: <String>['analyze'],
statusTextContains: <String>['No issues found!'],
);
@@ -98,7 +100,7 @@
// Analyze in the current directory - no arguments
await runCommand(
- command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)),
+ command: AnalyzeCommand(workingDirectory: globals.fs.directory(projectPath)),
arguments: <String>['analyze'],
statusTextContains: <String>[
'Analyzing',
@@ -117,7 +119,7 @@
testUsingContext('working directory with local options', () async {
// Insert an analysis_options.yaml file in the project
// which will trigger a lint for broken code that was inserted earlier
- final File optionsFile = fs.file(fs.path.join(projectPath, 'analysis_options.yaml'));
+ final File optionsFile = globals.fs.file(globals.fs.path.join(projectPath, 'analysis_options.yaml'));
await optionsFile.writeAsString('''
include: package:flutter/analysis_options_user.yaml
linter:
@@ -127,7 +129,7 @@
// Analyze in the current directory - no arguments
await runCommand(
- command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)),
+ command: AnalyzeCommand(workingDirectory: globals.fs.directory(projectPath)),
arguments: <String>['analyze'],
statusTextContains: <String>[
'Analyzing',
@@ -144,17 +146,17 @@
});
testUsingContext('no duplicate issues', () async {
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_2.').absolute;
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_2.').absolute;
try {
- final File foo = fs.file(fs.path.join(tempDir.path, 'foo.dart'));
+ final File foo = globals.fs.file(globals.fs.path.join(tempDir.path, 'foo.dart'));
foo.writeAsStringSync('''
import 'bar.dart';
void foo() => bar();
''');
- final File bar = fs.file(fs.path.join(tempDir.path, 'bar.dart'));
+ final File bar = globals.fs.file(globals.fs.path.join(tempDir.path, 'bar.dart'));
bar.writeAsStringSync('''
import 'dart:async'; // unused
@@ -184,11 +186,11 @@
const String contents = '''
StringBuffer bar = StringBuffer('baz');
''';
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_3.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_3.');
tempDir.childFile('main.dart').writeAsStringSync(contents);
try {
await runCommand(
- command: AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
+ command: AnalyzeCommand(workingDirectory: globals.fs.directory(tempDir)),
arguments: <String>['analyze'],
statusTextContains: <String>['No issues found!'],
);
@@ -205,11 +207,11 @@
// TODO(foobar):
StringBuffer bar = StringBuffer('baz');
''';
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_4.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_4.');
tempDir.childFile('main.dart').writeAsStringSync(contents);
try {
await runCommand(
- command: AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
+ command: AnalyzeCommand(workingDirectory: globals.fs.directory(tempDir)),
arguments: <String>['analyze'],
statusTextContains: <String>['No issues found!'],
);
diff --git a/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart b/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart
index 5254a36..3018b67 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart
@@ -15,6 +15,7 @@
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -26,7 +27,7 @@
MockBundleBuilder mockBundleBuilder;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
mockBundleBuilder = MockBundleBuilder();
when(
@@ -98,9 +99,9 @@
});
testUsingContext('bundle fails to build for Windows if feature is disabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync(recursive: true);
- fs.file('.packages').createSync(recursive: true);
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync(recursive: true);
+ globals.fs.file('.packages').createSync(recursive: true);
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = MockBundleBuilder());
@@ -116,9 +117,9 @@
});
testUsingContext('bundle fails to build for Linux if feature is disabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = MockBundleBuilder());
@@ -134,9 +135,9 @@
});
testUsingContext('bundle fails to build for macOS if feature is disabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = MockBundleBuilder());
@@ -152,9 +153,9 @@
});
testUsingContext('bundle can build for Windows if feature is enabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = MockBundleBuilder());
@@ -170,9 +171,9 @@
});
testUsingContext('bundle can build for Linux if feature is enabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = MockBundleBuilder());
@@ -188,9 +189,9 @@
});
testUsingContext('bundle can build for macOS if feature is enabled', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()
..bundleBuilder = MockBundleBuilder());
@@ -206,14 +207,14 @@
});
testUsingContext('passes track widget creation through', () async {
- fs.file('lib/main.dart').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('lib/main.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand());
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
final Environment environment = invocation.positionalArguments[1] as Environment;
expect(environment.defines, <String, String>{
- kTargetFile: fs.path.join('lib', 'main.dart'),
+ kTargetFile: globals.fs.path.join('lib', 'main.dart'),
kBuildMode: 'debug',
kTargetPlatform: 'android-arm',
kTrackWidgetCreation: 'true',
diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
index 102c0de..b1d284e 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
@@ -7,10 +7,11 @@
import 'dart:typed_data';
import 'package:args/command_runner.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/net.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/dart/pub.dart';
@@ -18,6 +19,7 @@
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -50,7 +52,7 @@
setUp(() {
loggingProcessManager = LoggingProcessManager();
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_create_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_create_test.');
projectDir = tempDir.childDirectory('flutter_project');
mockFlutterVersion = MockFlutterVersion();
});
@@ -455,12 +457,12 @@
await runner.run(<String>['create', '--no-pub', projectDir.path]);
void expectExists(String relPath) {
- expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
+ expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
}
expectExists('android/gradle.properties');
- final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString();
+ final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString();
expect(actualContents.contains('useAndroidX'), true);
});
@@ -476,12 +478,12 @@
await runner.run(<String>['create', '--no-pub', '--no-androidx', projectDir.path]);
void expectExists(String relPath) {
- expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
+ expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
}
expectExists('android/gradle.properties');
- final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString();
+ final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString();
expect(actualContents.contains('useAndroidX'), false);
});
@@ -531,12 +533,12 @@
await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
void expectExists(String relPath) {
- expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
+ expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
}
expectExists('android/gradle.properties');
- final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString();
+ final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString();
expect(actualContents.contains('useAndroidX'), true);
});
@@ -552,12 +554,12 @@
await runner.run(<String>['create', '--no-pub', '--template=plugin', '--no-androidx', projectDir.path]);
void expectExists(String relPath) {
- expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
+ expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
}
expectExists('android/gradle.properties');
- final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString();
+ final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString();
expect(actualContents.contains('useAndroidX'), false);
});
@@ -633,13 +635,13 @@
await runner.run(<String>['create', '--template=module', '--no-pub', '--org', 'com.foo.bar', projectDir.path]);
void expectExists(String relPath, [bool expectation = true]) {
- expect(fs.isFileSync('${projectDir.path}/$relPath'), expectation);
+ expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), expectation);
}
expectExists('lib/main.dart');
expectExists('test/widget_test.dart');
- final String actualContents = await fs.file(projectDir.path + '/test/widget_test.dart').readAsString();
+ final String actualContents = await globals.fs.file(projectDir.path + '/test/widget_test.dart').readAsString();
expect(actualContents.contains('flutter_test.dart'), true);
@@ -658,55 +660,55 @@
}
}
- await _runFlutterTest(projectDir, target: fs.path.join(projectDir.path, 'test', 'widget_test.dart'));
+ await _runFlutterTest(projectDir, target: globals.fs.path.join(projectDir.path, 'test', 'widget_test.dart'));
// Generated Xcode settings
- final String xcodeConfigPath = fs.path.join('.ios', 'Flutter', 'Generated.xcconfig');
+ final String xcodeConfigPath = globals.fs.path.join('.ios', 'Flutter', 'Generated.xcconfig');
expectExists(xcodeConfigPath);
- final File xcodeConfigFile = fs.file(fs.path.join(projectDir.path, xcodeConfigPath));
+ final File xcodeConfigFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeConfigPath));
final String xcodeConfig = xcodeConfigFile.readAsStringSync();
expect(xcodeConfig, contains('FLUTTER_ROOT='));
expect(xcodeConfig, contains('FLUTTER_APPLICATION_PATH='));
expect(xcodeConfig, contains('FLUTTER_TARGET='));
// Generated export environment variables script
- final String buildPhaseScriptPath = fs.path.join('.ios', 'Flutter', 'flutter_export_environment.sh');
+ final String buildPhaseScriptPath = globals.fs.path.join('.ios', 'Flutter', 'flutter_export_environment.sh');
expectExists(buildPhaseScriptPath);
- final File buildPhaseScriptFile = fs.file(fs.path.join(projectDir.path, buildPhaseScriptPath));
+ final File buildPhaseScriptFile = globals.fs.file(globals.fs.path.join(projectDir.path, buildPhaseScriptPath));
final String buildPhaseScript = buildPhaseScriptFile.readAsStringSync();
expect(buildPhaseScript, contains('FLUTTER_ROOT='));
expect(buildPhaseScript, contains('FLUTTER_APPLICATION_PATH='));
expect(buildPhaseScript, contains('FLUTTER_TARGET='));
// Generated podspec
- final String podspecPath = fs.path.join('.ios', 'Flutter', 'flutter_project.podspec');
+ final String podspecPath = globals.fs.path.join('.ios', 'Flutter', 'flutter_project.podspec');
expectExists(podspecPath);
- final File podspecFile = fs.file(fs.path.join(projectDir.path, podspecPath));
+ final File podspecFile = globals.fs.file(globals.fs.path.join(projectDir.path, podspecPath));
final String podspec = podspecFile.readAsStringSync();
expect(podspec, contains('Flutter module - flutter_project'));
// App identification
- final String xcodeProjectPath = fs.path.join('.ios', 'Runner.xcodeproj', 'project.pbxproj');
+ final String xcodeProjectPath = globals.fs.path.join('.ios', 'Runner.xcodeproj', 'project.pbxproj');
expectExists(xcodeProjectPath);
- final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath));
+ final File xcodeProjectFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeProjectPath));
final String xcodeProject = xcodeProjectFile.readAsStringSync();
expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject'));
// Xcode build system
- final String xcodeWorkspaceSettingsPath = fs.path.join('.ios', 'Runner.xcworkspace', 'xcshareddata', 'WorkspaceSettings.xcsettings');
+ final String xcodeWorkspaceSettingsPath = globals.fs.path.join('.ios', 'Runner.xcworkspace', 'xcshareddata', 'WorkspaceSettings.xcsettings');
expectExists(xcodeWorkspaceSettingsPath, false);
- final String versionPath = fs.path.join('.metadata');
+ final String versionPath = globals.fs.path.join('.metadata');
expectExists(versionPath);
- final String version = fs.file(fs.path.join(projectDir.path, versionPath)).readAsStringSync();
+ final String version = globals.fs.file(globals.fs.path.join(projectDir.path, versionPath)).readAsStringSync();
expect(version, contains('version:'));
expect(version, contains('revision: 12345678'));
expect(version, contains('channel: omega'));
// IntelliJ metadata
- final String intelliJSdkMetadataPath = fs.path.join('.idea', 'libraries', 'Dart_SDK.xml');
+ final String intelliJSdkMetadataPath = globals.fs.path.join('.idea', 'libraries', 'Dart_SDK.xml');
expectExists(intelliJSdkMetadataPath);
- final String sdkMetaContents = fs
- .file(fs.path.join(
+ final String sdkMetaContents = globals.fs
+ .file(globals.fs.path.join(
projectDir.path,
intelliJSdkMetadataPath,
))
@@ -729,7 +731,7 @@
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'com.foo.bar', projectDir.path]);
void expectExists(String relPath) {
- expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
+ expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
}
expectExists('lib/main.dart');
@@ -750,34 +752,34 @@
}
}
- await _runFlutterTest(projectDir, target: fs.path.join(projectDir.path, 'test', 'widget_test.dart'));
+ await _runFlutterTest(projectDir, target: globals.fs.path.join(projectDir.path, 'test', 'widget_test.dart'));
// Generated Xcode settings
- final String xcodeConfigPath = fs.path.join('ios', 'Flutter', 'Generated.xcconfig');
+ final String xcodeConfigPath = globals.fs.path.join('ios', 'Flutter', 'Generated.xcconfig');
expectExists(xcodeConfigPath);
- final File xcodeConfigFile = fs.file(fs.path.join(projectDir.path, xcodeConfigPath));
+ final File xcodeConfigFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeConfigPath));
final String xcodeConfig = xcodeConfigFile.readAsStringSync();
expect(xcodeConfig, contains('FLUTTER_ROOT='));
expect(xcodeConfig, contains('FLUTTER_APPLICATION_PATH='));
// App identification
- final String xcodeProjectPath = fs.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj');
+ final String xcodeProjectPath = globals.fs.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj');
expectExists(xcodeProjectPath);
- final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath));
+ final File xcodeProjectFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeProjectPath));
final String xcodeProject = xcodeProjectFile.readAsStringSync();
expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject'));
- final String versionPath = fs.path.join('.metadata');
+ final String versionPath = globals.fs.path.join('.metadata');
expectExists(versionPath);
- final String version = fs.file(fs.path.join(projectDir.path, versionPath)).readAsStringSync();
+ final String version = globals.fs.file(globals.fs.path.join(projectDir.path, versionPath)).readAsStringSync();
expect(version, contains('version:'));
expect(version, contains('revision: 12345678'));
expect(version, contains('channel: omega'));
// IntelliJ metadata
- final String intelliJSdkMetadataPath = fs.path.join('.idea', 'libraries', 'Dart_SDK.xml');
+ final String intelliJSdkMetadataPath = globals.fs.path.join('.idea', 'libraries', 'Dart_SDK.xml');
expectExists(intelliJSdkMetadataPath);
- final String sdkMetaContents = fs
- .file(fs.path.join(
+ final String sdkMetaContents = globals.fs
+ .file(globals.fs.path.join(
projectDir.path,
intelliJSdkMetadataPath,
))
@@ -797,9 +799,9 @@
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
- String tmpProjectDir = fs.path.join(tempDir.path, 'hello_flutter');
+ String tmpProjectDir = globals.fs.path.join(tempDir.path, 'hello_flutter');
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'com.example', tmpProjectDir]);
- FlutterProject project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir));
+ FlutterProject project = FlutterProject.fromDirectory(globals.fs.directory(tmpProjectDir));
expect(
await project.ios.productBundleIdentifier,
'com.example.helloFlutter',
@@ -809,9 +811,9 @@
'com.example.hello_flutter',
);
- tmpProjectDir = fs.path.join(tempDir.path, 'test_abc');
+ tmpProjectDir = globals.fs.path.join(tempDir.path, 'test_abc');
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'abc^*.1#@', tmpProjectDir]);
- project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir));
+ project = FlutterProject.fromDirectory(globals.fs.directory(tmpProjectDir));
expect(
await project.ios.productBundleIdentifier,
'abc.1.testAbc',
@@ -821,9 +823,9 @@
'abc.u1.test_abc',
);
- tmpProjectDir = fs.path.join(tempDir.path, 'flutter_project');
+ tmpProjectDir = globals.fs.path.join(tempDir.path, 'flutter_project');
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', '#+^%', tmpProjectDir]);
- project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir));
+ project = FlutterProject.fromDirectory(globals.fs.directory(tmpProjectDir));
expect(
await project.ios.productBundleIdentifier,
'flutterProject.untitled',
@@ -847,7 +849,7 @@
await runner.run(<String>['create', '--no-pub', projectDir.path]);
- final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
+ final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
expect(metadata, contains('project_type: app\n'));
});
@@ -860,11 +862,11 @@
await runner.run(<String>['create', '--no-pub', '--template=app', projectDir.path]);
// Remove the .metadata to simulate an older instantiation that didn't generate those.
- fs.file(fs.path.join(projectDir.path, '.metadata')).deleteSync();
+ globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).deleteSync();
await runner.run(<String>['create', '--no-pub', projectDir.path]);
- final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
+ final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
expect(metadata, contains('project_type: app\n'));
});
@@ -878,7 +880,7 @@
await runner.run(<String>['create', '--no-pub', projectDir.path]);
- final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
+ final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
expect(metadata, contains('project_type: app\n'));
});
@@ -892,7 +894,7 @@
await runner.run(<String>['create', '--no-pub', projectDir.path]);
- final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
+ final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
expect(metadata, contains('project_type: module\n'));
});
@@ -906,7 +908,7 @@
await runner.run(<String>['create', '--no-pub', projectDir.path]);
- final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
+ final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
expect(metadata, contains('project_type: plugin'));
});
@@ -920,7 +922,7 @@
await runner.run(<String>['create', '--no-pub', projectDir.path]);
- final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
+ final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync();
expect(metadata, contains('project_type: package'));
});
@@ -1038,7 +1040,7 @@
<String>['--no-pub', '--template=app', '--org', 'com.bar.foo'],
<String>[],
);
- fs.directory(fs.path.join(projectDir.path, 'ios')).deleteSync(recursive: true);
+ globals.fs.directory(globals.fs.path.join(projectDir.path, 'ios')).deleteSync(recursive: true);
await _createProject(
projectDir,
<String>['--no-pub', '--template=app', '--org', 'com.bar.baz'],
@@ -1067,7 +1069,7 @@
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
- final File existingFile = fs.file(fs.path.join(projectDir.path, 'bad'));
+ final File existingFile = globals.fs.file(globals.fs.path.join(projectDir.path, 'bad'));
if (!existingFile.existsSync()) {
existingFile.createSync(recursive: true);
}
@@ -1081,7 +1083,7 @@
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
- final File existingFile = fs.file(fs.path.join(projectDir.path, 'bad'));
+ final File existingFile = globals.fs.file(globals.fs.path.join(projectDir.path, 'bad'));
if (!existingFile.existsSync()) {
existingFile.createSync(recursive: true);
}
@@ -1093,14 +1095,14 @@
testUsingContext('overwrites existing directory when requested', () async {
Cache.flutterRoot = '../..';
- final Directory existingDirectory = fs.directory(fs.path.join(projectDir.path, 'bad'));
+ final Directory existingDirectory = globals.fs.directory(globals.fs.path.join(projectDir.path, 'bad'));
if (!existingDirectory.existsSync()) {
existingDirectory.createSync(recursive: true);
}
- final File existingFile = fs.file(fs.path.join(existingDirectory.path, 'lib', 'main.dart'));
+ final File existingFile = globals.fs.file(globals.fs.path.join(existingDirectory.path, 'lib', 'main.dart'));
existingFile.createSync(recursive: true);
await _createProject(
- fs.directory(existingDirectory.path),
+ globals.fs.directory(existingDirectory.path),
<String>['--overwrite', '-i', 'objc', '-a', 'java'],
<String>[
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java',
@@ -1169,7 +1171,7 @@
});
testUsingContext('can write samples index to disk', () async {
- final String outputFile = fs.path.join(tempDir.path, 'flutter_samples.json');
+ final String outputFile = globals.fs.path.join(tempDir.path, 'flutter_samples.json');
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
final List<String> args = <String>[
@@ -1179,7 +1181,7 @@
];
await runner.run(args);
- final File expectedFile = fs.file(outputFile);
+ final File expectedFile = globals.fs.file(outputFile);
expect(expectedFile.existsSync(), isTrue);
expect(expectedFile.readAsStringSync(), equals(samplesIndexJson));
}, overrides: <Type, Generator>{
@@ -1187,7 +1189,7 @@
() => MockHttpClient(200, result: samplesIndexJson),
});
testUsingContext('provides an error to the user if samples json download fails', () async {
- final String outputFile = fs.path.join(tempDir.path, 'flutter_samples.json');
+ final String outputFile = globals.fs.path.join(tempDir.path, 'flutter_samples.json');
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
final List<String> args = <String>[
@@ -1197,7 +1199,7 @@
];
await expectLater(runner.run(args), throwsToolExit(exitCode: 2, message: 'Failed to write samples'));
- expect(fs.file(outputFile).existsSync(), isFalse);
+ expect(globals.fs.file(outputFile).existsSync(), isFalse);
}, overrides: <Type, Generator>{
HttpClientFactory: () =>
() => MockHttpClient(404, result: 'not found'),
@@ -1220,8 +1222,8 @@
]);
bool pathExists(String path) {
- final String fullPath = fs.path.join(dir.path, path);
- return fs.typeSync(fullPath) != FileSystemEntityType.notFound;
+ final String fullPath = globals.fs.path.join(dir.path, path);
+ return globals.fs.typeSync(fullPath) != FileSystemEntityType.notFound;
}
final List<String> failures = <String>[
@@ -1246,22 +1248,22 @@
}
Future<void> _ensureFlutterToolsSnapshot() async {
- final String flutterToolsPath = fs.path.absolute(fs.path.join(
+ final String flutterToolsPath = globals.fs.path.absolute(globals.fs.path.join(
'bin',
'flutter_tools.dart',
));
- final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join(
+ final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join(
'..',
'..',
'bin',
'cache',
'flutter_tools.snapshot',
));
- final String dotPackages = fs.path.absolute(fs.path.join(
+ final String dotPackages = globals.fs.path.absolute(globals.fs.path.join(
'.packages',
));
- final File snapshotFile = fs.file(flutterToolsSnapshotPath);
+ final File snapshotFile = globals.fs.file(flutterToolsSnapshotPath);
if (snapshotFile.existsSync()) {
snapshotFile.renameSync(flutterToolsSnapshotPath + '.bak');
}
@@ -1284,7 +1286,7 @@
}
Future<void> _restoreFlutterToolsSnapshot() async {
- final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join(
+ final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join(
'..',
'..',
'bin',
@@ -1292,7 +1294,7 @@
'flutter_tools.snapshot',
));
- final File snapshotBackup = fs.file(flutterToolsSnapshotPath + '.bak');
+ final File snapshotBackup = globals.fs.file(flutterToolsSnapshotPath + '.bak');
if (!snapshotBackup.existsSync()) {
// No backup to restore.
return;
@@ -1302,7 +1304,7 @@
}
Future<void> _analyzeProject(String workingDir) async {
- final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join(
+ final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join(
'..',
'..',
'bin',
@@ -1329,7 +1331,7 @@
}
Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
- final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join(
+ final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join(
'..',
'..',
'bin',
diff --git a/packages/flutter_tools/test/commands.shard/permeable/format_test.dart b/packages/flutter_tools/test/commands.shard/permeable/format_test.dart
index 2b6d0b1..b591275 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/format_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/format_test.dart
@@ -6,6 +6,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/format.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -16,7 +17,7 @@
setUp(() {
Cache.disableLocking();
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_format_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_format_test.');
});
tearDown(() {
@@ -26,7 +27,7 @@
testUsingContext('a file', () async {
final String projectPath = await createProject(tempDir);
- final File srcFile = fs.file(fs.path.join(projectPath, 'lib', 'main.dart'));
+ final File srcFile = globals.fs.file(globals.fs.path.join(projectPath, 'lib', 'main.dart'));
final String original = srcFile.readAsStringSync();
srcFile.writeAsStringSync(original.replaceFirst('main()', 'main( )'));
@@ -41,8 +42,8 @@
testUsingContext('dry-run', () async {
final String projectPath = await createProject(tempDir);
- final File srcFile = fs.file(
- fs.path.join(projectPath, 'lib', 'main.dart'));
+ final File srcFile = globals.fs.file(
+ globals.fs.path.join(projectPath, 'lib', 'main.dart'));
final String nonFormatted = srcFile.readAsStringSync().replaceFirst(
'main()', 'main( )');
srcFile.writeAsStringSync(nonFormatted);
@@ -58,8 +59,8 @@
testUsingContext('dry-run with set-exit-if-changed', () async {
final String projectPath = await createProject(tempDir);
- final File srcFile = fs.file(
- fs.path.join(projectPath, 'lib', 'main.dart'));
+ final File srcFile = globals.fs.file(
+ globals.fs.path.join(projectPath, 'lib', 'main.dart'));
final String nonFormatted = srcFile.readAsStringSync().replaceFirst(
'main()', 'main( )');
srcFile.writeAsStringSync(nonFormatted);
@@ -80,8 +81,8 @@
const int lineLengthLong = 120;
final String projectPath = await createProject(tempDir);
- final File srcFile = fs.file(
- fs.path.join(projectPath, 'lib', 'main.dart'));
+ final File srcFile = globals.fs.file(
+ globals.fs.path.join(projectPath, 'lib', 'main.dart'));
final String nonFormatted = srcFile.readAsStringSync();
srcFile.writeAsStringSync(
nonFormatted.replaceFirst('main()',
diff --git a/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart b/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
index 375a390..657b580 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
@@ -14,6 +14,7 @@
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -42,7 +43,7 @@
Directory tempDir;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
});
tearDown(() {
@@ -51,7 +52,7 @@
Future<String> createProjectWithPlugin(String plugin, { List<String> arguments }) async {
final String projectPath = await createProject(tempDir, arguments: arguments);
- final File pubspec = fs.file(fs.path.join(projectPath, 'pubspec.yaml'));
+ final File pubspec = globals.fs.file(globals.fs.path.join(projectPath, 'pubspec.yaml'));
String content = await pubspec.readAsString();
content = content.replaceFirst(
'\ndependencies:\n',
@@ -75,7 +76,7 @@
void expectExists(String projectPath, String relPath) {
expect(
- fs.isFileSync(fs.path.join(projectPath, relPath)),
+ globals.fs.isFileSync(globals.fs.path.join(projectPath, relPath)),
true,
reason: '$projectPath/$relPath should exist, but does not',
);
@@ -84,7 +85,7 @@
void expectContains(String projectPath, String relPath, String substring) {
expectExists(projectPath, relPath);
expect(
- fs.file(fs.path.join(projectPath, relPath)).readAsStringSync(),
+ globals.fs.file(globals.fs.path.join(projectPath, relPath)).readAsStringSync(),
contains(substring),
reason: '$projectPath/$relPath has unexpected content',
);
@@ -92,7 +93,7 @@
void expectNotExists(String projectPath, String relPath) {
expect(
- fs.isFileSync(fs.path.join(projectPath, relPath)),
+ globals.fs.isFileSync(globals.fs.path.join(projectPath, relPath)),
false,
reason: '$projectPath/$relPath should not exist, but does',
);
@@ -101,7 +102,7 @@
void expectNotContains(String projectPath, String relPath, String substring) {
expectExists(projectPath, relPath);
expect(
- fs.file(fs.path.join(projectPath, relPath)).readAsStringSync(),
+ globals.fs.file(globals.fs.path.join(projectPath, relPath)).readAsStringSync(),
isNot(contains(substring)),
reason: '$projectPath/$relPath has unexpected content',
);
@@ -193,7 +194,7 @@
pluginWitnesses,
].expand<String>((List<String> list) => list);
for (String path in allFiles) {
- final File file = fs.file(fs.path.join(projectPath, path));
+ final File file = globals.fs.file(globals.fs.path.join(projectPath, path));
if (file.existsSync()) {
file.deleteSync();
}
@@ -329,7 +330,7 @@
tempDir,
arguments: <String>['--template=plugin', '--no-pub'],
);
- final String exampleProjectPath = fs.path.join(projectPath, 'example');
+ final String exampleProjectPath = globals.fs.path.join(projectPath, 'example');
removeGeneratedFiles(projectPath);
removeGeneratedFiles(exampleProjectPath);
diff --git a/packages/flutter_tools/test/commands.shard/permeable/test_test.dart b/packages/flutter_tools/test/commands.shard/permeable/test_test.dart
index 78924d8..b35dc7f 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/test_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/test_test.dart
@@ -9,6 +9,7 @@
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -18,8 +19,8 @@
Future<void> _testExclusionLock;
void main() {
- final String automatedTestsDirectory = fs.path.join('..', '..', 'dev', 'automated_tests');
- final String flutterTestDirectory = fs.path.join(automatedTestsDirectory, 'flutter_test');
+ final String automatedTestsDirectory = globals.fs.path.join('..', '..', 'dev', 'automated_tests');
+ final String flutterTestDirectory = globals.fs.path.join(automatedTestsDirectory, 'flutter_test');
testUsingContext('flutter test should not have extraneous error messages', () async {
Cache.flutterRoot = '../..';
@@ -47,7 +48,7 @@
});
testUsingContext('flutter test should report a nice error when a pubspec.yaml is missing a flutter_test dependency', () async {
- final String missingDependencyTests = fs.path.join('..', '..', 'dev', 'missing_dependency_tests');
+ final String missingDependencyTests = globals.fs.path.join('..', '..', 'dev', 'missing_dependency_tests');
Cache.flutterRoot = '../..';
return _testFile('trivial', missingDependencyTests, missingDependencyTests);
});
@@ -140,8 +141,8 @@
List<String> extraArguments = const <String>[],
}) async {
exitCode ??= isNonZero;
- final String fullTestExpectation = fs.path.join(testDirectory, '${testName}_expectation.txt');
- final File expectationFile = fs.file(fullTestExpectation);
+ final String fullTestExpectation = globals.fs.path.join(testDirectory, '${testName}_expectation.txt');
+ final File expectationFile = globals.fs.file(fullTestExpectation);
if (!expectationFile.existsSync()) {
fail('missing expectation file: $expectationFile');
}
@@ -167,7 +168,7 @@
}
output.add('<<stderr>>');
output.addAll((exec.stderr as String).split('\n'));
- final List<String> expectations = fs.file(fullTestExpectation).readAsLinesSync();
+ final List<String> expectations = globals.fs.file(fullTestExpectation).readAsLinesSync();
bool allowSkip = false;
int expectationLineNumber = 0;
int outputLineNumber = 0;
@@ -229,14 +230,14 @@
if (testName == null) {
// Test everything in the directory.
testPath = testDirectory;
- final Directory directoryToTest = fs.directory(testPath);
+ final Directory directoryToTest = globals.fs.directory(testPath);
if (!directoryToTest.existsSync()) {
fail('missing test directory: $directoryToTest');
}
} else {
// Test just a specific test file.
- testPath = fs.path.join(testDirectory, '${testName}_test.dart');
- final File testFile = fs.file(testPath);
+ testPath = globals.fs.path.join(testDirectory, '${testName}_test.dart');
+ final File testFile = globals.fs.file(testPath);
if (!testFile.existsSync()) {
fail('missing test file: $testFile');
}
@@ -244,7 +245,7 @@
final List<String> args = <String>[
...dartVmFlags,
- fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),
+ globals.fs.path.absolute(globals.fs.path.join('bin', 'flutter_tools.dart')),
'test',
'--no-color',
...extraArguments,
@@ -259,7 +260,7 @@
_testExclusionLock = testExclusionCompleter.future;
try {
return await Process.run(
- fs.path.join(dartSdkPath, 'bin', 'dart'),
+ globals.fs.path.join(dartSdkPath, 'bin', 'dart'),
args,
workingDirectory: workingDirectory,
stdoutEncoding: utf8,
diff --git a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
index b911682..e8961e0 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
@@ -5,7 +5,7 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/upgrade.dart';
@@ -16,6 +16,7 @@
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -38,7 +39,7 @@
processManager = MockProcessManager();
when(processManager.start(
<String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'upgrade',
'--continue',
'--no-version-check',
@@ -130,9 +131,9 @@
flutterVersion,
);
expect(await result, null);
- verifyNever(processManager.start(
+ verifyNever(globals.processManager.start(
<String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'upgrade',
'--continue',
'--no-version-check',
@@ -147,7 +148,7 @@
});
testUsingContext('verifyUpstreamConfigured', () async {
- when(processManager.run(
+ when(globals.processManager.run(
<String>['git', 'rev-parse', '@{u}'],
environment:anyNamed('environment'),
workingDirectory: anyNamed('workingDirectory')),
@@ -164,9 +165,9 @@
testUsingContext('flutterUpgradeContinue passes env variables to child process', () async {
await realCommandRunner.flutterUpgradeContinue();
- final VerificationResult result = verify(processManager.start(
+ final VerificationResult result = verify(globals.processManager.start(
<String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'upgrade',
'--continue',
'--no-version-check',
@@ -184,13 +185,13 @@
testUsingContext('precacheArtifacts passes env variables to child process', () async {
final List<String> precacheCommand = <String>[
- fs.path.join('bin', 'flutter'),
+ globals.fs.path.join('bin', 'flutter'),
'--no-color',
'--no-version-check',
'precache',
];
- when(processManager.start(
+ when(globals.processManager.start(
precacheCommand,
environment: anyNamed('environment'),
workingDirectory: anyNamed('workingDirectory'),
@@ -200,7 +201,7 @@
await realCommandRunner.precacheArtifacts();
- final VerificationResult result = verify(processManager.start(
+ final VerificationResult result = verify(globals.processManager.start(
precacheCommand,
environment: captureAnyNamed('environment'),
workingDirectory: anyNamed('workingDirectory'),
@@ -230,7 +231,7 @@
stdout: 'v1.12.16-19-gb45b676af',
),
]);
- tempDir = fs.systemTempDirectory.createTempSync('flutter_upgrade_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_upgrade_test.');
flutterToolState = tempDir.childFile('.flutter_tool_state');
mockFlutterVersion = MockFlutterVersion(isStable: true);
});
@@ -288,7 +289,7 @@
Directory tempDir;
setUp(() async {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_upgrade_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_upgrade_test.');
});
tearDown(() {
@@ -298,16 +299,16 @@
testUsingContext('in project', () async {
final String projectPath = await createProject(tempDir);
expect(findProjectRoot(projectPath), projectPath);
- expect(findProjectRoot(fs.path.join(projectPath, 'lib')), projectPath);
+ expect(findProjectRoot(globals.fs.path.join(projectPath, 'lib')), projectPath);
- final String hello = fs.path.join(Cache.flutterRoot, 'examples', 'hello_world');
+ final String hello = globals.fs.path.join(Cache.flutterRoot, 'examples', 'hello_world');
expect(findProjectRoot(hello), hello);
- expect(findProjectRoot(fs.path.join(hello, 'lib')), hello);
+ expect(findProjectRoot(globals.fs.path.join(hello, 'lib')), hello);
});
testUsingContext('outside project', () async {
final String projectPath = await createProject(tempDir);
- expect(findProjectRoot(fs.directory(projectPath).parent.path), null);
+ expect(findProjectRoot(globals.fs.directory(projectPath).parent.path), null);
expect(findProjectRoot(Cache.flutterRoot), null);
});
});
diff --git a/packages/flutter_tools/test/general.shard/analytics_test.dart b/packages/flutter_tools/test/general.shard/analytics_test.dart
index a6accb3..1bc5d2e 100644
--- a/packages/flutter_tools/test/general.shard/analytics_test.dart
+++ b/packages/flutter_tools/test/general.shard/analytics_test.dart
@@ -7,7 +7,7 @@
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
@@ -18,6 +18,7 @@
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
@@ -36,7 +37,7 @@
setUp(() {
Cache.flutterRoot = '../..';
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_analytics_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_test.');
mockFlutterConfig = MockFlutterConfig();
});
@@ -100,7 +101,7 @@
usage.sendCommand('test');
final String featuresKey = cdKey(CustomDimensions.enabledFlutterFeatures);
- expect(fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web'));
+ expect(globals.fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web'));
}, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(const SystemClock()),
Config: () => mockFlutterConfig,
@@ -122,7 +123,7 @@
usage.sendCommand('test');
final String featuresKey = cdKey(CustomDimensions.enabledFlutterFeatures);
- expect(fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web,enable-linux-desktop,enable-macos-desktop'));
+ expect(globals.fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web,enable-linux-desktop,enable-macos-desktop'));
}, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(const SystemClock()),
Config: () => mockFlutterConfig,
@@ -218,7 +219,7 @@
usage.sendCommand('test');
- final String log = fs.file('analytics.log').readAsStringSync();
+ final String log = globals.fs.file('analytics.log').readAsStringSync();
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(kMillis);
expect(log.contains(formatDateTime(dateTime)), isTrue);
}, overrides: <Type, Generator>{
@@ -244,7 +245,7 @@
usage.sendEvent('test', 'test');
- final String log = fs.file('analytics.log').readAsStringSync();
+ final String log = globals.fs.file('analytics.log').readAsStringSync();
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(kMillis);
expect(log.contains(formatDateTime(dateTime)), isTrue);
}, overrides: <Type, Generator>{
@@ -264,7 +265,7 @@
Directory tempDir;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.');
});
tearDown(() {
diff --git a/packages/flutter_tools/test/general.shard/android/android_device_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_test.dart
index 110f902..d2d82a7 100644
--- a/packages/flutter_tools/test/general.shard/android/android_device_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_device_test.dart
@@ -11,16 +11,16 @@
import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/application_package.dart';
-import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -111,8 +111,8 @@
final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel');
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
- final File adbExe = fs.file(getAdbPath(androidSdk));
+ globals.config.setValue('android-sdk', sdkDir.path);
+ final File adbExe = globals.fs.file(getAdbPath(androidSdk));
when(mockAndroidSdk.licensesAvailable).thenReturn(true);
when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion());
@@ -153,8 +153,8 @@
final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel');
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
- final File adbExe = fs.file(getAdbPath(androidSdk));
+ globals.config.setValue('android-sdk', sdkDir.path);
+ final File adbExe = globals.fs.file(getAdbPath(androidSdk));
when(mockAndroidSdk.licensesAvailable).thenReturn(true);
when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion());
@@ -194,9 +194,9 @@
testUsingContext('throws on missing adb path', () {
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
- final File adbExe = fs.file(getAdbPath(androidSdk));
+ final File adbExe = globals.fs.file(getAdbPath(androidSdk));
when(mockProcessManager.runSync(
<String>[adbExe.path, 'devices', '-l'],
)).thenThrow(ArgumentError(adbExe.path));
@@ -209,9 +209,9 @@
testUsingContext('throws on failing adb', () {
final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
- final File adbExe = fs.file(getAdbPath(androidSdk));
+ final File adbExe = globals.fs.file(getAdbPath(androidSdk));
when(mockProcessManager.runSync(
<String>[adbExe.path, 'devices', '-l'],
)).thenThrow(ProcessException(adbExe.path, <String>['devices', '-l']));
@@ -497,7 +497,7 @@
});
testUsingContext('isSupportedForProject is true on module project', () async {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
@@ -505,7 +505,7 @@
flutter:
module: {}
''');
- fs.file('.packages').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(AndroidDevice('test').isSupportedForProject(flutterProject), true);
@@ -515,9 +515,9 @@
});
testUsingContext('isSupportedForProject is true with editable host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.directory('android').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.directory('android').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(AndroidDevice('test').isSupportedForProject(flutterProject), true);
@@ -527,8 +527,8 @@
});
testUsingContext('isSupportedForProject is false with no host app and no module', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(AndroidDevice('test').isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart b/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart
index 56baf77..736531b 100644
--- a/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart
@@ -6,10 +6,10 @@
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart' show ProcessResult;
-import 'package:flutter_tools/src/base/platform.dart';
-import 'package:flutter_tools/src/base/config.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -38,7 +38,7 @@
testUsingContext('parse sdk', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
expect(sdk.latestVersion, isNotNull);
@@ -50,7 +50,7 @@
testUsingContext('parse sdk N', () {
sdkDir = MockAndroidSdk.createSdkDirectory(withAndroidN: true);
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
expect(sdk.latestVersion, isNotNull);
@@ -62,10 +62,10 @@
testUsingContext('returns sdkmanager path', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
- expect(sdk.sdkManagerPath, fs.path.join(sdk.directory, 'tools', 'bin', 'sdkmanager'));
+ expect(sdk.sdkManagerPath, globals.fs.path.join(sdk.directory, 'tools', 'bin', 'sdkmanager'));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
@@ -73,11 +73,11 @@
testUsingContext('returns sdkmanager version', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
- when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(true);
- when(processManager.runSync(<String>[sdk.sdkManagerPath, '--version'],
+ when(globals.processManager.canRun(sdk.sdkManagerPath)).thenReturn(true);
+ when(globals.processManager.runSync(<String>[sdk.sdkManagerPath, '--version'],
environment: argThat(isNotNull, named: 'environment')))
.thenReturn(ProcessResult(1, 0, '26.1.1\n', ''));
expect(sdk.sdkManagerVersion, '26.1.1');
@@ -88,10 +88,10 @@
testUsingContext('returns validate sdk is well formed', () {
sdkDir = MockBrokenAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
- when(processManager.canRun(sdk.adbPath)).thenReturn(true);
+ when(globals.processManager.canRun(sdk.adbPath)).thenReturn(true);
final List<String> validationIssues = sdk.validateSdkWellFormed();
expect(validationIssues.first, 'No valid Android SDK platforms found in'
@@ -105,11 +105,11 @@
testUsingContext('does not throw on sdkmanager version check failure', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
- when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(true);
- when(processManager.runSync(<String>[sdk.sdkManagerPath, '--version'],
+ when(globals.processManager.canRun(sdk.sdkManagerPath)).thenReturn(true);
+ when(globals.processManager.runSync(<String>[sdk.sdkManagerPath, '--version'],
environment: argThat(isNotNull, named: 'environment')))
.thenReturn(ProcessResult(1, 1, '26.1.1\n', 'Mystery error'));
expect(sdk.sdkManagerVersion, isNull);
@@ -120,10 +120,10 @@
testUsingContext('throws on sdkmanager version check if sdkmanager not found', () {
sdkDir = MockAndroidSdk.createSdkDirectory(withSdkManager: false);
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
- when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(false);
+ when(globals.processManager.canRun(sdk.sdkManagerPath)).thenReturn(false);
expect(() => sdk.sdkManagerVersion, throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => fs,
@@ -138,11 +138,11 @@
testUsingContext('detection on $os', () {
sdkDir = MockAndroidSdk.createSdkDirectory(
withAndroidN: true, withNdkDir: osDir, withNdkSysroot: true);
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final String realSdkDir = sdkDir.path;
- final String realNdkDir = fs.path.join(realSdkDir, 'ndk-bundle');
- final String realNdkCompiler = fs.path.join(
+ final String realNdkDir = globals.fs.path.join(realSdkDir, 'ndk-bundle');
+ final String realNdkCompiler = globals.fs.path.join(
realNdkDir,
'toolchains',
'arm-linux-androideabi-4.9',
@@ -151,7 +151,7 @@
'bin',
'arm-linux-androideabi-gcc');
final String realNdkSysroot =
- fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm');
+ globals.fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm');
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
expect(sdk.directory, realSdkDir);
@@ -168,25 +168,25 @@
testUsingContext('newer NDK require explicit -fuse-ld on $os', () {
sdkDir = MockAndroidSdk.createSdkDirectory(
withAndroidN: true, withNdkDir: osDir, withNdkSysroot: true, ndkVersion: 18);
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final String realSdkDir = sdkDir.path;
- final String realNdkDir = fs.path.join(realSdkDir, 'ndk-bundle');
- final String realNdkToolchainBin = fs.path.join(
+ final String realNdkDir = globals.fs.path.join(realSdkDir, 'ndk-bundle');
+ final String realNdkToolchainBin = globals.fs.path.join(
realNdkDir,
'toolchains',
'arm-linux-androideabi-4.9',
'prebuilt',
osDir,
'bin');
- final String realNdkCompiler = fs.path.join(
+ final String realNdkCompiler = globals.fs.path.join(
realNdkToolchainBin,
'arm-linux-androideabi-gcc');
- final String realNdkLinker = fs.path.join(
+ final String realNdkLinker = globals.fs.path.join(
realNdkToolchainBin,
'arm-linux-androideabi-ld');
final String realNdkSysroot =
- fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm');
+ globals.fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm');
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
expect(sdk.directory, realSdkDir);
@@ -204,7 +204,7 @@
for (String os in <String>['linux', 'macos']) {
testUsingContext('detection on $os (no ndk available)', () {
sdkDir = MockAndroidSdk.createSdkDirectory(withAndroidN: true);
- Config.instance.setValue('android-sdk', sdkDir.path);
+ globals.config.setValue('android-sdk', sdkDir.path);
final String realSdkDir = sdkDir.path;
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
@@ -230,8 +230,8 @@
bool withNdkSysroot = false,
bool withSdkManager = true,
}) {
- final Directory dir = fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
- final String exe = platform.isWindows ? '.exe' : '';
+ final Directory dir = globals.fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
+ final String exe = globals.platform.isWindows ? '.exe' : '';
_createSdkFile(dir, 'licenses/dummy');
_createSdkFile(dir, 'platform-tools/adb$exe');
diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart
index e36dbce..7f39b2e 100644
--- a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart
@@ -5,9 +5,11 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -55,12 +57,12 @@
const String installPath = '/opt/android-studio-with-cheese-5.0';
const String studioHome = '$homeLinux/.AndroidStudioWithCheese5.0';
const String homeFile = '$studioHome/system/.home';
- fs.directory(installPath).createSync(recursive: true);
- fs.file(homeFile).createSync(recursive: true);
- fs.file(homeFile).writeAsStringSync(installPath);
+ globals.fs.directory(installPath).createSync(recursive: true);
+ globals.fs.file(homeFile).createSync(recursive: true);
+ globals.fs.file(homeFile).writeAsStringSync(installPath);
final AndroidStudio studio =
- AndroidStudio.fromHomeDot(fs.directory(studioHome));
+ AndroidStudio.fromHomeDot(globals.fs.directory(studioHome));
expect(studio, isNotNull);
expect(studio.pluginsPath,
equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins'));
@@ -75,15 +77,15 @@
group('pluginsPath on Mac', () {
testUsingContext('extracts custom paths for directly downloaded Android Studio on Mac', () {
- final String studioInApplicationPlistFolder = fs.path.join('/', 'Application', 'Android Studio.app', 'Contents');
- fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
+ final String studioInApplicationPlistFolder = globals.fs.path.join('/', 'Application', 'Android Studio.app', 'Contents');
+ globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
- final String plistFilePath = fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
+ final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
when(plistUtils.parseFile(plistFilePath)).thenReturn(macStudioInfoPlist);
- final AndroidStudio studio = AndroidStudio.fromMacOSBundle(fs.directory(studioInApplicationPlistFolder)?.parent?.path);
+ final AndroidStudio studio = AndroidStudio.fromMacOSBundle(globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path);
expect(studio, isNotNull);
expect(studio.pluginsPath,
- equals(fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3')));
+ equals(globals.fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3')));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
@@ -94,26 +96,26 @@
});
testUsingContext('extracts custom paths for Android Studio downloaded by JetBrainsToolbox on Mac', () {
- final String jetbrainsStudioInApplicationPlistFolder = fs.path.join(homeMac, 'Application', 'JetBrains Toolbox', 'Android Studio.app', 'Contents');
- fs.directory(jetbrainsStudioInApplicationPlistFolder).createSync(recursive: true);
+ final String jetbrainsStudioInApplicationPlistFolder = globals.fs.path.join(homeMac, 'Application', 'JetBrains Toolbox', 'Android Studio.app', 'Contents');
+ globals.fs.directory(jetbrainsStudioInApplicationPlistFolder).createSync(recursive: true);
const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{
'CFBundleLongVersionString': '3.3',
'CFBundleShortVersionString': '3.3',
'CFBundleVersion': '3.3',
'JetBrainsToolboxApp': '$homeMac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5256920/Android Studio 3.3.app',
};
- final String jetbrainsPlistFilePath = fs.path.join(jetbrainsStudioInApplicationPlistFolder, 'Info.plist');
+ final String jetbrainsPlistFilePath = globals.fs.path.join(jetbrainsStudioInApplicationPlistFolder, 'Info.plist');
when(plistUtils.parseFile(jetbrainsPlistFilePath)).thenReturn(jetbrainsInfoPlist);
- final String studioInApplicationPlistFolder = fs.path.join(fs.path.join(homeMac, 'Library', 'Application Support'), 'JetBrains', 'Toolbox', 'apps', 'AndroidStudio', 'ch-0', '183.5256920', fs.path.join('Android Studio 3.3.app', 'Contents'));
- fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
- final String studioPlistFilePath = fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
+ final String studioInApplicationPlistFolder = globals.fs.path.join(globals.fs.path.join(homeMac, 'Library', 'Application Support'), 'JetBrains', 'Toolbox', 'apps', 'AndroidStudio', 'ch-0', '183.5256920', globals.fs.path.join('Android Studio 3.3.app', 'Contents'));
+ globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true);
+ final String studioPlistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist');
when(plistUtils.parseFile(studioPlistFilePath)).thenReturn(macStudioInfoPlist);
- final AndroidStudio studio = AndroidStudio.fromMacOSBundle(fs.directory(jetbrainsStudioInApplicationPlistFolder)?.parent?.path);
+ final AndroidStudio studio = AndroidStudio.fromMacOSBundle(globals.fs.directory(jetbrainsStudioInApplicationPlistFolder)?.parent?.path);
expect(studio, isNotNull);
expect(studio.pluginsPath,
- equals(fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3')));
+ equals(globals.fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3')));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart
index 89e4ecb..b56103a 100644
--- a/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart
@@ -4,7 +4,7 @@
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/android/android_studio_validator.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart b/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart
index 8945c1b..67db28c 100644
--- a/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart
@@ -12,6 +12,8 @@
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/base/version.dart';
import 'package:flutter_tools/src/doctor.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
@@ -291,7 +293,7 @@
//Test with older version of JDK
const String javaVersionText = 'openjdk version "1.7.0_212"';
- when(processManager.run(argThat(contains('-version')))).thenAnswer((_) =>
+ when(globals.processManager.run(argThat(contains('-version')))).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(0, 0, null, javaVersionText)));
final String errorMessage = userMessages.androidJavaMinimumVersion(javaVersionText);
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
index 6735fea..0c7a01c 100644
--- a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
@@ -8,9 +8,11 @@
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
@@ -284,7 +286,7 @@
});
testUsingContext('handler - plugins and no AndroidX', () async {
- fs.file('.flutter-plugins').createSync(recursive: true);
+ globals.fs.file('.flutter-plugins').createSync(recursive: true);
final GradleBuildStatus status = await androidXFailureHandler
.handler(
@@ -316,7 +318,7 @@
});
testUsingContext('handler - plugins, AndroidX, and AAR', () async {
- fs.file('.flutter-plugins').createSync(recursive: true);
+ globals.fs.file('.flutter-plugins').createSync(recursive: true);
final GradleBuildStatus status = await androidXFailureHandler.handler(
line: '',
@@ -342,7 +344,7 @@
});
testUsingContext('handler - plugins, AndroidX, and no AAR', () async {
- fs.file('.flutter-plugins').createSync(recursive: true);
+ globals.fs.file('.flutter-plugins').createSync(recursive: true);
final GradleBuildStatus status = await androidXFailureHandler.handler(
line: '',
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_test.dart
index 1c026bf..17cb651 100644
--- a/packages/flutter_tools/test/general.shard/android/gradle_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/gradle_test.dart
@@ -16,13 +16,13 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
@@ -41,11 +41,11 @@
final AndroidProject androidProject = MockAndroidProject();
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(false);
- when(androidProject.buildDirectory).thenReturn(fs.directory('foo'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo'));
expect(
getApkDirectory(project).path,
- equals(fs.path.join('foo', 'app', 'outputs', 'apk')),
+ equals(globals.fs.path.join('foo', 'app', 'outputs', 'apk')),
);
});
@@ -54,11 +54,11 @@
final AndroidProject androidProject = MockAndroidProject();
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(true);
- when(androidProject.buildDirectory).thenReturn(fs.directory('foo'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo'));
expect(
getApkDirectory(project).path,
- equals(fs.path.join('foo', 'host', 'outputs', 'apk')),
+ equals(globals.fs.path.join('foo', 'host', 'outputs', 'apk')),
);
});
@@ -67,11 +67,11 @@
final AndroidProject androidProject = MockAndroidProject();
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(false);
- when(androidProject.buildDirectory).thenReturn(fs.directory('foo'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo'));
expect(
getBundleDirectory(project).path,
- equals(fs.path.join('foo', 'app', 'outputs', 'bundle')),
+ equals(globals.fs.path.join('foo', 'app', 'outputs', 'bundle')),
);
});
@@ -80,18 +80,18 @@
final AndroidProject androidProject = MockAndroidProject();
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(true);
- when(androidProject.buildDirectory).thenReturn(fs.directory('foo'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo'));
expect(
getBundleDirectory(project).path,
- equals(fs.path.join('foo', 'host', 'outputs', 'bundle')),
+ equals(globals.fs.path.join('foo', 'host', 'outputs', 'bundle')),
);
});
test('getRepoDirectory', () {
expect(
- getRepoDirectory(fs.directory('foo')).path,
- equals(fs.path.join('foo','outputs', 'repo')),
+ getRepoDirectory(globals.fs.directory('foo')).path,
+ equals(globals.fs.path.join('foo','outputs', 'repo')),
);
});
});
@@ -138,7 +138,7 @@
final FlutterProject project = generateFakeAppBundle('foo_barRelease', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, 'foo_bar'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -148,7 +148,7 @@
final FlutterProject project = generateFakeAppBundle('fooRelease', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, 'foo'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooRelease', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooRelease', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -158,7 +158,7 @@
final FlutterProject project = generateFakeAppBundle('release', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, null));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -168,7 +168,7 @@
final FlutterProject project = generateFakeAppBundle('foo_barDebug', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, 'foo_bar'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barDebug', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barDebug', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -178,7 +178,7 @@
final FlutterProject project = generateFakeAppBundle('fooDebug', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, 'foo'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooDebug', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooDebug', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -188,7 +188,7 @@
final FlutterProject project = generateFakeAppBundle('debug', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, null));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -198,7 +198,7 @@
final FlutterProject project = generateFakeAppBundle('foo_barProfile', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, 'foo_bar'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -208,7 +208,7 @@
final FlutterProject project = generateFakeAppBundle('fooProfile', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, 'foo'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooProfile', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooProfile', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -218,7 +218,7 @@
final FlutterProject project = generateFakeAppBundle('profile', 'app.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, null));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -228,7 +228,7 @@
final FlutterProject project = generateFakeAppBundle('release', 'app-release.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, null));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app-release.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app-release.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -238,7 +238,7 @@
final FlutterProject project = generateFakeAppBundle('profile', 'app-profile.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, null));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app-profile.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app-profile.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -248,7 +248,7 @@
final FlutterProject project = generateFakeAppBundle('debug', 'app-debug.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, null));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app-debug.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app-debug.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -258,7 +258,7 @@
final FlutterProject project = generateFakeAppBundle('foo_barRelease', 'app-foo_bar-release.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, 'foo_bar'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app-foo_bar-release.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app-foo_bar-release.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -268,7 +268,7 @@
final FlutterProject project = generateFakeAppBundle('foo_barProfile', 'app-foo_bar-profile.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, 'foo_bar'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app-foo_bar-profile.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app-foo_bar-profile.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -278,7 +278,7 @@
final FlutterProject project = generateFakeAppBundle('foo_barDebug', 'app-foo_bar-debug.aab');
final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, 'foo_bar'));
expect(bundle, isNotNull);
- expect(bundle.path, fs.path.join('irrelevant','app', 'outputs', 'bundle', 'foo_barDebug', 'app-foo_bar-debug.aab'));
+ expect(bundle.path, globals.fs.path.join('irrelevant','app', 'outputs', 'bundle', 'foo_barDebug', 'app-foo_bar-debug.aab'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -322,9 +322,9 @@
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(false);
- when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant'));
- final Directory apkDirectory = fs.directory(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release'));
+ final Directory apkDirectory = globals.fs.directory(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release'));
apkDirectory.createSync(recursive: true);
apkDirectory.childFile('app-release.apk').createSync();
@@ -333,7 +333,7 @@
const AndroidBuildInfo(BuildInfo(BuildMode.release, '')),
);
expect(apks.isNotEmpty, isTrue);
- expect(apks.first.path, equals(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-release.apk')));
+ expect(apks.first.path, equals(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-release.apk')));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -345,9 +345,9 @@
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(false);
- when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant'));
- final Directory apkDirectory = fs.directory(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release'));
+ final Directory apkDirectory = globals.fs.directory(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release'));
apkDirectory.createSync(recursive: true);
apkDirectory.childFile('app-flavor1-release.apk').createSync();
@@ -356,7 +356,7 @@
const AndroidBuildInfo(BuildInfo(BuildMode.release, 'flavor1')),
);
expect(apks.isNotEmpty, isTrue);
- expect(apks.first.path, equals(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-flavor1-release.apk')));
+ expect(apks.first.path, equals(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-flavor1-release.apk')));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -368,9 +368,9 @@
when(project.android).thenReturn(androidProject);
when(project.isModule).thenReturn(false);
- when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant'));
- final Directory apkDirectory = fs.directory(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release'));
+ final Directory apkDirectory = globals.fs.directory(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release'));
apkDirectory.createSync(recursive: true);
apkDirectory.childFile('app-flavor1-release.apk').createSync();
@@ -379,7 +379,7 @@
const AndroidBuildInfo(BuildInfo(BuildMode.release, 'flavor1')),
);
expect(apks.isNotEmpty, isTrue);
- expect(apks.first.path, equals(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release', 'app-flavor1-release.apk')));
+ expect(apks.first.path, equals(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release', 'app-flavor1-release.apk')));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -456,7 +456,7 @@
setUp(() {
mockLogger = BufferLogger();
- tempDir = fs.systemTempDirectory.createTempSync('flutter_settings_aar_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_settings_aar_test.');
});
testUsingContext('create settings_aar.gradle when current settings.gradle loads plugins', () {
@@ -484,16 +484,16 @@
tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle);
- final String toolGradlePath = fs.path.join(
- fs.path.absolute(Cache.flutterRoot),
+ final String toolGradlePath = globals.fs.path.join(
+ globals.fs.path.absolute(Cache.flutterRoot),
'packages',
'flutter_tools',
'gradle');
- fs.directory(toolGradlePath).createSync(recursive: true);
- fs.file(fs.path.join(toolGradlePath, 'deprecated_settings.gradle'))
+ globals.fs.directory(toolGradlePath).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(toolGradlePath, 'deprecated_settings.gradle'))
.writeAsStringSync(currentSettingsGradle);
- fs.file(fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
+ globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
.writeAsStringSync(settingsAarFile);
createSettingsAarGradle(tempDir);
@@ -518,16 +518,16 @@
tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle);
- final String toolGradlePath = fs.path.join(
- fs.path.absolute(Cache.flutterRoot),
+ final String toolGradlePath = globals.fs.path.join(
+ globals.fs.path.absolute(Cache.flutterRoot),
'packages',
'flutter_tools',
'gradle');
- fs.directory(toolGradlePath).createSync(recursive: true);
- fs.file(fs.path.join(toolGradlePath, 'deprecated_settings.gradle'))
+ globals.fs.directory(toolGradlePath).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(toolGradlePath, 'deprecated_settings.gradle'))
.writeAsStringSync(currentSettingsGradle);
- fs.file(fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
+ globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
.writeAsStringSync(settingsAarFile);
createSettingsAarGradle(tempDir);
@@ -579,9 +579,9 @@
}) async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm'));
- final File manifestFile = fs.file('path/to/project/pubspec.yaml');
+ final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync(manifest);
@@ -594,7 +594,7 @@
requireAndroidSdk: false,
);
- final File localPropertiesFile = fs.file('path/to/project/android/local.properties');
+ final File localPropertiesFile = globals.fs.file('path/to/project/android/local.properties');
expect(propertyFor('flutter.versionName', localPropertiesFile), expectedBuildName);
expect(propertyFor('flutter.versionCode', localPropertiesFile), expectedBuildNumber);
}
@@ -822,7 +822,7 @@
});
testUsingContext('returns true when the project is using AndroidX', () async {
- final Directory androidDirectory = fs.systemTempDirectory.createTempSync('flutter_android.');
+ final Directory androidDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_android.');
androidDirectory
.childFile('gradle.properties')
@@ -836,7 +836,7 @@
});
testUsingContext('returns false when the project is not using AndroidX', () async {
- final Directory androidDirectory = fs.systemTempDirectory.createTempSync('flutter_android.');
+ final Directory androidDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_android.');
androidDirectory
.childFile('gradle.properties')
@@ -850,7 +850,7 @@
});
testUsingContext('returns false when gradle.properties does not exist', () async {
- final Directory androidDirectory = fs.systemTempDirectory.createTempSync('flutter_android.');
+ final Directory androidDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_android.');
expect(isAppUsingAndroidX(androidDirectory), isFalse);
@@ -880,13 +880,13 @@
});
testUsingContext('calls gradle', () async {
- final Directory androidDirectory = fs.directory('android.');
+ final Directory androidDirectory = globals.fs.directory('android.');
androidDirectory.createSync();
androidDirectory
.childFile('pubspec.yaml')
.writeAsStringSync('name: irrelevant');
- final Directory plugin1 = fs.directory('plugin1.');
+ final Directory plugin1 = globals.fs.directory('plugin1.');
plugin1
..createSync()
..childFile('pubspec.yaml')
@@ -902,7 +902,7 @@
.childFile('build.gradle')
.createSync(recursive: true);
- final Directory plugin2 = fs.directory('plugin2.');
+ final Directory plugin2 = globals.fs.directory('plugin2.');
plugin2
..createSync()
..childFile('pubspec.yaml')
@@ -937,8 +937,8 @@
buildDirectory: buildDirectory,
);
- final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
- final String initScript = fs.path.join(
+ final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
+ final String initScript = globals.fs.path.join(
flutterRoot,
'packages',
'flutter_tools',
@@ -983,13 +983,13 @@
});
testUsingContext('skips plugin without a android/build.gradle file', () async {
- final Directory androidDirectory = fs.directory('android.');
+ final Directory androidDirectory = globals.fs.directory('android.');
androidDirectory.createSync();
androidDirectory
.childFile('pubspec.yaml')
.writeAsStringSync('name: irrelevant');
- final Directory plugin1 = fs.directory('plugin1.');
+ final Directory plugin1 = globals.fs.directory('plugin1.');
plugin1
..createSync()
..childFile('pubspec.yaml')
@@ -1022,8 +1022,8 @@
buildDirectory: buildDirectory,
);
- final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
- final String initScript = fs.path.join(
+ final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
+ final String initScript = globals.fs.path.join(
flutterRoot,
'packages',
'flutter_tools',
@@ -1103,15 +1103,15 @@
environment: anyNamed('environment')))
.thenAnswer((_) => Future<Process>.value(process));
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
@@ -1182,15 +1182,15 @@
return Future<Process>.value(process);
});
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
@@ -1257,15 +1257,15 @@
environment: anyNamed('environment')))
.thenThrow(const ProcessException('', <String>[], 'Some gradle message'));
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
@@ -1330,15 +1330,15 @@
environment: anyNamed('environment')))
.thenThrow(const ProcessException('', <String>[], 'Unrecognized'));
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
@@ -1390,21 +1390,21 @@
return Future<Process>.value(process);
});
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
..writeAsStringSync('apply from: irrelevant/flutter.gradle');
- fs.directory('build')
+ globals.fs.directory('build')
.childDirectory('app')
.childDirectory('outputs')
.childDirectory('apk')
@@ -1468,15 +1468,15 @@
return Future<Process>.value(process);
});
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
@@ -1554,21 +1554,21 @@
));
});
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
..writeAsStringSync('apply from: irrelevant/flutter.gradle');
- fs.directory('build')
+ globals.fs.directory('build')
.childDirectory('app')
.childDirectory('outputs')
.childDirectory('apk')
@@ -1603,7 +1603,7 @@
});
testUsingContext('doesn\'t indicate how to consume an AAR when printHowToConsumeAaar is false', () async {
- final File manifestFile = fs.file('pubspec.yaml');
+ final File manifestFile = globals.fs.file('pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync('''
flutter:
@@ -1612,12 +1612,12 @@
'''
);
- fs.file('.android/gradlew').createSync(recursive: true);
+ globals.fs.file('.android/gradlew').createSync(recursive: true);
- fs.file('.android/gradle.properties')
+ globals.fs.file('.android/gradle.properties')
.writeAsStringSync('irrelevant');
- fs.file('.android/build.gradle')
+ globals.fs.file('.android/build.gradle')
.createSync(recursive: true);
// Let any process start. Assert after.
@@ -1627,12 +1627,12 @@
workingDirectory: anyNamed('workingDirectory'),
)).thenAnswer((_) async => ProcessResult(1, 0, '', ''));
- fs.directory('build/outputs/repo').createSync(recursive: true);
+ globals.fs.directory('build/outputs/repo').createSync(recursive: true);
await buildGradleAar(
androidBuildInfo: const AndroidBuildInfo(BuildInfo(BuildMode.release, null)),
project: FlutterProject.current(),
- outputDirectory: fs.directory('build/'),
+ outputDirectory: globals.fs.directory('build/'),
target: '',
buildNumber: '1.0',
);
@@ -1658,9 +1658,9 @@
testUsingContext('build apk uses selected local engine', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm'));
- fs.file('out/android_arm/flutter_embedding_release.pom')
+ globals.fs.file('out/android_arm/flutter_embedding_release.pom')
..createSync(recursive: true)
..writeAsStringSync(
'''<?xml version="1.0" encoding="UTF-8"?>
@@ -1670,21 +1670,21 @@
</dependencies>
</project>
''');
- fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true);
- fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true);
- fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true);
- fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true);
+ globals.fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true);
+ globals.fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true);
+ globals.fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true);
+ globals.fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true);
- fs.file('android/gradlew').createSync(recursive: true);
+ globals.fs.file('android/gradlew').createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childFile('gradle.properties')
.createSync(recursive: true);
- fs.file('android/build.gradle')
+ globals.fs.file('android/build.gradle')
.createSync(recursive: true);
- fs.directory('android')
+ globals.fs.directory('android')
.childDirectory('app')
.childFile('build.gradle')
..createSync(recursive: true)
@@ -1749,9 +1749,9 @@
testUsingContext('build aar uses selected local engine', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm'));
- fs.file('out/android_arm/flutter_embedding_release.pom')
+ globals.fs.file('out/android_arm/flutter_embedding_release.pom')
..createSync(recursive: true)
..writeAsStringSync(
'''<?xml version="1.0" encoding="UTF-8"?>
@@ -1761,12 +1761,12 @@
</dependencies>
</project>
''');
- fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true);
- fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true);
- fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true);
- fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true);
+ globals.fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true);
+ globals.fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true);
+ globals.fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true);
+ globals.fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true);
- final File manifestFile = fs.file('pubspec.yaml');
+ final File manifestFile = globals.fs.file('pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync('''
flutter:
@@ -1775,12 +1775,12 @@
'''
);
- fs.file('.android/gradlew').createSync(recursive: true);
+ globals.fs.file('.android/gradlew').createSync(recursive: true);
- fs.file('.android/gradle.properties')
+ globals.fs.file('.android/gradle.properties')
.writeAsStringSync('irrelevant');
- fs.file('.android/build.gradle')
+ globals.fs.file('.android/build.gradle')
.createSync(recursive: true);
// Let any process start. Assert after.
@@ -1790,12 +1790,12 @@
workingDirectory: anyNamed('workingDirectory'),
)).thenAnswer((_) async => ProcessResult(1, 0, '', ''));
- fs.directory('build/outputs/repo').createSync(recursive: true);
+ globals.fs.directory('build/outputs/repo').createSync(recursive: true);
await buildGradleAar(
androidBuildInfo: const AndroidBuildInfo(BuildInfo(BuildMode.release, null)),
project: FlutterProject.current(),
- outputDirectory: fs.directory('build/'),
+ outputDirectory: globals.fs.directory('build/'),
target: '',
buildNumber: '2.0',
);
@@ -1830,7 +1830,7 @@
printHowToConsumeAar(
buildModes: const <String>{'release', 'debug', 'profile'},
androidPackage: 'com.mycompany',
- repoDirectory: fs.directory('build/'),
+ repoDirectory: globals.fs.directory('build/'),
buildNumber: '2.2',
);
@@ -1883,7 +1883,7 @@
printHowToConsumeAar(
buildModes: const <String>{'release'},
androidPackage: 'com.mycompany',
- repoDirectory: fs.directory('build/'),
+ repoDirectory: globals.fs.directory('build/'),
);
expect(
@@ -1922,7 +1922,7 @@
printHowToConsumeAar(
buildModes: const <String>{'debug'},
androidPackage: 'com.mycompany',
- repoDirectory: fs.directory('build/'),
+ repoDirectory: globals.fs.directory('build/'),
);
expect(
@@ -1961,7 +1961,7 @@
printHowToConsumeAar(
buildModes: const <String>{'profile'},
androidPackage: 'com.mycompany',
- repoDirectory: fs.directory('build/'),
+ repoDirectory: globals.fs.directory('build/'),
buildNumber: '1.0',
);
@@ -2017,7 +2017,7 @@
when(project.isModule).thenReturn(false);
when(project.android).thenReturn(androidProject);
- when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant'));
+ when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant'));
final Directory bundleDirectory = getBundleDirectory(project);
bundleDirectory
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart
index d0cca2a..f405124 100644
--- a/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart
@@ -6,9 +6,9 @@
import 'package:flutter_tools/src/android/gradle_utils.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -42,7 +42,7 @@
});
testUsingContext('injects the wrapper when all files are missing', () {
- final Directory sampleAppAndroid = fs.directory('/sample-app/android');
+ final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
sampleAppAndroid.createSync(recursive: true);
gradleUtils.injectGradleWrapperIfNeeded(sampleAppAndroid);
@@ -78,7 +78,7 @@
});
testUsingContext('injects the wrapper when some files are missing', () {
- final Directory sampleAppAndroid = fs.directory('/sample-app/android');
+ final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
sampleAppAndroid.createSync(recursive: true);
// There's an existing gradlew
@@ -128,7 +128,7 @@
});
testUsingContext('throws ToolExit if gradle.properties doesn\'t exist', () {
- final Directory sampleAppAndroid = fs.directory('/sample-app/android');
+ final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
sampleAppAndroid.createSync(recursive: true);
expect(() {
@@ -162,7 +162,7 @@
});
testUsingContext('does not update gradle.properties if it already uses R8', () {
- final Directory sampleAppAndroid = fs.directory('/sample-app/android');
+ final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
sampleAppAndroid.createSync(recursive: true);
sampleAppAndroid.childFile('gradle.properties')
.writeAsStringSync('android.enableR8=true');
@@ -179,7 +179,7 @@
});
testUsingContext('sets android.enableR8=true', () {
- final Directory sampleAppAndroid = fs.directory('/sample-app/android');
+ final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
sampleAppAndroid.createSync(recursive: true);
sampleAppAndroid.childFile('gradle.properties')
.writeAsStringSync('org.gradle.jvmargs=-Xmx1536M\n');
@@ -200,7 +200,7 @@
});
testUsingContext('appends android.enableR8=true to the new line', () {
- final Directory sampleAppAndroid = fs.directory('/sample-app/android');
+ final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
sampleAppAndroid.createSync(recursive: true);
sampleAppAndroid.childFile('gradle.properties')
.writeAsStringSync('org.gradle.jvmargs=-Xmx1536M');
@@ -222,7 +222,7 @@
});
group('GradleUtils.getExecutable', () {
- final String gradlewFilename = platform.isWindows ? 'gradlew.bat' : 'gradlew';
+ final String gradlewFilename = globals.platform.isWindows ? 'gradlew.bat' : 'gradlew';
MemoryFileSystem memoryFileSystem;
OperatingSystemUtils operatingSystemUtils;
@@ -235,7 +235,7 @@
});
testUsingContext('returns the gradlew path', () {
- final Directory androidDirectory = fs.directory('/android')..createSync();
+ final Directory androidDirectory = globals.fs.directory('/android')..createSync();
androidDirectory.childFile('gradlew')..createSync();
androidDirectory.childFile('gradlew.bat')..createSync();
androidDirectory.childFile('gradle.properties').createSync();
diff --git a/packages/flutter_tools/test/general.shard/application_package_test.dart b/packages/flutter_tools/test/general.shard/application_package_test.dart
index d049188..cfa21ee 100644
--- a/packages/flutter_tools/test/general.shard/application_package_test.dart
+++ b/packages/flutter_tools/test/general.shard/application_package_test.dart
@@ -12,14 +12,15 @@
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/fuchsia/application_package.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../src/common.dart';
import '../src/context.dart';
@@ -62,14 +63,14 @@
)).thenAnswer((_) async => ProcessResult(1, 0, 'stdout', 'stderr'));
when(mockProcessManager.runSync(any)).thenReturn(ProcessResult(1, 0, 'stdout', 'stderr'));
final FlutterProject project = FlutterProject.current();
- gradle = fs.file(project.android.hostAppGradleRoot.childFile(
- platform.isWindows ? 'gradlew.bat' : 'gradlew',
+ gradle = globals.fs.file(project.android.hostAppGradleRoot.childFile(
+ globals.platform.isWindows ? 'gradlew.bat' : 'gradlew',
).path)..createSync(recursive: true);
});
testUsingContext('Licenses not available, platform and buildtools available, apk exists', () async {
const String aaptPath = 'aaptPath';
- final File apkFile = fs.file('app.apk');
+ final File apkFile = globals.fs.file('app.apk');
final AndroidSdkVersion sdkVersion = MockitoAndroidSdkVersion();
when(sdkVersion.aaptPath).thenReturn(aaptPath);
when(sdk.latestVersion).thenReturn(sdkVersion);
@@ -99,24 +100,24 @@
when(sdk.latestVersion).thenReturn(null);
final FlutterProject project = FlutterProject.current();
final File gradle = project.android.hostAppGradleRoot.childFile(
- platform.isWindows ? 'gradlew.bat' : 'gradlew',
+ globals.platform.isWindows ? 'gradlew.bat' : 'gradlew',
)..createSync(recursive: true);
project.android.hostAppGradleRoot
.childFile('gradle.properties')
.writeAsStringSync('irrelevant');
- final Directory gradleWrapperDir = fs.systemTempDirectory.createTempSync('flutter_application_package_test_gradle_wrapper.');
+ final Directory gradleWrapperDir = globals.fs.systemTempDirectory.createTempSync('flutter_application_package_test_gradle_wrapper.');
when(mockCache.getArtifactDirectory('gradle_wrapper')).thenReturn(gradleWrapperDir);
- fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper'))
+ globals.fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper'))
.createSync(recursive: true);
- fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant');
- fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant');
+ globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant');
+ globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant');
await ApplicationPackageFactory.instance.getPackageForPlatform(
TargetPlatform.android_arm,
- applicationBinary: fs.file('app.apk'),
+ applicationBinary: globals.fs.file('app.apk'),
);
verify(
mockProcessManager.run(
@@ -215,7 +216,7 @@
testUsingContext('Error on non-existing file', () {
final PrebuiltIOSApp iosApp =
- IOSApp.fromPrebuiltApp(fs.file('not_existing.ipa')) as PrebuiltIOSApp;
+ IOSApp.fromPrebuiltApp(globals.fs.file('not_existing.ipa')) as PrebuiltIOSApp;
expect(iosApp, isNull);
expect(
testLogger.errorText,
@@ -224,17 +225,17 @@
}, overrides: overrides);
testUsingContext('Error on non-app-bundle folder', () {
- fs.directory('regular_folder').createSync();
+ globals.fs.directory('regular_folder').createSync();
final PrebuiltIOSApp iosApp =
- IOSApp.fromPrebuiltApp(fs.file('regular_folder')) as PrebuiltIOSApp;
+ IOSApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltIOSApp;
expect(iosApp, isNull);
expect(
testLogger.errorText, 'Folder "regular_folder" is not an app bundle.\n');
}, overrides: overrides);
testUsingContext('Error on no info.plist', () {
- fs.directory('bundle.app').createSync();
- final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')) as PrebuiltIOSApp;
+ globals.fs.directory('bundle.app').createSync();
+ final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
expect(iosApp, isNull);
expect(
testLogger.errorText,
@@ -243,9 +244,9 @@
}, overrides: overrides);
testUsingContext('Error on bad info.plist', () {
- fs.directory('bundle.app').createSync();
- fs.file('bundle.app/Info.plist').writeAsStringSync(badPlistData);
- final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')) as PrebuiltIOSApp;
+ globals.fs.directory('bundle.app').createSync();
+ globals.fs.file('bundle.app/Info.plist').writeAsStringSync(badPlistData);
+ final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
expect(iosApp, isNull);
expect(
testLogger.errorText,
@@ -255,9 +256,9 @@
}, overrides: overrides);
testUsingContext('Success with app bundle', () {
- fs.directory('bundle.app').createSync();
- fs.file('bundle.app/Info.plist').writeAsStringSync(plistData);
- final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')) as PrebuiltIOSApp;
+ globals.fs.directory('bundle.app').createSync();
+ globals.fs.file('bundle.app/Info.plist').writeAsStringSync(plistData);
+ final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp;
expect(testLogger.errorText, isEmpty);
expect(iosApp.bundleDir.path, 'bundle.app');
expect(iosApp.id, 'fooBundleId');
@@ -265,9 +266,9 @@
}, overrides: overrides);
testUsingContext('Bad ipa zip-file, no payload dir', () {
- fs.file('app.ipa').createSync();
- when(os.unzip(fs.file('app.ipa'), any)).thenAnswer((Invocation _) { });
- final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')) as PrebuiltIOSApp;
+ globals.fs.file('app.ipa').createSync();
+ when(os.unzip(globals.fs.file('app.ipa'), any)).thenAnswer((Invocation _) { });
+ final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
expect(iosApp, isNull);
expect(
testLogger.errorText,
@@ -276,7 +277,7 @@
}, overrides: overrides);
testUsingContext('Bad ipa zip-file, two app bundles', () {
- fs.file('app.ipa').createSync();
+ globals.fs.file('app.ipa').createSync();
when(os.unzip(any, any)).thenAnswer((Invocation invocation) {
final File zipFile = invocation.positionalArguments[0] as File;
if (zipFile.path != 'app.ipa') {
@@ -284,34 +285,34 @@
}
final Directory targetDirectory = invocation.positionalArguments[1] as Directory;
final String bundlePath1 =
- fs.path.join(targetDirectory.path, 'Payload', 'bundle1.app');
+ globals.fs.path.join(targetDirectory.path, 'Payload', 'bundle1.app');
final String bundlePath2 =
- fs.path.join(targetDirectory.path, 'Payload', 'bundle2.app');
- fs.directory(bundlePath1).createSync(recursive: true);
- fs.directory(bundlePath2).createSync(recursive: true);
+ globals.fs.path.join(targetDirectory.path, 'Payload', 'bundle2.app');
+ globals.fs.directory(bundlePath1).createSync(recursive: true);
+ globals.fs.directory(bundlePath2).createSync(recursive: true);
});
- final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')) as PrebuiltIOSApp;
+ final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
expect(iosApp, isNull);
expect(testLogger.errorText,
'Invalid prebuilt iOS ipa. Does not contain a single app bundle.\n');
}, overrides: overrides);
testUsingContext('Success with ipa', () {
- fs.file('app.ipa').createSync();
+ globals.fs.file('app.ipa').createSync();
when(os.unzip(any, any)).thenAnswer((Invocation invocation) {
final File zipFile = invocation.positionalArguments[0] as File;
if (zipFile.path != 'app.ipa') {
return null;
}
final Directory targetDirectory = invocation.positionalArguments[1] as Directory;
- final Directory bundleAppDir = fs.directory(
- fs.path.join(targetDirectory.path, 'Payload', 'bundle.app'));
+ final Directory bundleAppDir = globals.fs.directory(
+ globals.fs.path.join(targetDirectory.path, 'Payload', 'bundle.app'));
bundleAppDir.createSync(recursive: true);
- fs
- .file(fs.path.join(bundleAppDir.path, 'Info.plist'))
+ globals.fs
+ .file(globals.fs.path.join(bundleAppDir.path, 'Info.plist'))
.writeAsStringSync(plistData);
});
- final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')) as PrebuiltIOSApp;
+ final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp;
expect(testLogger.errorText, isEmpty);
expect(iosApp.bundleDir.path, endsWith('bundle.app'));
expect(iosApp.id, 'fooBundleId');
@@ -319,30 +320,30 @@
}, overrides: overrides);
testUsingContext('returns null when there is no ios or .ios directory', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
- FlutterProject.fromDirectory(fs.currentDirectory).ios) as BuildableIOSApp;
+ FlutterProject.fromDirectory(globals.fs.currentDirectory).ios) as BuildableIOSApp;
expect(iosApp, null);
}, overrides: overrides);
testUsingContext('returns null when there is no Runner.xcodeproj', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file('ios/FooBar.xcodeproj').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file('ios/FooBar.xcodeproj').createSync(recursive: true);
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
- FlutterProject.fromDirectory(fs.currentDirectory).ios) as BuildableIOSApp;
+ FlutterProject.fromDirectory(globals.fs.currentDirectory).ios) as BuildableIOSApp;
expect(iosApp, null);
}, overrides: overrides);
testUsingContext('returns null when there is no Runner.xcodeproj/project.pbxproj', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file('ios/Runner.xcodeproj').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file('ios/Runner.xcodeproj').createSync(recursive: true);
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
- FlutterProject.fromDirectory(fs.currentDirectory).ios) as BuildableIOSApp;
+ FlutterProject.fromDirectory(globals.fs.currentDirectory).ios) as BuildableIOSApp;
expect(iosApp, null);
}, overrides: overrides);
@@ -358,7 +359,7 @@
testUsingContext('Error on non-existing file', () {
final PrebuiltFuchsiaApp fuchsiaApp =
- FuchsiaApp.fromPrebuiltApp(fs.file('not_existing.far')) as PrebuiltFuchsiaApp;
+ FuchsiaApp.fromPrebuiltApp(globals.fs.file('not_existing.far')) as PrebuiltFuchsiaApp;
expect(fuchsiaApp, isNull);
expect(
testLogger.errorText,
@@ -367,9 +368,9 @@
}, overrides: overrides);
testUsingContext('Error on non-far file', () {
- fs.directory('regular_folder').createSync();
+ globals.fs.directory('regular_folder').createSync();
final PrebuiltFuchsiaApp fuchsiaApp =
- FuchsiaApp.fromPrebuiltApp(fs.file('regular_folder')) as PrebuiltFuchsiaApp;
+ FuchsiaApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltFuchsiaApp;
expect(fuchsiaApp, isNull);
expect(
testLogger.errorText,
@@ -378,16 +379,16 @@
}, overrides: overrides);
testUsingContext('Success with far file', () {
- fs.file('bundle.far').createSync();
- final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(fs.file('bundle.far')) as PrebuiltFuchsiaApp;
+ globals.fs.file('bundle.far').createSync();
+ final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp;
expect(testLogger.errorText, isEmpty);
expect(fuchsiaApp.id, 'bundle.far');
}, overrides: overrides);
testUsingContext('returns null when there is no fuchsia', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- final BuildableFuchsiaApp fuchsiaApp = FuchsiaApp.fromFuchsiaProject(FlutterProject.fromDirectory(fs.currentDirectory).fuchsia) as BuildableFuchsiaApp;
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ final BuildableFuchsiaApp fuchsiaApp = FuchsiaApp.fromFuchsiaProject(FlutterProject.fromDirectory(globals.fs.currentDirectory).fuchsia) as BuildableFuchsiaApp;
expect(fuchsiaApp, null);
}, overrides: overrides);
@@ -639,7 +640,7 @@
class MockPlistUtils extends Mock implements PlistParser {
@override
String getValueFromFile(String path, String key) {
- final File file = fs.file(path);
+ final File file = globals.fs.file(path);
if (!file.existsSync()) {
return null;
}
diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart
index da35d1c..d902357 100644
--- a/packages/flutter_tools/test/general.shard/artifacts_test.dart
+++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart
@@ -3,11 +3,13 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/context.dart';
@@ -36,11 +38,11 @@
testUsingContext('getArtifactPath', () {
expect(
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
- fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'),
+ globals.fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'),
);
expect(
artifacts.getArtifactPath(Artifact.flutterTester),
- fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
+ globals.fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
);
}, overrides: <Type, Generator>{
Cache: () => Cache(rootOverride: tempDir),
@@ -83,15 +85,15 @@
testUsingContext('getArtifactPath', () {
expect(
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
- fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'),
+ globals.fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'),
);
expect(
artifacts.getArtifactPath(Artifact.flutterTester),
- fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester'),
+ globals.fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester'),
);
expect(
artifacts.getArtifactPath(Artifact.engineDartSdkPath),
- fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk'),
+ globals.fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk'),
);
}, overrides: <Type, Generator>{
FileSystem: () => memoryFileSystem,
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart
index c6e26fd..222c96f 100644
--- a/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart
+++ b/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart
@@ -10,8 +10,9 @@
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/context.dart';
@@ -24,7 +25,7 @@
// fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter.
- return path?.replaceAll('/', fs.path.separator);
+ return path?.replaceAll('/', globals.fs.path.separator);
}
void writePubspecFile(String path, String name, { String fontsSection }) {
if (fontsSection == null) {
@@ -37,7 +38,7 @@
''';
}
- fs.file(fixPath(path))
+ globals.fs.file(fixPath(path))
..createSync(recursive: true)
..writeAsStringSync('''
name: $name
@@ -55,7 +56,7 @@
}
void writePackagesFile(String packages) {
- fs.file('.packages')
+ globals.fs.file('.packages')
..createSync()
..writeAsStringSync(packages);
}
@@ -95,7 +96,7 @@
}
void writeFontAsset(String path, String font) {
- fs.file(fixPath('$path$font'))
+ globals.fs.file(fixPath('$path$font'))
..createSync(recursive: true)
..writeAsStringSync(font);
}
@@ -105,7 +106,7 @@
setUp(() async {
testFileSystem = MemoryFileSystem(
- style: platform.isWindows
+ style: globals.platform.isWindows
? FileSystemStyle.windows
: FileSystemStyle.posix,
);
@@ -114,7 +115,7 @@
testUsingContext('App includes neither font manifest nor fonts when no defines fonts', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -131,7 +132,7 @@
testUsingContext('App font uses font file from package', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
const String fontsSection = '''
- family: foo
@@ -160,7 +161,7 @@
testUsingContext('App font uses local font file and package font file', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
const String fontsSection = '''
- family: foo
@@ -193,7 +194,7 @@
testUsingContext('App uses package font with own font file', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -227,7 +228,7 @@
testUsingContext('App uses package font with font file from another package', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/');
@@ -262,7 +263,7 @@
testUsingContext('App uses package font with properties and own font file', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -298,7 +299,7 @@
testUsingContext('App uses local font and package font with own font file.', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
const String fontsSection = '''
- family: foo
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart
index eb1f72d..25e2089 100644
--- a/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart
+++ b/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart
@@ -10,8 +10,9 @@
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/context.dart';
@@ -24,7 +25,7 @@
// fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter.
- return path?.replaceAll('/', fs.path.separator);
+ return path?.replaceAll('/', globals.fs.path.separator);
}
void writePubspecFile(String path, String name, { List<String> assets }) {
String assetsSection;
@@ -45,7 +46,7 @@
assetsSection = buffer.toString();
}
- fs.file(fixPath(path))
+ globals.fs.file(fixPath(path))
..createSync(recursive: true)
..writeAsStringSync('''
name: $name
@@ -61,7 +62,7 @@
}
void writePackagesFile(String packages) {
- fs.file('.packages')
+ globals.fs.file('.packages')
..createSync()
..writeAsStringSync(packages);
}
@@ -93,9 +94,9 @@
void writeAssets(String path, List<String> assets) {
for (String asset in assets) {
- final String fullPath = fixPath(fs.path.join(path, asset));
+ final String fullPath = fixPath(globals.fs.path.join(path, asset));
- fs.file(fullPath)
+ globals.fs.file(fullPath)
..createSync(recursive: true)
..writeAsStringSync(asset);
}
@@ -105,7 +106,7 @@
setUp(() async {
testFileSystem = MemoryFileSystem(
- style: platform.isWindows
+ style: globals.platform.isWindows
? FileSystemStyle.windows
: FileSystemStyle.posix,
);
@@ -115,7 +116,7 @@
group('AssetBundle assets from packages', () {
testUsingContext('No assets are bundled when the package has no assets', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -140,7 +141,7 @@
testUsingContext('No assets are bundled when the package has an asset that is not listed', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -168,7 +169,7 @@
testUsingContext('One asset is bundled when the package has and lists one asset its pubspec', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -196,7 +197,7 @@
testUsingContext("One asset is bundled when the package has one asset, listed in the app's pubspec", () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
final List<String> assetEntries = <String>['packages/test_package/a/foo'];
writePubspecFile(
@@ -224,7 +225,7 @@
testUsingContext('One asset and its variant are bundled when the package has an asset and a variant, and lists the asset in its pubspec', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -252,7 +253,7 @@
testUsingContext('One asset and its variant are bundled when the package has an asset and a variant, and the app lists the asset in its pubspec', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile(
'pubspec.yaml',
@@ -283,7 +284,7 @@
testUsingContext('Two assets are bundled when the package has and lists two assets in its pubspec', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -312,7 +313,7 @@
testUsingContext("Two assets are bundled when the package has two assets, listed in the app's pubspec", () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
final List<String> assetEntries = <String>[
'packages/test_package/a/foo',
@@ -348,7 +349,7 @@
testUsingContext('Two assets are bundled when two packages each have and list an asset their pubspec', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile(
'pubspec.yaml',
@@ -388,7 +389,7 @@
testUsingContext("Two assets are bundled when two packages each have an asset, listed in the app's pubspec", () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
final List<String> assetEntries = <String>[
'packages/test_package/a/foo',
@@ -431,7 +432,7 @@
testUsingContext('One asset is bundled when the app depends on a package, listing in its pubspec an asset from another package', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile(
'pubspec.yaml',
'test',
@@ -467,7 +468,7 @@
testUsingContext('Asset paths can contain URL reserved characters', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -497,7 +498,7 @@
group('AssetBundle assets from scanned paths', () {
testUsingContext('Two assets are bundled when scanning their directory', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -528,7 +529,7 @@
testUsingContext('Two assets are bundled when listing one and scanning second directory', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -559,7 +560,7 @@
testUsingContext('One asset is bundled with variant, scanning wrong directory', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -587,7 +588,7 @@
group('AssetBundle assets from scanned paths with MemoryFileSystem', () {
testUsingContext('One asset is bundled with variant, scanning directory', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -617,7 +618,7 @@
testUsingContext('No asset is bundled with variant, no assets or directories are listed', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
@@ -646,7 +647,7 @@
testUsingContext('Expect error generating manifest, wrong non-existing directory is listed', () async {
establishFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
writePubspecFile('pubspec.yaml', 'test');
writePackagesFile('test_package:p/p/lib/');
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
index c530ea4..39c8b02 100644
--- a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
+++ b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
@@ -10,10 +10,10 @@
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/bundle.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/devfs.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../src/common.dart';
@@ -29,7 +29,7 @@
setUp(() async {
testFileSystem = MemoryFileSystem(
- style: platform.isWindows
+ style: globals.platform.isWindows
? FileSystemStyle.windows
: FileSystemStyle.posix,
);
@@ -46,7 +46,7 @@
});
testUsingContext('empty pubspec', () async {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync('');
@@ -64,9 +64,9 @@
});
testUsingContext('wildcard directories are updated when filesystem changes', () async {
- final File packageFile = fs.file('.packages')..createSync();
- fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
- fs.file('pubspec.yaml')
+ final File packageFile = globals.fs.file('.packages')..createSync();
+ globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
@@ -85,7 +85,7 @@
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
// Simulate modifying the files by updating the filestat time manually.
- fs.file(fs.path.join('assets', 'foo', 'fizz.txt'))
+ globals.fs.file(globals.fs.path.join('assets', 'foo', 'fizz.txt'))
..createSync(recursive: true)
..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1)));
@@ -104,8 +104,8 @@
});
testUsingContext('handle removal of wildcard directories', () async {
- fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
- final File pubspec = fs.file('pubspec.yaml')
+ globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
+ final File pubspec = globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
@@ -113,7 +113,7 @@
assets:
- assets/foo/
''');
- fs.file('.packages').createSync();
+ globals.fs.file('.packages').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
// Expected assets:
@@ -126,15 +126,15 @@
// Delete the wildcard directory and update pubspec file.
final DateTime modifiedTime = pubspec.lastModifiedSync().add(const Duration(hours: 1));
- fs.directory(fs.path.join('assets', 'foo')).deleteSync(recursive: true);
- fs.file('pubspec.yaml')
+ globals.fs.directory(globals.fs.path.join('assets', 'foo')).deleteSync(recursive: true);
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example''')
..setLastModifiedSync(modifiedTime);
// touch .packages to make sure its change time is after pubspec.yaml's
- fs.file('.packages')
+ globals.fs.file('.packages')
..setLastModifiedSync(modifiedTime);
// Even though the previous file was removed, it is left in the
@@ -155,11 +155,11 @@
// https://github.com/flutter/flutter/issues/42723
testUsingContext('Test regression for mistyped file', () async {
- fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
// Create a directory in the same path to test that we're only looking at File
// objects.
- fs.directory(fs.path.join('assets', 'foo', 'bar')).createSync();
- fs.file('pubspec.yaml')
+ globals.fs.directory(globals.fs.path.join('assets', 'foo', 'bar')).createSync();
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
@@ -167,7 +167,7 @@
assets:
- assets/foo/
''');
- fs.file('.packages').createSync();
+ globals.fs.file('.packages').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
// Expected assets:
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart
index 2dab3d3..dcd7627 100644
--- a/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart
+++ b/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart
@@ -9,8 +9,9 @@
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/context.dart';
@@ -23,14 +24,14 @@
// fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter.
- return path?.replaceAll('/', fs.path.separator);
+ return path?.replaceAll('/', globals.fs.path.separator);
}
group('AssetBundle asset variants', () {
FileSystem testFileSystem;
setUp(() async {
testFileSystem = MemoryFileSystem(
- style: platform.isWindows
+ style: globals.platform.isWindows
? FileSystemStyle.windows
: FileSystemStyle.posix,
);
@@ -41,9 +42,9 @@
// Setting flutterRoot here so that it picks up the MemoryFileSystem's
// path separator.
Cache.flutterRoot = getFlutterRoot();
- writeEmptySchemaFile(fs);
+ writeEmptySchemaFile(globals.fs);
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(
'''
@@ -56,7 +57,7 @@
- a/b/c/foo
'''
);
- fs.file('.packages')..createSync();
+ globals.fs.file('.packages')..createSync();
final List<String> assets = <String>[
'a/b/c/foo',
@@ -65,7 +66,7 @@
'a/b/c/var3/foo',
];
for (String asset in assets) {
- fs.file(fixPath(asset))
+ globals.fs.file(fixPath(asset))
..createSync(recursive: true)
..writeAsStringSync(asset);
}
@@ -79,7 +80,7 @@
expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset);
}
- fs.file(fixPath('a/b/c/foo')).deleteSync();
+ globals.fs.file(fixPath('a/b/c/foo')).deleteSync();
bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml');
diff --git a/packages/flutter_tools/test/general.shard/asset_test.dart b/packages/flutter_tools/test/general.shard/asset_test.dart
index 25cc64e..73e0a46 100644
--- a/packages/flutter_tools/test/general.shard/asset_test.dart
+++ b/packages/flutter_tools/test/general.shard/asset_test.dart
@@ -5,15 +5,15 @@
import 'dart:async';
import 'package:flutter_tools/src/asset.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/context.dart';
void main() {
group('Assets', () {
- final String dataPath = fs.path.join(
+ final String dataPath = globals.fs.path.join(
getFlutterRoot(),
'packages',
'flutter_tools',
@@ -31,8 +31,8 @@
testUsingContext('app font uses local font file', () async {
final AssetBundle asset = AssetBundleFactory.instance.createBundle();
await asset.build(
- manifestPath : fs.path.join(dataPath, 'main', 'pubspec.yaml'),
- packagesPath: fs.path.join(dataPath, 'main', '.packages'),
+ manifestPath : globals.fs.path.join(dataPath, 'main', 'pubspec.yaml'),
+ packagesPath: globals.fs.path.join(dataPath, 'main', '.packages'),
includeDefaultFonts: false,
);
@@ -45,7 +45,7 @@
});
testUsingContext('handles empty pubspec with .packages', () async {
- final String dataPath = fs.path.join(
+ final String dataPath = globals.fs.path.join(
getFlutterRoot(),
'packages',
'flutter_tools',
@@ -55,8 +55,8 @@
);
final AssetBundle asset = AssetBundleFactory.instance.createBundle();
await asset.build(
- manifestPath : fs.path.join(dataPath, 'main', 'pubspec.yaml'), // file doesn't exist
- packagesPath: fs.path.join(dataPath, 'main', '.packages'),
+ manifestPath : globals.fs.path.join(dataPath, 'main', 'pubspec.yaml'), // file doesn't exist
+ packagesPath: globals.fs.path.join(dataPath, 'main', '.packages'),
includeDefaultFonts: false,
);
expect(asset.wasBuiltOnce(), true);
diff --git a/packages/flutter_tools/test/general.shard/base/build_test.dart b/packages/flutter_tools/test/general.shard/base/build_test.dart
index ecea2c3..62c4c18 100644
--- a/packages/flutter_tools/test/general.shard/base/build_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/build_test.dart
@@ -17,6 +17,7 @@
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -66,7 +67,7 @@
return 1;
}
outputs.forEach((String filePath, String fileContent) {
- fs.file(filePath).writeAsString(fileContent);
+ globals.fs.file(filePath).writeAsString(fileContent);
});
return 0;
}
@@ -264,7 +265,7 @@
};
testUsingContext('iOS debug AOT snapshot is invalid', () async {
- final String outputPath = fs.path.join('build', 'foo');
+ final String outputPath = globals.fs.path.join('build', 'foo');
expect(await snapshotter.build(
platform: TargetPlatform.ios,
buildMode: BuildMode.debug,
@@ -276,7 +277,7 @@
}, overrides: contextOverrides);
testUsingContext('Android arm debug AOT snapshot is invalid', () async {
- final String outputPath = fs.path.join('build', 'foo');
+ final String outputPath = globals.fs.path.join('build', 'foo');
expect(await snapshotter.build(
platform: TargetPlatform.android_arm,
buildMode: BuildMode.debug,
@@ -288,7 +289,7 @@
}, overrides: contextOverrides);
testUsingContext('Android arm64 debug AOT snapshot is invalid', () async {
- final String outputPath = fs.path.join('build', 'foo');
+ final String outputPath = globals.fs.path.join('build', 'foo');
expect(await snapshotter.build(
platform: TargetPlatform.android_arm64,
buildMode: BuildMode.debug,
@@ -300,12 +301,12 @@
}, overrides: contextOverrides);
testUsingContext('iOS profile AOT with bitcode uses right flags', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
- final String assembly = fs.path.join(outputPath, 'snapshot_assembly.S');
+ final String assembly = globals.fs.path.join(outputPath, 'snapshot_assembly.S');
genSnapshot.outputs = <String, String>{
assembly: 'blah blah\n.section __DWARF\nblah blah\n',
};
@@ -351,18 +352,18 @@
expect(clangArgs, contains('-isysroot'));
expect(clangArgs, contains(kSDKPath));
- final File assemblyFile = fs.file(assembly);
+ final File assemblyFile = globals.fs.file(assembly);
expect(assemblyFile.existsSync(), true);
expect(assemblyFile.readAsStringSync().contains('.section __DWARF'), true);
}, overrides: contextOverrides);
testUsingContext('iOS release AOT with bitcode uses right flags', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
- final String assembly = fs.path.join(outputPath, 'snapshot_assembly.S');
+ final String assembly = globals.fs.path.join(outputPath, 'snapshot_assembly.S');
genSnapshot.outputs = <String, String>{
assembly: 'blah blah\n.section __DWARF\nblah blah\n',
};
@@ -408,8 +409,8 @@
expect(clangArgs, contains('-isysroot'));
expect(clangArgs, contains(kSDKPath));
- final File assemblyFile = fs.file(assembly);
- final File assemblyBitcodeFile = fs.file('$assembly.stripped.S');
+ final File assemblyFile = globals.fs.file(assembly);
+ final File assemblyBitcodeFile = globals.fs.file('$assembly.stripped.S');
expect(assemblyFile.existsSync(), true);
expect(assemblyBitcodeFile.existsSync(), true);
expect(assemblyFile.readAsStringSync().contains('.section __DWARF'), true);
@@ -417,12 +418,12 @@
}, overrides: contextOverrides);
testUsingContext('builds iOS armv7 profile AOT snapshot', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
- final String assembly = fs.path.join(outputPath, 'snapshot_assembly.S');
+ final String assembly = globals.fs.path.join(outputPath, 'snapshot_assembly.S');
genSnapshot.outputs = <String, String>{
assembly: 'blah blah\n.section __DWARF\nblah blah\n',
};
@@ -459,19 +460,19 @@
verify(xcode.cc(argThat(contains('-isysroot')))).called(1);
verify(xcode.clang(argThat(contains('-isysroot')))).called(1);
- final File assemblyFile = fs.file(assembly);
+ final File assemblyFile = globals.fs.file(assembly);
expect(assemblyFile.existsSync(), true);
expect(assemblyFile.readAsStringSync().contains('.section __DWARF'), true);
}, overrides: contextOverrides);
testUsingContext('builds iOS arm64 profile AOT snapshot', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
genSnapshot.outputs = <String, String>{
- fs.path.join(outputPath, 'snapshot_assembly.S'): '',
+ globals.fs.path.join(outputPath, 'snapshot_assembly.S'): '',
};
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
@@ -495,19 +496,19 @@
expect(genSnapshot.additionalArgs, <String>[
'--deterministic',
'--snapshot_kind=app-aot-assembly',
- '--assembly=${fs.path.join(outputPath, 'snapshot_assembly.S')}',
+ '--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}',
'main.dill',
]);
}, overrides: contextOverrides);
testUsingContext('builds iOS release armv7 AOT snapshot', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
genSnapshot.outputs = <String, String>{
- fs.path.join(outputPath, 'snapshot_assembly.S'): '',
+ globals.fs.path.join(outputPath, 'snapshot_assembly.S'): '',
};
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
@@ -531,7 +532,7 @@
expect(genSnapshot.additionalArgs, <String>[
'--deterministic',
'--snapshot_kind=app-aot-assembly',
- '--assembly=${fs.path.join(outputPath, 'snapshot_assembly.S')}',
+ '--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}',
'--no-sim-use-hardfp',
'--no-use-integer-division',
'main.dill',
@@ -539,13 +540,13 @@
}, overrides: contextOverrides);
testUsingContext('builds iOS release arm64 AOT snapshot', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
genSnapshot.outputs = <String, String>{
- fs.path.join(outputPath, 'snapshot_assembly.S'): '',
+ globals.fs.path.join(outputPath, 'snapshot_assembly.S'): '',
};
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
@@ -569,16 +570,16 @@
expect(genSnapshot.additionalArgs, <String>[
'--deterministic',
'--snapshot_kind=app-aot-assembly',
- '--assembly=${fs.path.join(outputPath, 'snapshot_assembly.S')}',
+ '--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}',
'main.dill',
]);
}, overrides: contextOverrides);
testUsingContext('builds shared library for android-arm', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.android_arm,
@@ -605,10 +606,10 @@
}, overrides: contextOverrides);
testUsingContext('builds shared library for android-arm64', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
final int genSnapshotExitCode = await snapshotter.build(
platform: TargetPlatform.android_arm64,
@@ -633,13 +634,13 @@
}, overrides: contextOverrides);
testUsingContext('reports timing', () async {
- fs.file('main.dill').writeAsStringSync('binary magic');
+ globals.fs.file('main.dill').writeAsStringSync('binary magic');
- final String outputPath = fs.path.join('build', 'foo');
- fs.directory(outputPath).createSync(recursive: true);
+ final String outputPath = globals.fs.path.join('build', 'foo');
+ globals.fs.directory(outputPath).createSync(recursive: true);
genSnapshot.outputs = <String, String>{
- fs.path.join(outputPath, 'app.so'): '',
+ globals.fs.path.join(outputPath, 'app.so'): '',
};
final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
diff --git a/packages/flutter_tools/test/general.shard/base/file_system_test.dart b/packages/flutter_tools/test/general.shard/base/file_system_test.dart
index 96bd310..2cb94fd 100644
--- a/packages/flutter_tools/test/general.shard/base/file_system_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/file_system_test.dart
@@ -4,6 +4,7 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:platform/platform.dart';
import '../../src/common.dart';
@@ -66,14 +67,14 @@
});
testUsingContext('Skip files if shouldCopyFile returns false', () {
- final Directory origin = fs.directory('/origin');
+ final Directory origin = globals.fs.directory('/origin');
origin.createSync();
- fs.file(fs.path.join('origin', 'a.txt')).writeAsStringSync('irrelevant');
- fs.directory('/origin/nested').createSync();
- fs.file(fs.path.join('origin', 'nested', 'a.txt')).writeAsStringSync('irrelevant');
- fs.file(fs.path.join('origin', 'nested', 'b.txt')).writeAsStringSync('irrelevant');
+ globals.fs.file(globals.fs.path.join('origin', 'a.txt')).writeAsStringSync('irrelevant');
+ globals.fs.directory('/origin/nested').createSync();
+ globals.fs.file(globals.fs.path.join('origin', 'nested', 'a.txt')).writeAsStringSync('irrelevant');
+ globals.fs.file(globals.fs.path.join('origin', 'nested', 'b.txt')).writeAsStringSync('irrelevant');
- final Directory destination = fs.directory('/destination');
+ final Directory destination = globals.fs.directory('/destination');
copyDirectorySync(origin, destination, shouldCopyFile: (File origin, File dest) {
return origin.basename == 'b.txt';
});
@@ -94,24 +95,24 @@
test('does not lowercase on Windows', () {
String path = 'C:\\Foo\\bAr\\cOOL.dart';
expect(canonicalizePath(path), path);
- // fs.path.canonicalize does lowercase on Windows
- expect(fs.path.canonicalize(path), isNot(path));
+ // globals.fs.path.canonicalize does lowercase on Windows
+ expect(globals.fs.path.canonicalize(path), isNot(path));
path = '..\\bar\\.\\\\Foo';
- final String expected = fs.path.join(fs.currentDirectory.parent.absolute.path, 'bar', 'Foo');
+ final String expected = globals.fs.path.join(globals.fs.currentDirectory.parent.absolute.path, 'bar', 'Foo');
expect(canonicalizePath(path), expected);
- // fs.path.canonicalize should return the same result (modulo casing)
- expect(fs.path.canonicalize(path), expected.toLowerCase());
+ // globals.fs.path.canonicalize should return the same result (modulo casing)
+ expect(globals.fs.path.canonicalize(path), expected.toLowerCase());
}, testOn: 'windows');
test('does not lowercase on posix', () {
String path = '/Foo/bAr/cOOL.dart';
expect(canonicalizePath(path), path);
- // fs.path.canonicalize and canonicalizePath should be the same on Posix
- expect(fs.path.canonicalize(path), path);
+ // globals.fs.path.canonicalize and canonicalizePath should be the same on Posix
+ expect(globals.fs.path.canonicalize(path), path);
path = '../bar/.//Foo';
- final String expected = fs.path.join(fs.currentDirectory.parent.absolute.path, 'bar', 'Foo');
+ final String expected = globals.fs.path.join(globals.fs.currentDirectory.parent.absolute.path, 'bar', 'Foo');
expect(canonicalizePath(path), expected);
}, testOn: 'posix');
});
diff --git a/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart b/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart
index c83e5ca..f57c970 100644
--- a/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart
@@ -5,12 +5,13 @@
import 'dart:convert' show json;
import 'package:file/memory.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/fingerprint.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
@@ -35,9 +36,9 @@
};
testUsingContext('throws when depfile is malformed', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
- fs.file('depfile').createSync();
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
+ globals.fs.file('depfile').createSync();
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -52,7 +53,7 @@
}, overrides: contextOverrides);
testUsingContext('creates fingerprint with specified properties and files', () {
- fs.file('a.dart').createSync();
+ globals.fs.file('a.dart').createSync();
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -70,9 +71,9 @@
}, overrides: contextOverrides);
testUsingContext('creates fingerprint with file checksums', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
- fs.file('depfile').writeAsStringSync('depfile : b.dart');
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
+ globals.fs.file('depfile').writeAsStringSync('depfile : b.dart');
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -91,8 +92,8 @@
}, overrides: contextOverrides);
testUsingContext('fingerprint does not match if not present', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -106,8 +107,8 @@
}, overrides: contextOverrides);
testUsingContext('fingerprint does match if different', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
final Fingerprinter fingerprinter1 = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -131,9 +132,9 @@
}, overrides: contextOverrides);
testUsingContext('fingerprint does not match if depfile is malformed', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
- fs.file('depfile').writeAsStringSync('depfile : b.dart');
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
+ globals.fs.file('depfile').writeAsStringSync('depfile : b.dart');
// Write a valid fingerprint
final Fingerprinter fingerprinter = Fingerprinter(
@@ -148,7 +149,7 @@
fingerprinter.writeFingerprint();
// Write a corrupt depfile.
- fs.file('depfile').writeAsStringSync('');
+ globals.fs.file('depfile').writeAsStringSync('');
final Fingerprinter badFingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
paths: <String>['a.dart', 'b.dart'],
@@ -163,9 +164,9 @@
}, overrides: contextOverrides);
testUsingContext('fingerprint does not match if previous fingerprint is malformed', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
- fs.file('out.fingerprint').writeAsStringSync('** not JSON **');
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
+ globals.fs.file('out.fingerprint').writeAsStringSync('** not JSON **');
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -180,8 +181,8 @@
}, overrides: contextOverrides);
testUsingContext('fingerprint does match if identical', () {
- fs.file('a.dart').createSync();
- fs.file('b.dart').createSync();
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('b.dart').createSync();
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -205,13 +206,13 @@
},
);
fingerprinter.writeFingerprint();
- expect(fs.file('out.fingerprint').existsSync(), isFalse);
+ expect(globals.fs.file('out.fingerprint').existsSync(), isFalse);
}, overrides: contextOverrides);
testUsingContext('applies path filter to inputs paths', () {
- fs.file('a.dart').createSync();
- fs.file('ab.dart').createSync();
- fs.file('depfile').writeAsStringSync('depfile : ab.dart c.dart');
+ globals.fs.file('a.dart').createSync();
+ globals.fs.file('ab.dart').createSync();
+ globals.fs.file('depfile').writeAsStringSync('depfile : ab.dart c.dart');
final Fingerprinter fingerprinter = Fingerprinter(
fingerprintPath: 'out.fingerprint',
@@ -224,7 +225,7 @@
pathFilter: (String path) => path.startsWith('a'),
);
fingerprinter.writeFingerprint();
- expect(fs.file('out.fingerprint').existsSync(), isTrue);
+ expect(globals.fs.file('out.fingerprint').existsSync(), isTrue);
}, overrides: contextOverrides);
});
@@ -245,7 +246,7 @@
});
testUsingContext('throws if any input file does not exist', () {
- fs.file('a.dart').createSync();
+ globals.fs.file('a.dart').createSync();
expect(
() => Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']),
throwsArgumentError,
@@ -256,8 +257,8 @@
});
testUsingContext('populates checksums for valid files', () {
- fs.file('a.dart').writeAsStringSync('This is a');
- fs.file('b.dart').writeAsStringSync('This is b');
+ globals.fs.file('a.dart').writeAsStringSync('This is a');
+ globals.fs.file('b.dart').writeAsStringSync('This is b');
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']);
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
@@ -452,12 +453,12 @@
};
testUsingContext('returns one file if only one is listed', () {
- fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart');
+ globals.fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart');
expect(readDepfile('a.d'), unorderedEquals(<String>['/foo/a.dart']));
}, overrides: contextOverrides);
testUsingContext('returns multiple files', () {
- fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart');
+ globals.fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart');
expect(readDepfile('a.d'), unorderedEquals(<String>[
'/foo/a.dart',
'/foo/b.dart',
@@ -465,7 +466,7 @@
}, overrides: contextOverrides);
testUsingContext('trims extra spaces between files', () {
- fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart /foo/c.dart');
+ globals.fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart /foo/c.dart');
expect(readDepfile('a.d'), unorderedEquals(<String>[
'/foo/a.dart',
'/foo/b.dart',
@@ -474,7 +475,7 @@
}, overrides: contextOverrides);
testUsingContext('returns files with spaces and backslashes', () {
- fs.file('a.d').writeAsStringSync(r'snapshot.d: /foo/a\ a.dart /foo/b\\b.dart /foo/c\\ c.dart');
+ globals.fs.file('a.d').writeAsStringSync(r'snapshot.d: /foo/a\ a.dart /foo/b\\b.dart /foo/c\\ c.dart');
expect(readDepfile('a.d'), unorderedEquals(<String>[
r'/foo/a a.dart',
r'/foo/b\b.dart',
diff --git a/packages/flutter_tools/test/general.shard/base/logger_test.dart b/packages/flutter_tools/test/general.shard/base/logger_test.dart
index e9caf38..b30772b 100644
--- a/packages/flutter_tools/test/general.shard/base/logger_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/logger_test.dart
@@ -4,11 +4,12 @@
import 'dart:convert' show jsonEncode;
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:quiver/testing/async.dart';
import '../../src/common.dart';
@@ -113,7 +114,7 @@
doWhileAsync(time, () => ansiSpinner.ticks < 10);
List<String> lines = outputStdout();
expect(lines[0], startsWith(
- platform.isWindows
+ globals.platform.isWindows
? ' \b\\\b|\b/\b-\b\\\b|\b/\b-'
: ' \b⣽\b⣻\b⢿\b⡿\b⣟\b⣯\b⣷\b⣾\b⣽\b⣻'
),
@@ -181,10 +182,10 @@
expect(outputStderr().length, equals(1));
expect(outputStderr().first, isEmpty);
// the 5 below is the margin that is always included between the message and the time.
- expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\$' :
+ expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\$' :
r'^Hello {15} {5} {8}[\b]{8} {7}⣽$'));
status.stop();
- expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\[\b]{8} {8}[\b]{8}[\d, ]{4}[\d]\.[\d]s[\n]$' :
+ expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\[\b]{8} {8}[\b]{8}[\d, ]{4}[\d]\.[\d]s[\n]$' :
r'^Hello {15} {5} {8}[\b]{8} {7}⣽[\b]{8} {8}[\b]{8}[\d, ]{4}[\d]\.[\d]s[\n]$'));
done = true;
});
@@ -208,8 +209,8 @@
);
logger.printStatus('Rude Interrupting Cow');
status.stop();
- final String a = platform.isWindows ? '\\' : '⣽';
- final String b = platform.isWindows ? '|' : '⣻';
+ final String a = globals.platform.isWindows ? '\\' : '⣽';
+ final String b = globals.platform.isWindows ? '|' : '⣻';
expect(
outputStdout().join('\n'),
'Knock Knock, Who\'s There ' // initial message
@@ -281,7 +282,7 @@
mockStopwatch.elapsed = const Duration(seconds: 1);
doWhileAsync(time, () => ansiStatus.ticks < 10);
List<String> lines = outputStdout();
- expect(lines[0], startsWith(platform.isWindows
+ expect(lines[0], startsWith(globals.platform.isWindows
? 'Hello world \b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |'
: 'Hello world \b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻\b\b\b\b\b\b\b\b ⢿\b\b\b\b\b\b\b\b ⡿\b\b\b\b\b\b\b\b ⣟\b\b\b\b\b\b\b\b ⣯\b\b\b\b\b\b\b\b ⣷\b\b\b\b\b\b\b\b ⣾\b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻'));
expect(lines.length, equals(1));
@@ -292,7 +293,7 @@
lines = outputStdout();
final List<Match> matches = secondDigits.allMatches(lines[0]).toList();
expect(matches, isEmpty);
- final String x = platform.isWindows ? '|' : '⣻';
+ final String x = globals.platform.isWindows ? '|' : '⣻';
expect(lines[0], endsWith('$x\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b'));
expect(called, equals(1));
expect(lines.length, equals(2));
@@ -320,7 +321,7 @@
List<String> lines = outputStdout();
expect(lines, hasLength(1));
expect(lines[0],
- platform.isWindows
+ globals.platform.isWindows
? 'Hello world \b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |'
: 'Hello world \b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻\b\b\b\b\b\b\b\b ⢿\b\b\b\b\b\b\b\b ⡿\b\b\b\b\b\b\b\b ⣟\b\b\b\b\b\b\b\b ⣯\b\b\b\b\b\b\b\b ⣷\b\b\b\b\b\b\b\b ⣾\b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻',
);
@@ -330,7 +331,7 @@
lines = outputStdout();
expect(lines, hasLength(2));
expect(lines[0], matches(
- platform.isWindows
+ globals.platform.isWindows
? r'Hello world {8}[\b]{8} {7}\\[\b]{8} {7}|[\b]{8} {7}/[\b]{8} {7}-[\b]{8} {7}\\[\b]{8} {7}|[\b]{8} {7}/[\b]{8} {7}-[\b]{8} {7}\\[\b]{8} {7}|[\b]{8} {7} [\b]{8}[\d., ]{6}[\d]ms$'
: r'Hello world {8}[\b]{8} {7}⣽[\b]{8} {7}⣻[\b]{8} {7}⢿[\b]{8} {7}⡿[\b]{8} {7}⣟[\b]{8} {7}⣯[\b]{8} {7}⣷[\b]{8} {7}⣾[\b]{8} {7}⣽[\b]{8} {7}⣻[\b]{8} {7} [\b]{8}[\d., ]{5}[\d]ms$'
));
@@ -610,10 +611,10 @@
expect(outputStderr().length, equals(1));
expect(outputStderr().first, isEmpty);
// the 5 below is the margin that is always included between the message and the time.
- expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5}$' :
+ expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5}$' :
r'^Hello {15} {5}$'));
status.stop();
- expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5}[\d, ]{4}[\d]\.[\d]s[\n]$' :
+ expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5}[\d, ]{4}[\d]\.[\d]s[\n]$' :
r'^Hello {15} {5}[\d, ]{4}[\d]\.[\d]s[\n]$'));
done = true;
});
diff --git a/packages/flutter_tools/test/general.shard/base/net_test.dart b/packages/flutter_tools/test/general.shard/base/net_test.dart
index 8a20822..7f4e78f 100644
--- a/packages/flutter_tools/test/general.shard/base/net_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/net_test.dart
@@ -7,10 +7,12 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart' as io;
import 'package:flutter_tools/src/base/net.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:quiver/testing/async.dart';
import '../../src/common.dart';
@@ -33,7 +35,7 @@
});
testUsingContext('fetchUrl(destFile) writes the data to a file', () async {
- final File destFile = fs.file('dest_file')..createSync();
+ final File destFile = globals.fs.file('dest_file')..createSync();
final List<int> data = await fetchUrl(
Uri.parse('http://example.invalid/'),
destFile: destFile,
diff --git a/packages/flutter_tools/test/general.shard/base/os_utils_test.dart b/packages/flutter_tools/test/general.shard/base/os_utils_test.dart
index 8a6d983..9c407d5 100644
--- a/packages/flutter_tools/test/general.shard/base/os_utils_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/os_utils_test.dart
@@ -4,7 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -14,7 +14,7 @@
Directory tempDir;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.');
});
tearDown(() {
@@ -22,12 +22,12 @@
});
testUsingContext('makeExecutable', () async {
- final File file = fs.file(fs.path.join(tempDir.path, 'foo.script'));
+ final File file = globals.fs.file(globals.fs.path.join(tempDir.path, 'foo.script'));
file.writeAsStringSync('hello world');
os.makeExecutable(file);
// Skip this test on windows.
- if (!platform.isWindows) {
+ if (!globals.platform.isWindows) {
final String mode = file.statSync().modeString();
// rwxr--r--
expect(mode.substring(0, 3), endsWith('x'));
diff --git a/packages/flutter_tools/test/general.shard/base/process_test.dart b/packages/flutter_tools/test/general.shard/base/process_test.dart
index f415ffe..bc4383c 100644
--- a/packages/flutter_tools/test/general.shard/base/process_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/process_test.dart
@@ -4,9 +4,9 @@
import 'dart:async';
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:mockito/mockito.dart';
diff --git a/packages/flutter_tools/test/general.shard/base/terminal_test.dart b/packages/flutter_tools/test/general.shard/base/terminal_test.dart
index 99af7fa..f6bc675 100644
--- a/packages/flutter_tools/test/general.shard/base/terminal_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/terminal_test.dart
@@ -4,10 +4,10 @@
import 'dart:async';
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
@@ -16,7 +16,7 @@
void main() {
group('output preferences', () {
testUsingContext('can wrap output', () async {
- printStatus('0123456789' * 8);
+ globals.printStatus('0123456789' * 8);
expect(testLogger.statusText, equals(('0123456789' * 4 + '\n') * 2));
}, overrides: <Type, Generator>{
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40),
@@ -24,7 +24,7 @@
testUsingContext('can turn off wrapping', () async {
final String testString = '0123456789' * 20;
- printStatus(testString);
+ globals.printStatus(testString);
expect(testLogger.statusText, equals('$testString\n'));
}, overrides: <Type, Generator>{
Platform: () => FakePlatform()..stdoutSupportsAnsi = true,
@@ -174,7 +174,7 @@
when(stdio.stdin).thenThrow(StateError('This should not be called'));
when(stdio.stdinHasTerminal).thenReturn(false);
- terminal.singleCharMode = true;
+ globals.terminal.singleCharMode = true;
}, overrides: <Type, Generator>{
Stdio: () => MockStdio(),
});
diff --git a/packages/flutter_tools/test/general.shard/base/utils_test.dart b/packages/flutter_tools/test/general.shard/base/utils_test.dart
index d5287a2..c4e5f1d 100644
--- a/packages/flutter_tools/test/general.shard/base/utils_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/utils_test.dart
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/utils.dart';
import 'package:platform/platform.dart';
diff --git a/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart b/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart
index 8bbf230..adeba5c 100644
--- a/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart
@@ -7,8 +7,8 @@
import 'package:build/build.dart';
import 'package:build_runner_core/build_runner_core.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_runner/web_compilation_delegate.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:glob/glob.dart';
import '../../src/common.dart';
@@ -22,15 +22,15 @@
setUp(() {
testbed = Testbed(setup: () {
- final PackageNode root = PackageNode('foobar', fs.currentDirectory.path, DependencyType.path);
+ final PackageNode root = PackageNode('foobar', globals.fs.currentDirectory.path, DependencyType.path);
packageGraph = FakePackageGraph(root, <String, PackageNode>{'foobar': root});
- fs.file(fs.path.join('lib', 'main.dart'))
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
..createSync(recursive: true)
..writeAsStringSync('main');
- fs.file(fs.path.join('.dart_tool', 'build', 'generated', 'foobar', 'lib', 'bar.dart'))
+ globals.fs.file(globals.fs.path.join('.dart_tool', 'build', 'generated', 'foobar', 'lib', 'bar.dart'))
..createSync(recursive: true)
..writeAsStringSync('bar');
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync('name: foobar');
});
@@ -40,7 +40,7 @@
await IOOverrides.runWithIOOverrides(() async {
final MultirootFileBasedAssetReader reader = MultirootFileBasedAssetReader(
packageGraph,
- fs.directory(fs.path.join('.dart_tool', 'build', 'generated')),
+ globals.fs.directory(globals.fs.path.join('.dart_tool', 'build', 'generated')),
);
expect(await reader.canRead(AssetId('foobar', 'lib/bar.dart')), true);
expect(await reader.canRead(AssetId('foobar', 'lib/main.dart')), true);
@@ -56,7 +56,7 @@
AssetId('foobar', 'lib/bar.dart'),
AssetId('foobar', 'lib/main.dart'),
]));
- }, FlutterIOOverrides(fileSystem: fs));
+ }, FlutterIOOverrides(fileSystem: globals.fs));
// Some component of either dart:io or build_runner normalizes file uris
// into file paths for windows. This doesn't seem to work with IOOverrides
// leaving all filepaths on windows with forward slashes.
diff --git a/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart b/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart
index f1535a3..a3277a7 100644
--- a/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/exceptions.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/convert.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
@@ -93,13 +94,13 @@
testbed = Testbed(
setup: () {
environment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
);
- fs.file('foo.dart')
+ globals.fs.file('foo.dart')
..createSync(recursive: true)
..writeAsStringSync('');
- fs.file('pubspec.yaml').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
},
overrides: <Type, Generator>{
Platform: () => mockPlatform,
@@ -109,7 +110,7 @@
test('Does not throw exception if asked to build with missing inputs', () => testbed.run(() async {
// Delete required input file.
- fs.file('foo.dart').deleteSync();
+ globals.fs.file('foo.dart').deleteSync();
final BuildResult buildResult = await buildSystem.build(fooTarget, environment);
expect(buildResult.hasException, false);
@@ -131,7 +132,7 @@
test('Saves a stamp file with inputs and outputs', () => testbed.run(() async {
await buildSystem.build(fooTarget, environment);
- final File stampFile = fs.file(fs.path.join(environment.buildDir.path, 'foo.stamp'));
+ final File stampFile = globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'foo.stamp'));
expect(stampFile.existsSync(), true);
final Map<String, dynamic> stampContents = castStringKeyedMap(json.decode(stampFile.readAsStringSync()));
@@ -141,9 +142,9 @@
test('Creates a BuildResult with inputs and outputs', () => testbed.run(() async {
final BuildResult result = await buildSystem.build(fooTarget, environment);
- expect(result.inputFiles.single.path, fs.path.absolute('foo.dart'));
+ expect(result.inputFiles.single.path, globals.fs.path.absolute('foo.dart'));
expect(result.outputFiles.single.path,
- fs.path.absolute(fs.path.join(environment.buildDir.path, 'out')));
+ globals.fs.path.absolute(globals.fs.path.join(environment.buildDir.path, 'out')));
}));
test('Does not re-invoke build if stamp is valid', () => testbed.run(() async {
@@ -156,7 +157,7 @@
test('Re-invoke build if input is modified', () => testbed.run(() async {
await buildSystem.build(fooTarget, environment);
- fs.file('foo.dart').writeAsStringSync('new contents');
+ globals.fs.file('foo.dart').writeAsStringSync('new contents');
await buildSystem.build(fooTarget, environment);
expect(fooInvocations, 2);
@@ -165,7 +166,7 @@
test('does not re-invoke build if input timestamp changes', () => testbed.run(() async {
await buildSystem.build(fooTarget, environment);
- fs.file('foo.dart').writeAsStringSync('');
+ globals.fs.file('foo.dart').writeAsStringSync('');
await buildSystem.build(fooTarget, environment);
expect(fooInvocations, 1);
@@ -195,7 +196,7 @@
await buildSystem.build(barTarget, environment);
- expect(fs.file(fs.path.join(environment.buildDir.path, 'bar')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'bar')).existsSync(), true);
expect(fooInvocations, 1);
expect(barInvocations, 1);
}));
@@ -216,7 +217,7 @@
})
..inputs = const <Source>[Source.pattern('{PROJECT_DIR}/foo.dart')]
..outputs = const <Source>[Source.pattern('{BUILD_DIR}/foo.out')];
- fs.file('foo.dart').createSync();
+ globals.fs.file('foo.dart').createSync();
await buildSystem.build(testTarget, environment);
@@ -240,7 +241,7 @@
})
..inputs = const <Source>[Source.pattern('{PROJECT_DIR}/foo.dart')]
..outputs = const <Source>[Source.pattern('{BUILD_DIR}/foo.out')];
- fs.file('foo.dart').createSync();
+ globals.fs.file('foo.dart').createSync();
await buildSystem.build(testTarget, environment);
@@ -265,7 +266,7 @@
})
..inputs = const <Source>[Source.pattern('{PROJECT_DIR}/foo.dart')]
..outputs = const <Source>[Source.pattern('{BUILD_DIR}/foo.out')];
- fs.file('foo.dart').createSync();
+ globals.fs.file('foo.dart').createSync();
await buildSystem.build(testTarget, environment);
// invalid JSON
@@ -295,11 +296,11 @@
'/foo.dart',
],
'outputs': <Object>[
- fs.path.join(environment.buildDir.path, 'out'),
+ globals.fs.path.join(environment.buildDir.path, 'out'),
],
'dependencies': <Object>[],
'name': 'foo',
- 'stamp': fs.path.join(environment.buildDir.path, 'foo.stamp'),
+ 'stamp': globals.fs.path.join(environment.buildDir.path, 'foo.stamp'),
});
}));
@@ -317,15 +318,15 @@
final TestTarget target = TestTarget((Environment environment) async {
environment.buildDir.childFile('example.d')
.writeAsStringSync('a.txt: b.txt');
- fs.file('a.txt').writeAsStringSync('a');
+ globals.fs.file('a.txt').writeAsStringSync('a');
called += 1;
})
..depfiles = <String>['example.d'];
- fs.file('b.txt').writeAsStringSync('b');
+ globals.fs.file('b.txt').writeAsStringSync('b');
await buildSystem.build(target, environment);
- expect(fs.file('a.txt').existsSync(), true);
+ expect(globals.fs.file('a.txt').existsSync(), true);
expect(called, 1);
// Second build is up to date due to depfil parse.
@@ -334,8 +335,8 @@
}));
test('output directory is an input to the build', () => testbed.run(() async {
- final Environment environmentA = Environment(projectDir: fs.currentDirectory, outputDir: fs.directory('a'));
- final Environment environmentB = Environment(projectDir: fs.currentDirectory, outputDir: fs.directory('b'));
+ final Environment environmentA = Environment(projectDir: globals.fs.currentDirectory, outputDir: globals.fs.directory('a'));
+ final Environment environmentB = Environment(projectDir: globals.fs.currentDirectory, outputDir: globals.fs.directory('b'));
expect(environmentA.buildDir.path, isNot(environmentB.buildDir.path));
}));
@@ -346,31 +347,31 @@
if (called == 0) {
environment.buildDir.childFile('example.d')
.writeAsStringSync('a.txt c.txt: b.txt');
- fs.file('a.txt').writeAsStringSync('a');
- fs.file('c.txt').writeAsStringSync('a');
+ globals.fs.file('a.txt').writeAsStringSync('a');
+ globals.fs.file('c.txt').writeAsStringSync('a');
} else {
// On second run, we no longer claim c.txt as an output.
environment.buildDir.childFile('example.d')
.writeAsStringSync('a.txt: b.txt');
- fs.file('a.txt').writeAsStringSync('a');
+ globals.fs.file('a.txt').writeAsStringSync('a');
}
called += 1;
})
..depfiles = const <String>['example.d'];
- fs.file('b.txt').writeAsStringSync('b');
+ globals.fs.file('b.txt').writeAsStringSync('b');
await buildSystem.build(target, environment);
- expect(fs.file('a.txt').existsSync(), true);
- expect(fs.file('c.txt').existsSync(), true);
+ expect(globals.fs.file('a.txt').existsSync(), true);
+ expect(globals.fs.file('c.txt').existsSync(), true);
expect(called, 1);
// rewrite an input to force a rerun, espect that the old c.txt is deleted.
- fs.file('b.txt').writeAsStringSync('ba');
+ globals.fs.file('b.txt').writeAsStringSync('ba');
await buildSystem.build(target, environment);
- expect(fs.file('a.txt').existsSync(), true);
- expect(fs.file('c.txt').existsSync(), false);
+ expect(globals.fs.file('a.txt').existsSync(), true);
+ expect(globals.fs.file('c.txt').existsSync(), false);
expect(called, 2);
}));
}
diff --git a/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart b/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart
index b7b4cf6..60331fa 100644
--- a/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart
@@ -5,6 +5,7 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/depfile.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/testbed.dart';
@@ -16,7 +17,7 @@
testbed = Testbed();
});
test('Can parse depfile from file', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync('''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync('''
a.txt: b.txt
''');
final Depfile depfile = Depfile.parse(depfileSource);
@@ -26,7 +27,7 @@
}));
test('Can parse depfile with multiple inputs', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync('''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync('''
a.txt: b.txt c.txt d.txt
''');
final Depfile depfile = Depfile.parse(depfileSource);
@@ -40,7 +41,7 @@
}));
test('Can parse depfile with multiple outputs', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync('''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync('''
a.txt c.txt d.txt: b.txt
''');
final Depfile depfile = Depfile.parse(depfileSource);
@@ -54,7 +55,7 @@
}));
test('Can parse depfile with windows file paths', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync(r'''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r'''
C:\\a.txt: C:\\b.txt
''');
final Depfile depfile = Depfile.parse(depfileSource);
@@ -66,7 +67,7 @@
}));
test('Resillient to weird whitespace', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync(r'''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r'''
a.txt
: b.txt c.txt
@@ -79,7 +80,7 @@
}));
test('Resillient to duplicate files', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync(r'''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r'''
a.txt: b.txt b.txt
''');
final Depfile depfile = Depfile.parse(depfileSource);
@@ -89,7 +90,7 @@
}));
test('Resillient to malformed file, missing :', () => testbed.run(() {
- final File depfileSource = fs.file('example.d')..writeAsStringSync(r'''
+ final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r'''
a.text b.txt
''');
final Depfile depfile = Depfile.parse(depfileSource);
@@ -99,18 +100,18 @@
}));
test('Can parse dart2js output format', () => testbed.run(() {
- final File dart2jsDependencyFile = fs.file('main.dart.js.deps')..writeAsStringSync(r'''
+ final File dart2jsDependencyFile = globals.fs.file('main.dart.js.deps')..writeAsStringSync(r'''
file:///Users/foo/collection.dart
file:///Users/foo/algorithms.dart
file:///Users/foo/canonicalized_map.dart
''');
- final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, fs.file('foo.dart.js'));
+ final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, globals.fs.file('foo.dart.js'));
expect(depfile.inputs.map((File file) => file.path), <String>[
- fs.path.absolute(fs.path.join('Users', 'foo', 'collection.dart')),
- fs.path.absolute(fs.path.join('Users', 'foo', 'algorithms.dart')),
- fs.path.absolute(fs.path.join('Users', 'foo', 'canonicalized_map.dart')),
+ globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'collection.dart')),
+ globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'algorithms.dart')),
+ globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'canonicalized_map.dart')),
]);
expect(depfile.outputs.single.path, 'foo.dart.js');
}, overrides: <Type, Generator>{
@@ -118,17 +119,17 @@
}));
test('Can parse handle invalid uri', () => testbed.run(() {
- final File dart2jsDependencyFile = fs.file('main.dart.js.deps')..writeAsStringSync('''
+ final File dart2jsDependencyFile = globals.fs.file('main.dart.js.deps')..writeAsStringSync('''
file:///Users/foo/collection.dart
abcdevf
file:///Users/foo/canonicalized_map.dart
''');
- final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, fs.file('foo.dart.js'));
+ final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, globals.fs.file('foo.dart.js'));
expect(depfile.inputs.map((File file) => file.path), <String>[
- fs.path.absolute(fs.path.join('Users', 'foo', 'collection.dart')),
- fs.path.absolute(fs.path.join('Users', 'foo', 'canonicalized_map.dart')),
+ globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'collection.dart')),
+ globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'canonicalized_map.dart')),
]);
expect(depfile.outputs.single.path, 'foo.dart.js');
}, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart b/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart
index 6675ab3..66e0405 100644
--- a/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart
@@ -5,13 +5,14 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/exceptions.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
void main() {
test('Exceptions', () {
final MissingInputException missingInputException = MissingInputException(
- <File>[fs.file('foo'), fs.file('bar')], 'example');
+ <File>[globals.fs.file('foo'), globals.fs.file('bar')], 'example');
final CycleException cycleException = CycleException(<Target>{
TestTarget()..name = 'foo',
TestTarget()..name = 'bar',
@@ -20,7 +21,7 @@
'ABC'
);
final MissingOutputException missingOutputException = MissingOutputException(
- <File>[ fs.file('foo'), fs.file('bar') ],
+ <File>[ globals.fs.file('foo'), globals.fs.file('bar') ],
'example',
);
final MisplacedOutputException misplacedOutputException = MisplacedOutputException(
diff --git a/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart b/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart
index 02c225d..c51d0f4 100644
--- a/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart
@@ -7,6 +7,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/file_hash_store.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
@@ -19,23 +20,23 @@
setUp(() {
testbed = Testbed(setup: () {
- fs.directory('build').createSync();
+ globals.fs.directory('build').createSync();
environment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
);
environment.buildDir.createSync(recursive: true);
});
});
test('Initializes file cache', () => testbed.run(() {
- final FileHashStore fileCache = FileHashStore(environment, fs);
+ final FileHashStore fileCache = FileHashStore(environment, globals.fs);
fileCache.initialize();
fileCache.persist();
- expect(fs.file(fs.path.join(environment.buildDir.path, '.filecache')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')).existsSync(), true);
- final Uint8List buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache'))
+ final Uint8List buffer = globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache'))
.readAsBytesSync();
final FileStorage fileStorage = FileStorage.fromBuffer(buffer);
@@ -44,15 +45,15 @@
}));
test('saves and restores to file cache', () => testbed.run(() async {
- final File file = fs.file('foo.dart')
+ final File file = globals.fs.file('foo.dart')
..createSync()
..writeAsStringSync('hello');
- final FileHashStore fileCache = FileHashStore(environment, fs);
+ final FileHashStore fileCache = FileHashStore(environment, globals.fs);
fileCache.initialize();
await fileCache.hashFiles(<File>[file]);
fileCache.persist();
final String currentHash = fileCache.currentHashes[file.path];
- final Uint8List buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache'))
+ final Uint8List buffer = globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache'))
.readAsBytesSync();
FileStorage fileStorage = FileStorage.fromBuffer(buffer);
@@ -60,7 +61,7 @@
expect(fileStorage.files.single.path, file.path);
- final FileHashStore newFileCache = FileHashStore(environment, fs);
+ final FileHashStore newFileCache = FileHashStore(environment, globals.fs);
newFileCache.initialize();
expect(newFileCache.currentHashes, isEmpty);
expect(newFileCache.previousHashes['foo.dart'], currentHash);
@@ -74,10 +75,10 @@
}));
test('handles persisting with a missing build directory', () => testbed.run(() async {
- final File file = fs.file('foo.dart')
+ final File file = globals.fs.file('foo.dart')
..createSync()
..writeAsStringSync('hello');
- final FileHashStore fileCache = FileHashStore(environment, fs);
+ final FileHashStore fileCache = FileHashStore(environment, globals.fs);
fileCache.initialize();
environment.buildDir.deleteSync(recursive: true);
@@ -87,18 +88,18 @@
}));
test('handles hashing missing files', () => testbed.run(() async {
- final FileHashStore fileCache = FileHashStore(environment, fs);
+ final FileHashStore fileCache = FileHashStore(environment, globals.fs);
fileCache.initialize();
- final List<File> results = await fileCache.hashFiles(<File>[fs.file('hello.dart')]);
+ final List<File> results = await fileCache.hashFiles(<File>[globals.fs.file('hello.dart')]);
expect(results, hasLength(1));
expect(results.single.path, 'hello.dart');
- expect(fileCache.currentHashes, isNot(contains(fs.path.absolute('hello.dart'))));
+ expect(fileCache.currentHashes, isNot(contains(globals.fs.path.absolute('hello.dart'))));
}));
test('handles failure to persist file cache', () => testbed.run(() async {
- final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fs);
+ final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(globals.fs);
final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem);
final String cacheFile = environment.buildDir.childFile('.filecache').path;
final MockFile mockFile = MockFile();
@@ -113,7 +114,7 @@
}));
test('handles failure to restore file cache', () => testbed.run(() async {
- final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fs);
+ final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(globals.fs);
final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem);
final String cacheFile = environment.buildDir.childFile('.filecache').path;
final MockFile mockFile = MockFile();
diff --git a/packages/flutter_tools/test/general.shard/build_system/source_test.dart b/packages/flutter_tools/test/general.shard/build_system/source_test.dart
index afc0506..18f6b32 100644
--- a/packages/flutter_tools/test/general.shard/build_system/source_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/source_test.dart
@@ -4,13 +4,14 @@
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/exceptions.dart';
import 'package:flutter_tools/src/build_system/source.dart';
-import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/testbed.dart';
@@ -25,13 +26,13 @@
mockPlatform = MockPlatform();
when(mockPlatform.isWindows).thenReturn(true);
testbed = Testbed(setup: () {
- fs.directory('cache').createSync();
- final Directory outputs = fs.directory('outputs')
+ globals.fs.directory('cache').createSync();
+ final Directory outputs = globals.fs.directory('outputs')
..createSync();
environment = Environment(
outputDir: outputs,
- projectDir: fs.currentDirectory,
- buildDir: fs.directory('build'),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.directory('build'),
);
visitor = SourceVisitor(environment);
environment.buildDir.createSync(recursive: true);
@@ -44,51 +45,51 @@
}));
test('can substitute {PROJECT_DIR}/foo', () => testbed.run(() {
- fs.file('foo').createSync();
+ globals.fs.file('foo').createSync();
const Source fooSource = Source.pattern('{PROJECT_DIR}/foo');
fooSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute('foo'));
+ expect(visitor.sources.single.path, globals.fs.path.absolute('foo'));
}));
test('can substitute {OUTPUT_DIR}/foo', () => testbed.run(() {
- fs.file('foo').createSync();
+ globals.fs.file('foo').createSync();
const Source fooSource = Source.pattern('{OUTPUT_DIR}/foo');
fooSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute(fs.path.join('outputs', 'foo')));
+ expect(visitor.sources.single.path, globals.fs.path.absolute(globals.fs.path.join('outputs', 'foo')));
}));
test('can substitute {BUILD_DIR}/bar', () => testbed.run(() {
- final String path = fs.path.join(environment.buildDir.path, 'bar');
- fs.file(path).createSync();
+ final String path = globals.fs.path.join(environment.buildDir.path, 'bar');
+ globals.fs.file(path).createSync();
const Source barSource = Source.pattern('{BUILD_DIR}/bar');
barSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute(path));
+ expect(visitor.sources.single.path, globals.fs.path.absolute(path));
}));
test('can substitute {FLUTTER_ROOT}/foo', () => testbed.run(() {
- final String path = fs.path.join(environment.flutterRootDir.path, 'foo');
- fs.file(path).createSync();
+ final String path = globals.fs.path.join(environment.flutterRootDir.path, 'foo');
+ globals.fs.file(path).createSync();
const Source barSource = Source.pattern('{FLUTTER_ROOT}/foo');
barSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute(path));
+ expect(visitor.sources.single.path, globals.fs.path.absolute(path));
}));
test('can substitute Artifact', () => testbed.run(() {
- final String path = fs.path.join(
- Cache.instance.getArtifactDirectory('engine').path,
+ final String path = globals.fs.path.join(
+ globals.cache.getArtifactDirectory('engine').path,
'windows-x64',
'foo',
);
- fs.file(path).createSync(recursive: true);
+ globals.fs.file(path).createSync(recursive: true);
const Source fizzSource = Source.artifact(Artifact.windowsDesktopPath, platform: TargetPlatform.windows_x64);
fizzSource.accept(visitor);
- expect(visitor.sources.single.resolveSymbolicLinksSync(), fs.path.absolute(path));
+ expect(visitor.sources.single.resolveSymbolicLinksSync(), globals.fs.path.absolute(path));
}));
test('can substitute {PROJECT_DIR}/*.fizz', () => testbed.run(() {
@@ -97,13 +98,13 @@
expect(visitor.sources, isEmpty);
- fs.file('foo.fizz').createSync();
- fs.file('foofizz').createSync();
+ globals.fs.file('foo.fizz').createSync();
+ globals.fs.file('foofizz').createSync();
fizzSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute('foo.fizz'));
+ expect(visitor.sources.single.path, globals.fs.path.absolute('foo.fizz'));
}));
test('can substitute {PROJECT_DIR}/fizz.*', () => testbed.run(() {
@@ -112,12 +113,12 @@
expect(visitor.sources, isEmpty);
- fs.file('fizz.foo').createSync();
- fs.file('fizz').createSync();
+ globals.fs.file('fizz.foo').createSync();
+ globals.fs.file('fizz').createSync();
fizzSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute('fizz.foo'));
+ expect(visitor.sources.single.path, globals.fs.path.absolute('fizz.foo'));
}));
@@ -127,19 +128,19 @@
expect(visitor.sources, isEmpty);
- fs.file('bcbc').createSync();
- fs.file('bc').createSync();
+ globals.fs.file('bcbc').createSync();
+ globals.fs.file('bc').createSync();
fizzSource.accept(visitor);
- expect(visitor.sources.single.path, fs.path.absolute('bcbc'));
+ expect(visitor.sources.single.path, globals.fs.path.absolute('bcbc'));
}));
test('crashes on bad substitute of two **', () => testbed.run(() {
const Source fizzSource = Source.pattern('{PROJECT_DIR}/*.*bar');
- fs.file('abcd.bar').createSync();
+ globals.fs.file('abcd.bar').createSync();
expect(() => fizzSource.accept(visitor), throwsA(isInstanceOf<InvalidPatternException>()));
}));
@@ -154,7 +155,7 @@
test('can substitute optional files', () => testbed.run(() {
const Source missingSource = Source.pattern('{PROJECT_DIR}/foo', optional: true);
- expect(fs.file('foo').existsSync(), false);
+ expect(globals.fs.file('foo').existsSync(), false);
missingSource.accept(visitor);
expect(visitor.sources, isEmpty);
}));
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
index e690ead..d67e6e9 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
@@ -8,7 +8,9 @@
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/android.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/cache.dart';
+
import 'package:mockito/mockito.dart';
import '../../../src/common.dart';
@@ -21,9 +23,9 @@
testbed.test('debug bundle contains expected resources', () async {
final Environment environment = Environment(
- outputDir: fs.directory('out')..createSync(),
- projectDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ outputDir: globals.fs.directory('out')..createSync(),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'debug',
}
@@ -33,7 +35,7 @@
// create pre-requisites.
environment.buildDir.childFile('app.dill')
..writeAsStringSync('abcd');
- final Directory hostDirectory = fs.currentDirectory
+ final Directory hostDirectory = globals.fs.currentDirectory
.childDirectory(getNameForHostPlatform(getCurrentHostPlatform()))
..createSync(recursive: true);
hostDirectory.childFile('vm_isolate_snapshot.bin').createSync();
@@ -42,16 +44,16 @@
await const DebugAndroidApplication().build(environment);
- expect(fs.file(fs.path.join('out', 'flutter_assets', 'isolate_snapshot_data')).existsSync(), true);
- expect(fs.file(fs.path.join('out', 'flutter_assets', 'vm_snapshot_data')).existsSync(), true);
- expect(fs.file(fs.path.join('out', 'flutter_assets', 'kernel_blob.bin')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('out', 'flutter_assets', 'isolate_snapshot_data')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('out', 'flutter_assets', 'vm_snapshot_data')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('out', 'flutter_assets', 'kernel_blob.bin')).existsSync(), true);
});
testbed.test('profile bundle contains expected resources', () async {
final Environment environment = Environment(
- outputDir: fs.directory('out')..createSync(),
- projectDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ outputDir: globals.fs.directory('out')..createSync(),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'profile',
}
@@ -64,14 +66,14 @@
await const ProfileAndroidApplication().build(environment);
- expect(fs.file(fs.path.join('out', 'app.so')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('out', 'app.so')).existsSync(), true);
});
testbed.test('release bundle contains expected resources', () async {
final Environment environment = Environment(
- outputDir: fs.directory('out')..createSync(),
- projectDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ outputDir: globals.fs.directory('out')..createSync(),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'release',
}
@@ -84,14 +86,14 @@
await const ReleaseAndroidApplication().build(environment);
- expect(fs.file(fs.path.join('out', 'app.so')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('out', 'app.so')).existsSync(), true);
});
testbed.test('AndroidAot can build provided target platform', () async {
final Environment environment = Environment(
- outputDir: fs.directory('out')..createSync(),
- projectDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ outputDir: globals.fs.directory('out')..createSync(),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'release',
}
@@ -125,9 +127,9 @@
testbed.test('kExtraGenSnapshotOptions passes values to gen_snapshot', () async {
final Environment environment = Environment(
- outputDir: fs.directory('out')..createSync(),
- projectDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ outputDir: globals.fs.directory('out')..createSync(),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'release',
kExtraGenSnapshotOptions: 'foo,bar,baz=2',
@@ -160,9 +162,9 @@
testbed.test('android aot bundle copies so from abi directory', () async {
final Environment environment = Environment(
- outputDir: fs.directory('out')..createSync(),
- projectDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ outputDir: globals.fs.directory('out')..createSync(),
+ projectDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'release',
}
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
index 7b3b091..659709c 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
@@ -4,9 +4,9 @@
import 'dart:io';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/assets.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../../src/common.dart';
import '../../../src/testbed.dart';
@@ -19,19 +19,19 @@
setUp(() {
testbed = Testbed(setup: () {
environment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
);
- fs.file(fs.path.join('packages', 'flutter_tools', 'lib', 'src',
+ globals.fs.file(globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src',
'build_system', 'targets', 'assets.dart'))
..createSync(recursive: true);
- fs.file(fs.path.join('assets', 'foo', 'bar.png'))
+ globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.png'))
..createSync(recursive: true);
- fs.file(fs.path.join('assets', 'wildcard', '#bar.png'))
+ globals.fs.file(globals.fs.path.join('assets', 'wildcard', '#bar.png'))
..createSync(recursive: true);
- fs.file('.packages')
+ globals.fs.file('.packages')
..createSync();
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync('''
name: example
@@ -47,21 +47,21 @@
test('Copies files to correct asset directory', () => testbed.run(() async {
await buildSystem.build(const CopyAssets(), environment);
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'AssetManifest.json')).existsSync(), true);
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'FontManifest.json')).existsSync(), true);
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'LICENSE')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'AssetManifest.json')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'FontManifest.json')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'LICENSE')).existsSync(), true);
// See https://github.com/flutter/flutter/issues/35293
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true);
// See https://github.com/flutter/flutter/issues/46163
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/wildcard/%23bar.png')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/wildcard/%23bar.png')).existsSync(), true);
}));
test('Does not leave stale files in build directory', () => testbed.run(() async {
await buildSystem.build(const CopyAssets(), environment);
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true);
// Modify manifest to remove asset.
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync('''
name: example
@@ -71,18 +71,18 @@
await buildSystem.build(const CopyAssets(), environment);
// See https://github.com/flutter/flutter/issues/35293
- expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), false);
+ expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), false);
}), skip: Platform.isWindows); // See https://github.com/google/file.dart/issues/131
test('FlutterPlugins updates required files as needed', () => testbed.run(() async {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..writeAsStringSync('name: foo\ndependencies:\n foo: any\n');
await const FlutterPlugins().build(Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
));
- expect(fs.file('.flutter-plugins').existsSync(), true);
+ expect(globals.fs.file('.flutter-plugins').existsSync(), true);
}));
}
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart
index 82e56be..b83b51b 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart
@@ -4,7 +4,6 @@
import 'package:flutter_tools/src/base/build.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
@@ -15,6 +14,8 @@
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -39,64 +40,64 @@
mockProcessManager = MockProcessManager();
testbed = Testbed(setup: () {
androidEnvironment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: getNameForBuildMode(BuildMode.profile),
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm),
},
);
iosEnvironment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: getNameForBuildMode(BuildMode.profile),
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.ios),
},
);
HostPlatform hostPlatform;
- if (platform.isWindows) {
+ if (globals.platform.isWindows) {
hostPlatform = HostPlatform.windows_x64;
- } else if (platform.isLinux) {
+ } else if (globals.platform.isLinux) {
hostPlatform = HostPlatform.linux_x64;
- } else if (platform.isMacOS) {
+ } else if (globals.platform.isMacOS) {
hostPlatform = HostPlatform.darwin_x64;
} else {
assert(false);
}
- final String skyEngineLine = platform.isWindows
+ final String skyEngineLine = globals.platform.isWindows
? r'sky_engine:file:///C:/bin/cache/pkg/sky_engine/lib/'
: 'sky_engine:file:///bin/cache/pkg/sky_engine/lib/';
- fs.file('.packages')
+ globals.fs.file('.packages')
..createSync()
..writeAsStringSync('''
# Generated
$skyEngineLine
flutter_tools:lib/''');
- final String engineArtifacts = fs.path.join('bin', 'cache',
+ final String engineArtifacts = globals.fs.path.join('bin', 'cache',
'artifacts', 'engine');
final List<String> paths = <String>[
- fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui',
+ globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui',
'ui.dart'),
- fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext',
+ globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext',
'vmservice_io.dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart.exe'),
- fs.path.join(engineArtifacts, getNameForHostPlatform(hostPlatform),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart.exe'),
+ globals.fs.path.join(engineArtifacts, getNameForHostPlatform(hostPlatform),
'frontend_server.dart.snapshot'),
- fs.path.join(engineArtifacts, 'android-arm-profile',
+ globals.fs.path.join(engineArtifacts, 'android-arm-profile',
getNameForHostPlatform(hostPlatform), 'gen_snapshot'),
- fs.path.join(engineArtifacts, 'ios-profile', 'gen_snapshot'),
- fs.path.join(engineArtifacts, 'common', 'flutter_patched_sdk',
+ globals.fs.path.join(engineArtifacts, 'ios-profile', 'gen_snapshot'),
+ globals.fs.path.join(engineArtifacts, 'common', 'flutter_patched_sdk',
'platform_strong.dill'),
- fs.path.join('lib', 'foo.dart'),
- fs.path.join('lib', 'bar.dart'),
- fs.path.join('lib', 'fizz'),
- fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'dart.dart'),
- fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'ios.dart'),
+ globals.fs.path.join('lib', 'foo.dart'),
+ globals.fs.path.join('lib', 'bar.dart'),
+ globals.fs.path.join('lib', 'fizz'),
+ globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'dart.dart'),
+ globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'ios.dart'),
];
for (String path in paths) {
- fs.file(path).createSync(recursive: true);
+ globals.fs.file(path).createSync(recursive: true);
}
}, overrides: <Type, Generator>{
KernelCompilerFactory: () => FakeKernelCompilerFactory(),
@@ -107,7 +108,7 @@
test('kernel_snapshot Produces correct output directory', () => testbed.run(() async {
await buildSystem.build(const KernelSnapshot(), androidEnvironment);
- expect(fs.file(fs.path.join(androidEnvironment.buildDir.path,'app.dill')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(androidEnvironment.buildDir.path,'app.dill')).existsSync(), true);
}));
test('kernel_snapshot throws error if missing build mode', () => testbed.run(() async {
@@ -264,8 +265,8 @@
});
await const KernelSnapshot().build(Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'debug',
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm),
@@ -277,8 +278,8 @@
test('aot_elf_profile Produces correct output directory', () => testbed.run(() async {
await buildSystem.build(const AotElfProfile(), androidEnvironment);
- expect(fs.file(fs.path.join(androidEnvironment.buildDir.path, 'app.dill')).existsSync(), true);
- expect(fs.file(fs.path.join(androidEnvironment.buildDir.path, 'app.so')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(androidEnvironment.buildDir.path, 'app.dill')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join(androidEnvironment.buildDir.path, 'app.so')).existsSync(), true);
}));
test('aot_elf_profile throws error if missing build mode', () => testbed.run(() async {
@@ -319,7 +320,7 @@
test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async {
iosEnvironment.defines[kIosArchs] ='armv7,arm64';
when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
- fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
+ globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
.createSync(recursive: true);
return FakeProcessResult(
stdout: '',
@@ -343,7 +344,7 @@
);
final RunResult fakeRunResult = RunResult(fakeProcessResult, const <String>['foo']);
when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
- fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
+ globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
.createSync(recursive: true);
return fakeProcessResult;
});
@@ -371,7 +372,7 @@
);
final RunResult fakeRunResult = RunResult(fakeProcessResult, const <String>['foo']);
when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
- fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
+ globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
.createSync(recursive: true);
return fakeProcessResult;
});
@@ -392,7 +393,7 @@
test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async {
iosEnvironment.defines[kIosArchs] = 'armv7,arm64';
when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
- fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
+ globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App'))
.createSync(recursive: true);
return FakeProcessResult(
stdout: '',
@@ -446,7 +447,7 @@
@override
Future<int> run({SnapshotType snapshotType, DarwinArch darwinArch, Iterable<String> additionalArgs = const <String>[]}) async {
lastCallAdditionalArgs = additionalArgs.toList();
- final Directory out = fs.file(lastCallAdditionalArgs.last).parent;
+ final Directory out = globals.fs.file(lastCallAdditionalArgs.last).parent;
if (darwinArch == null) {
out.childFile('app.so').createSync();
out.childFile('gen_snapshot.d').createSync();
@@ -457,8 +458,8 @@
final String assembly = lastCallAdditionalArgs
.firstWhere((String arg) => arg.startsWith('--assembly'))
.substring('--assembly='.length);
- fs.file(assembly).createSync();
- fs.file(assembly.replaceAll('.S', '.o')).createSync();
+ globals.fs.file(assembly).createSync();
+ globals.fs.file(assembly.replaceAll('.S', '.o')).createSync();
return 0;
}
}
@@ -493,7 +494,7 @@
String initializeFromDill,
List<String> dartDefines,
}) async {
- fs.file(outputFilePath).createSync(recursive: true);
+ globals.fs.file(outputFilePath).createSync(recursive: true);
return CompilerOutput(outputFilePath, 0, null);
}
}
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart
index 045a284..6eb658e 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
import 'package:flutter_tools/src/build_system/targets/linux.dart';
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../../src/common.dart';
@@ -33,22 +34,22 @@
testbed = Testbed(setup: () {
Cache.flutterRoot = '';
environment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'debug',
}
);
- fs.file('bin/cache/artifacts/engine/linux-x64/unrelated-stuff').createSync(recursive: true);
- fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').createSync(recursive: true);
- fs.file('bin/cache/artifacts/engine/linux-x64/flutter_export.h').createSync();
- fs.file('bin/cache/artifacts/engine/linux-x64/flutter_messenger.h').createSync();
- fs.file('bin/cache/artifacts/engine/linux-x64/flutter_plugin_registrar.h').createSync();
- fs.file('bin/cache/artifacts/engine/linux-x64/flutter_glfw.h').createSync();
- fs.file('bin/cache/artifacts/engine/linux-x64/icudtl.dat').createSync();
- fs.file('bin/cache/artifacts/engine/linux-x64/cpp_client_wrapper_glfw/foo').createSync(recursive: true);
- fs.file('packages/flutter_tools/lib/src/build_system/targets/linux.dart').createSync(recursive: true);
- fs.directory('linux').createSync();
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/unrelated-stuff').createSync(recursive: true);
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').createSync(recursive: true);
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_export.h').createSync();
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_messenger.h').createSync();
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_plugin_registrar.h').createSync();
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_glfw.h').createSync();
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/icudtl.dat').createSync();
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/cpp_client_wrapper_glfw/foo').createSync(recursive: true);
+ globals.fs.file('packages/flutter_tools/lib/src/build_system/targets/linux.dart').createSync(recursive: true);
+ globals.fs.directory('linux').createSync();
}, overrides: <Type, Generator>{
Platform: () => mockPlatform,
});
@@ -58,14 +59,14 @@
final BuildResult result = await buildSystem.build(const UnpackLinuxDebug(), environment);
expect(result.hasException, false);
- expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/flutter_export.h').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/flutter_messenger.h').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/flutter_plugin_registrar.h').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/flutter_glfw.h').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/icudtl.dat').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/cpp_client_wrapper_glfw/foo').existsSync(), true);
- expect(fs.file('linux/flutter/ephemeral/unrelated-stuff').existsSync(), false);
+ expect(globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/flutter_export.h').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/flutter_messenger.h').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/flutter_plugin_registrar.h').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/flutter_glfw.h').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/icudtl.dat').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/cpp_client_wrapper_glfw/foo').existsSync(), true);
+ expect(globals.fs.file('linux/flutter/ephemeral/unrelated-stuff').existsSync(), false);
}));
test('Does not re-copy files unecessarily', () => testbed.run(() async {
@@ -73,19 +74,19 @@
// Set a date in the far distant past to deal with the limited resolution
// of the windows filesystem.
final DateTime theDistantPast = DateTime(1991, 8, 23);
- fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').setLastModifiedSync(theDistantPast);
+ globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').setLastModifiedSync(theDistantPast);
await buildSystem.build(const UnpackLinuxDebug(), environment);
- expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').statSync().modified, equals(theDistantPast));
+ expect(globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').statSync().modified, equals(theDistantPast));
}));
test('Detects changes in input cache files', () => testbed.run(() async {
await buildSystem.build(const UnpackLinuxDebug(), environment);
- fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').writeAsStringSync('asd'); // modify cache.
+ globals.fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').writeAsStringSync('asd'); // modify cache.
await buildSystem.build(const UnpackLinuxDebug(), environment);
- expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').readAsStringSync(), 'asd');
+ expect(globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').readAsStringSync(), 'asd');
}));
test('Copies artifacts to out directory', () => testbed.run(() async {
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
index b5ef7dd..cd09381 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
@@ -5,17 +5,17 @@
import 'package:flutter_tools/src/base/build.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
-import 'package:flutter_tools/src/base/process_manager.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
import 'package:flutter_tools/src/build_system/targets/macos.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/macos/cocoapods.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../../src/common.dart';
import '../../../src/testbed.dart';
@@ -24,25 +24,25 @@
const String _kOutputPrefix = 'FlutterMacOS.framework';
final List<File> inputs = <File>[
- fs.file('$_kInputPrefix/FlutterMacOS'),
+ globals.fs.file('$_kInputPrefix/FlutterMacOS'),
// Headers
- fs.file('$_kInputPrefix/Headers/FlutterDartProject.h'),
- fs.file('$_kInputPrefix/Headers/FlutterEngine.h'),
- fs.file('$_kInputPrefix/Headers/FlutterViewController.h'),
- fs.file('$_kInputPrefix/Headers/FlutterBinaryMessenger.h'),
- fs.file('$_kInputPrefix/Headers/FlutterChannels.h'),
- fs.file('$_kInputPrefix/Headers/FlutterCodecs.h'),
- fs.file('$_kInputPrefix/Headers/FlutterMacros.h'),
- fs.file('$_kInputPrefix/Headers/FlutterPluginMacOS.h'),
- fs.file('$_kInputPrefix/Headers/FlutterPluginRegistrarMacOS.h'),
- fs.file('$_kInputPrefix/Headers/FlutterMacOS.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterDartProject.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterEngine.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterViewController.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterBinaryMessenger.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterChannels.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterCodecs.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterMacros.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterPluginMacOS.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterPluginRegistrarMacOS.h'),
+ globals.fs.file('$_kInputPrefix/Headers/FlutterMacOS.h'),
// Modules
- fs.file('$_kInputPrefix/Modules/module.modulemap'),
+ globals.fs.file('$_kInputPrefix/Modules/module.modulemap'),
// Resources
- fs.file('$_kInputPrefix/Resources/icudtl.dat'),
- fs.file('$_kInputPrefix/Resources/Info.plist'),
+ globals.fs.file('$_kInputPrefix/Resources/icudtl.dat'),
+ globals.fs.file('$_kInputPrefix/Resources/Info.plist'),
// Ignore Versions folder for now
- fs.file('packages/flutter_tools/lib/src/build_system/targets/macos.dart'),
+ globals.fs.file('packages/flutter_tools/lib/src/build_system/targets/macos.dart'),
];
void main() {
@@ -62,14 +62,14 @@
when(mockPlatform.isLinux).thenReturn(false);
when(mockPlatform.environment).thenReturn(const <String, String>{});
testbed = Testbed(setup: () {
- fs.file(fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui',
'ui.dart')).createSync(recursive: true);
- fs.file(fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext',
'vmservice_io.dart')).createSync(recursive: true);
environment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
defines: <String, String>{
kBuildMode: 'debug',
kTargetPlatform: 'darwin-x64',
@@ -89,12 +89,12 @@
environment.outputDir.childDirectory(_kOutputPrefix)
.createSync(recursive: true);
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
final List<String> arguments = invocation.positionalArguments.first as List<String>;
final String sourcePath = arguments[arguments.length - 2];
final String targetPath = arguments.last;
- final Directory source = fs.directory(sourcePath);
- final Directory target = fs.directory(targetPath);
+ final Directory source = globals.fs.directory(sourcePath);
+ final Directory target = globals.fs.directory(targetPath);
// verify directory was deleted by command.
expect(target.existsSync(), false);
@@ -102,10 +102,10 @@
for (FileSystemEntity entity in source.listSync(recursive: true)) {
if (entity is File) {
- final String relative = fs.path.relative(entity.path, from: source.path);
- final String destination = fs.path.join(target.path, relative);
- if (!fs.file(destination).parent.existsSync()) {
- fs.file(destination).parent.createSync();
+ final String relative = globals.fs.path.relative(entity.path, from: source.path);
+ final String destination = globals.fs.path.join(target.path, relative);
+ if (!globals.fs.file(destination).parent.existsSync()) {
+ globals.fs.file(destination).parent.createSync();
}
entity.copySync(destination);
}
@@ -114,15 +114,15 @@
});
await const DebugUnpackMacOS().build(environment);
- expect(fs.directory('$_kOutputPrefix').existsSync(), true);
+ expect(globals.fs.directory('$_kOutputPrefix').existsSync(), true);
for (File file in inputs) {
- expect(fs.file(file.path.replaceFirst(_kInputPrefix, _kOutputPrefix)).existsSync(), true);
+ expect(globals.fs.file(file.path.replaceFirst(_kInputPrefix, _kOutputPrefix)).existsSync(), true);
}
}));
test('debug macOS application fails if App.framework missing', () => testbed.run(() async {
- final String inputKernel = fs.path.join(environment.buildDir.path, 'app.dill');
- fs.file(inputKernel)
+ final String inputKernel = globals.fs.path.join(environment.buildDir.path, 'app.dill');
+ globals.fs.file(inputKernel)
..createSync(recursive: true)
..writeAsStringSync('testing');
@@ -131,59 +131,59 @@
}));
test('debug macOS application creates correctly structured framework', () => testbed.run(() async {
- fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
- fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
- fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
+ globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
..createSync(recursive: true);
- final String inputKernel = fs.path.join(environment.buildDir.path, 'app.dill');
- final String outputKernel = fs.path.join('App.framework', 'Versions', 'A', 'Resources',
+ final String inputKernel = globals.fs.path.join(environment.buildDir.path, 'app.dill');
+ final String outputKernel = globals.fs.path.join('App.framework', 'Versions', 'A', 'Resources',
'flutter_assets', 'kernel_blob.bin');
- final String outputPlist = fs.path.join('App.framework', 'Versions', 'A', 'Resources',
+ final String outputPlist = globals.fs.path.join('App.framework', 'Versions', 'A', 'Resources',
'Info.plist');
- fs.file(inputKernel)
+ globals.fs.file(inputKernel)
..createSync(recursive: true)
..writeAsStringSync('testing');
await const DebugMacOSBundleFlutterAssets().build(environment);
- expect(fs.file(outputKernel).readAsStringSync(), 'testing');
- expect(fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app'));
+ expect(globals.fs.file(outputKernel).readAsStringSync(), 'testing');
+ expect(globals.fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app'));
}));
test('release/profile macOS application has no blob or precompiled runtime', () => testbed.run(() async {
- fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
- fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
- fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
+ globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
..createSync(recursive: true);
- final String outputKernel = fs.path.join('App.framework', 'Resources',
+ final String outputKernel = globals.fs.path.join('App.framework', 'Resources',
'flutter_assets', 'kernel_blob.bin');
- final String precompiledVm = fs.path.join('App.framework', 'Resources',
+ final String precompiledVm = globals.fs.path.join('App.framework', 'Resources',
'flutter_assets', 'vm_snapshot_data');
- final String precompiledIsolate = fs.path.join('App.framework', 'Resources',
+ final String precompiledIsolate = globals.fs.path.join('App.framework', 'Resources',
'flutter_assets', 'isolate_snapshot_data');
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
- expect(fs.file(outputKernel).existsSync(), false);
- expect(fs.file(precompiledVm).existsSync(), false);
- expect(fs.file(precompiledIsolate).existsSync(), false);
+ expect(globals.fs.file(outputKernel).existsSync(), false);
+ expect(globals.fs.file(precompiledVm).existsSync(), false);
+ expect(globals.fs.file(precompiledIsolate).existsSync(), false);
}));
test('release/profile macOS application updates when App.framework updates', () => testbed.run(() async {
- fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
- fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
+ globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
- final File inputFramework = fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
+ final File inputFramework = globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
..createSync(recursive: true)
..writeAsStringSync('ABC');
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
- final File outputFramework = fs.file(fs.path.join(environment.outputDir.path, 'App.framework', 'App'));
+ final File outputFramework = globals.fs.file(globals.fs.path.join(environment.outputDir.path, 'App.framework', 'App'));
expect(outputFramework.readAsStringSync(), 'ABC');
@@ -210,7 +210,7 @@
return Future<RunResult>.value(RunResult(FakeProcessResult()..exitCode = 0, <String>['test']));
});
environment.buildDir.childFile('app.dill').createSync(recursive: true);
- fs.file('.packages')
+ globals.fs.file('.packages')
..createSync()
..writeAsStringSync('''
# Generated
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
index d5b1e44..4c3b261 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
@@ -3,15 +3,16 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
-import 'package:flutter_tools/src/base/process_manager.dart';
+
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/depfile.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
import 'package:flutter_tools/src/build_system/targets/web.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../../src/common.dart';
import '../../../src/mocks.dart';
@@ -36,17 +37,17 @@
when(mockWindowsPlatform.isLinux).thenReturn(false);
testbed = Testbed(setup: () {
- final File packagesFile = fs.file(fs.path.join('foo', '.packages'))
+ final File packagesFile = globals.fs.file(globals.fs.path.join('foo', '.packages'))
..createSync(recursive: true)
..writeAsStringSync('foo:lib/\n');
PackageMap.globalPackagesPath = packagesFile.path;
environment = Environment(
- projectDir: fs.currentDirectory.childDirectory('foo'),
- outputDir: fs.currentDirectory,
- buildDir: fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory.childDirectory('foo'),
+ outputDir: globals.fs.currentDirectory,
+ buildDir: globals.fs.currentDirectory,
defines: <String, String>{
- kTargetFile: fs.path.join('foo', 'lib', 'main.dart'),
+ kTargetFile: globals.fs.path.join('foo', 'lib', 'main.dart'),
}
);
environment.buildDir.createSync(recursive: true);
@@ -77,7 +78,7 @@
}));
test('WebEntrypointTarget generates an entrypoint for a file outside of main', () => testbed.run(() async {
- environment.defines[kTargetFile] = fs.path.join('other', 'lib', 'main.dart');
+ environment.defines[kTargetFile] = globals.fs.path.join('other', 'lib', 'main.dart');
await const WebEntrypointTarget().build(environment);
final String generated = environment.buildDir.childFile('main.dart').readAsStringSync();
@@ -166,47 +167,47 @@
test('Dart2JSTarget calls dart2js with expected args in profile mode', () => testbed.run(() async {
environment.defines[kBuildMode] = 'profile';
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
return FakeProcessResult(exitCode: 0);
});
await const Dart2JSTarget().build(environment);
final List<String> expected = <String>[
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
- '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
+ '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
'-O4', // highest optimizations
'--no-minify', // but uses unminified names for debugging
'-o',
environment.buildDir.childFile('main.dart.js').absolute.path,
- '--packages=${fs.path.join('foo', '.packages')}',
+ '--packages=${globals.fs.path.join('foo', '.packages')}',
'-Ddart.vm.profile=true',
environment.buildDir.childFile('main.dart').absolute.path,
];
- verify(processManager.run(expected)).called(1);
+ verify(globals.processManager.run(expected)).called(1);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
}));
test('Dart2JSTarget calls dart2js with expected args in release mode', () => testbed.run(() async {
environment.defines[kBuildMode] = 'release';
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
return FakeProcessResult(exitCode: 0);
});
await const Dart2JSTarget().build(environment);
final List<String> expected = <String>[
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
- '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
+ '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
'-O4', // highest optimizations.
'-o',
environment.buildDir.childFile('main.dart.js').absolute.path,
- '--packages=${fs.path.join('foo', '.packages')}',
+ '--packages=${globals.fs.path.join('foo', '.packages')}',
'-Ddart.vm.product=true',
environment.buildDir.childFile('main.dart').absolute.path,
];
- verify(processManager.run(expected)).called(1);
+ verify(globals.processManager.run(expected)).called(1);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
}));
@@ -214,30 +215,30 @@
test('Dart2JSTarget calls dart2js with expected args in release with dart2js optimization override', () => testbed.run(() async {
environment.defines[kBuildMode] = 'release';
environment.defines[kDart2jsOptimization] = 'O3';
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
return FakeProcessResult(exitCode: 0);
});
await const Dart2JSTarget().build(environment);
final List<String> expected = <String>[
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
- '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
+ '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
'-O3', // configured optimizations.
'-o',
environment.buildDir.childFile('main.dart.js').absolute.path,
- '--packages=${fs.path.join('foo', '.packages')}',
+ '--packages=${globals.fs.path.join('foo', '.packages')}',
'-Ddart.vm.product=true',
environment.buildDir.childFile('main.dart').absolute.path,
];
- verify(processManager.run(expected)).called(1);
+ verify(globals.processManager.run(expected)).called(1);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
}));
test('Dart2JSTarget produces expected depfile', () => testbed.run(() async {
environment.defines[kBuildMode] = 'release';
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
environment.buildDir.childFile('main.dart.js.deps')
..writeAsStringSync('file:///a.dart');
return FakeProcessResult(exitCode: 0);
@@ -247,7 +248,7 @@
expect(environment.buildDir.childFile('dart2js.d').existsSync(), true);
final Depfile depfile = Depfile.parse(environment.buildDir.childFile('dart2js.d'));
- expect(depfile.inputs.single.path, fs.path.absolute('a.dart'));
+ expect(depfile.inputs.single.path, globals.fs.path.absolute('a.dart'));
expect(depfile.outputs.single.path,
environment.buildDir.childFile('main.dart.js').absolute.path);
}, overrides: <Type, Generator>{
@@ -257,25 +258,25 @@
test('Dart2JSTarget calls dart2js with Dart defines in release mode', () => testbed.run(() async {
environment.defines[kBuildMode] = 'release';
environment.defines[kDartDefines] = '["FOO=bar","BAZ=qux"]';
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
return FakeProcessResult(exitCode: 0);
});
await const Dart2JSTarget().build(environment);
final List<String> expected = <String>[
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
- '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
+ '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
'-O4',
'-o',
environment.buildDir.childFile('main.dart.js').absolute.path,
- '--packages=${fs.path.join('foo', '.packages')}',
+ '--packages=${globals.fs.path.join('foo', '.packages')}',
'-Ddart.vm.product=true',
'-DFOO=bar',
'-DBAZ=qux',
environment.buildDir.childFile('main.dart').absolute.path,
];
- verify(processManager.run(expected)).called(1);
+ verify(globals.processManager.run(expected)).called(1);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
}));
@@ -283,26 +284,26 @@
test('Dart2JSTarget calls dart2js with Dart defines in profile mode', () => testbed.run(() async {
environment.defines[kBuildMode] = 'profile';
environment.defines[kDartDefines] = '["FOO=bar","BAZ=qux"]';
- when(processManager.run(any)).thenAnswer((Invocation invocation) async {
+ when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async {
return FakeProcessResult(exitCode: 0);
});
await const Dart2JSTarget().build(environment);
final List<String> expected = <String>[
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
- fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
- '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'),
+ globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'),
+ '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'),
'-O4',
'--no-minify',
'-o',
environment.buildDir.childFile('main.dart.js').absolute.path,
- '--packages=${fs.path.join('foo', '.packages')}',
+ '--packages=${globals.fs.path.join('foo', '.packages')}',
'-Ddart.vm.profile=true',
'-DFOO=bar',
'-DBAZ=qux',
environment.buildDir.childFile('main.dart').absolute.path,
];
- verify(processManager.run(expected)).called(1);
+ verify(globals.processManager.run(expected)).called(1);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
}));
@@ -323,7 +324,7 @@
}
// Should not attempt to run any processes.
- verifyNever(processManager.run(any));
+ verifyNever(globals.processManager.run(any));
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
}));
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart
index 4e28a9e..acce757 100644
--- a/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart
+++ b/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart
@@ -4,11 +4,13 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/windows.dart';
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
import '../../../src/common.dart';
import '../../../src/fake_process_manager.dart';
@@ -33,23 +35,23 @@
when(platform.pathSeparator).thenReturn(r'\');
testbed = Testbed(setup: () {
environment = Environment(
- outputDir: fs.currentDirectory,
- projectDir: fs.currentDirectory,
+ outputDir: globals.fs.currentDirectory,
+ projectDir: globals.fs.currentDirectory,
);
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').createSync(recursive: true);
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.exp').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.lib').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.pdb').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\lutter_export.h').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_plugin_registrar.h').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.h').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\icudtl.dat').createSync();
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\cpp_client_wrapper\foo').createSync(recursive: true);
- fs.file(r'C:\packages\flutter_tools\lib\src\build_system\targets\windows.dart').createSync(recursive: true);
- fs.directory('windows').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').createSync(recursive: true);
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.exp').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.lib').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.pdb').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\lutter_export.h').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_plugin_registrar.h').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.h').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\icudtl.dat').createSync();
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\cpp_client_wrapper\foo').createSync(recursive: true);
+ globals.fs.file(r'C:\packages\flutter_tools\lib\src\build_system\targets\windows.dart').createSync(recursive: true);
+ globals.fs.directory('windows').createSync();
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
ProcessManager: () => FakeProcessManager.any(),
@@ -60,18 +62,18 @@
test('Copies files to correct cache directory', () => testbed.run(() async {
await buildSystem.build(const UnpackWindows(), environment);
- expect(fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_windows.dll').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_windows.dll.exp').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_windows.dll.lib').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_windows.dll.pdb').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_plugin_registrar.h').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\flutter_windows.h').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\icudtl.dat').existsSync(), true);
- expect(fs.file(r'C:\windows\flutter\cpp_client_wrapper\foo').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll.exp').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll.lib').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll.pdb').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_plugin_registrar.h').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.h').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\icudtl.dat').existsSync(), true);
+ expect(globals.fs.file(r'C:\windows\flutter\cpp_client_wrapper\foo').existsSync(), true);
}));
test('Does not re-copy files unecessarily', () => testbed.run(() async {
@@ -79,10 +81,10 @@
// Set a date in the far distant past to deal with the limited resolution
// of the windows filesystem.
final DateTime theDistantPast = DateTime(1991, 8, 23);
- fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast);
+ globals.fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast);
await buildSystem.build(const UnpackWindows(), environment);
- expect(fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, equals(theDistantPast));
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, equals(theDistantPast));
}));
test('Detects changes in input cache files', () => testbed.run(() async {
@@ -90,13 +92,13 @@
// Set a date in the far distant past to deal with the limited resolution
// of the windows filesystem.
final DateTime theDistantPast = DateTime(1991, 8, 23);
- fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast);
- final DateTime modified = fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified;
- fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').writeAsStringSync('asd'); // modify cache.
+ globals.fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast);
+ final DateTime modified = globals.fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified;
+ globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').writeAsStringSync('asd'); // modify cache.
await buildSystem.build(const UnpackWindows(), environment);
- expect(fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, isNot(modified));
+ expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, isNot(modified));
}));
}
diff --git a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart
index b4c1376..706bf73 100644
--- a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart
+++ b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart
@@ -3,11 +3,11 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/common.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/bundle.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../src/common.dart';
@@ -35,15 +35,15 @@
await buildWithAssemble(
buildMode: BuildMode.debug,
flutterProject: FlutterProject.current(),
- mainPath: fs.path.join('lib', 'main.dart'),
+ mainPath: globals.fs.path.join('lib', 'main.dart'),
outputDir: 'example',
targetPlatform: TargetPlatform.ios,
depfilePath: 'example.d',
precompiled: false,
);
- expect(fs.file(fs.path.join('example', 'kernel_blob.bin')).existsSync(), true);
- expect(fs.file(fs.path.join('example', 'LICENSE')).existsSync(), true);
- expect(fs.file(fs.path.join('example.d')).existsSync(), false);
+ expect(globals.fs.file(globals.fs.path.join('example', 'kernel_blob.bin')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('example', 'LICENSE')).existsSync(), true);
+ expect(globals.fs.file(globals.fs.path.join('example.d')).existsSync(), false);
}));
test('Handles build system failure', () => testbed.run(() {
diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart
index f77cf52..c0aaf67 100644
--- a/packages/flutter_tools/test/general.shard/cache_test.dart
+++ b/packages/flutter_tools/test/general.shard/cache_test.dart
@@ -5,7 +5,7 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
@@ -19,6 +19,7 @@
import 'package:flutter_tools/src/base/io.dart' show InternetAddress, SocketException;
import 'package:flutter_tools/src/base/net.dart';
import 'package:flutter_tools/src/base/os.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/context.dart';
@@ -94,8 +95,8 @@
});
testUsingContext('Continues on failed delete', () async {
- final Directory artifactDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
- final Directory downloadDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_download.');
+ final Directory artifactDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
+ final Directory downloadDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_download.');
when(mockCache.getArtifactDirectory(any)).thenReturn(artifactDir);
when(mockCache.getDownloadDir()).thenReturn(downloadDir);
final File mockFile = MockFile();
@@ -116,10 +117,10 @@
testUsingContext('Gradle wrapper should not be up to date, if some cached artifact is not available', () {
final GradleWrapper gradleWrapper = GradleWrapper(mockCache);
- final Directory directory = fs.directory('/Applications/flutter/bin/cache');
+ final Directory directory = globals.fs.directory('/Applications/flutter/bin/cache');
directory.createSync(recursive: true);
- fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true);
- when(mockCache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(fs.directory(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper')));
+ globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true);
+ when(mockCache.getCacheDir(globals.fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(globals.fs.directory(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper')));
expect(gradleWrapper.isUpToDateInner(), false);
}, overrides: <Type, Generator>{
Cache: () => mockCache,
@@ -129,13 +130,13 @@
testUsingContext('Gradle wrapper should be up to date, only if all cached artifact are available', () {
final GradleWrapper gradleWrapper = GradleWrapper(mockCache);
- final Directory directory = fs.directory('/Applications/flutter/bin/cache');
+ final Directory directory = globals.fs.directory('/Applications/flutter/bin/cache');
directory.createSync(recursive: true);
- fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true);
- fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew')).createSync(recursive: true);
- fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew.bat')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew.bat')).createSync(recursive: true);
- when(mockCache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(fs.directory(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper')));
+ when(mockCache.getCacheDir(globals.fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(globals.fs.directory(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper')));
expect(gradleWrapper.isUpToDateInner(), true);
}, overrides: <Type, Generator>{
Cache: () => mockCache,
@@ -226,7 +227,7 @@
});
testUsingContext('Invalid URI for FLUTTER_STORAGE_BASE_URL throws ToolExit', () async {
- when(platform.environment).thenReturn(const <String, String>{
+ when(globals.platform.environment).thenReturn(const <String, String>{
'FLUTTER_STORAGE_BASE_URL': ' http://foo',
});
final Cache cache = Cache();
@@ -271,8 +272,8 @@
});
testUsingContext('makes binary dirs readable and executable by all', () async {
- final Directory artifactDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
- final Directory downloadDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_download.');
+ final Directory artifactDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
+ final Directory downloadDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_download.');
when(mockCache.getArtifactDirectory(any)).thenReturn(artifactDir);
when(mockCache.getDownloadDir()).thenReturn(downloadDir);
final FakeCachedArtifact artifact = FakeCachedArtifact(
@@ -320,15 +321,15 @@
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts();
expect(mavenArtifacts.isUpToDate(), isFalse);
- final Directory gradleWrapperDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_gradle_wrapper.');
+ final Directory gradleWrapperDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_gradle_wrapper.');
when(mockCache.getArtifactDirectory('gradle_wrapper')).thenReturn(gradleWrapperDir);
- fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper'))
+ globals.fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper'))
.createSync(recursive: true);
- fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant');
- fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant');
+ globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant');
+ globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant');
- when(processManager.run(any, environment: captureAnyNamed('environment')))
+ when(globals.processManager.run(any, environment: captureAnyNamed('environment')))
.thenAnswer((Invocation invocation) {
final List<String> args = invocation.positionalArguments[0] as List<String>;
expect(args.length, 6);
@@ -358,7 +359,7 @@
testUsingContext('verifies executables for libimobiledevice in isUpToDateInner', () async {
final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('libimobiledevice', mockCache);
- when(mockCache.getArtifactDirectory(any)).thenReturn(fs.currentDirectory);
+ when(mockCache.getArtifactDirectory(any)).thenReturn(globals.fs.currentDirectory);
iosUsbArtifacts.location.createSync();
final File ideviceIdFile = iosUsbArtifacts.location.childFile('idevice_id')
..createSync();
@@ -378,7 +379,7 @@
testUsingContext('Does not verify executables for openssl in isUpToDateInner', () async {
final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('openssl', mockCache);
- when(mockCache.getArtifactDirectory(any)).thenReturn(fs.currentDirectory);
+ when(mockCache.getArtifactDirectory(any)).thenReturn(globals.fs.currentDirectory);
iosUsbArtifacts.location.createSync();
expect(iosUsbArtifacts.isUpToDateInner(), true);
@@ -427,7 +428,7 @@
mockPackageResolver.resolveUrl('fuchsia-debug-symbols-arm64', any),
]);
});
- }, skip: !platform.isLinux);
+ }, skip: !globals.platform.isLinux);
}
class FakeCachedArtifact extends EngineCachedArtifact {
diff --git a/packages/flutter_tools/test/general.shard/channel_test.dart b/packages/flutter_tools/test/general.shard/channel_test.dart
index dbd87fa..51e7cb5 100644
--- a/packages/flutter_tools/test/general.shard/channel_test.dart
+++ b/packages/flutter_tools/test/general.shard/channel_test.dart
@@ -9,6 +9,7 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/commands/channel.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
@@ -180,7 +181,7 @@
environment: anyNamed('environment'),
)).thenAnswer((_) => Future<Process>.value(createMockProcess()));
- final File versionCheckFile = Cache.instance.getStampFileFor(
+ final File versionCheckFile = globals.cache.getStampFileFor(
VersionCheckStamp.flutterVersionCheckStampFile,
);
diff --git a/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart b/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart
index 303dcd0..cfb15a4 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart
@@ -12,6 +12,7 @@
import 'package:flutter_tools/src/commands/build_aar.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -27,7 +28,7 @@
Directory tempDir;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
});
tearDown(() {
@@ -94,7 +95,7 @@
mockUsage = MockUsage();
when(mockUsage.isFirstRun).thenReturn(true);
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
mockProcessManager = MockProcessManager();
when(mockProcessManager.run(any,
@@ -149,7 +150,7 @@
arguments: <String>['--no-pub'],
);
}, throwsToolExit(
- message: '[!] No Android SDK found. Try setting the ANDROID_HOME environment variable',
+ message: 'No Android SDK found. Try setting the ANDROID_HOME environment variable',
));
},
overrides: <Type, Generator>{
@@ -171,7 +172,7 @@
'aar',
'--no-pub',
...?arguments,
- fs.path.join(target, 'lib', 'main.dart'),
+ globals.fs.path.join(target, 'lib', 'main.dart'),
]);
return command;
}
diff --git a/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart b/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
index 88900ab..50569cb 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
@@ -9,11 +9,12 @@
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_apk.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -29,7 +30,7 @@
Directory tempDir;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
});
tearDown(() {
@@ -104,9 +105,9 @@
mockUsage = MockUsage();
when(mockUsage.isFirstRun).thenReturn(true);
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
- gradlew = fs.path.join(tempDir.path, 'flutter_project', 'android',
- platform.isWindows ? 'gradlew.bat' : 'gradlew');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', 'android',
+ globals.platform.isWindows ? 'gradlew.bat' : 'gradlew');
mockProcessManager = MockProcessManager();
when(mockProcessManager.run(<String>[gradlew, '-v'],
@@ -170,7 +171,7 @@
arguments: <String>['--no-pub'],
);
}, throwsToolExit(
- message: '[!] No Android SDK found. Try setting the ANDROID_HOME environment variable',
+ message: 'No Android SDK found. Try setting the ANDROID_HOME environment variable',
));
},
overrides: <Type, Generator>{
@@ -192,7 +193,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -223,7 +224,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleRelease',
@@ -246,7 +247,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -301,7 +302,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -352,7 +353,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=true',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -409,7 +410,7 @@
'apk',
...?arguments,
'--no-pub',
- fs.path.join(target, 'lib', 'main.dart'),
+ globals.fs.path.join(target, 'lib', 'main.dart'),
]);
return command;
}
diff --git a/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart b/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
index bccbd0d..fc48b8d 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
@@ -9,11 +9,12 @@
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_appbundle.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -29,7 +30,7 @@
Directory tempDir;
setUp(() {
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
});
tearDown(() {
@@ -83,14 +84,13 @@
String gradlew;
Usage mockUsage;
-
setUp(() {
mockUsage = MockUsage();
when(mockUsage.isFirstRun).thenReturn(true);
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
- gradlew = fs.path.join(tempDir.path, 'flutter_project', 'android',
- platform.isWindows ? 'gradlew.bat' : 'gradlew');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
+ gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', 'android',
+ globals.platform.isWindows ? 'gradlew.bat' : 'gradlew');
mockProcessManager = MockProcessManager();
when(mockProcessManager.run(<String>[gradlew, '-v'],
@@ -155,7 +155,7 @@
arguments: <String>['--no-pub'],
);
}, throwsToolExit(
- message: '[!] No Android SDK found. Try setting the ANDROID_HOME environment variable',
+ message: 'No Android SDK found. Try setting the ANDROID_HOME environment variable',
));
},
overrides: <Type, Generator>{
@@ -179,7 +179,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -212,7 +212,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'bundleRelease',
@@ -235,7 +235,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -290,7 +290,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -341,7 +341,7 @@
<String>[
gradlew,
'-q',
- '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
+ '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
'-Ptrack-widget-creation=false',
'-Pshrink=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
@@ -398,7 +398,7 @@
'appbundle',
...?arguments,
'--no-pub',
- fs.path.join(target, 'lib', 'main.dart'),
+ globals.fs.path.join(target, 'lib', 'main.dart'),
]);
return command;
}
diff --git a/packages/flutter_tools/test/general.shard/compile_batch_test.dart b/packages/flutter_tools/test/general.shard/compile_batch_test.dart
index 4b498a3..adf6027 100644
--- a/packages/flutter_tools/test/general.shard/compile_batch_test.dart
+++ b/packages/flutter_tools/test/general.shard/compile_batch_test.dart
@@ -5,13 +5,14 @@
import 'dart:async';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../src/common.dart';
import '../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/compile_expression_test.dart b/packages/flutter_tools/test/general.shard/compile_expression_test.dart
index fbb654b..eaa7f25 100644
--- a/packages/flutter_tools/test/general.shard/compile_expression_test.dart
+++ b/packages/flutter_tools/test/general.shard/compile_expression_test.dart
@@ -7,13 +7,13 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../src/common.dart';
import '../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart
index f11e9c6..9279c8b 100644
--- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart
+++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart
@@ -7,13 +7,13 @@
import 'package:flutter_tools/src/base/async_guard.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../src/common.dart';
import '../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/crash_reporting_test.dart b/packages/flutter_tools/test/general.shard/crash_reporting_test.dart
index 134a914..7a86004 100644
--- a/packages/flutter_tools/test/general.shard/crash_reporting_test.dart
+++ b/packages/flutter_tools/test/general.shard/crash_reporting_test.dart
@@ -12,14 +12,15 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:http/http.dart';
import 'package:http/testing.dart';
import 'package:quiver/testing/async.dart';
+import 'package:platform/platform.dart';
import '../src/common.dart';
import '../src/context.dart';
@@ -251,7 +252,7 @@
expect(crashInfo.fields['uuid'], '00000000-0000-4000-0000-000000000000');
expect(crashInfo.fields['product'], 'Flutter_Tools');
expect(crashInfo.fields['version'], 'test-version');
- expect(crashInfo.fields['osName'], platform.operatingSystem);
+ expect(crashInfo.fields['osName'], globals.platform.operatingSystem);
expect(crashInfo.fields['osVersion'], 'fake OS name and version');
expect(crashInfo.fields['type'], 'DartError');
expect(crashInfo.fields['error_runtime_type'], 'StateError');
diff --git a/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart b/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
index 8b5eae7..3e6911c 100644
--- a/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
+++ b/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
@@ -11,15 +11,16 @@
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:quiver/testing/async.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -258,7 +259,7 @@
'--no-precompile',
],
onRun: () {
- fs.file('.packages')
+ globals.fs.file('.packages')
..setLastModifiedSync(DateTime(2002));
}
),
@@ -278,7 +279,7 @@
'--no-precompile',
],
onRun: () {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..setLastModifiedSync(DateTime(2002));
}
),
@@ -293,35 +294,35 @@
]);
await Testbed().run(() async {
// the good scenario: .packages is old, pub updates the file.
- fs.file('.packages')
+ globals.fs.file('.packages')
..createSync()
..setLastModifiedSync(DateTime(2000));
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..setLastModifiedSync(DateTime(2001));
await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub sets date of .packages to 2002
expect(testLogger.statusText, 'Running "flutter pub get" in /...\n');
expect(testLogger.errorText, isEmpty);
- expect(fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
- expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because pub changes it to 2002
- expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // because we set the timestamp again after pub
+ expect(globals.fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
+ expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because pub changes it to 2002
+ expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // because we set the timestamp again after pub
testLogger.clear();
// bad scenario 1: pub doesn't update file; doesn't matter, because we do instead
- fs.file('.packages')
+ globals.fs.file('.packages')
..setLastModifiedSync(DateTime(2000));
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..setLastModifiedSync(DateTime(2001));
await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub does nothing
expect(testLogger.statusText, 'Running "flutter pub get" in /...\n');
expect(testLogger.errorText, isEmpty);
- expect(fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
- expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because we set the timestamp
- expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // just in case FakeProcessManager is buggy
+ expect(globals.fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
+ expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because we set the timestamp
+ expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // just in case FakeProcessManager is buggy
testLogger.clear();
// bad scenario 2: pub changes pubspec.yaml instead
- fs.file('.packages')
+ globals.fs.file('.packages')
..setLastModifiedSync(DateTime(2000));
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..setLastModifiedSync(DateTime(2001));
try {
await pub.get(context: PubContext.flutterTests, checkLastModified: true);
@@ -332,12 +333,12 @@
}
expect(testLogger.statusText, 'Running "flutter pub get" in /...\n');
expect(testLogger.errorText, isEmpty);
- expect(fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2002)); // because fake pub above touched it
- expect(fs.file('.packages').lastModifiedSync(), DateTime(2000)); // because nothing touched it
+ expect(globals.fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2002)); // because fake pub above touched it
+ expect(globals.fs.file('.packages').lastModifiedSync(), DateTime(2000)); // because nothing touched it
// bad scenario 3: pubspec.yaml was created in the future
- fs.file('.packages')
+ globals.fs.file('.packages')
..setLastModifiedSync(DateTime(2000));
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..setLastModifiedSync(DateTime(9999));
assert(DateTime(9999).isAfter(DateTime.now()));
await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub does nothing
diff --git a/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart b/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart
index 90f3535..9d864c1 100644
--- a/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart
+++ b/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart
@@ -9,6 +9,7 @@
import 'package:flutter_tools/src/dart/analysis.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -23,10 +24,10 @@
void testSampleProject(String lib, String member) {
testUsingContext('contains dart:$lib', () async {
Cache.disableLocking();
- final Directory projectDirectory = fs.systemTempDirectory.createTempSync('flutter_sdk_validation_${lib}_test.').absolute;
+ final Directory projectDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_sdk_validation_${lib}_test.').absolute;
try {
- final File pubspecFile = fs.file(fs.path.join(projectDirectory.path, 'pubspec.yaml'));
+ final File pubspecFile = globals.fs.file(globals.fs.path.join(projectDirectory.path, 'pubspec.yaml'));
pubspecFile.writeAsStringSync('''
name: ${lib}_project
dependencies:
@@ -34,7 +35,7 @@
sdk: flutter
''');
- final File dartFile = fs.file(fs.path.join(projectDirectory.path, 'lib', 'main.dart'));
+ final File dartFile = globals.fs.file(globals.fs.path.join(projectDirectory.path, 'lib', 'main.dart'));
dartFile.parent.createSync();
dartFile.writeAsStringSync('''
import 'dart:$lib' as $lib;
diff --git a/packages/flutter_tools/test/general.shard/devfs_test.dart b/packages/flutter_tools/test/general.shard/devfs_test.dart
index ce6e0e5..f56b6f0 100644
--- a/packages/flutter_tools/test/general.shard/devfs_test.dart
+++ b/packages/flutter_tools/test/general.shard/devfs_test.dart
@@ -14,6 +14,7 @@
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/vmservice.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:mockito/mockito.dart';
@@ -29,7 +30,7 @@
setUpAll(() {
fs = MemoryFileSystem();
- filePath = fs.path.join('lib', 'foo.txt');
+ filePath = globals.fs.path.join('lib', 'foo.txt');
});
group('DevFSContent', () {
@@ -61,7 +62,7 @@
expect(content.isModified, isFalse);
});
testUsingContext('file', () async {
- final File file = fs.file(filePath);
+ final File file = globals.fs.file(filePath);
final DevFSFileContent content = DevFSFileContent(file);
expect(content.isModified, isFalse);
expect(content.isModified, isFalse);
@@ -110,7 +111,7 @@
});
testUsingContext('retry uploads when failure', () async {
- final File file = fs.file(fs.path.join(basePath, filePath));
+ final File file = globals.fs.file(globals.fs.path.join(basePath, filePath));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3]);
// simulate package
@@ -188,7 +189,7 @@
testUsingContext('create dev file system', () async {
// simulate workspace
- final File file = fs.file(fs.path.join(basePath, filePath));
+ final File file = globals.fs.file(globals.fs.path.join(basePath, filePath));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3]);
@@ -230,7 +231,7 @@
testUsingContext('cleanup preexisting file system', () async {
// simulate workspace
- final File file = fs.file(fs.path.join(basePath, filePath));
+ final File file = globals.fs.file(globals.fs.path.join(basePath, filePath));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3]);
@@ -297,7 +298,7 @@
outputPath: anyNamed('outputPath'),
packagesFilePath: anyNamed('packagesFilePath'),
)).thenAnswer((Invocation invocation) {
- fs.file('example').createSync();
+ globals.fs.file('example').createSync();
return Future<CompilerOutput>.value(CompilerOutput('example', 0, <Uri>[sourceFile.uri]));
});
@@ -417,7 +418,7 @@
final Map <String, Uri> _packages = <String, Uri>{};
Directory _newTempDir(FileSystem fs) {
- final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_devfs${_tempDirs.length}_test.');
+ final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_devfs${_tempDirs.length}_test.');
_tempDirs.add(tempDir);
return tempDir;
}
@@ -430,21 +431,21 @@
Future<File> _createPackage(FileSystem fs, String pkgName, String pkgFileName, { bool doubleSlash = false }) async {
final Directory pkgTempDir = _newTempDir(fs);
- String pkgFilePath = fs.path.join(pkgTempDir.path, pkgName, 'lib', pkgFileName);
+ String pkgFilePath = globals.fs.path.join(pkgTempDir.path, pkgName, 'lib', pkgFileName);
if (doubleSlash) {
// Force two separators into the path.
- final String doubleSlash = fs.path.separator + fs.path.separator;
- pkgFilePath = pkgTempDir.path + doubleSlash + fs.path.join(pkgName, 'lib', pkgFileName);
+ final String doubleSlash = globals.fs.path.separator + globals.fs.path.separator;
+ pkgFilePath = pkgTempDir.path + doubleSlash + globals.fs.path.join(pkgName, 'lib', pkgFileName);
}
- final File pkgFile = fs.file(pkgFilePath);
+ final File pkgFile = globals.fs.file(pkgFilePath);
await pkgFile.parent.create(recursive: true);
pkgFile.writeAsBytesSync(<int>[11, 12, 13]);
- _packages[pkgName] = fs.path.toUri(pkgFile.parent.path);
+ _packages[pkgName] = globals.fs.path.toUri(pkgFile.parent.path);
final StringBuffer sb = StringBuffer();
_packages.forEach((String pkgName, Uri pkgUri) {
sb.writeln('$pkgName:$pkgUri');
});
- return fs.file(fs.path.join(_tempDirs[0].path, '.packages'))
+ return globals.fs.file(globals.fs.path.join(_tempDirs[0].path, '.packages'))
..writeAsStringSync(sb.toString());
}
diff --git a/packages/flutter_tools/test/general.shard/features_test.dart b/packages/flutter_tools/test/general.shard/features_test.dart
index 5891260..8dea6b0 100644
--- a/packages/flutter_tools/test/general.shard/features_test.dart
+++ b/packages/flutter_tools/test/general.shard/features_test.dart
@@ -4,9 +4,9 @@
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/features.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
import '../src/common.dart';
import '../src/testbed.dart';
diff --git a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart
index 26d00d6..fb9f9f1 100644
--- a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart
+++ b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart
@@ -5,10 +5,10 @@
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/test/flutter_platform.dart';
import 'package:meta/meta.dart';
+import 'package:platform/platform.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:test_core/backend.dart'; // ignore: deprecated_member_use
diff --git a/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart b/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart
index bd74954..dce6b55 100644
--- a/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart
+++ b/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart
@@ -3,20 +3,21 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
void main() {
- final String flutterTools = fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools');
+ final String flutterTools = globals.fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools');
test('no imports of commands/* or test/* in lib/src/*', () {
final List<String> skippedPaths = <String> [
- fs.path.join(flutterTools, 'lib', 'src', 'commands'),
- fs.path.join(flutterTools, 'lib', 'src', 'test'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'commands'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'test'),
];
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
- final Iterable<File> files = fs.directory(fs.path.join(flutterTools, 'lib', 'src'))
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, 'lib', 'src'))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotSkipped)
@@ -28,7 +29,7 @@
}
if (line.startsWith(RegExp(r'import.*commands/'))
|| line.startsWith(RegExp(r'import.*test/'))) {
- final String relativePath = fs.path.relative(file.path, from:flutterTools);
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
fail('$relativePath imports $line. This import introduces a layering violation. '
'Please find another way to access the information you are using.');
}
@@ -36,15 +37,36 @@
}
});
+ test('no imports of globals without a global prefix', () {
+ final List<String> skippedPaths = <String> [];
+ bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
+
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, 'lib', 'src'))
+ .listSync(recursive: true)
+ .followedBy(globals.fs.directory(globals.fs.path.join(flutterTools, 'test',)).listSync(recursive: true))
+ .where(_isDartFile)
+ .where(_isNotSkipped)
+ .map(_asFile);
+ for (File file in files) {
+ for (String line in file.readAsLinesSync()) {
+ if (line.startsWith(RegExp(r'import.*globals.dart'))
+ && !line.contains(r'as globals')) {
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
+ fail('$relativePath imports globals.dart without a globals prefix.');
+ }
+ }
+ }
+ });
+
test('no unauthorized imports of dart:io', () {
final List<String> whitelistedPaths = <String>[
- fs.path.join(flutterTools, 'lib', 'src', 'base', 'io.dart'),
- fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'io.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'),
];
bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => path != entity.path);
for (String dirName in <String>['lib', 'bin']) {
- final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotWhitelisted)
@@ -53,7 +75,7 @@
for (String line in file.readAsLinesSync()) {
if (line.startsWith(RegExp(r'import.*dart:io')) &&
!line.contains('ignore: dart_io_import')) {
- final String relativePath = fs.path.relative(file.path, from:flutterTools);
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead");
}
}
@@ -63,15 +85,15 @@
test('no unauthorized imports of test_api', () {
final List<String> whitelistedPaths = <String>[
- fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'build_script.dart'),
- fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_platform.dart'),
- fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'),
- fs.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'build_script.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_platform.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'),
];
bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => path != entity.path);
for (String dirName in <String>['lib']) {
- final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotWhitelisted)
@@ -80,7 +102,7 @@
for (String line in file.readAsLinesSync()) {
if (line.startsWith(RegExp(r'import.*package:test_api')) &&
!line.contains('ignore: test_api_import')) {
- final String relativePath = fs.path.relative(file.path, from:flutterTools);
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
fail("$relativePath imports 'package:test_api/test_api.dart';");
}
}
@@ -89,9 +111,9 @@
});
test('no unauthorized imports of package:path', () {
- final String whitelistedPath = fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'web_compilation_delegate.dart');
+ final String whitelistedPath = globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'web_compilation_delegate.dart');
for (String dirName in <String>['lib', 'bin', 'test']) {
- final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where((FileSystemEntity entity) => entity.path != whitelistedPath)
@@ -100,8 +122,8 @@
for (String line in file.readAsLinesSync()) {
if (line.startsWith(RegExp(r'import.*package:path/path.dart')) &&
!line.contains('ignore: package_path_import')) {
- final String relativePath = fs.path.relative(file.path, from:flutterTools);
- fail("$relativePath imports 'package:path/path.dart'; use 'fs.path' instead");
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
+ fail("$relativePath imports 'package:path/path.dart'; use 'globals.fs.path' instead");
}
}
}
@@ -110,13 +132,13 @@
test('no unauthorized imports of dart:convert', () {
final List<String> whitelistedPaths = <String>[
- fs.path.join(flutterTools, 'lib', 'src', 'convert.dart'),
- fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'convert.dart'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'),
];
bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => path != entity.path);
for (String dirName in <String>['lib']) {
- final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotWhitelisted)
@@ -125,7 +147,7 @@
for (String line in file.readAsLinesSync()) {
if (line.startsWith(RegExp(r'import.*dart:convert')) &&
!line.contains('ignore: dart_convert_import')) {
- final String relativePath = fs.path.relative(file.path, from:flutterTools);
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
fail("$relativePath imports 'dart:convert'; import 'lib/src/convert.dart' instead");
}
}
@@ -135,14 +157,14 @@
test('no unauthorized imports of build_runner', () {
final List<String> whitelistedPaths = <String>[
- fs.path.join(flutterTools, 'test', 'src', 'build_runner'),
- fs.path.join(flutterTools, 'lib', 'src', 'build_runner'),
- fs.path.join(flutterTools, 'lib', 'executable.dart'),
+ globals.fs.path.join(flutterTools, 'test', 'src', 'build_runner'),
+ globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner'),
+ globals.fs.path.join(flutterTools, 'lib', 'executable.dart'),
];
bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => !entity.path.contains(path));
for (String dirName in <String>['lib']) {
- final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName))
+ final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotWhitelisted)
@@ -153,7 +175,7 @@
line.startsWith(RegExp(r'import.*package:build_runner/build_runner.dart')) ||
line.startsWith(RegExp(r'import.*package:build_config/build_config.dart')) ||
line.startsWith(RegExp(r'import.*build_runner/.*.dart'))) {
- final String relativePath = fs.path.relative(file.path, from:flutterTools);
+ final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
fail('$relativePath imports a build_runner package');
}
}
diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
index d009ea3..d5b4e58 100644
--- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
@@ -25,7 +25,7 @@
import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
import 'package:flutter_tools/src/fuchsia/tiles_ctl.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:meta/meta.dart';
@@ -81,8 +81,8 @@
testUsingContext('default capabilities', () async {
final FuchsiaDevice device = FuchsiaDevice('123');
- fs.directory('fuchsia').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
+ globals.fs.directory('fuchsia').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
expect(device.supportsHotReload, true);
expect(device.supportsHotRestart, false);
@@ -95,8 +95,8 @@
testUsingContext('supported for project', () async {
final FuchsiaDevice device = FuchsiaDevice('123');
- fs.directory('fuchsia').createSync(recursive: true);
- fs.file('pubspec.yaml').createSync();
+ globals.fs.directory('fuchsia').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
expect(device.isSupportedForProject(FlutterProject.current()), true);
}, overrides: <Type, Generator>{
FileSystem: () => memoryFileSystem,
@@ -105,7 +105,7 @@
testUsingContext('not supported for project', () async {
final FuchsiaDevice device = FuchsiaDevice('123');
- fs.file('pubspec.yaml').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
expect(device.isSupportedForProject(FlutterProject.current()), false);
}, overrides: <Type, Generator>{
FileSystem: () => memoryFileSystem,
@@ -391,28 +391,28 @@
});
testUsingContext('Correct flutter runner', () async {
- expect(artifacts.getArtifactPath(
+ expect(globals.artifacts.getArtifactPath(
Artifact.fuchsiaFlutterRunner,
platform: TargetPlatform.fuchsia_x64,
mode: BuildMode.debug,
),
contains('flutter_jit_runner'),
);
- expect(artifacts.getArtifactPath(
+ expect(globals.artifacts.getArtifactPath(
Artifact.fuchsiaFlutterRunner,
platform: TargetPlatform.fuchsia_x64,
mode: BuildMode.profile,
),
contains('flutter_aot_runner'),
);
- expect(artifacts.getArtifactPath(
+ expect(globals.artifacts.getArtifactPath(
Artifact.fuchsiaFlutterRunner,
platform: TargetPlatform.fuchsia_x64,
mode: BuildMode.release,
),
contains('flutter_aot_product_runner'),
);
- expect(artifacts.getArtifactPath(
+ expect(globals.artifacts.getArtifactPath(
Artifact.fuchsiaFlutterRunner,
platform: TargetPlatform.fuchsia_x64,
mode: BuildMode.jitRelease,
@@ -475,20 +475,20 @@
}) async {
const String appName = 'app_name';
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123');
- fs.directory('fuchsia').createSync(recursive: true);
- final File pubspecFile = fs.file('pubspec.yaml')..createSync();
+ globals.fs.directory('fuchsia').createSync(recursive: true);
+ final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
FuchsiaApp app;
if (prebuilt) {
- final File far = fs.file('app_name-0.far')..createSync();
+ final File far = globals.fs.file('app_name-0.far')..createSync();
app = FuchsiaApp.fromPrebuiltApp(far);
} else {
- fs.file(fs.path.join('fuchsia', 'meta', '$appName.cmx'))
+ globals.fs.file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx'))
..createSync(recursive: true)
..writeAsStringSync('{}');
- fs.file('.packages').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file('.packages').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
app = BuildableFuchsiaApp(project: FlutterProject.current().fuchsia);
}
@@ -518,10 +518,10 @@
testUsingContext('start and stop prebuilt in release mode', () async {
const String appName = 'app_name';
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123');
- fs.directory('fuchsia').createSync(recursive: true);
- final File pubspecFile = fs.file('pubspec.yaml')..createSync();
+ globals.fs.directory('fuchsia').createSync(recursive: true);
+ final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
- final File far = fs.file('app_name-0.far')..createSync();
+ final File far = globals.fs.file('app_name-0.far')..createSync();
final FuchsiaApp app = FuchsiaApp.fromPrebuiltApp(far);
final DebuggingOptions debuggingOptions =
@@ -983,11 +983,11 @@
@override
Future<bool> init(String buildPath, String appName) async {
- if (!fs.directory(buildPath).existsSync()) {
+ if (!globals.fs.directory(buildPath).existsSync()) {
return false;
}
- fs
- .file(fs.path.join(buildPath, 'meta', 'package'))
+ globals.fs
+ .file(globals.fs.path.join(buildPath, 'meta', 'package'))
.createSync(recursive: true);
_appName = appName;
return true;
@@ -995,43 +995,43 @@
@override
Future<bool> genkey(String buildPath, String outKeyPath) async {
- if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync()) {
+ if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync()) {
return false;
}
- fs.file(outKeyPath).createSync(recursive: true);
+ globals.fs.file(outKeyPath).createSync(recursive: true);
return true;
}
@override
Future<bool> build(String buildPath, String keyPath, String manifestPath) async {
- if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
- !fs.file(keyPath).existsSync() ||
- !fs.file(manifestPath).existsSync()) {
+ if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
+ !globals.fs.file(keyPath).existsSync() ||
+ !globals.fs.file(manifestPath).existsSync()) {
return false;
}
- fs.file(fs.path.join(buildPath, 'meta.far')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(buildPath, 'meta.far')).createSync(recursive: true);
return true;
}
@override
Future<bool> archive(String buildPath, String keyPath, String manifestPath) async {
- if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
- !fs.file(keyPath).existsSync() ||
- !fs.file(manifestPath).existsSync()) {
+ if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() ||
+ !globals.fs.file(keyPath).existsSync() ||
+ !globals.fs.file(manifestPath).existsSync()) {
return false;
}
if (_appName == null) {
return false;
}
- fs
- .file(fs.path.join(buildPath, '$_appName-0.far'))
+ globals.fs
+ .file(globals.fs.path.join(buildPath, '$_appName-0.far'))
.createSync(recursive: true);
return true;
}
@override
Future<bool> newrepo(String repoPath) async {
- if (!fs.directory(repoPath).existsSync()) {
+ if (!globals.fs.directory(repoPath).existsSync()) {
return false;
}
return true;
@@ -1044,10 +1044,10 @@
@override
Future<bool> publish(String repoPath, String packagePath) async {
- if (!fs.directory(repoPath).existsSync()) {
+ if (!globals.fs.directory(repoPath).existsSync()) {
return false;
}
- if (!fs.file(packagePath).existsSync()) {
+ if (!globals.fs.file(packagePath).existsSync()) {
return false;
}
return true;
@@ -1100,8 +1100,8 @@
}) async {
final String outDir = getFuchsiaBuildDirectory();
final String appName = fuchsiaProject.project.manifest.appName;
- final String manifestPath = fs.path.join(outDir, '$appName.dilpmanifest');
- fs.file(manifestPath).createSync(recursive: true);
+ final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest');
+ globals.fs.file(manifestPath).createSync(recursive: true);
}
}
diff --git a/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart b/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart
index 18b2c80..a0ff560 100644
--- a/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart
+++ b/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart
@@ -10,6 +10,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/intellij/intellij.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -18,7 +19,7 @@
FileSystem fs;
void writeFileCreatingDirectories(String path, List<int> bytes) {
- final File file = fs.file(path);
+ final File file = globals.fs.file(path);
file.parent.createSync(recursive: true);
file.writeAsBytesSync(bytes);
}
@@ -40,7 +41,7 @@
</idea-plugin>
''');
writeFileCreatingDirectories(
- fs.path.join(_kPluginsPath, 'Dart', 'lib', 'Dart.jar'),
+ globals.fs.path.join(_kPluginsPath, 'Dart', 'lib', 'Dart.jar'),
ZipEncoder().encode(dartJarArchive));
final Archive flutterJarArchive =
@@ -51,7 +52,7 @@
</idea-plugin>
''');
writeFileCreatingDirectories(
- fs.path.join(_kPluginsPath, 'flutter-intellij.jar'),
+ globals.fs.path.join(_kPluginsPath, 'flutter-intellij.jar'),
ZipEncoder().encode(flutterJarArchive));
final List<ValidationMessage> messages = <ValidationMessage>[];
diff --git a/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart b/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart
index ff57bab..973bfa1 100644
--- a/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart
@@ -13,7 +13,7 @@
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/ios/code_signing.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:process/process.dart';
import '../../src/common.dart';
@@ -316,7 +316,7 @@
verify(mockOpenSslStdIn.write('This is a mock certificate'));
expect(signingConfigs, <String, String>{'DEVELOPMENT_TEAM': '4444DDDD44'});
- verify(config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)'));
+ verify(globals.config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)'));
},
overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
@@ -549,7 +549,7 @@
contains('Certificate choice "iPhone Developer: Profile 3 (3333CCCC33)"'),
);
expect(signingConfigs, <String, String>{'DEVELOPMENT_TEAM': '4444DDDD44'});
- verify(config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)'));
+ verify(globals.config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)'));
},
overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
diff --git a/packages/flutter_tools/test/general.shard/ios/devices_test.dart b/packages/flutter_tools/test/general.shard/ios/devices_test.dart
index f584891..4820ae2 100644
--- a/packages/flutter_tools/test/general.shard/ios/devices_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/devices_test.dart
@@ -24,6 +24,8 @@
import 'package:flutter_tools/src/mdns_discovery.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
@@ -193,7 +195,7 @@
mockIosDeploy = MockIOSDeploy();
mockUsage = MockUsage();
- tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_create_test.');
+ tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_create_test.');
projectDir = tempDir.childDirectory('flutter_project');
when(
@@ -527,7 +529,7 @@
projectDir.childDirectory('build/ios/iphoneos/Debug-arm64');
// The -showBuildSettings calls have a timeout and so go through
- // processManager.start().
+ // globals.processManager.start().
mockProcessManager.processFactory = flakyProcessFactory(
flakes: showBuildSettingsFlakes ? 1 : 0,
delay: const Duration(seconds: 62),
@@ -919,7 +921,7 @@
});
});
testUsingContext('IOSDevice.isSupportedForProject is true on module project', () async {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
@@ -927,7 +929,7 @@
flutter:
module: {}
''');
- fs.file('.packages').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(IOSDevice('test').isSupportedForProject(flutterProject), true);
@@ -937,9 +939,9 @@
Platform: () => macPlatform,
});
testUsingContext('IOSDevice.isSupportedForProject is true with editable host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.directory('ios').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.directory('ios').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(IOSDevice('test').isSupportedForProject(flutterProject), true);
@@ -950,8 +952,8 @@
});
testUsingContext('IOSDevice.isSupportedForProject is false with no host app and no module', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(IOSDevice('test').isSupportedForProject(flutterProject), false);
@@ -973,7 +975,7 @@
@override
String get deviceBundlePath =>
- fs.path.join(project.parent.directory.path, 'build', 'ios', 'iphoneos', name);
+ globals.fs.path.join(project.parent.directory.path, 'build', 'ios', 'iphoneos', name);
}
diff --git a/packages/flutter_tools/test/general.shard/ios/mac_test.dart b/packages/flutter_tools/test/general.shard/ios/mac_test.dart
index 7a87dfa..ae846bf 100644
--- a/packages/flutter_tools/test/general.shard/ios/mac_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/mac_test.dart
@@ -13,6 +13,8 @@
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
@@ -37,10 +39,10 @@
final FakePlatform osx = FakePlatform.fromPlatform(const LocalPlatform())
..operatingSystem = 'macos';
MockProcessManager mockProcessManager;
- final String libimobiledevicePath = fs.path.join('bin', 'cache', 'artifacts', 'libimobiledevice');
- final String ideviceIdPath = fs.path.join(libimobiledevicePath, 'idevice_id');
- final String ideviceInfoPath = fs.path.join(libimobiledevicePath, 'ideviceinfo');
- final String idevicescreenshotPath = fs.path.join(libimobiledevicePath, 'idevicescreenshot');
+ final String libimobiledevicePath = globals.fs.path.join('bin', 'cache', 'artifacts', 'libimobiledevice');
+ final String ideviceIdPath = globals.fs.path.join(libimobiledevicePath, 'idevice_id');
+ final String ideviceInfoPath = globals.fs.path.join(libimobiledevicePath, 'ideviceinfo');
+ final String idevicescreenshotPath = globals.fs.path.join(libimobiledevicePath, 'idevicescreenshot');
MockArtifacts mockArtifacts;
MockCache mockCache;
@@ -177,7 +179,7 @@
});
group('screenshot', () {
- final String outputPath = fs.path.join('some', 'test', 'path', 'image.png');
+ final String outputPath = globals.fs.path.join('some', 'test', 'path', 'image.png');
MockProcessManager mockProcessManager;
MockFile mockOutputFile;
diff --git a/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart b/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart
index 6d4c74b..4f32aaf 100644
--- a/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart
@@ -8,6 +8,8 @@
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:process/process.dart';
import '../../src/common.dart';
@@ -48,7 +50,7 @@
File file;
setUp(() {
- file = fs.file('foo.plist')..createSync();
+ file = globals.fs.file('foo.plist')..createSync();
});
tearDown(() {
diff --git a/packages/flutter_tools/test/general.shard/ios/simulators_test.dart b/packages/flutter_tools/test/general.shard/ios/simulators_test.dart
index 7eb77ef..153ac57 100644
--- a/packages/flutter_tools/test/general.shard/ios/simulators_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/simulators_test.dart
@@ -18,6 +18,8 @@
import 'package:flutter_tools/src/ios/simulators.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
@@ -239,7 +241,7 @@
when(mockXcode.minorVersion).thenReturn(2);
expect(deviceUnderTest.supportsScreenshot, true);
final MockFile mockFile = MockFile();
- when(mockFile.path).thenReturn(fs.path.join('some', 'path', 'to', 'screenshot.png'));
+ when(mockFile.path).thenReturn(globals.fs.path.join('some', 'path', 'to', 'screenshot.png'));
await deviceUnderTest.takeScreenshot(mockFile);
verify(mockProcessManager.run(
<String>[
@@ -248,7 +250,7 @@
'io',
'x',
'screenshot',
- fs.path.join('some', 'path', 'to', 'screenshot.png'),
+ globals.fs.path.join('some', 'path', 'to', 'screenshot.png'),
],
environment: null,
workingDirectory: null,
@@ -478,7 +480,7 @@
final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', simulatorCategory: 'iOS 11.2');
when(PlistParser.instance.getValueFromFile(any, any)).thenReturn('correct');
- final Directory mockDir = fs.currentDirectory;
+ final Directory mockDir = globals.fs.currentDirectory;
final IOSApp package = PrebuiltIOSApp(projectBundleId: 'incorrect', bundleName: 'name', bundleDir: mockDir);
const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor');
@@ -493,7 +495,7 @@
});
testUsingContext('IOSDevice.isSupportedForProject is true on module project', () async {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
@@ -501,7 +503,7 @@
flutter:
module: {}
''');
- fs.file('.packages').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(IOSSimulator('test').isSupportedForProject(flutterProject), true);
@@ -511,9 +513,9 @@
});
testUsingContext('IOSDevice.isSupportedForProject is true with editable host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.directory('ios').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.directory('ios').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(IOSSimulator('test').isSupportedForProject(flutterProject), true);
@@ -523,8 +525,8 @@
});
testUsingContext('IOSDevice.isSupportedForProject is false with no host app and no module', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(IOSSimulator('test').isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
index 17119f9..98544ec 100644
--- a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
+++ b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
@@ -11,6 +11,8 @@
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
@@ -418,7 +420,7 @@
mockArtifacts = MockLocalEngineArtifacts();
mockProcessManager = MockProcessManager();
macOS = fakePlatform('macos');
- fs.file(xcodebuild).createSync(recursive: true);
+ globals.fs.file(xcodebuild).createSync(recursive: true);
});
void testUsingOsxContext(String description, dynamic testMethod()) {
@@ -433,7 +435,7 @@
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null);
final FlutterProject project = FlutterProject.fromPath('path/to/project');
@@ -442,13 +444,13 @@
buildInfo: buildInfo,
);
- final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
+ final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('ARCHS=armv7'), isTrue);
- final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
+ final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
@@ -458,7 +460,7 @@
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true);
final FlutterProject project = FlutterProject.fromPath('path/to/project');
await updateGeneratedXcodeProperties(
@@ -466,13 +468,13 @@
buildInfo: buildInfo,
);
- final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
+ final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('TRACK_WIDGET_CREATION=true'), isTrue);
- final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
+ final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
@@ -482,7 +484,7 @@
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null);
final FlutterProject project = FlutterProject.fromPath('path/to/project');
await updateGeneratedXcodeProperties(
@@ -490,13 +492,13 @@
buildInfo: buildInfo,
);
- final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
+ final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('TRACK_WIDGET_CREATION=true'), isFalse);
- final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
+ final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
@@ -506,7 +508,7 @@
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null);
final FlutterProject project = FlutterProject.fromPath('path/to/project');
@@ -515,7 +517,7 @@
buildInfo: buildInfo,
);
- final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
+ final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
@@ -539,9 +541,9 @@
}) async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
- when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios'));
+ when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios'));
- final File manifestFile = fs.file('path/to/project/pubspec.yaml');
+ final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync(manifestString);
@@ -553,7 +555,7 @@
buildInfo: buildInfo,
);
- final File localPropertiesFile = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
+ final File localPropertiesFile = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(propertyFor('FLUTTER_BUILD_NAME', localPropertiesFile), expectedBuildName);
expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), expectedBuildNumber);
expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), isNotNull);
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart
index e8628e8..5bfe7b4 100644
--- a/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart
+++ b/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart
@@ -4,13 +4,15 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/linux/application_package.dart';
import 'package:flutter_tools/src/linux/linux_device.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
+
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -40,9 +42,9 @@
});
testUsingContext('LinuxDevice.isSupportedForProject is true with editable host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.directory('linux').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.directory('linux').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(LinuxDevice().isSupportedForProject(flutterProject), true);
@@ -52,8 +54,8 @@
});
testUsingContext('LinuxDevice.isSupportedForProject is false with no host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(LinuxDevice().isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart
index dc4b761..095fcdc 100644
--- a/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart
+++ b/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/doctor.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/linux/linux_doctor.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -22,13 +23,13 @@
});
testUsingContext('Returns full validation when clang++ and make are availibe', () async {
- when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
+ when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
return FakeProcessResult(
stdout: 'clang version 4.0.1-10 (tags/RELEASE_401/final)\njunk',
exitCode: 0,
);
});
- when(processManager.run(<String>[
+ when(globals.processManager.run(<String>[
'make',
'--version',
])).thenAnswer((_) async {
@@ -49,13 +50,13 @@
});
testUsingContext('Returns partial validation when clang++ version is too old', () async {
- when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
+ when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
return FakeProcessResult(
stdout: 'clang version 2.0.1-10 (tags/RELEASE_401/final)\njunk',
exitCode: 0,
);
});
- when(processManager.run(<String>[
+ when(globals.processManager.run(<String>[
'make',
'--version',
])).thenAnswer((_) async {
@@ -76,13 +77,13 @@
});
testUsingContext('Returns mising validation when make is not availible', () async {
- when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
+ when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
return FakeProcessResult(
stdout: 'clang version 4.0.1-10 (tags/RELEASE_401/final)\njunk',
exitCode: 0,
);
});
- when(processManager.run(<String>[
+ when(globals.processManager.run(<String>[
'make',
'--version',
])).thenAnswer((_) async {
@@ -103,13 +104,13 @@
});
testUsingContext('Returns mising validation when clang++ is not availible', () async {
- when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
+ when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
return FakeProcessResult(
stdout: '',
exitCode: 1,
);
});
- when(processManager.run(<String>[
+ when(globals.processManager.run(<String>[
'make',
'--version',
])).thenAnswer((_) async {
@@ -131,13 +132,13 @@
testUsingContext('Returns missing validation when clang and make are not availible', () async {
- when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
+ when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async {
return FakeProcessResult(
stdout: '',
exitCode: 1,
);
});
- when(processManager.run(<String>[
+ when(globals.processManager.run(<String>[
'make',
'--version',
])).thenAnswer((_) async {
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
index 0028765..5630431 100644
--- a/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
@@ -4,8 +4,9 @@
import 'package:flutter_tools/src/features.dart';
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/linux/linux_workflow.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
index 19ae134..ecd7e47 100644
--- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
@@ -6,16 +6,17 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
+import 'package:platform/platform.dart';
+import 'package:mockito/mockito.dart';
+import 'package:process/process.dart';
+
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/macos/cocoapods.dart';
import 'package:flutter_tools/src/plugins.dart';
import 'package:flutter_tools/src/project.dart';
-import 'package:mockito/mockito.dart';
-import 'package:process/process.dart';
import '../../src/common.dart';
import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart
index ed3affb..f88ebb1 100644
--- a/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart
@@ -7,14 +7,15 @@
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/macos/application_package.dart';
import 'package:flutter_tools/src/macos/macos_device.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
@@ -48,9 +49,9 @@
});
testUsingContext('isSupportedForProject is true with editable host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.directory('macos').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.directory('macos').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(MacOSDevice().isSupportedForProject(flutterProject), true);
@@ -60,8 +61,8 @@
});
testUsingContext('isSupportedForProject is false with no host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(MacOSDevice().isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
index 6edd62e..b845326 100644
--- a/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
@@ -4,10 +4,9 @@
import 'package:flutter_tools/src/features.dart';
import 'package:mockito/mockito.dart';
-
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/macos/macos_workflow.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart
index 8a56721..90407de 100644
--- a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart
@@ -3,11 +3,11 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart' show ProcessException, ProcessResult;
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart b/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart
index 9c86f7b..c03f3df 100644
--- a/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart
+++ b/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart
@@ -7,6 +7,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../src/common.dart';
@@ -31,7 +32,7 @@
setUp(() {
mockFileSystem = MockFileSystem();
mockFile = MockFile();
- when(mockFileSystem.path).thenReturn(fs.path);
+ when(mockFileSystem.path).thenReturn(globals.fs.path);
when(mockFileSystem.file(any)).thenReturn(mockFile);
when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(packagesContents) as Uint8List);
});
@@ -65,7 +66,7 @@
testUsingContext('multi-root maps main file from same package on multiroot scheme', () async {
final MockFileSystem mockFileSystem = MockFileSystem();
final MockFile mockFile = MockFile();
- when(mockFileSystem.path).thenReturn(fs.path);
+ when(mockFileSystem.path).thenReturn(globals.fs.path);
when(mockFileSystem.file(any)).thenReturn(mockFile);
when(mockFile.readAsBytesSync())
.thenReturn(utf8.encode(multiRootPackagesContents) as Uint8List);
diff --git a/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart b/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
index f1778c9..b27257e 100644
--- a/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
+++ b/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
@@ -4,6 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/persistent_tool_state.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/testbed.dart';
@@ -16,7 +17,7 @@
});
test('state can be set and persists', () => testbed.run(() {
- final File stateFile = fs.file('.flutter_tool_state');
+ final File stateFile = globals.fs.file('.flutter_tool_state');
final PersistentToolState state1 = PersistentToolState(stateFile);
expect(state1.redisplayWelcomeMessage, null);
state1.redisplayWelcomeMessage = true;
diff --git a/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart b/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart
index 9d6dd39..3d251a5 100644
--- a/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart
+++ b/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart
@@ -4,9 +4,10 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/run_hot.dart';
+import 'package:platform/platform.dart';
+
import '../src/common.dart';
// assumption: tests have a timeout less than 100 days
diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart
index c8d3a09..d42a617 100644
--- a/packages/flutter_tools/test/general.shard/project_test.dart
+++ b/packages/flutter_tools/test/general.shard/project_test.dart
@@ -9,13 +9,13 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/flutter_manifest.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
@@ -34,7 +34,7 @@
});
testInMemory('fails on invalid pubspec.yaml', () async {
- final Directory directory = fs.directory('myproject');
+ final Directory directory = globals.fs.directory('myproject');
directory.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync(invalidPubspec);
@@ -46,7 +46,7 @@
});
testInMemory('fails on pubspec.yaml parse failure', () async {
- final Directory directory = fs.directory('myproject');
+ final Directory directory = globals.fs.directory('myproject');
directory.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync(parseErrorPubspec);
@@ -58,7 +58,7 @@
});
testInMemory('fails on invalid example/pubspec.yaml', () async {
- final Directory directory = fs.directory('myproject');
+ final Directory directory = globals.fs.directory('myproject');
directory.childDirectory('example').childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync(invalidPubspec);
@@ -70,7 +70,7 @@
});
testInMemory('treats missing pubspec.yaml as empty', () async {
- final Directory directory = fs.directory('myproject')
+ final Directory directory = globals.fs.directory('myproject')
..createSync(recursive: true);
expect((FlutterProject.fromDirectory(directory)).manifest.isEmpty,
true,
@@ -78,7 +78,7 @@
});
testInMemory('reads valid pubspec.yaml', () async {
- final Directory directory = fs.directory('myproject');
+ final Directory directory = globals.fs.directory('myproject');
directory.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync(validPubspec);
@@ -89,7 +89,7 @@
});
testInMemory('sets up location', () async {
- final Directory directory = fs.directory('myproject');
+ final Directory directory = globals.fs.directory('myproject');
expect(
FlutterProject.fromDirectory(directory).directory.absolute.path,
directory.absolute.path,
@@ -100,7 +100,7 @@
);
expect(
FlutterProject.current().directory.absolute.path,
- fs.currentDirectory.absolute.path,
+ globals.fs.currentDirectory.absolute.path,
);
});
});
@@ -154,7 +154,7 @@
group('ensure ready for platform-specific tooling', () {
testInMemory('does nothing, if project is not created', () async {
final FlutterProject project = FlutterProject(
- fs.directory('not_created'),
+ globals.fs.directory('not_created'),
FlutterManifest.empty(),
FlutterManifest.empty(),
);
@@ -513,7 +513,7 @@
});
test('Handles asking for builders from an invalid pubspec', () => testbed.run(() {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
# Hello, World
@@ -526,7 +526,7 @@
}));
test('Handles asking for builders from a trivial pubspec', () => testbed.run(() {
- fs.file('pubspec.yaml')
+ globals.fs.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
# Hello, World
@@ -542,7 +542,7 @@
}
Future<FlutterProject> someProject() async {
- final Directory directory = fs.directory('some_project');
+ final Directory directory = globals.fs.directory('some_project');
directory.childFile('.packages').createSync(recursive: true);
directory.childDirectory('ios').createSync(recursive: true);
final Directory androidDirectory = directory
@@ -555,7 +555,7 @@
}
Future<FlutterProject> aPluginProject({bool legacy = true}) async {
- final Directory directory = fs.directory('plugin_project');
+ final Directory directory = globals.fs.directory('plugin_project');
directory.childDirectory('ios').createSync(recursive: true);
directory.childDirectory('android').createSync(recursive: true);
directory.childDirectory('example').createSync(recursive: true);
@@ -593,7 +593,7 @@
}
Future<FlutterProject> aModuleProject() async {
- final Directory directory = fs.directory('module_project');
+ final Directory directory = globals.fs.directory('module_project');
directory.childFile('.packages').createSync(recursive: true);
directory.childFile('pubspec.yaml').writeAsStringSync('''
name: my_module
@@ -610,16 +610,16 @@
void testInMemory(String description, Future<void> testMethod()) {
Cache.flutterRoot = getFlutterRoot();
final FileSystem testFileSystem = MemoryFileSystem(
- style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix,
+ style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix,
);
// Transfer needed parts of the Flutter installation folder
// to the in-memory file system used during testing.
transfer(Cache().getArtifactDirectory('gradle_wrapper'), testFileSystem);
- transfer(fs.directory(Cache.flutterRoot)
+ transfer(globals.fs.directory(Cache.flutterRoot)
.childDirectory('packages')
.childDirectory('flutter_tools')
.childDirectory('templates'), testFileSystem);
- transfer(fs.directory(Cache.flutterRoot)
+ transfer(globals.fs.directory(Cache.flutterRoot)
.childDirectory('packages')
.childDirectory('flutter_tools')
.childDirectory('schema'), testFileSystem);
diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart
index 187991f..19c4593 100644
--- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart
@@ -15,7 +15,7 @@
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/features.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/resident_runner.dart';
@@ -42,7 +42,7 @@
setUp(() {
testbed = Testbed(setup: () {
- fs.file(fs.path.join('build', 'app.dill'))
+ globals.fs.file(globals.fs.path.join('build', 'app.dill'))
..createSync(recursive: true)
..writeAsStringSync('ABC');
residentRunner = HotRunner(
@@ -352,7 +352,7 @@
],
stayResident: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
- dillOutputPath: fs.path.join('foobar', 'app.dill'),
+ dillOutputPath: globals.fs.path.join('foobar', 'app.dill'),
);
expect(otherRunner.artifactDirectory.path, contains('foobar'));
}));
@@ -566,7 +566,7 @@
}));
test('HotRunner writes vm service file when providing debugging option', () => testbed.run(() async {
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = HotRunner(
<FlutterDevice>[
mockFlutterDevice,
@@ -582,13 +582,13 @@
});
await residentRunner.run();
- expect(await fs.file('foo').readAsString(), testUri.toString());
+ expect(await globals.fs.file('foo').readAsString(), testUri.toString());
}));
test('HotRunner unforwards device ports', () => testbed.run(() async {
final MockDevicePortForwarder mockPortForwarder = MockDevicePortForwarder();
when(mockDevice.portForwarder).thenReturn(mockPortForwarder);
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = HotRunner(
<FlutterDevice>[
mockFlutterDevice,
@@ -613,7 +613,7 @@
}));
test('HotRunner handles failure to write vmservice file', () => testbed.run(() async {
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = HotRunner(
<FlutterDevice>[
mockFlutterDevice,
@@ -636,7 +636,7 @@
test('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async {
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = ColdRunner(
<FlutterDevice>[
mockFlutterDevice,
@@ -652,7 +652,7 @@
});
await residentRunner.run();
- expect(await fs.file('foo').readAsString(), testUri.toString());
+ expect(await globals.fs.file('foo').readAsString(), testUri.toString());
}));
test('FlutterDevice uses dartdevc configuration when targeting web', () => testbed.run(() async {
@@ -671,10 +671,10 @@
expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot,
- artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: BuildMode.debug) + '/');
+ globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: BuildMode.debug) + '/');
expect(
residentCompiler.platformDill,
- fs.file(artifacts.getArtifactPath(Artifact.webPlatformKernelDill, mode: BuildMode.debug))
+ globals.fs.file(globals.artifacts.getArtifactPath(Artifact.webPlatformKernelDill, mode: BuildMode.debug))
.absolute.uri.toString(),
);
}, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
index ebf2127..854c39f 100644
--- a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
@@ -6,12 +6,11 @@
import 'package:dwds/dwds.dart';
import 'package:flutter_tools/src/base/common.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/net.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
@@ -65,15 +64,15 @@
});
void _setupMocks() {
- fs.file('pubspec.yaml').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
- fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true);
when(mockWebFs.connect(any)).thenThrow(StateError('debugging not supported'));
}
test('Can successfully run and connect without vmservice', () => testbed.run(() async {
_setupMocks();
- final DelegateLogger delegateLogger = logger as DelegateLogger;
+ final DelegateLogger delegateLogger = globals.logger as DelegateLogger;
final MockStatus mockStatus = MockStatus();
delegateLogger.status = mockStatus;
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
index 9633014..da322c4 100644
--- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
@@ -8,7 +8,6 @@
import 'package:build_daemon/client.dart';
import 'package:dwds/dwds.dart';
import 'package:flutter_tools/src/base/common.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/net.dart';
@@ -19,7 +18,7 @@
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/features.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/resident_runner.dart';
@@ -102,9 +101,9 @@
});
void _setupMocks() {
- fs.file('pubspec.yaml').createSync();
- fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
- fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true);
when(mockWebFs.connect(any)).thenAnswer((Invocation _) async {
return ConnectionResult(mockAppConnection, mockDebugConnection);
});
@@ -224,24 +223,24 @@
}));
test('Exits on run if application does not support the web', () => testbed.run(() async {
- fs.file('pubspec.yaml').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
expect(await residentWebRunner.run(), 1);
expect(testLogger.errorText, contains('This application is not configured to build on the web'));
}));
test('Exits on run if target file does not exist', () => testbed.run(() async {
- fs.file('pubspec.yaml').createSync();
- fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true);
expect(await residentWebRunner.run(), 1);
- final String absoluteMain = fs.path.absolute(fs.path.join('lib', 'main.dart'));
+ final String absoluteMain = globals.fs.path.absolute(globals.fs.path.join('lib', 'main.dart'));
expect(testLogger.errorText, contains('Tried to run $absoluteMain, but that file does not exist.'));
}));
test('Can successfully run and connect to vmservice', () => testbed.run(() async {
_setupMocks();
- final DelegateLogger delegateLogger = logger as DelegateLogger;
+ final DelegateLogger delegateLogger = globals.logger as DelegateLogger;
final BufferLogger bufferLogger = delegateLogger.delegate as BufferLogger;
final MockStatus status = MockStatus();
delegateLogger.status = status;
@@ -832,14 +831,14 @@
));
await connectionInfoCompleter.future;
- expect(testLogger.statusText, contains('Launching ${fs.path.join('lib', 'main.dart')} on Chromez in debug mode'));
+ expect(testLogger.statusText, contains('Launching ${globals.fs.path.join('lib', 'main.dart')} on Chromez in debug mode'));
}));
test('Sends launched app.webLaunchUrl event for Chrome device', () => testbed.run(() async {
_setupMocks();
when(mockFlutterDevice.device).thenReturn(ChromeDevice());
- final DelegateLogger delegateLogger = logger as DelegateLogger;
+ final DelegateLogger delegateLogger = globals.logger as DelegateLogger;
final MockStatus mockStatus = MockStatus();
delegateLogger.status = mockStatus;
final ResidentWebRunner runner = DwdsWebRunnerFactory().createWebRunner(
@@ -859,7 +858,7 @@
await connectionInfoCompleter.future;
// Ensure we got the URL and that it was already launched.
- verify(logger.sendEvent(
+ verify(globals.logger.sendEvent(
'app.webLaunchUrl',
argThat(allOf(
containsPair('url', 'http://localhost:8765/app/'),
@@ -875,7 +874,7 @@
_setupMocks();
when(mockFlutterDevice.device).thenReturn(WebServerDevice());
- final DelegateLogger delegateLogger = logger as DelegateLogger;
+ final DelegateLogger delegateLogger = globals.logger as DelegateLogger;
final MockStatus mockStatus = MockStatus();
delegateLogger.status = mockStatus;
final ResidentWebRunner runner = DwdsWebRunnerFactory().createWebRunner(
@@ -895,7 +894,7 @@
await connectionInfoCompleter.future;
// Ensure we got the URL and that it was not already launched.
- verify(logger.sendEvent(
+ verify(globals.logger.sendEvent(
'app.webLaunchUrl',
argThat(allOf(
containsPair('url', 'http://localhost:8765/app/'),
@@ -1061,7 +1060,7 @@
test('Rethrows unknown exception type from web tooling', () => testbed.run(() async {
_setupMocks();
- final DelegateLogger delegateLogger = logger as DelegateLogger;
+ final DelegateLogger delegateLogger = globals.logger as DelegateLogger;
final MockStatus mockStatus = MockStatus();
delegateLogger.status = mockStatus;
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
index 6bd474f..a1ae4e8 100644
--- a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
+++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
@@ -7,7 +7,6 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/error_handling_file_system.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/signals.dart';
import 'package:flutter_tools/src/base/time.dart';
@@ -15,6 +14,7 @@
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
@@ -70,7 +70,7 @@
testUsingContext('uses the error handling file system', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(
commandFunction: () async {
- expect(fs, isA<ErrorHandlingFileSystem>());
+ expect(globals.fs, isA<ErrorHandlingFileSystem>());
return const FlutterCommandResult(ExitStatus.success);
}
);
diff --git a/packages/flutter_tools/test/general.shard/test_compiler_test.dart b/packages/flutter_tools/test/general.shard/test_compiler_test.dart
index 115e122..c6bc637 100644
--- a/packages/flutter_tools/test/general.shard/test_compiler_test.dart
+++ b/packages/flutter_tools/test/general.shard/test_compiler_test.dart
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/test/test_compiler.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import '../src/common.dart';
@@ -21,9 +21,9 @@
setUp(() {
testbed = Testbed(
setup: () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.file('test/foo.dart').createSync(recursive: true);
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.file('test/foo.dart').createSync(recursive: true);
residentCompiler = MockResidentCompiler();
testCompiler = FakeTestCompiler(
BuildMode.debug,
@@ -41,12 +41,12 @@
<Uri>[Uri.parse('test/foo.dart')],
outputPath: testCompiler.outputDill.path,
)).thenAnswer((Invocation invocation) async {
- fs.file('abc.dill').createSync();
+ globals.fs.file('abc.dill').createSync();
return const CompilerOutput('abc.dill', 0, <Uri>[]);
});
expect(await testCompiler.compile('test/foo.dart'), 'test/foo.dart.dill');
- expect(fs.file('test/foo.dart.dill').existsSync(), true);
+ expect(globals.fs.file('test/foo.dart.dill').existsSync(), true);
}));
test('Reports null when a compile fails', () => testbed.run(() async {
@@ -55,12 +55,12 @@
<Uri>[Uri.parse('test/foo.dart')],
outputPath: testCompiler.outputDill.path,
)).thenAnswer((Invocation invocation) async {
- fs.file('abc.dill').createSync();
+ globals.fs.file('abc.dill').createSync();
return const CompilerOutput('abc.dill', 1, <Uri>[]);
});
expect(await testCompiler.compile('test/foo.dart'), null);
- expect(fs.file('test/foo.dart.dill').existsSync(), false);
+ expect(globals.fs.file('test/foo.dart.dill').existsSync(), false);
verify(residentCompiler.shutdown()).called(1);
}));
diff --git a/packages/flutter_tools/test/general.shard/testbed_test.dart b/packages/flutter_tools/test/general.shard/testbed_test.dart
index 7d1c396..6e10a6b 100644
--- a/packages/flutter_tools/test/general.shard/testbed_test.dart
+++ b/packages/flutter_tools/test/general.shard/testbed_test.dart
@@ -10,6 +10,7 @@
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/error_handling_file_system.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
import '../src/testbed.dart';
@@ -22,7 +23,7 @@
FileSystem localFileSystem;
await testbed.run(() {
- localFileSystem = fs;
+ localFileSystem = globals.fs;
});
expect(localFileSystem, isA<ErrorHandlingFileSystem>());
diff --git a/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart b/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart
index a16ea4d..ea2eed1 100644
--- a/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart
+++ b/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart
@@ -7,36 +7,36 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/tester/flutter_tester.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/mocks.dart';
void main() {
- MemoryFileSystem fs;
+ MemoryFileSystem fileSystem;
setUp(() {
- fs = MemoryFileSystem();
+ fileSystem = MemoryFileSystem();
});
group('FlutterTesterApp', () {
testUsingContext('fromCurrentDirectory', () async {
const String projectPath = '/home/my/projects/my_project';
- await fs.directory(projectPath).create(recursive: true);
- fs.currentDirectory = projectPath;
+ await fileSystem.directory(projectPath).create(recursive: true);
+ fileSystem.currentDirectory = projectPath;
final FlutterTesterApp app = FlutterTesterApp.fromCurrentDirectory();
expect(app.name, 'my_project');
- expect(app.packagesFile.path, fs.path.join(projectPath, '.packages'));
+ expect(app.packagesFile.path, fileSystem.path.join(projectPath, '.packages'));
}, overrides: <Type, Generator>{
- FileSystem: () => fs,
+ FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
});
@@ -106,7 +106,7 @@
final Map<Type, Generator> startOverrides = <Type, Generator>{
Platform: () => FakePlatform(operatingSystem: 'linux'),
- FileSystem: () => fs,
+ FileSystem: () => fileSystem,
ProcessManager: () => mockProcessManager,
Artifacts: () => mockArtifacts,
BuildSystem: () => mockBuildSystem,
@@ -114,23 +114,23 @@
setUp(() {
mockBuildSystem = MockBuildSystem();
- flutterRoot = fs.path.join('home', 'me', 'flutter');
- flutterTesterPath = fs.path.join(flutterRoot, 'bin', 'cache',
+ flutterRoot = fileSystem.path.join('home', 'me', 'flutter');
+ flutterTesterPath = fileSystem.path.join(flutterRoot, 'bin', 'cache',
'artifacts', 'engine', 'linux-x64', 'flutter_tester');
- final File flutterTesterFile = fs.file(flutterTesterPath);
+ final File flutterTesterFile = fileSystem.file(flutterTesterPath);
flutterTesterFile.parent.createSync(recursive: true);
flutterTesterFile.writeAsBytesSync(const <int>[]);
- projectPath = fs.path.join('home', 'me', 'hello');
- mainPath = fs.path.join(projectPath, 'lin', 'main.dart');
+ projectPath = fileSystem.path.join('home', 'me', 'hello');
+ mainPath = fileSystem.path.join(projectPath, 'lin', 'main.dart');
mockProcessManager = MockProcessManager();
mockProcessManager.processFactory =
(List<String> commands) => mockProcess;
mockArtifacts = MockArtifacts();
- final String artifactPath = fs.path.join(flutterRoot, 'artifact');
- fs.file(artifactPath).createSync(recursive: true);
+ final String artifactPath = fileSystem.path.join(flutterRoot, 'artifact');
+ fileSystem.file(artifactPath).createSync(recursive: true);
when(mockArtifacts.getArtifactPath(
any,
mode: anyNamed('mode')
@@ -140,7 +140,7 @@
any,
any,
)).thenAnswer((_) async {
- fs.file('$mainPath.dill').createSync(recursive: true);
+ fileSystem.file('$mainPath.dill').createSync(recursive: true);
return BuildResult(success: true);
});
});
diff --git a/packages/flutter_tools/test/general.shard/vscode_test.dart b/packages/flutter_tools/test/general.shard/vscode_test.dart
index afc4744..8e58859 100644
--- a/packages/flutter_tools/test/general.shard/vscode_test.dart
+++ b/packages/flutter_tools/test/general.shard/vscode_test.dart
@@ -7,7 +7,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/version.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/vscode/vscode.dart';
import '../src/common.dart';
@@ -15,9 +15,9 @@
void main() {
testUsingContext('VsCode.fromDirectory does not crash when packages.json is malformed', () {
- final BufferLogger bufferLogger = logger as BufferLogger;
+ final BufferLogger bufferLogger = globals.logger as BufferLogger;
// Create invalid JSON file.
- fs.file(fs.path.join('', 'resources', 'app', 'package.json'))
+ globals.fs.file(globals.fs.path.join('', 'resources', 'app', 'package.json'))
..createSync(recursive: true)
..writeAsStringSync('{');
diff --git a/packages/flutter_tools/test/general.shard/web/asset_server_test.dart b/packages/flutter_tools/test/general.shard/web/asset_server_test.dart
index c51b93c..d964a5b 100644
--- a/packages/flutter_tools/test/general.shard/web/asset_server_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/asset_server_test.dart
@@ -6,7 +6,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/build_runner/web_fs.dart';
-import 'package:flutter_tools/src/globals.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:shelf/shelf.dart';
@@ -28,18 +28,18 @@
setUp(() {
testbed = Testbed(
setup: () {
- fs.file(fs.path.join('lib', 'main.dart'))
+ globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
.createSync(recursive: true);
- fs.file(fs.path.join('web', 'index.html'))
+ globals.fs.file(globals.fs.path.join('web', 'index.html'))
..createSync(recursive: true)
..writeAsStringSync('hello');
- fs.file(fs.path.join('build', 'flutter_assets', 'foo.png'))
+ globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo.png'))
..createSync(recursive: true)
..writeAsBytesSync(kTransparentImage);
- fs.file(fs.path.join('build', 'flutter_assets', 'bar'))
+ globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'bar'))
..createSync(recursive: true)
..writeAsBytesSync(<int>[1, 2, 3]);
- assetServer = DebugAssetServer(FlutterProject.current(), fs.path.join('main'));
+ assetServer = DebugAssetServer(FlutterProject.current(), globals.fs.path.join('main'));
}
);
});
@@ -56,8 +56,8 @@
}));
test('can serve a sourcemap from dart:ui', () => testbed.run(() async {
- final String flutterWebSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
- final File windowSourceFile = fs.file(fs.path.join(flutterWebSdkPath, 'lib', 'ui', 'src', 'ui', 'window.dart'))
+ final String flutterWebSdkPath = globals.artifacts.getArtifactPath(Artifact.flutterWebSdk);
+ final File windowSourceFile = globals.fs.file(globals.fs.path.join(flutterWebSdkPath, 'lib', 'ui', 'src', 'ui', 'window.dart'))
..createSync(recursive: true)
..writeAsStringSync('test');
final Response response = await assetServer
@@ -70,8 +70,8 @@
}));
test('can serve a sourcemap from the dart:sdk', () => testbed.run(() async {
- final String dartSdkPath = artifacts.getArtifactPath(Artifact.engineDartSdkPath);
- final File listSourceFile = fs.file(fs.path.join(dartSdkPath, 'lib', 'core', 'list.dart'))
+ final String dartSdkPath = globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath);
+ final File listSourceFile = globals.fs.file(globals.fs.path.join(dartSdkPath, 'lib', 'core', 'list.dart'))
..createSync(recursive: true)
..writeAsStringSync('test');
@@ -113,7 +113,7 @@
test('release asset server serves correct mime type and content length for png', () => testbed.run(() async {
assetServer = ReleaseAssetServer();
- fs.file(fs.path.join('build', 'web', 'assets', 'foo.png'))
+ globals.fs.file(globals.fs.path.join('build', 'web', 'assets', 'foo.png'))
..createSync(recursive: true)
..writeAsBytesSync(kTransparentImage);
final Response response = await assetServer
@@ -127,7 +127,7 @@
test('release asset server serves correct mime type and content length for JavaScript', () => testbed.run(() async {
assetServer = ReleaseAssetServer();
- fs.file(fs.path.join('build', 'web', 'assets', 'foo.js'))
+ globals.fs.file(globals.fs.path.join('build', 'web', 'assets', 'foo.js'))
..createSync(recursive: true)
..writeAsStringSync('function main() {}');
final Response response = await assetServer
@@ -141,7 +141,7 @@
test('release asset server serves correct mime type and content length for html', () => testbed.run(() async {
assetServer = ReleaseAssetServer();
- fs.file(fs.path.join('build', 'web', 'assets', 'foo.html'))
+ globals.fs.file(globals.fs.path.join('build', 'web', 'assets', 'foo.html'))
..createSync(recursive: true)
..writeAsStringSync('<!doctype html><html></html>');
final Response response = await assetServer
@@ -155,7 +155,7 @@
test('release asset server serves content from flutter root', () => testbed.run(() async {
assetServer = ReleaseAssetServer();
- fs.file(fs.path.join('flutter', 'bar.dart'))
+ globals.fs.file(globals.fs.path.join('flutter', 'bar.dart'))
..createSync(recursive: true)
..writeAsStringSync('void main() { }');
final Response response = await assetServer
@@ -166,7 +166,7 @@
test('release asset server serves content from project directory', () => testbed.run(() async {
assetServer = ReleaseAssetServer();
- fs.file(fs.path.join('lib', 'bar.dart'))
+ globals.fs.file(globals.fs.path.join('lib', 'bar.dart'))
..createSync(recursive: true)
..writeAsStringSync('void main() { }');
final Response response = await assetServer
diff --git a/packages/flutter_tools/test/general.shard/web/chrome_test.dart b/packages/flutter_tools/test/general.shard/web/chrome_test.dart
index 48ad64c..3e10239 100644
--- a/packages/flutter_tools/test/general.shard/web/chrome_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/chrome_test.dart
@@ -6,12 +6,12 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart';
-import 'package:flutter_tools/src/base/platform.dart';
-import 'package:flutter_tools/src/base/process_manager.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/web/chrome.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/mocks.dart';
@@ -36,7 +36,7 @@
when(platform.environment).thenReturn(<String, String>{
kChromeEnvironment: 'example_chrome',
});
- when(processManager.start(any))
+ when(globals.processManager.start(any))
.thenAnswer((Invocation invocation) async {
return FakeProcess(
exitCode: exitCompleter.future,
@@ -69,13 +69,13 @@
];
await chromeLauncher.launch('example_url', skipCheck: true);
- final VerificationResult result = verify(processManager.start(captureAny));
+ final VerificationResult result = verify(globals.processManager.start(captureAny));
expect(result.captured.single, containsAll(expected));
}));
test('can seed chrome temp directory with existing preferences', () => testbed.run(() async {
- final Directory dataDir = fs.directory('chrome-stuff');
+ final Directory dataDir = globals.fs.directory('chrome-stuff');
final File preferencesFile = dataDir
.childDirectory('Default')
.childFile('preferences');
@@ -84,10 +84,10 @@
..writeAsStringSync('example');
await chromeLauncher.launch('example_url', skipCheck: true, dataDir: dataDir);
- final VerificationResult result = verify(processManager.start(captureAny));
+ final VerificationResult result = verify(globals.processManager.start(captureAny));
final String arg = (result.captured.single as List<String>)
.firstWhere((String arg) => arg.startsWith('--user-data-dir='));
- final Directory tempDirectory = fs.directory(arg.split('=')[1]);
+ final Directory tempDirectory = globals.fs.directory(arg.split('=')[1]);
final File tempFile = tempDirectory
.childDirectory('Default')
.childFile('preferences');
diff --git a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
index 3b735e7..1c63148 100644
--- a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
@@ -8,10 +8,11 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/web/devfs_web.dart';
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/testbed.dart';
@@ -87,18 +88,18 @@
}));
test('Handles against malformed manifest', () => testbed.run(() async {
- final File source = fs.file('source')
+ final File source = globals.fs.file('source')
..writeAsStringSync('main() {}');
- final File sourcemap = fs.file('sourcemap')
+ final File sourcemap = globals.fs.file('sourcemap')
..writeAsStringSync('{}');
// Missing ending offset.
- final File manifestMissingOffset = fs.file('manifestA')
+ final File manifestMissingOffset = globals.fs.file('manifestA')
..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{
'code': <int>[0],
'sourcemap': <int>[0],
}}));
- final File manifestOutOfBounds = fs.file('manifest')
+ final File manifestOutOfBounds = globals.fs.file('manifest')
..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{
'code': <int>[0, 100],
'sourcemap': <int>[0],
@@ -109,11 +110,11 @@
}));
test('serves JavaScript files from in memory cache', () => testbed.run(() async {
- final File source = fs.file('source')
+ final File source = globals.fs.file('source')
..writeAsStringSync('main() {}');
- final File sourcemap = fs.file('sourcemap')
+ final File sourcemap = globals.fs.file('sourcemap')
..writeAsStringSync('{}');
- final File manifest = fs.file('manifest')
+ final File manifest = globals.fs.file('manifest')
..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{
'code': <int>[0, source.lengthSync()],
'sourcemap': <int>[0, 2],
@@ -132,11 +133,11 @@
}));
test('serves JavaScript files from in memory cache on Windows', () => testbed.run(() async {
- final File source = fs.file('source')
+ final File source = globals.fs.file('source')
..writeAsStringSync('main() {}');
- final File sourcemap = fs.file('sourcemap')
+ final File sourcemap = globals.fs.file('sourcemap')
..writeAsStringSync('{}');
- final File manifest = fs.file('manifest')
+ final File manifest = globals.fs.file('manifest')
..writeAsStringSync(json.encode(<String, Object>{'/C:/foo.js': <String, Object>{
'code': <int>[0, source.lengthSync()],
'sourcemap': <int>[0, 2],
@@ -167,11 +168,11 @@
}));
test('handles missing JavaScript files from in memory cache', () => testbed.run(() async {
- final File source = fs.file('source')
+ final File source = globals.fs.file('source')
..writeAsStringSync('main() {}');
- final File sourcemap = fs.file('sourcemap')
+ final File sourcemap = globals.fs.file('sourcemap')
..writeAsStringSync('{}');
- final File manifest = fs.file('manifest')
+ final File manifest = globals.fs.file('manifest')
..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{
'code': <int>[0, source.lengthSync()],
'sourcemap': <int>[0, 2],
@@ -186,7 +187,7 @@
}));
test('serves Dart files from in filesystem on Windows', () => testbed.run(() async {
- final File source = fs.file('foo.dart').absolute
+ final File source = globals.fs.file('foo.dart').absolute
..createSync(recursive: true)
..writeAsStringSync('void main() {}');
@@ -201,7 +202,7 @@
}));
test('serves Dart files from in filesystem on Linux/macOS', () => testbed.run(() async {
- final File source = fs.file('foo.dart').absolute
+ final File source = globals.fs.file('foo.dart').absolute
..createSync(recursive: true)
..writeAsStringSync('void main() {}');
@@ -224,7 +225,7 @@
}));
test('serves asset files from in filesystem with known mime type', () => testbed.run(() async {
- final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo.png'))
+ final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo.png'))
..createSync(recursive: true)
..writeAsBytesSync(kTransparentImage);
@@ -238,7 +239,7 @@
}));
test('serves asset files from in filesystem with known mime type on Windows', () => testbed.run(() async {
- final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo.png'))
+ final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo.png'))
..createSync(recursive: true)
..writeAsBytesSync(kTransparentImage);
@@ -255,7 +256,7 @@
test('serves asset files files from in filesystem with unknown mime type and length > 12', () => testbed.run(() async {
- final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo'))
+ final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo'))
..createSync(recursive: true)
..writeAsBytesSync(List<int>.filled(100, 0));
@@ -269,7 +270,7 @@
}));
test('serves asset files files from in filesystem with unknown mime type and length < 12', () => testbed.run(() async {
- final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo'))
+ final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo'))
..createSync(recursive: true)
..writeAsBytesSync(<int>[1, 2, 3]);
diff --git a/packages/flutter_tools/test/general.shard/web/devices_test.dart b/packages/flutter_tools/test/general.shard/web/devices_test.dart
index 20afe07..47958a7 100644
--- a/packages/flutter_tools/test/general.shard/web/devices_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/devices_test.dart
@@ -3,12 +3,12 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/web/chrome.dart';
import 'package:flutter_tools/src/web/web_device.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart b/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart
index 2cc377b..127a635 100644
--- a/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart
@@ -6,6 +6,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/test/flutter_web_platform.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/mocks.dart';
@@ -22,9 +23,9 @@
MockProcess Function(String) createMockProcess;
setUpAll(() {
- imageFile = fs.file('test_image_file');
+ imageFile = globals.fs.file('test_image_file');
goldenKey = Uri.parse('file://golden_key');
- imageFile2 = fs.file('second_test_image_file');
+ imageFile2 = globals.fs.file('second_test_image_file');
goldenKey2 = Uri.parse('file://second_golden_key');
createMockProcess = (String stdout) => MockProcess(
exitCode: Future<int>.value(0),
diff --git a/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart b/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart
index e2e1c74..eab269e 100644
--- a/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart
@@ -6,9 +6,9 @@
import 'dart:convert';
import 'dart:typed_data';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/test/flutter_web_platform.dart';
import 'package:flutter_tools/src/test/test_compiler.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -175,7 +175,7 @@
expect(result, null);
await comparator.close();
- expect(fs.systemTempDirectory.listSync(recursive: true), isEmpty);
+ expect(globals.fs.systemTempDirectory.listSync(recursive: true), isEmpty);
}));
});
}
diff --git a/packages/flutter_tools/test/general.shard/web/web_fs_test.dart b/packages/flutter_tools/test/general.shard/web/web_fs_test.dart
index dd372e3..a81216d 100644
--- a/packages/flutter_tools/test/general.shard/web/web_fs_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/web_fs_test.dart
@@ -7,7 +7,6 @@
import 'package:built_collection/built_collection.dart';
import 'package:dwds/asset_handler.dart';
import 'package:dwds/dwds.dart';
-import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
@@ -15,6 +14,7 @@
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/web/chrome.dart';
import 'package:flutter_tools/src/build_runner/web_fs.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:http_multi_server/http_multi_server.dart';
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
@@ -61,7 +61,7 @@
environment: anyNamed('environment'),
)).thenAnswer((Invocation invocation) async {
final String workingDirectory = invocation.namedArguments[#workingDirectory] as String;
- fs.file(fs.path.join(workingDirectory, '.packages')).createSync(recursive: true);
+ globals.fs.file(globals.fs.path.join(workingDirectory, '.packages')).createSync(recursive: true);
return 0;
});
when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) {
@@ -81,12 +81,12 @@
when(mockBuildDaemonCreator.assetServerPort(any)).thenReturn(4321);
testbed = Testbed(
setup: () {
- fs.file(fs.path.join('packages', 'flutter_tools', 'pubspec.yaml'))
+ globals.fs.file(globals.fs.path.join('packages', 'flutter_tools', 'pubspec.yaml'))
..createSync(recursive: true)
..setLastModifiedSync(DateTime(1991, 08, 23));
// Create an empty .packages file so we can read it when we check for
- // plugins on WebFs.start()
- fs.file('.packages').createSync();
+ // plugins on Webglobals.fs.start()
+ globals.fs.file('.packages').createSync();
},
overrides: <Type, Generator>{
Pub: () => MockPub(),
@@ -121,7 +121,7 @@
final FlutterProject flutterProject = FlutterProject.current();
await WebFs.start(
skipDwds: false,
- target: fs.path.join('lib', 'main.dart'),
+ target: globals.fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug,
flutterProject: flutterProject,
initializePlatform: true,
@@ -152,7 +152,7 @@
final FlutterProject flutterProject = FlutterProject.current();
await WebFs.start(
skipDwds: false,
- target: fs.path.join('lib', 'main.dart'),
+ target: globals.fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug,
flutterProject: flutterProject,
initializePlatform: false,
@@ -174,7 +174,7 @@
final FlutterProject flutterProject = FlutterProject.current();
final WebFs webFs = await WebFs.start(
skipDwds: false,
- target: fs.path.join('lib', 'main.dart'),
+ target: globals.fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug,
flutterProject: flutterProject,
initializePlatform: false,
@@ -208,7 +208,7 @@
expect(WebFs.start(
skipDwds: false,
- target: fs.path.join('lib', 'main.dart'),
+ target: globals.fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug,
flutterProject: flutterProject,
initializePlatform: false,
diff --git a/packages/flutter_tools/test/general.shard/web/web_validator_test.dart b/packages/flutter_tools/test/general.shard/web/web_validator_test.dart
index 4717ba6..2bcdb9d 100644
--- a/packages/flutter_tools/test/general.shard/web/web_validator_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/web_validator_test.dart
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/web/chrome.dart';
import 'package:flutter_tools/src/web/web_validator.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/testbed.dart';
diff --git a/packages/flutter_tools/test/general.shard/web/workflow_test.dart b/packages/flutter_tools/test/general.shard/web/workflow_test.dart
index 483c3cb..0adeac2 100644
--- a/packages/flutter_tools/test/general.shard/web/workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/web/workflow_test.dart
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/web/chrome.dart';
import 'package:flutter_tools/src/web/workflow.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -32,7 +33,7 @@
workflow = const WebWorkflow();
mockProcessManager = MockProcessManager();
testbed = Testbed(setup: () async {
- fs.file('chrome').createSync();
+ globals.fs.file('chrome').createSync();
when(mockProcessManager.canRun('chrome')).thenReturn(true);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
diff --git a/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart b/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
index 6a9935e..008d1b0 100644
--- a/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
+++ b/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
@@ -5,11 +5,13 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart' show ProcessException, ProcessResult;
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/windows/visual_studio.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -73,8 +75,8 @@
Map<String, dynamic> response,
String responseOverride,
]) {
- fs.file(vswherePath).createSync(recursive: true);
- fs.file(vcvarsPath).createSync(recursive: true);
+ globals.fs.file(vswherePath).createSync(recursive: true);
+ globals.fs.file(vcvarsPath).createSync(recursive: true);
final MockProcessResult result = MockProcessResult();
when(result.exitCode).thenReturn(0);
diff --git a/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart b/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart
index f59642f..319cf55 100644
--- a/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart
+++ b/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart
@@ -4,13 +4,14 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/windows/application_package.dart';
import 'package:flutter_tools/src/windows/windows_device.dart';
import 'package:flutter_tools/src/device.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
+import 'package:platform/platform.dart';
import '../../src/common.dart';
import '../../src/context.dart';
@@ -41,9 +42,9 @@
});
testUsingContext('isSupportedForProject is true with editable host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
- fs.directory('windows').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
+ globals.fs.directory('windows').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(WindowsDevice().isSupportedForProject(flutterProject), true);
@@ -53,8 +54,8 @@
});
testUsingContext('isSupportedForProject is false with no host app', () async {
- fs.file('pubspec.yaml').createSync();
- fs.file('.packages').createSync();
+ globals.fs.file('pubspec.yaml').createSync();
+ globals.fs.file('.packages').createSync();
final FlutterProject flutterProject = FlutterProject.current();
expect(WindowsDevice().isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart b/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
index 93a6e30..2a047d0 100644
--- a/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
+++ b/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
@@ -4,8 +4,7 @@
import 'package:flutter_tools/src/features.dart';
import 'package:mockito/mockito.dart';
-
-import 'package:flutter_tools/src/base/platform.dart';
+import 'package:platform/platform.dart';
import 'package:flutter_tools/src/windows/windows_workflow.dart';
import '../../src/common.dart';
diff --git a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart
index 571da8a..fbf4163 100644
--- a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart
+++ b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart
@@ -9,6 +9,7 @@
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:process/process.dart';
import '../src/common.dart';
@@ -23,7 +24,7 @@
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
- final String flutterBin = fs.path.join(getFlutterRoot(), 'bin', 'flutter');
+ final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
const ProcessManager processManager = LocalProcessManager();
final Process process = await processManager.start(
diff --git a/packages/flutter_tools/test/integration.shard/flutter_run_test.dart b/packages/flutter_tools/test/integration.shard/flutter_run_test.dart
index d4d1902..e1bfcab 100644
--- a/packages/flutter_tools/test/integration.shard/flutter_run_test.dart
+++ b/packages/flutter_tools/test/integration.shard/flutter_run_test.dart
@@ -5,6 +5,7 @@
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:process/process.dart';
import '../src/common.dart';
@@ -33,7 +34,7 @@
// like https://github.com/flutter/flutter/issues/21418 which were skipped
// over because other integration tests run using flutter-tester which short-cuts
// some of the checks for devices.
- final String flutterBin = fs.path.join(getFlutterRoot(), 'bin', 'flutter');
+ final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
const ProcessManager _processManager = LocalProcessManager();
final ProcessResult _proc = await _processManager.run(
diff --git a/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart b/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart
index 7462ffa..47ae295 100644
--- a/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart
+++ b/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter_tools/src/base/file_system.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../test_utils.dart';
import 'project.dart';
@@ -86,6 +86,6 @@
'// printHotReloadWorked();',
'printHotReloadWorked();',
);
- writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
+ writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
}
}
diff --git a/packages/flutter_tools/test/integration.shard/test_data/project.dart b/packages/flutter_tools/test/integration.shard/test_data/project.dart
index d98147f..cee6092 100644
--- a/packages/flutter_tools/test/integration.shard/test_data/project.dart
+++ b/packages/flutter_tools/test/integration.shard/test_data/project.dart
@@ -6,6 +6,7 @@
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../test_utils.dart';
@@ -19,9 +20,9 @@
Future<void> setUpIn(Directory dir) async {
this.dir = dir;
- writeFile(fs.path.join(dir.path, 'pubspec.yaml'), pubspec);
+ writeFile(globals.fs.path.join(dir.path, 'pubspec.yaml'), pubspec);
if (main != null) {
- writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), main);
+ writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), main);
}
await getPackages(dir.path);
}
diff --git a/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart b/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart
index 0abad69..c452bb6 100644
--- a/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart
+++ b/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart
@@ -5,6 +5,7 @@
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../test_utils.dart';
import 'project.dart';
@@ -45,7 +46,7 @@
return super.setUpIn(dir);
}
- String get testFilePath => fs.path.join(dir.path, 'test', 'test.dart');
+ String get testFilePath => globals.fs.path.join(dir.path, 'test', 'test.dart');
Uri get breakpointUri => Uri.file(testFilePath);
diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart
index ff881e1..8dc062f 100644
--- a/packages/flutter_tools/test/integration.shard/test_driver.dart
+++ b/packages/flutter_tools/test/integration.shard/test_driver.dart
@@ -10,6 +10,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/utils.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:process/process.dart';
import 'package:vm_service/vm_service.dart';
@@ -83,7 +84,7 @@
bool withDebugger = false,
File pidFile,
}) async {
- final String flutterBin = fs.path.join(getFlutterRoot(), 'bin', 'flutter');
+ final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
if (withDebugger) {
arguments.add('--start-paused');
}
diff --git a/packages/flutter_tools/test/integration.shard/test_utils.dart b/packages/flutter_tools/test/integration.shard/test_utils.dart
index 1833a2d..5aa7549 100644
--- a/packages/flutter_tools/test/integration.shard/test_utils.dart
+++ b/packages/flutter_tools/test/integration.shard/test_utils.dart
@@ -6,7 +6,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/process_manager.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import '../src/common.dart';
@@ -15,24 +15,24 @@
/// https://github.com/flutter/flutter/pull/21741
Directory createResolvedTempDirectorySync(String prefix) {
assert(prefix.endsWith('.'));
- final Directory tempDirectory = fs.systemTempDirectory.createTempSync('flutter_$prefix');
- return fs.directory(tempDirectory.resolveSymbolicLinksSync());
+ final Directory tempDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_$prefix');
+ return globals.fs.directory(tempDirectory.resolveSymbolicLinksSync());
}
void writeFile(String path, String content) {
- fs.file(path)
+ globals.fs.file(path)
..createSync(recursive: true)
..writeAsStringSync(content);
}
void writePackages(String folder) {
- writeFile(fs.path.join(folder, '.packages'), '''
-test:${fs.path.join(fs.currentDirectory.path, 'lib')}/
+ writeFile(globals.fs.path.join(folder, '.packages'), '''
+test:${globals.fs.path.join(globals.fs.currentDirectory.path, 'lib')}/
''');
}
void writePubspec(String folder) {
- writeFile(fs.path.join(folder, 'pubspec.yaml'), '''
+ writeFile(globals.fs.path.join(folder, 'pubspec.yaml'), '''
name: test
dependencies:
flutter:
@@ -42,11 +42,11 @@
Future<void> getPackages(String folder) async {
final List<String> command = <String>[
- fs.path.join(getFlutterRoot(), 'bin', 'flutter'),
+ globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'),
'pub',
'get',
];
- final ProcessResult result = await processManager.run(command, workingDirectory: folder);
+ final ProcessResult result = await globals.processManager.run(command, workingDirectory: folder);
if (result.exitCode != 0) {
throw Exception('flutter pub get failed: ${result.stderr}\n${result.stdout}');
}
diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart
index c693e52..419674a 100644
--- a/packages/flutter_tools/test/src/common.dart
+++ b/packages/flutter_tools/test/src/common.dart
@@ -8,11 +8,12 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:test_api/test_api.dart' as test_package show TypeMatcher, test; // ignore: deprecated_member_use
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
@@ -40,20 +41,20 @@
/// environment variable is set, it will be returned. Otherwise, this will
/// deduce the path from `platform.script`.
String getFlutterRoot() {
- if (platform.environment.containsKey('FLUTTER_ROOT')) {
- return platform.environment['FLUTTER_ROOT'];
+ if (globals.platform.environment.containsKey('FLUTTER_ROOT')) {
+ return globals.platform.environment['FLUTTER_ROOT'];
}
- Error invalidScript() => StateError('Could not determine flutter_tools/ path from script URL (${platform.script}); consider setting FLUTTER_ROOT explicitly.');
+ Error invalidScript() => StateError('Could not determine flutter_tools/ path from script URL (${globals.platform.script}); consider setting FLUTTER_ROOT explicitly.');
Uri scriptUri;
- switch (platform.script.scheme) {
+ switch (globals.platform.script.scheme) {
case 'file':
- scriptUri = platform.script;
+ scriptUri = globals.platform.script;
break;
case 'data':
final RegExp flutterTools = RegExp(r'(file://[^"]*[/\\]flutter_tools[/\\][^"]+\.dart)', multiLine: true);
- final Match match = flutterTools.firstMatch(Uri.decodeFull(platform.script.path));
+ final Match match = flutterTools.firstMatch(Uri.decodeFull(globals.platform.script.path));
if (match == null) {
throw invalidScript();
}
@@ -63,13 +64,13 @@
throw invalidScript();
}
- final List<String> parts = fs.path.split(fs.path.fromUri(scriptUri));
+ final List<String> parts = globals.fs.path.split(globals.fs.path.fromUri(scriptUri));
final int toolsIndex = parts.indexOf('flutter_tools');
if (toolsIndex == -1) {
throw invalidScript();
}
- final String toolsPath = fs.path.joinAll(parts.sublist(0, toolsIndex + 1));
- return fs.path.normalize(fs.path.join(toolsPath, '..', '..'));
+ final String toolsPath = globals.fs.path.joinAll(parts.sublist(0, toolsIndex + 1));
+ return globals.fs.path.normalize(globals.fs.path.join(toolsPath, '..', '..'));
}
CommandRunner<void> createTestCommandRunner([ FlutterCommand command ]) {
@@ -87,7 +88,7 @@
int seconds,
) {
final DateTime modificationTime = baseTime.add(Duration(seconds: seconds));
- fs.file(path).setLastModifiedSync(modificationTime);
+ globals.fs.file(path).setLastModifiedSync(modificationTime);
}
/// Matcher for functions that throw [ToolExit].
@@ -120,12 +121,12 @@
/// Returns the path to the flutter project.
Future<String> createProject(Directory temp, { List<String> arguments }) async {
arguments ??= <String>['--no-pub'];
- final String projectPath = fs.path.join(temp.path, 'flutter_project');
+ final String projectPath = globals.fs.path.join(temp.path, 'flutter_project');
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', ...arguments, projectPath]);
// Created `.packages` since it's not created when the flag `--no-pub` is passed.
- fs.file(fs.path.join(projectPath, '.packages')).createSync();
+ globals.fs.file(globals.fs.path.join(projectPath, '.packages')).createSync();
return projectPath;
}
diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart
index 4229d2b..8c29688 100644
--- a/packages/flutter_tools/test/src/context.dart
+++ b/packages/flutter_tools/test/src/context.dart
@@ -28,6 +28,7 @@
import 'package:flutter_tools/src/reporting/github_template.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
@@ -73,16 +74,16 @@
}
});
Config buildConfig(FileSystem fs) {
- configDir ??= fs.systemTempDirectory.createTempSync('flutter_config_dir_test.');
- final File settingsFile = fs.file(
- fs.path.join(configDir.path, '.flutter_settings')
+ configDir ??= globals.fs.systemTempDirectory.createTempSync('flutter_config_dir_test.');
+ final File settingsFile = globals.fs.file(
+ globals.fs.path.join(configDir.path, '.flutter_settings')
);
return Config(settingsFile);
}
PersistentToolState buildPersistentToolState(FileSystem fs) {
- configDir ??= fs.systemTempDirectory.createTempSync('flutter_config_dir_test.');
- final File toolStateFile = fs.file(
- fs.path.join(configDir.path, '.flutter_tool_state'));
+ configDir ??= globals.fs.systemTempDirectory.createTempSync('flutter_config_dir_test.');
+ final File toolStateFile = globals.fs.file(
+ globals.fs.path.join(configDir.path, '.flutter_tool_state'));
return PersistentToolState(toolStateFile);
}
@@ -91,7 +92,7 @@
return context.run<dynamic>(
name: 'mocks',
overrides: <Type, Generator>{
- Config: () => buildConfig(fs),
+ Config: () => buildConfig(globals.fs),
DeviceManager: () => FakeDeviceManager(),
Doctor: () => FakeDoctor(),
FlutterVersion: () => MockFlutterVersion(),
@@ -104,7 +105,7 @@
OutputPreferences: () => OutputPreferences.test(),
Logger: () => BufferLogger(),
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
- PersistentToolState: () => buildPersistentToolState(fs),
+ PersistentToolState: () => buildPersistentToolState(globals.fs),
SimControl: () => MockSimControl(),
Usage: () => FakeUsage(),
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(),
@@ -410,10 +411,10 @@
@override
set currentDirectory(dynamic value) {
- throw 'fs.currentDirectory should not be set on the local file system during '
+ throw 'globals.fs.currentDirectory should not be set on the local file system during '
'tests as this can cause race conditions with concurrent tests. '
'Consider using a MemoryFileSystem for testing if possible or refactor '
- 'code to not require setting fs.currentDirectory.';
+ 'code to not require setting globals.fs.currentDirectory.';
}
}
diff --git a/packages/flutter_tools/test/src/mocks.dart b/packages/flutter_tools/test/src/mocks.dart
index 539f8ab..95fdd64 100644
--- a/packages/flutter_tools/test/src/mocks.dart
+++ b/packages/flutter_tools/test/src/mocks.dart
@@ -6,13 +6,14 @@
import 'dart:convert';
import 'dart:io' as io show IOSink, ProcessSignal, Stdout, StdoutException;
+import 'package:platform/platform.dart';
+
import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/android/android_sdk.dart' show AndroidSdk;
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart' hide IOSink;
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
@@ -21,6 +22,7 @@
import 'package:flutter_tools/src/ios/simulators.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
@@ -36,7 +38,7 @@
MockApplicationPackageStore() : super(
android: AndroidApk(
id: 'io.flutter.android.mock',
- file: fs.file('/mock/path/to/android/SkyShell.apk'),
+ file: globals.fs.file('/mock/path/to/android/SkyShell.apk'),
versionCode: 1,
launchActivity: 'io.flutter.android.mock.MockActivity',
),
@@ -67,9 +69,9 @@
bool withPlatformTools = true,
bool withBuildTools = true,
}) {
- final Directory dir = fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
- final String exe = platform.isWindows ? '.exe' : '';
- final String bat = platform.isWindows ? '.bat' : '';
+ final Directory dir = globals.fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
+ final String exe = globals.platform.isWindows ? '.exe' : '';
+ final String bat = globals.platform.isWindows ? '.bat' : '';
_createDir(dir, 'licenses');
@@ -98,7 +100,7 @@
}
if (withNdkDir != null) {
- final String ndkToolchainBin = fs.path.join(
+ final String ndkToolchainBin = globals.fs.path.join(
'ndk-bundle',
'toolchains',
'arm-linux-androideabi-4.9',
@@ -106,24 +108,24 @@
withNdkDir,
'bin',
);
- final String ndkCompiler = fs.path.join(
+ final String ndkCompiler = globals.fs.path.join(
ndkToolchainBin,
'arm-linux-androideabi-gcc',
);
- final String ndkLinker = fs.path.join(
+ final String ndkLinker = globals.fs.path.join(
ndkToolchainBin,
'arm-linux-androideabi-ld',
);
_createSdkFile(dir, ndkCompiler);
_createSdkFile(dir, ndkLinker);
- _createSdkFile(dir, fs.path.join('ndk-bundle', 'source.properties'), contents: '''
+ _createSdkFile(dir, globals.fs.path.join('ndk-bundle', 'source.properties'), contents: '''
Pkg.Desc = Android NDK[]
Pkg.Revision = $ndkVersion.1.5063045
''');
}
if (withNdkSysroot) {
- final String armPlatform = fs.path.join(
+ final String armPlatform = globals.fs.path.join(
'ndk-bundle',
'platforms',
'android-9',
@@ -144,7 +146,7 @@
}
static void _createDir(Directory dir, String path) {
- final Directory directory = fs.directory(fs.path.join(dir.path, path));
+ final Directory directory = globals.fs.directory(globals.fs.path.join(dir.path, path));
directory.createSync(recursive: true);
}
@@ -675,8 +677,8 @@
}
@override
Future<CompilerOutput> recompile(String mainPath, List<Uri> invalidatedFiles, { String outputPath, String packagesFilePath }) async {
- fs.file(outputPath).createSync(recursive: true);
- fs.file(outputPath).writeAsStringSync('compiled_kernel_output');
+ globals.fs.file(outputPath).createSync(recursive: true);
+ globals.fs.file(outputPath).writeAsStringSync('compiled_kernel_output');
return CompilerOutput(outputPath, 0, <Uri>[]);
}
}
diff --git a/packages/flutter_tools/test/src/testbed.dart b/packages/flutter_tools/test/src/testbed.dart
index 476bb72..2022ebf 100644
--- a/packages/flutter_tools/test/src/testbed.dart
+++ b/packages/flutter_tools/test/src/testbed.dart
@@ -12,7 +12,7 @@
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
-import 'package:flutter_tools/src/base/platform.dart';
+
import 'package:flutter_tools/src/base/signals.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart';
@@ -21,6 +21,7 @@
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/version.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:process/process.dart';
@@ -35,7 +36,7 @@
// this provider. For example, [BufferLogger], [MemoryFileSystem].
final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
// Keeps tests fast by avoiding the actual file system.
- FileSystem: () => MemoryFileSystem(style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix),
+ FileSystem: () => MemoryFileSystem(style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix),
ProcessManager: () => FakeProcessManager.any(),
Logger: () => BufferLogger(), // Allows reading logs and prevents stdout.
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
@@ -61,14 +62,14 @@
///
/// setUp(() {
/// testbed = Testbed(setUp: () {
-/// fs.file('foo').createSync()
+/// globals.fs.file('foo').createSync()
/// });
/// })
///
/// test('Can delete a file', () => testbed.run(() {
-/// expect(fs.file('foo').existsSync(), true);
-/// fs.file('foo').deleteSync();
-/// expect(fs.file('foo').existsSync(), false);
+/// expect(globals.fs.file('foo').existsSync(), true);
+/// globals.fs.file('foo').deleteSync();
+/// expect(globals.fs.file('foo').existsSync(), false);
/// }));
/// });
/// }
@@ -843,32 +844,32 @@
@override
Directory getArtifactDirectory(String name) {
- return fs.currentDirectory;
+ return globals.fs.currentDirectory;
}
@override
Directory getCacheArtifacts() {
- return fs.currentDirectory;
+ return globals.fs.currentDirectory;
}
@override
Directory getCacheDir(String name) {
- return fs.currentDirectory;
+ return globals.fs.currentDirectory;
}
@override
Directory getDownloadDir() {
- return fs.currentDirectory;
+ return globals.fs.currentDirectory;
}
@override
Directory getRoot() {
- return fs.currentDirectory;
+ return globals.fs.currentDirectory;
}
@override
File getLicenseFile() {
- return fs.currentDirectory.childFile('LICENSE');
+ return globals.fs.currentDirectory.childFile('LICENSE');
}
@override
@@ -893,7 +894,7 @@
@override
Directory getWebSdkDirectory() {
- return fs.currentDirectory;
+ return globals.fs.currentDirectory;
}
@override
diff --git a/packages/flutter_tools/test/template_test.dart b/packages/flutter_tools/test/template_test.dart
index 8c042c9..2aedd4e 100644
--- a/packages/flutter_tools/test/template_test.dart
+++ b/packages/flutter_tools/test/template_test.dart
@@ -5,6 +5,7 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/template.dart';
+import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'src/common.dart';
@@ -18,7 +19,7 @@
});
test('Template.render throws ToolExit when FileSystem exception is raised', () => testbed.run(() {
- final Template template = Template(fs.directory('examples'), fs.currentDirectory);
+ final Template template = Template(globals.fs.directory('examples'), globals.fs.currentDirectory);
final MockDirectory mockDirectory = MockDirectory();
when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());