From ca3c65433c5ab1141c30be204bfcb3eee659ed3b Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 9 Oct 2024 15:30:10 -0700 Subject: [PATCH 1/4] Recognize groups, and warn when we silently discard targets. --- .../lib/src/commands/build_command.dart | 9 +++ tools/engine_tool/lib/src/gn.dart | 42 +++++++++++ .../engine_tool/test/build_command_test.dart | 69 +++++++++++++++++++ .../test/external_tools/gn_test.dart | 34 +++++++++ 4 files changed, 154 insertions(+) diff --git a/tools/engine_tool/lib/src/commands/build_command.dart b/tools/engine_tool/lib/src/commands/build_command.dart index 70fa5b8feb4af..5c5aefa660307 100644 --- a/tools/engine_tool/lib/src/commands/build_command.dart +++ b/tools/engine_tool/lib/src/commands/build_command.dart @@ -72,6 +72,15 @@ et build //flutter/fml:fml_benchmarks # Build a specific target in `//flutter/f allTargets.addAll(targets.map((target) => target.label)); } + // Warn that we've discarded some targets. + // Other warnings should have been emitted above, so if this ends up being + // unneccesarily noisy, we can remove it or limit it to verbose mode. + if (allTargets.length < commandLineTargets.length) { + environment.logger.warning( + 'One or more targets specified did not match any build targets.', + ); + } + return runBuild( environment, plan.build, diff --git a/tools/engine_tool/lib/src/gn.dart b/tools/engine_tool/lib/src/gn.dart index c2e6b71af5af9..e9cdd489b7260 100644 --- a/tools/engine_tool/lib/src/gn.dart +++ b/tools/engine_tool/lib/src/gn.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; @@ -106,6 +107,9 @@ interface class Gn { JsonObject(properties), ); if (target == null) { + _environment.logger.warning( + 'Unknown target type for $label: type=${properties['type']}', + ); return null; } return target; @@ -180,6 +184,11 @@ sealed class BuildTarget { testOnly: testOnly, json: json, ), + 'group' => GroupBuildTarget( + label: Label.parseGn(label), + testOnly: testOnly, + deps: json.stringList('deps').map(Label.parseGn).toList(), + ), _ => null, }; } @@ -281,3 +290,36 @@ final class ExecutableBuildTarget extends BuildTarget { String toString() => 'ExecutableBuildTarget($label, testOnly=$testOnly, executable=$executable)'; } + +/// A build target that [group]s a meta-target of other build targets. +/// +/// [group]: https://gn.googlesource.com/gn/+/main/docs/reference.md#func_group +final class GroupBuildTarget extends BuildTarget { + /// Construct a group build target. + const GroupBuildTarget({ + required super.label, + required super.testOnly, + required this.deps, + }); + + /// The list of dependencies for this group target. + final List