remove usage of Usage from build system (#160663)

Towards https://github.com/flutter/flutter/issues/150575

This effectively just removes `Usage` as a dependency of `Environment`
(in build_system.dart). All other changes are a direct result of that.


<details>

<summary> Pre-launch checklist </summary> 


- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

</details>

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Andrew Kolos
2025-01-16 13:54:58 -08:00
committed by GitHub
parent 5a3541c40c
commit 8ef7b93287
14 changed files with 0 additions and 52 deletions

View File

@@ -19,7 +19,6 @@ import '../base/utils.dart';
import '../build_info.dart';
import '../cache.dart';
import '../convert.dart';
import '../reporting/reporting.dart';
import 'depfile.dart';
import 'exceptions.dart';
import 'file_store.dart';
@@ -334,7 +333,6 @@ class Environment {
required Artifacts artifacts,
required ProcessManager processManager,
required Platform platform,
required Usage usage,
required Analytics analytics,
String? engineVersion,
required bool generateDartPluginRegistry,
@@ -377,7 +375,6 @@ class Environment {
artifacts: artifacts,
processManager: processManager,
platform: platform,
usage: usage,
analytics: analytics,
engineVersion: engineVersion,
inputs: inputs,
@@ -401,7 +398,6 @@ class Environment {
Map<String, String> inputs = const <String, String>{},
String? engineVersion,
Platform? platform,
Usage? usage,
Analytics? analytics,
bool generateDartPluginRegistry = false,
required FileSystem fileSystem,
@@ -423,7 +419,6 @@ class Environment {
artifacts: artifacts,
processManager: processManager,
platform: platform ?? FakePlatform(),
usage: usage ?? TestUsage(),
analytics: analytics ?? const NoOpAnalytics(),
engineVersion: engineVersion,
generateDartPluginRegistry: generateDartPluginRegistry,
@@ -444,7 +439,6 @@ class Environment {
required this.logger,
required this.fileSystem,
required this.artifacts,
required this.usage,
required this.analytics,
this.engineVersion,
required this.inputs,
@@ -537,8 +531,6 @@ class Environment {
final FileSystem fileSystem;
final Usage usage;
final Analytics analytics;
/// The version of the current engine, or `null` if built with a local engine.

View File

@@ -17,7 +17,6 @@ import '../../globals.dart' as globals;
import '../../ios/mac.dart';
import '../../macos/xcode.dart';
import '../../project.dart';
import '../../reporting/reporting.dart';
import '../build_system.dart';
import '../depfile.dart';
import '../exceptions.dart';
@@ -639,12 +638,6 @@ class ReleaseIosApplicationBundle extends _IosAssetBundleWithDSYM {
// archive command from Xcode, this is a more accurate count than `flutter build ipa` alone.
if (environment.defines[kXcodeAction]?.toLowerCase() == 'install') {
environment.logger.printTrace('Sending archive event if usage enabled.');
UsageEvent(
'assemble',
'ios-archive',
label: buildSuccess ? 'success' : 'fail',
flutterUsage: environment.usage,
).send();
environment.analytics.send(
Event.appleUsageEvent(
workflow: 'assemble',

View File

@@ -12,7 +12,6 @@ import '../../base/process.dart';
import '../../build_info.dart';
import '../../devfs.dart';
import '../../globals.dart' as globals show xcode;
import '../../reporting/reporting.dart';
import '../build_system.dart';
import '../depfile.dart';
import '../exceptions.dart';
@@ -714,12 +713,6 @@ class ReleaseMacOSBundleFlutterAssets extends MacOSBundleFlutterAssets {
// Send a usage event when the app is being archived from Xcode.
if (environment.defines[kXcodeAction]?.toLowerCase() == 'install') {
environment.logger.printTrace('Sending archive event if usage enabled.');
UsageEvent(
'assemble',
'macos-archive',
label: buildSuccess ? 'success' : 'fail',
flutterUsage: environment.usage,
).send();
environment.analytics.send(
Event.appleUsageEvent(
workflow: 'assemble',

View File

@@ -74,7 +74,6 @@ class BundleBuilder {
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
analytics: globals.analytics,
platform: globals.platform,
generateDartPluginRegistry: true,

View File

@@ -258,7 +258,6 @@ class AssembleCommand extends FlutterCommand {
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
analytics: globals.analytics,
platform: globals.platform,
engineVersion: artifacts.usesLocalArtifacts ? null : globals.flutterVersion.engineRevision,

View File

@@ -483,7 +483,6 @@ end
logger: globals.logger,
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: globals.analytics,
engineVersion:
globals.artifacts!.usesLocalArtifacts ? null : globals.flutterVersion.engineRevision,

View File

@@ -240,7 +240,6 @@ end
logger: globals.logger,
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: globals.analytics,
engineVersion:
globals.artifacts!.usesLocalArtifacts ? null : globals.flutterVersion.engineRevision,

View File

@@ -505,7 +505,6 @@ mixin CreateBase on FlutterCommand {
outputDir: globals.fs.directory(getBuildDirectory()),
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: globals.analytics,
projectDir: project.directory,
packageConfigPath: packageConfigPath(),

View File

@@ -301,7 +301,6 @@ class PackagesGetCommand extends FlutterCommand {
outputDir: globals.fs.directory(getBuildDirectory()),
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: analytics,
projectDir: rootProject.directory,
packageConfigPath: packageConfigPath(),

View File

@@ -1193,7 +1193,6 @@ abstract class ResidentRunner extends ResidentHandlers {
outputDir: globals.fs.directory(getBuildDirectory()),
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: globals.analytics,
projectDir: globals.fs.currentDirectory,
packageConfigPath: debuggingOptions.buildInfo.packageConfigPath,

View File

@@ -1887,7 +1887,6 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
outputDir: globals.fs.directory(getBuildDirectory()),
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: analytics,
projectDir: project.directory,
packageConfigPath: packageConfigPath(),

View File

@@ -111,7 +111,6 @@ class WebBuilder {
logger: _logger,
processManager: _processManager,
platform: globals.platform,
usage: _flutterUsage,
analytics: _analytics,
cacheDir: globals.cache.getRoot(),
engineVersion:

View File

@@ -71,7 +71,6 @@ void main() {
logger: logger,
fileSystem: fileSystem,
engineVersion: '2',
usage: usage,
analytics: fakeAnalytics,
);
});
@@ -504,10 +503,6 @@ void main() {
]);
await const ReleaseIosApplicationBundle().build(environment);
expect(
usage.events,
contains(const TestUsageEvent('assemble', 'ios-archive', label: 'success')),
);
expect(
fakeAnalytics.sentEvents,
contains(
@@ -533,10 +528,6 @@ void main() {
() => const ReleaseIosApplicationBundle().build(environment),
throwsA(const TypeMatcher<FileSystemException>()),
);
expect(
usage.events,
contains(const TestUsageEvent('assemble', 'ios-archive', label: 'fail')),
);
expect(
fakeAnalytics.sentEvents,
contains(

View File

@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/macos.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:unified_analytics/unified_analytics.dart';
import '../../../src/common.dart';
@@ -34,7 +33,6 @@ void main() {
late FakeCommand lipoInfoFatCommand;
late FakeCommand lipoVerifyX86_64Command;
late FakeCommand lipoExtractX86_64Command;
late TestUsage usage;
late FakeAnalytics fakeAnalytics;
setUp(() {
@@ -42,7 +40,6 @@ void main() {
artifacts = Artifacts.test();
fileSystem = MemoryFileSystem.test();
logger = BufferLogger.test();
usage = TestUsage();
fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem,
fakeFlutterVersion: FakeFlutterVersion(),
@@ -60,7 +57,6 @@ void main() {
logger: logger,
fileSystem: fileSystem,
engineVersion: '2',
usage: usage,
analytics: fakeAnalytics,
);
@@ -605,10 +601,6 @@ void main() {
fileSystem.file(environment.buildDir.childFile('native_assets.json')).createSync();
await const ReleaseMacOSBundleFlutterAssets().build(environment);
expect(
usage.events,
contains(const TestUsageEvent('assemble', 'macos-archive', label: 'success')),
);
expect(
fakeAnalytics.sentEvents,
contains(
@@ -637,10 +629,6 @@ void main() {
() => const ReleaseMacOSBundleFlutterAssets().build(environment),
throwsA(const TypeMatcher<FileSystemException>()),
);
expect(
usage.events,
contains(const TestUsageEvent('assemble', 'macos-archive', label: 'fail')),
);
expect(
fakeAnalytics.sentEvents,
contains(