Unverified Commit 537cf33a authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Move processUtils to globals (#67976)

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