mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Move processUtils to globals (#67976)
This commit is contained in:
parent
cd60da784f
commit
537cf33a21
@ -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(
|
||||
<String>['/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(
|
||||
<String>[sdkManagerPath, '--version'],
|
||||
environment: sdkManagerEnv,
|
||||
);
|
||||
|
||||
@ -333,7 +333,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
|
||||
} else {
|
||||
RunResult result;
|
||||
try {
|
||||
result = processUtils.runSync(<String>[javaExecutable, '-version']);
|
||||
result = globals.processUtils.runSync(<String>[javaExecutable, '-version']);
|
||||
} on ProcessException catch (e) {
|
||||
_validationMessages.add('Failed to run Java: $e');
|
||||
}
|
||||
|
||||
@ -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(
|
||||
<String>[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(
|
||||
<String>[globals.androidSdk.sdkManagerPath, '--licenses'],
|
||||
environment: globals.androidSdk.sdkManagerEnv,
|
||||
);
|
||||
|
||||
@ -138,7 +138,7 @@ Future<void> checkGradleDependencies() async {
|
||||
'Ensuring gradle dependencies are up to date...',
|
||||
);
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
await processUtils.run(<String>[
|
||||
await globals.processUtils.run(<String>[
|
||||
gradleUtils.getExecutable(flutterProject),
|
||||
'dependencies',
|
||||
],
|
||||
@ -385,7 +385,7 @@ Future<void> 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<void> 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,
|
||||
|
||||
@ -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(
|
||||
<String>[
|
||||
gradleUtils.getExecutable(project),
|
||||
'app:tasks' ,
|
||||
|
||||
@ -116,7 +116,7 @@ class AndroidApk extends ApplicationPackage {
|
||||
|
||||
String apptStdout;
|
||||
try {
|
||||
apptStdout = processUtils.runSync(
|
||||
apptStdout = globals.processUtils.runSync(
|
||||
<String>[
|
||||
aaptPath,
|
||||
'dump',
|
||||
|
||||
@ -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<ProcessUtils>();
|
||||
|
||||
/// Spawns a child process to run the command [cmd].
|
||||
///
|
||||
/// When [throwOnError] is `true`, if the child process finishes with a non-zero
|
||||
|
||||
@ -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,
|
||||
);
|
||||
|
||||
|
||||
@ -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(
|
||||
<String>[
|
||||
gradleExecutable,
|
||||
'-b', globals.fs.path.join(flutterSdk, 'packages', 'flutter_tools', 'gradle', 'resolve_dependencies.gradle'),
|
||||
|
||||
@ -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,
|
||||
);
|
||||
|
||||
@ -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(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
mapFunction: (String line) {
|
||||
@ -138,28 +137,28 @@ class ChannelCommand extends FlutterCommand {
|
||||
|
||||
static Future<void> _checkout(String branchName) async {
|
||||
// Get latest refs from upstream.
|
||||
int result = await processUtils.stream(
|
||||
int result = await globals.processUtils.stream(
|
||||
<String>['git', 'fetch'],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
);
|
||||
|
||||
if (result == 0) {
|
||||
result = await processUtils.stream(
|
||||
result = await globals.processUtils.stream(
|
||||
<String>['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(
|
||||
<String>['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(
|
||||
<String>['git', 'checkout', '--track', '-b', branchName, 'origin/$branchName'],
|
||||
workingDirectory: Cache.flutterRoot,
|
||||
prefix: 'git: ',
|
||||
|
||||
@ -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<void> _runTests(List<String> testArgs, Map<String, String> 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(
|
||||
<String>[
|
||||
globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
...testArgs,
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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<void> flutterUpgradeContinue() async {
|
||||
final int code = await processUtils.stream(
|
||||
final int code = await globals.processUtils.stream(
|
||||
<String>[
|
||||
globals.fs.path.join('bin', 'flutter'),
|
||||
'upgrade',
|
||||
@ -180,7 +180,7 @@ class UpgradeCommandRunner {
|
||||
|
||||
Future<bool> hasUncommittedChanges() async {
|
||||
try {
|
||||
final RunResult result = await processUtils.run(
|
||||
final RunResult result = await globals.processUtils.run(
|
||||
<String>['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(
|
||||
<String>['git', 'fetch', '--tags'],
|
||||
throwOnError: true,
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
// '@{u}' means upstream HEAD
|
||||
final RunResult result = await processUtils.run(
|
||||
final RunResult result = await globals.processUtils.run(
|
||||
<String>[ 'git', 'rev-parse', '--verify', '@{u}'],
|
||||
throwOnError: true,
|
||||
workingDirectory: workingDirectory,
|
||||
@ -254,7 +254,7 @@ class UpgradeCommandRunner {
|
||||
/// to the next release.
|
||||
Future<void> attemptReset(String newRevision) async {
|
||||
try {
|
||||
await processUtils.run(
|
||||
await globals.processUtils.run(
|
||||
<String>['git', 'reset', '--hard', newRevision],
|
||||
throwOnError: true,
|
||||
workingDirectory: workingDirectory,
|
||||
@ -272,7 +272,7 @@ class UpgradeCommandRunner {
|
||||
Future<void> precacheArtifacts() async {
|
||||
globals.printStatus('');
|
||||
globals.printStatus('Upgrading engine...');
|
||||
final int code = await processUtils.stream(
|
||||
final int code = await globals.processUtils.stream(
|
||||
<String>[
|
||||
globals.fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache',
|
||||
],
|
||||
@ -306,7 +306,7 @@ class UpgradeCommandRunner {
|
||||
Future<void> runDoctor() async {
|
||||
globals.printStatus('');
|
||||
globals.printStatus('Running flutter doctor...');
|
||||
await processUtils.stream(
|
||||
await globals.processUtils.stream(
|
||||
<String>[
|
||||
globals.fs.path.join('bin', 'flutter'), '--no-version-check', 'doctor',
|
||||
],
|
||||
|
||||
@ -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<void> _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();
|
||||
}
|
||||
|
||||
@ -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(<String>[
|
||||
return await globals.processUtils.run(<String>[
|
||||
'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(<String>[
|
||||
return await globals.processUtils.run(<String>[
|
||||
'scp',
|
||||
'-F',
|
||||
globals.fuchsiaArtifacts.sshConfig.absolute.path,
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<ProcessManager>() ?? _kLocalProcessManager;
|
||||
ProcessUtils get processUtils => context.get<ProcessUtils>();
|
||||
|
||||
const Platform _kLocalPlatform = LocalPlatform();
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -117,7 +117,7 @@ Future<XcodeBuildResult> 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<XcodeBuildResult> buildXcodeProject({
|
||||
const Duration showBuildSettingsTimeout = Duration(minutes: 1);
|
||||
Map<String, String> 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<RunResult> _runBuildWithRetries(List<String> buildCommands, BuildableIOSA
|
||||
remainingTries--;
|
||||
buildRetryDelaySeconds *= 2;
|
||||
|
||||
buildResult = await processUtils.run(
|
||||
buildResult = await globals.processUtils.run(
|
||||
buildCommands,
|
||||
workingDirectory: app.project.hostAppRoot.path,
|
||||
allowReentrantFlutter: true,
|
||||
|
||||
@ -612,7 +612,7 @@ class IOSSimulator extends Device {
|
||||
/// Launches the device log reader process on the host and parses the syslog.
|
||||
@visibleForTesting
|
||||
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.
|
||||
@ -638,7 +638,7 @@ Future<Process> launchDeviceUnifiedLogging (IOSSimulator device, String appName)
|
||||
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,
|
||||
]);
|
||||
}
|
||||
@ -647,7 +647,7 @@ Future<Process> launchDeviceUnifiedLogging (IOSSimulator device, String appName)
|
||||
Future<Process> launchSystemLogTool(IOSSimulator device) async {
|
||||
// Versions of iOS prior to 11 tail the simulator syslog file.
|
||||
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.
|
||||
|
||||
@ -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<void> _runCmake(String buildModeName, Directory sourceDir, Directory buil
|
||||
final String buildFlag = toTitleCase(buildModeName);
|
||||
int result;
|
||||
try {
|
||||
result = await processUtils.stream(
|
||||
result = await globals.processUtils.stream(
|
||||
<String>[
|
||||
'cmake',
|
||||
'-G',
|
||||
@ -117,7 +116,7 @@ Future<void> _runBuild(Directory buildDir) async {
|
||||
|
||||
int result;
|
||||
try {
|
||||
result = await processUtils.stream(
|
||||
result = await globals.processUtils.stream(
|
||||
<String>[
|
||||
'ninja',
|
||||
'-C',
|
||||
|
||||
@ -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<void> buildMacOS({
|
||||
);
|
||||
int result;
|
||||
try {
|
||||
result = await processUtils.stream(<String>[
|
||||
result = await globals.processUtils.stream(<String>[
|
||||
'/usr/bin/env',
|
||||
'xcrun',
|
||||
'xcodebuild',
|
||||
|
||||
@ -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(<String>[
|
||||
final RunResult result = globals.processUtils.runSync(<String>[
|
||||
'lcov',
|
||||
'--add-tracefile', baseCoverageData,
|
||||
'--add-tracefile', sourceFile.path,
|
||||
|
||||
@ -70,10 +70,10 @@ class FlutterVersion {
|
||||
FlutterVersion([this._clock = const SystemClock(), this._workingDirectory]) {
|
||||
_frameworkRevision = _runGit(
|
||||
gitLog(<String>['-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(<String>['-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) {
|
||||
|
||||
@ -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<void> _runCmakeGeneration(String cmakePath, Directory buildDir, Directory
|
||||
await buildDir.create(recursive: true);
|
||||
int result;
|
||||
try {
|
||||
result = await processUtils.stream(
|
||||
result = await globals.processUtils.stream(
|
||||
<String>[
|
||||
cmakePath,
|
||||
'-S',
|
||||
@ -124,7 +123,7 @@ Future<void> _runBuild(String cmakePath, Directory buildDir, String buildModeNam
|
||||
|
||||
int result;
|
||||
try {
|
||||
result = await processUtils.stream(
|
||||
result = await globals.processUtils.stream(
|
||||
<String>[
|
||||
cmakePath,
|
||||
'--build',
|
||||
|
||||
@ -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<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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user