diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart index 3039a01aee6..e2104f9f8db 100644 --- a/packages/flutter_tools/lib/src/android/android_sdk.dart +++ b/packages/flutter_tools/lib/src/android/android_sdk.dart @@ -370,7 +370,7 @@ class AndroidSdk { // See: http://stackoverflow.com/questions/14292698/how-do-i-check-if-the-java-jdk-is-installed-on-mac. if (platform.isMacOS) { try { - final String javaHomeOutput = processUtils.runSync( + final String javaHomeOutput = globals.processUtils.runSync( ['/usr/libexec/java_home', '-v', '1.8'], throwOnError: true, hideStdout: true, @@ -415,7 +415,7 @@ class AndroidSdk { if (!globals.processManager.canRun(sdkManagerPath)) { throwToolExit('Android sdkmanager not found. Update to the latest Android SDK to resolve this.'); } - final RunResult result = processUtils.runSync( + final RunResult result = globals.processUtils.runSync( [sdkManagerPath, '--version'], environment: sdkManagerEnv, ); diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart index a7f65403b3a..19370c19b5d 100644 --- a/packages/flutter_tools/lib/src/android/android_studio.dart +++ b/packages/flutter_tools/lib/src/android/android_studio.dart @@ -333,7 +333,7 @@ class AndroidStudio implements Comparable { } else { RunResult result; try { - result = processUtils.runSync([javaExecutable, '-version']); + result = globals.processUtils.runSync([javaExecutable, '-version']); } on ProcessException catch (e) { _validationMessages.add('Failed to run Java: $e'); } diff --git a/packages/flutter_tools/lib/src/android/android_workflow.dart b/packages/flutter_tools/lib/src/android/android_workflow.dart index 0b46e47a64a..4c881ec38b7 100644 --- a/packages/flutter_tools/lib/src/android/android_workflow.dart +++ b/packages/flutter_tools/lib/src/android/android_workflow.dart @@ -12,7 +12,6 @@ import '../base/io.dart'; import '../base/logger.dart'; import '../base/os.dart'; import '../base/platform.dart'; -import '../base/process.dart'; import '../base/user_messages.dart'; import '../base/utils.dart'; import '../base/version.dart'; @@ -346,7 +345,7 @@ class AndroidLicenseValidator extends DoctorValidator { } try { - final Process process = await processUtils.start( + final Process process = await globals.processUtils.start( [globals.androidSdk.sdkManagerPath, '--licenses'], environment: globals.androidSdk.sdkManagerEnv, ); @@ -383,7 +382,7 @@ class AndroidLicenseValidator extends DoctorValidator { } try { - final Process process = await processUtils.start( + final Process process = await globals.processUtils.start( [globals.androidSdk.sdkManagerPath, '--licenses'], environment: globals.androidSdk.sdkManagerEnv, ); diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index bde418d17ae..9645a4eb2c9 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -138,7 +138,7 @@ Future checkGradleDependencies() async { 'Ensuring gradle dependencies are up to date...', ); final FlutterProject flutterProject = FlutterProject.current(); - await processUtils.run([ + await globals.processUtils.run([ gradleUtils.getExecutable(flutterProject), 'dependencies', ], @@ -385,7 +385,7 @@ Future buildGradleApp({ final Stopwatch sw = Stopwatch()..start(); int exitCode = 1; try { - exitCode = await processUtils.stream( + exitCode = await globals.processUtils.stream( command, workingDirectory: project.android.hostAppGradleRoot.path, allowReentrantFlutter: true, @@ -649,7 +649,7 @@ Future buildGradleAar({ final Stopwatch sw = Stopwatch()..start(); RunResult result; try { - result = await processUtils.run( + result = await globals.processUtils.run( command, workingDirectory: project.android.hostAppGradleRoot.path, allowReentrantFlutter: true, diff --git a/packages/flutter_tools/lib/src/android/gradle_errors.dart b/packages/flutter_tools/lib/src/android/gradle_errors.dart index 142655ad2d7..e19caf94fde 100644 --- a/packages/flutter_tools/lib/src/android/gradle_errors.dart +++ b/packages/flutter_tools/lib/src/android/gradle_errors.dart @@ -274,7 +274,7 @@ final GradleHandledError flavorUndefinedHandler = GradleHandledError( bool usesAndroidX, bool shouldBuildPluginAsAar, }) async { - final RunResult tasksRunResult = await processUtils.run( + final RunResult tasksRunResult = await globals.processUtils.run( [ gradleUtils.getExecutable(project), 'app:tasks' , diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart index 04513af7f0d..2423edfa6b1 100644 --- a/packages/flutter_tools/lib/src/application_package.dart +++ b/packages/flutter_tools/lib/src/application_package.dart @@ -116,7 +116,7 @@ class AndroidApk extends ApplicationPackage { String apptStdout; try { - apptStdout = processUtils.runSync( + apptStdout = globals.processUtils.runSync( [ aaptPath, 'dump', diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart index d7691849cc5..e72d9846eb1 100644 --- a/packages/flutter_tools/lib/src/base/process.dart +++ b/packages/flutter_tools/lib/src/base/process.dart @@ -180,8 +180,6 @@ class RunResult { typedef RunResultChecker = bool Function(int); -ProcessUtils get processUtils => ProcessUtils.instance; - abstract class ProcessUtils { factory ProcessUtils({ @required ProcessManager processManager, @@ -191,8 +189,6 @@ abstract class ProcessUtils { logger: logger, ); - static ProcessUtils get instance => context.get(); - /// Spawns a child process to run the command [cmd]. /// /// When [throwOnError] is `true`, if the child process finishes with a non-zero 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 d92568d22ff..518de121462 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart @@ -244,7 +244,7 @@ class DebugUniversalFramework extends Target { '-output', lipoOutputFile.path ]; - final RunResult lipoResult = await processUtils.run( + final RunResult lipoResult = await globals.processUtils.run( lipoCommand, ); diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index 834c97fe7d1..e31acad3c61 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -1085,7 +1085,7 @@ class AndroidMavenArtifacts extends ArtifactSet { try { final String gradleExecutable = gradle.absolute.path; final String flutterSdk = globals.fsUtils.escapePath(Cache.flutterRoot); - final RunResult processResult = await processUtils.run( + final RunResult processResult = await globals.processUtils.run( [ gradleExecutable, '-b', globals.fs.path.join(flutterSdk, 'packages', 'flutter_tools', 'gradle', 'resolve_dependencies.gradle'), 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 e68901bcf14..3230021d46d 100644 --- a/packages/flutter_tools/lib/src/commands/build_ios_framework.dart +++ b/packages/flutter_tools/lib/src/commands/build_ios_framework.dart @@ -323,7 +323,7 @@ end '-output', fatFlutterFrameworkBinary.path ]; - final RunResult lipoResult = await processUtils.run( + final RunResult lipoResult = await globals.processUtils.run( lipoCommand, allowReentrantFlutter: false, ); @@ -436,7 +436,7 @@ end 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', ]; - RunResult buildPluginsResult = await processUtils.run( + RunResult buildPluginsResult = await globals.processUtils.run( pluginsBuildCommand, workingDirectory: _project.ios.hostAppRoot.childDirectory('Pods').path, allowReentrantFlutter: false, @@ -462,7 +462,7 @@ end 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES', ]; - buildPluginsResult = await processUtils.run( + buildPluginsResult = await globals.processUtils.run( pluginsBuildCommand, workingDirectory: _project.ios.hostAppRoot .childDirectory('Pods') @@ -514,7 +514,7 @@ end modeDirectory.childDirectory(podFrameworkName).childFile(binaryName).path ]; - final RunResult pluginsLipoResult = await processUtils.run( + final RunResult pluginsLipoResult = await globals.processUtils.run( lipoCommand, workingDirectory: outputDirectory.path, allowReentrantFlutter: false, @@ -545,7 +545,7 @@ end modeDirectory.childFile('$binaryName.xcframework').path ]; - final RunResult xcframeworkResult = await processUtils.run( + final RunResult xcframeworkResult = await globals.processUtils.run( xcframeworkCommand, workingDirectory: outputDirectory.path, allowReentrantFlutter: false, @@ -621,7 +621,7 @@ end armFlutterFrameworkBinary.path ]; - RunResult lipoResult = await processUtils.run( + RunResult lipoResult = await globals.processUtils.run( lipoCommand, allowReentrantFlutter: false, ); @@ -647,7 +647,7 @@ end simulatorFlutterFrameworkBinary.path ]; - lipoResult = await processUtils.run( + lipoResult = await globals.processUtils.run( lipoCommand, allowReentrantFlutter: false, ); @@ -669,7 +669,7 @@ end .path ]; - final RunResult xcframeworkResult = await processUtils.run( + final RunResult xcframeworkResult = await globals.processUtils.run( xcframeworkCommand, allowReentrantFlutter: false, ); @@ -701,7 +701,7 @@ end .path ]; - final RunResult xcframeworkResult = await processUtils.run( + final RunResult xcframeworkResult = await globals.processUtils.run( xcframeworkCommand, allowReentrantFlutter: false, ); diff --git a/packages/flutter_tools/lib/src/commands/channel.dart b/packages/flutter_tools/lib/src/commands/channel.dart index 431c8f95126..7ab0d5f4b21 100644 --- a/packages/flutter_tools/lib/src/commands/channel.dart +++ b/packages/flutter_tools/lib/src/commands/channel.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import '../base/common.dart'; -import '../base/process.dart'; import '../cache.dart'; import '../globals.dart' as globals; import '../runner/flutter_command.dart'; @@ -59,7 +58,7 @@ class ChannelCommand extends FlutterCommand { showAll = showAll || currentChannel != currentBranch; globals.printStatus('Flutter channels:'); - final int result = await processUtils.stream( + final int result = await globals.processUtils.stream( ['git', 'branch', '-r'], workingDirectory: Cache.flutterRoot, mapFunction: (String line) { @@ -138,28 +137,28 @@ class ChannelCommand extends FlutterCommand { static Future _checkout(String branchName) async { // Get latest refs from upstream. - int result = await processUtils.stream( + int result = await globals.processUtils.stream( ['git', 'fetch'], workingDirectory: Cache.flutterRoot, prefix: 'git: ', ); if (result == 0) { - result = await processUtils.stream( + result = await globals.processUtils.stream( ['git', 'show-ref', '--verify', '--quiet', 'refs/heads/$branchName'], workingDirectory: Cache.flutterRoot, prefix: 'git: ', ); if (result == 0) { // branch already exists, try just switching to it - result = await processUtils.stream( + result = await globals.processUtils.stream( ['git', 'checkout', branchName, '--'], workingDirectory: Cache.flutterRoot, prefix: 'git: ', ); } else { // branch does not exist, we have to create it - result = await processUtils.stream( + result = await globals.processUtils.stream( ['git', 'checkout', '--track', '-b', branchName, 'origin/$branchName'], workingDirectory: Cache.flutterRoot, prefix: 'git: ', diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index a81c07c5ac4..bcc6fc896e2 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -16,7 +16,6 @@ import '../application_package.dart'; import '../artifacts.dart'; import '../base/common.dart'; import '../base/file_system.dart'; -import '../base/process.dart'; import '../build_info.dart'; import '../convert.dart'; import '../dart/package_map.dart'; @@ -536,7 +535,7 @@ Future _runTests(List testArgs, Map environment) a globals.printTrace('Running driver tests.'); globalPackagesPath = globals.fs.path.normalize(globals.fs.path.absolute(globalPackagesPath)); - final int result = await processUtils.stream( + final int result = await globals.processUtils.stream( [ globals.artifacts.getArtifactPath(Artifact.engineDartBinary), ...testArgs, diff --git a/packages/flutter_tools/lib/src/commands/format.dart b/packages/flutter_tools/lib/src/commands/format.dart index da92d72ab47..4ec89311ce4 100644 --- a/packages/flutter_tools/lib/src/commands/format.dart +++ b/packages/flutter_tools/lib/src/commands/format.dart @@ -4,7 +4,6 @@ import '../artifacts.dart'; import '../base/common.dart'; -import '../base/process.dart'; import '../globals.dart' as globals; import '../runner/flutter_command.dart'; @@ -72,7 +71,7 @@ class FormatCommand extends FlutterCommand { ...argResults.rest, ]; - final int result = await processUtils.stream(command); + final int result = await globals.processUtils.stream(command); if (result != 0) { throwToolExit('Formatting failed: $result', exitCode: result); } diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart index 0253d49a150..4b2b364c26c 100644 --- a/packages/flutter_tools/lib/src/commands/upgrade.dart +++ b/packages/flutter_tools/lib/src/commands/upgrade.dart @@ -59,7 +59,7 @@ class UpgradeCommand extends FlutterCommand { force: boolArg('force'), continueFlow: boolArg('continue'), testFlow: stringArg('working-directory') != null, - gitTagVersion: GitTagVersion.determine(processUtils), + gitTagVersion: GitTagVersion.determine(globals.processUtils), flutterVersion: stringArg('working-directory') == null ? globals.flutterVersion : FlutterVersion(const SystemClock(), _commandRunner.workingDirectory), @@ -150,7 +150,7 @@ class UpgradeCommandRunner { } Future flutterUpgradeContinue() async { - final int code = await processUtils.stream( + final int code = await globals.processUtils.stream( [ globals.fs.path.join('bin', 'flutter'), 'upgrade', @@ -180,7 +180,7 @@ class UpgradeCommandRunner { Future hasUncommittedChanges() async { try { - final RunResult result = await processUtils.run( + final RunResult result = await globals.processUtils.run( ['git', 'status', '-s'], throwOnError: true, workingDirectory: workingDirectory, @@ -205,13 +205,13 @@ class UpgradeCommandRunner { String revision; try { // Fetch upstream branch's commits and tags - await processUtils.run( + await globals.processUtils.run( ['git', 'fetch', '--tags'], throwOnError: true, workingDirectory: workingDirectory, ); // '@{u}' means upstream HEAD - final RunResult result = await processUtils.run( + final RunResult result = await globals.processUtils.run( [ 'git', 'rev-parse', '--verify', '@{u}'], throwOnError: true, workingDirectory: workingDirectory, @@ -254,7 +254,7 @@ class UpgradeCommandRunner { /// to the next release. Future attemptReset(String newRevision) async { try { - await processUtils.run( + await globals.processUtils.run( ['git', 'reset', '--hard', newRevision], throwOnError: true, workingDirectory: workingDirectory, @@ -272,7 +272,7 @@ class UpgradeCommandRunner { Future precacheArtifacts() async { globals.printStatus(''); globals.printStatus('Upgrading engine...'); - final int code = await processUtils.stream( + final int code = await globals.processUtils.stream( [ globals.fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache', ], @@ -306,7 +306,7 @@ class UpgradeCommandRunner { Future runDoctor() async { globals.printStatus(''); globals.printStatus('Running flutter doctor...'); - await processUtils.stream( + await globals.processUtils.stream( [ globals.fs.path.join('bin', 'flutter'), '--no-version-check', 'doctor', ], diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart index e01c6783f6d..68dca655cbc 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart @@ -10,7 +10,6 @@ import '../base/common.dart'; import '../base/file_system.dart'; import '../base/io.dart'; import '../base/logger.dart'; -import '../base/process.dart'; import '../base/utils.dart'; import '../build_info.dart'; import '../bundle.dart'; @@ -105,7 +104,7 @@ Future _genSnapshot( 'Compiling Fuchsia application to native code...', ); try { - result = await processUtils.stream(command, trace: true); + result = await globals.processUtils.stream(command, trace: true); } finally { status.cancel(); } diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index ed1864116ac..6d16d7a5618 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -656,7 +656,7 @@ class FuchsiaDevice extends Device { throwToolExit('Cannot interact with device. No ssh config.\n' 'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'); } - return await processUtils.run([ + return await globals.processUtils.run([ 'ssh', '-F', globals.fuchsiaArtifacts.sshConfig.absolute.path, @@ -671,7 +671,7 @@ class FuchsiaDevice extends Device { throwToolExit('Cannot interact with device. No ssh config.\n' 'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'); } - return await processUtils.run([ + return await globals.processUtils.run([ 'scp', '-F', globals.fuchsiaArtifacts.sshConfig.absolute.path, 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 8e3ce77943e..21338135979 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart @@ -7,7 +7,6 @@ import 'package:meta/meta.dart'; import '../artifacts.dart'; import '../base/common.dart'; import '../base/logger.dart'; -import '../base/process.dart'; import '../build_info.dart'; import '../globals.dart' as globals; import '../project.dart'; @@ -74,7 +73,7 @@ class FuchsiaKernelCompiler { ); int result; try { - result = await processUtils.stream(command, trace: true); + result = await globals.processUtils.stream(command, trace: true); } finally { status.cancel(); } diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart index f8e7bd0332b..65fd72f7d67 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart @@ -121,7 +121,7 @@ class FuchsiaPM { '-l', '$host:$port', ]; - final Process process = await processUtils.start(command); + final Process process = await globals.processUtils.start(command); process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -155,7 +155,7 @@ class FuchsiaPM { throwToolExit('Fuchsia pm tool not found'); } final List command = [globals.fuchsiaArtifacts.pm.path, ...args]; - final RunResult result = await processUtils.run(command); + final RunResult result = await globals.processUtils.run(command); return result.exitCode == 0; } } diff --git a/packages/flutter_tools/lib/src/globals.dart b/packages/flutter_tools/lib/src/globals.dart index 329f6d981d9..755f23d67eb 100644 --- a/packages/flutter_tools/lib/src/globals.dart +++ b/packages/flutter_tools/lib/src/globals.dart @@ -17,6 +17,7 @@ import 'base/logger.dart'; import 'base/net.dart'; import 'base/os.dart'; import 'base/platform.dart'; +import 'base/process.dart'; import 'base/signals.dart'; import 'base/template.dart'; import 'base/terminal.dart'; @@ -83,6 +84,7 @@ const ProcessManager _kLocalProcessManager = LocalProcessManager(); /// The active process manager. ProcessManager get processManager => context.get() ?? _kLocalProcessManager; +ProcessUtils get processUtils => context.get(); const Platform _kLocalPlatform = LocalPlatform(); diff --git a/packages/flutter_tools/lib/src/ios/ios_emulators.dart b/packages/flutter_tools/lib/src/ios/ios_emulators.dart index 8edbab1ec01..f54748b1b66 100644 --- a/packages/flutter_tools/lib/src/ios/ios_emulators.dart +++ b/packages/flutter_tools/lib/src/ios/ios_emulators.dart @@ -47,7 +47,7 @@ class IOSEmulator extends Emulator { globals.xcode.getSimulatorPath(), ]; - final RunResult launchResult = await processUtils.run(args); + final RunResult launchResult = await globals.processUtils.run(args); if (launchResult.exitCode != 0) { globals.printError('$launchResult'); return false; diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index d54aa766daf..9c01e29d59e 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -117,7 +117,7 @@ Future buildXcodeProject({ return XcodeBuildResult(success: false); } - await removeFinderExtendedAttributes(app.project.hostAppRoot, processUtils, globals.logger); + await removeFinderExtendedAttributes(app.project.hostAppRoot, globals.processUtils, globals.logger); final XcodeProjectInfo projectInfo = await app.project.projectInfo(); final String scheme = projectInfo.schemeFor(buildInfo); @@ -365,7 +365,7 @@ Future buildXcodeProject({ const Duration showBuildSettingsTimeout = Duration(minutes: 1); Map buildSettings; try { - final RunResult showBuildSettingsResult = await processUtils.run( + final RunResult showBuildSettingsResult = await globals.processUtils.run( showBuildSettingsCommand, throwOnError: true, workingDirectory: app.project.hostAppRoot.path, @@ -484,7 +484,7 @@ Future _runBuildWithRetries(List buildCommands, BuildableIOSA remainingTries--; buildRetryDelaySeconds *= 2; - buildResult = await processUtils.run( + buildResult = await globals.processUtils.run( buildCommands, workingDirectory: app.project.hostAppRoot.path, allowReentrantFlutter: true, diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index c013ca08c9a..832964be066 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -612,7 +612,7 @@ class IOSSimulator extends Device { /// Launches the device log reader process on the host and parses the syslog. @visibleForTesting Future launchDeviceSystemLogTool(IOSSimulator device) async { - return processUtils.start(['tail', '-n', '0', '-F', device.logFilePath]); + return globals.processUtils.start(['tail', '-n', '0', '-F', device.logFilePath]); } /// Launches the device log reader process on the host and parses unified logging. @@ -638,7 +638,7 @@ Future launchDeviceUnifiedLogging (IOSSimulator device, String appName) notP('eventMessage CONTAINS " libxpc.dylib "'), ]); - return processUtils.start([ + return globals.processUtils.start([ _xcrunPath, 'simctl', 'spawn', device.id, 'log', 'stream', '--style', 'json', '--predicate', predicate, ]); } @@ -647,7 +647,7 @@ Future launchDeviceUnifiedLogging (IOSSimulator device, String appName) Future launchSystemLogTool(IOSSimulator device) async { // Versions of iOS prior to 11 tail the simulator syslog file. if (await device.sdkMajorVersion < 11) { - return processUtils.start(['tail', '-n', '0', '-F', '/private/var/log/system.log']); + return globals.processUtils.start(['tail', '-n', '0', '-F', '/private/var/log/system.log']); } // For iOS 11 and later, all relevant detail is in the device log. diff --git a/packages/flutter_tools/lib/src/linux/build_linux.dart b/packages/flutter_tools/lib/src/linux/build_linux.dart index b41a7083c24..41c8a87609c 100644 --- a/packages/flutter_tools/lib/src/linux/build_linux.dart +++ b/packages/flutter_tools/lib/src/linux/build_linux.dart @@ -7,7 +7,6 @@ import '../base/analyze_size.dart'; import '../base/common.dart'; import '../base/file_system.dart'; import '../base/logger.dart'; -import '../base/process.dart'; import '../base/utils.dart'; import '../build_info.dart'; import '../cache.dart'; @@ -88,7 +87,7 @@ Future _runCmake(String buildModeName, Directory sourceDir, Directory buil final String buildFlag = toTitleCase(buildModeName); int result; try { - result = await processUtils.stream( + result = await globals.processUtils.stream( [ 'cmake', '-G', @@ -117,7 +116,7 @@ Future _runBuild(Directory buildDir) async { int result; try { - result = await processUtils.stream( + result = await globals.processUtils.stream( [ 'ninja', '-C', diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index a68c18f5e21..5c8e8b034a4 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -8,7 +8,6 @@ import '../base/analyze_size.dart'; import '../base/common.dart'; import '../base/file_system.dart'; import '../base/logger.dart'; -import '../base/process.dart'; import '../build_info.dart'; import '../convert.dart'; import '../globals.dart' as globals; @@ -82,7 +81,7 @@ Future buildMacOS({ ); int result; try { - result = await processUtils.stream([ + result = await globals.processUtils.stream([ '/usr/bin/env', 'xcrun', 'xcodebuild', diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index 5b624719b93..48850df5ae9 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -168,7 +168,7 @@ class CoverageCollector extends TestWatcher { final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_test_coverage.'); try { final File sourceFile = coverageFile.copySync(globals.fs.path.join(tempDir.path, 'lcov.source.info')); - final RunResult result = processUtils.runSync([ + final RunResult result = globals.processUtils.runSync([ 'lcov', '--add-tracefile', baseCoverageData, '--add-tracefile', sourceFile.path, diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 52ed2fde571..47674cedfcc 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -70,10 +70,10 @@ class FlutterVersion { FlutterVersion([this._clock = const SystemClock(), this._workingDirectory]) { _frameworkRevision = _runGit( gitLog(['-n', '1', '--pretty=format:%H']).join(' '), - processUtils, + globals.processUtils, _workingDirectory, ); - _gitTagVersion = GitTagVersion.determine(processUtils, workingDirectory: _workingDirectory, fetchTags: false); + _gitTagVersion = GitTagVersion.determine(globals.processUtils, workingDirectory: _workingDirectory, fetchTags: false); _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); } @@ -84,7 +84,7 @@ class FlutterVersion { /// user explicitly wants to get the version, e.g. for `flutter --version` or /// `flutter doctor`. void fetchTagsAndUpdate() { - _gitTagVersion = GitTagVersion.determine(processUtils, workingDirectory: _workingDirectory, fetchTags: true); + _gitTagVersion = GitTagVersion.determine(globals.processUtils, workingDirectory: _workingDirectory, fetchTags: true); _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); } @@ -110,7 +110,7 @@ class FlutterVersion { if (_channel == null) { final String channel = _runGit( 'git rev-parse --abbrev-ref --symbolic @{u}', - processUtils, + globals.processUtils, _workingDirectory, ); final int slash = channel.indexOf('/'); @@ -118,7 +118,7 @@ class FlutterVersion { final String remote = channel.substring(0, slash); _repositoryUrl = _runGit( 'git ls-remote --get-url $remote', - processUtils, + globals.processUtils, _workingDirectory, ); _channel = channel.substring(slash + 1); @@ -146,7 +146,7 @@ class FlutterVersion { String get frameworkAge { return _frameworkAge ??= _runGit( gitLog(['-n', '1', '--pretty=format:%ar']).join(' '), - processUtils, + globals.processUtils, _workingDirectory, ); } @@ -293,7 +293,7 @@ class FlutterVersion { /// the branch name will be returned as `'[user-branch]'`. String getBranchName({ bool redactUnknownBranches = false }) { _branch ??= () { - final String branch = _runGit('git rev-parse --abbrev-ref HEAD', processUtils); + final String branch = _runGit('git rev-parse --abbrev-ref HEAD', globals.processUtils); return branch == 'HEAD' ? channel : branch; }(); if (redactUnknownBranches || _branch.isEmpty) { diff --git a/packages/flutter_tools/lib/src/windows/build_windows.dart b/packages/flutter_tools/lib/src/windows/build_windows.dart index 4b132ebe9ba..228a05a2e22 100644 --- a/packages/flutter_tools/lib/src/windows/build_windows.dart +++ b/packages/flutter_tools/lib/src/windows/build_windows.dart @@ -7,7 +7,6 @@ import '../base/analyze_size.dart'; import '../base/common.dart'; import '../base/file_system.dart'; import '../base/logger.dart'; -import '../base/process.dart'; import '../base/utils.dart'; import '../build_info.dart'; import '../cache.dart'; @@ -94,7 +93,7 @@ Future _runCmakeGeneration(String cmakePath, Directory buildDir, Directory await buildDir.create(recursive: true); int result; try { - result = await processUtils.stream( + result = await globals.processUtils.stream( [ cmakePath, '-S', @@ -124,7 +123,7 @@ Future _runBuild(String cmakePath, Directory buildDir, String buildModeNam int result; try { - result = await processUtils.stream( + result = await globals.processUtils.stream( [ cmakePath, '--build', diff --git a/packages/flutter_tools/lib/src/windows/windows_device.dart b/packages/flutter_tools/lib/src/windows/windows_device.dart index 70233f0eba5..3b41a4e2e9c 100644 --- a/packages/flutter_tools/lib/src/windows/windows_device.dart +++ b/packages/flutter_tools/lib/src/windows/windows_device.dart @@ -6,10 +6,8 @@ import 'package:meta/meta.dart'; import 'package:process/process.dart'; import '../base/file_system.dart'; -import '../base/io.dart'; import '../base/logger.dart'; import '../base/os.dart'; -import '../base/process.dart'; import '../build_info.dart'; import '../desktop_device.dart'; import '../device.dart'; @@ -112,39 +110,3 @@ class WindowsDevices extends PollingDeviceDiscovery { @override Future> getDiagnostics() async => const []; } - -final RegExp _whitespace = RegExp(r'\s+'); - -/// Returns the running process matching `process` name. -/// -/// This list contains the process name and id. -@visibleForTesting -List runningProcess(String processName) { - // TODO(jonahwilliams): find a way to do this without powershell. - final RunResult result = processUtils.runSync( - ['powershell', '-script="Get-CimInstance Win32_Process"'], - ); - if (result.exitCode != 0) { - return null; - } - for (final String rawProcess in result.stdout.split('\n')) { - final String process = rawProcess.trim(); - if (!process.contains(processName)) { - continue; - } - final List parts = process.split(_whitespace); - - final String processPid = parts[0]; - final String currentRunningProcessPid = pid.toString(); - // Don't kill the flutter tool process - if (processPid == currentRunningProcessPid) { - continue; - } - final List data = [ - processPid, // ID - parts[1], // Name - ]; - return data; - } - return null; -}