Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8e13e9f

Browse files
committed
Add et run command
The `run` command builds both the host and target engines and then invokes `flutter run` so that it runs with the custom engine builds. It is expected that 'et run' be used inside the directory of a flutter application. Command line flags passed after `--` will be forwarded to `flutter run`. Some examples: `et run` Build the debug variant and runs the app in that mode. `et run -- --profile` Build the profile variant and runs the app in that mode. `et run -- --release` Build the release variant and runs the app in that mode.
1 parent 5c09604 commit 8e13e9f

File tree

12 files changed

+488
-33
lines changed

12 files changed

+488
-33
lines changed

ci/builders/local_engine.json

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"builds": [
3+
{
4+
"drone_dimensions": [
5+
"os=Mac-13",
6+
"os=Linux"
7+
],
8+
"gn": [
9+
"--runtime-mode",
10+
"debug",
11+
"--android",
12+
"--android-cpu=arm64",
13+
"--no-stripped",
14+
"--enable-impeller-vulkan",
15+
"--no-lto"
16+
],
17+
"name": "android_debug_arm64",
18+
"ninja": {
19+
"config": "android_debug_arm64",
20+
"targets": [
21+
"flutter",
22+
"flutter/shell/platform/android:abi_jars"
23+
]
24+
}
25+
},
26+
{
27+
"drone_dimensions": [
28+
"os=Mac-13",
29+
"os=Linux"
30+
],
31+
"gn": [
32+
"--runtime-mode",
33+
"profile",
34+
"--android",
35+
"--android-cpu=arm64",
36+
"--no-stripped",
37+
"--enable-impeller-vulkan",
38+
"--no-lto"
39+
],
40+
"name": "android_profile_arm64",
41+
"ninja": {
42+
"config": "android_profile_arm64",
43+
"targets": [
44+
"flutter",
45+
"flutter/shell/platform/android:abi_jars"
46+
]
47+
}
48+
},
49+
{
50+
"drone_dimensions": [
51+
"os=Mac-13",
52+
"os=Linux"
53+
],
54+
"gn": [
55+
"--runtime-mode",
56+
"release",
57+
"--android",
58+
"--android-cpu=arm64",
59+
"--no-stripped",
60+
"--enable-impeller-vulkan",
61+
"--no-lto"
62+
],
63+
"name": "android_release_arm64",
64+
"ninja": {
65+
"config": "android_release_arm64",
66+
"targets": [
67+
"flutter",
68+
"flutter/shell/platform/android:abi_jars"
69+
]
70+
}
71+
},
72+
{
73+
"drone_dimensions": [
74+
"os=Mac-13",
75+
"os=Linux"
76+
],
77+
"gn": [
78+
"--runtime-mode",
79+
"debug",
80+
"--no-stripped",
81+
"--enable-impeller-vulkan",
82+
"--no-lto"
83+
],
84+
"name": "host_debug",
85+
"ninja": {
86+
"config": "host_debug",
87+
"targets": [
88+
"flutter:unittests",
89+
"flutter/build/archives:artifacts",
90+
"flutter/build/archives:dart_sdk_archive",
91+
"flutter/build/archives:embedder",
92+
"flutter/build/archives:flutter_patched_sdk",
93+
"flutter/build/dart:copy_dart_sdk",
94+
"flutter/tools/font_subset"
95+
]
96+
}
97+
},
98+
{
99+
"drone_dimensions": [
100+
"os=Mac-13",
101+
"os=Linux"
102+
],
103+
"gn": [
104+
"--runtime-mode",
105+
"profile",
106+
"--no-stripped",
107+
"--enable-impeller-vulkan",
108+
"--no-lto"
109+
],
110+
"name": "host_profile",
111+
"ninja": {
112+
"config": "host_profile",
113+
"targets": [
114+
"flutter:unittests",
115+
"flutter/build/archives:artifacts",
116+
"flutter/build/archives:dart_sdk_archive",
117+
"flutter/build/archives:embedder",
118+
"flutter/build/archives:flutter_patched_sdk",
119+
"flutter/build/dart:copy_dart_sdk",
120+
"flutter/tools/font_subset"
121+
]
122+
}
123+
},
124+
{
125+
"drone_dimensions": [
126+
"os=Mac-13",
127+
"os=Linux"
128+
],
129+
"gn": [
130+
"--runtime-mode",
131+
"release",
132+
"--no-stripped",
133+
"--enable-impeller-vulkan",
134+
"--no-lto"
135+
],
136+
"name": "host_release",
137+
"ninja": {
138+
"config": "host_release",
139+
"targets": [
140+
"flutter:unittests",
141+
"flutter/build/archives:artifacts",
142+
"flutter/build/archives:dart_sdk_archive",
143+
"flutter/build/archives:embedder",
144+
"flutter/build/archives:flutter_patched_sdk",
145+
"flutter/build/dart:copy_dart_sdk",
146+
"flutter/tools/font_subset"
147+
]
148+
}
149+
}
150+
]
151+
}

testing/litetest/lib/src/matchers.dart

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ void isNotEmpty(dynamic d) {
6262
/// Gives a [Matcher] that asserts that the value being matched is within
6363
/// `tolerance` of `value`.
6464
Matcher closeTo(num value, num tolerance) => (dynamic actual) {
65-
Expect.approxEquals(value, actual as num, tolerance);
66-
};
65+
Expect.approxEquals(value, actual as num, tolerance);
66+
};
6767

6868
/// A [Matcher] that matches NaN.
6969
void isNaN(dynamic v) {
@@ -74,8 +74,8 @@ void isNaN(dynamic v) {
7474
/// Gives a [Matcher] that asserts that the value being matched is not equal to
7575
/// `unexpected`.
7676
Matcher notEquals(dynamic unexpected) => (dynamic actual) {
77-
Expect.notEquals(unexpected, actual);
78-
};
77+
Expect.notEquals(unexpected, actual);
78+
};
7979

8080
/// A [Matcher] that matches non-zero values.
8181
void isNonZero(dynamic d) {
@@ -90,44 +90,62 @@ void throwsRangeError(dynamic d) {
9090
/// Gives a [Matcher] that asserts that the value being matched is a [String]
9191
/// that contains `s` as a substring.
9292
Matcher contains(String s) => (dynamic d) {
93-
expect(d, isInstanceOf<String>());
94-
Expect.contains(s, d as String);
95-
};
93+
expect(d, isInstanceOf<String>());
94+
Expect.contains(s, d as String);
95+
};
9696

9797
/// Gives a [Matcher] that asserts that the value being matched is an [Iterable]
9898
/// of length `d`.
9999
Matcher hasLength(int l) => (dynamic d) {
100-
expect(d, isInstanceOf<Iterable<dynamic>>());
101-
expect((d as Iterable<dynamic>).length, equals(l));
102-
};
100+
expect(d, isInstanceOf<Iterable<dynamic>>());
101+
expect((d as Iterable<dynamic>).length, equals(l));
102+
};
103103

104104
/// Gives a matcher that asserts that the value being matched is a [String] that
105105
/// starts with `s`.
106106
Matcher startsWith(String s) => (dynamic d) {
107-
expect(d, isInstanceOf<String>());
108-
final String h = d as String;
109-
if (!h.startsWith(s)) {
110-
Expect.fail('Expected "$h" to start with "$s"');
111-
}
112-
};
107+
expect(d, isInstanceOf<String>());
108+
final String h = d as String;
109+
if (!h.startsWith(s)) {
110+
Expect.fail('Expected "$h" to start with "$s"');
111+
}
112+
};
113113

114114
/// Gives a matcher that asserts that the value being matched is a [String] that
115115
/// ends with `s`.
116116
Matcher endsWith(String s) => (dynamic d) {
117-
expect(d, isInstanceOf<String>());
118-
final String h = d as String;
119-
if (!h.endsWith(s)) {
120-
Expect.fail('Expected "$h" to end with "$s"');
121-
}
122-
};
117+
expect(d, isInstanceOf<String>());
118+
final String h = d as String;
119+
if (!h.endsWith(s)) {
120+
Expect.fail('Expected "$h" to end with "$s"');
121+
}
122+
};
123123

124124
/// Gives a matcher that asserts that the value being matched is a [String] that
125125
/// regexp matches with `pattern`.
126126
Matcher hasMatch(String pattern) => (dynamic d) {
127-
expect(d, isInstanceOf<String>());
128-
final String h = d as String;
129-
final RegExp regExp = RegExp(pattern);
130-
if (!regExp.hasMatch(h)) {
131-
Expect.fail('Expected "$h" to match with "$pattern"');
132-
}
133-
};
127+
expect(d, isInstanceOf<String>());
128+
final String h = d as String;
129+
final RegExp regExp = RegExp(pattern);
130+
if (!regExp.hasMatch(h)) {
131+
Expect.fail('Expected "$h" to match with "$pattern"');
132+
}
133+
};
134+
135+
/// Gives a matcher that asserts that the value being matched is a List<String>
136+
/// that contains the entries in `pattern` in order. There may be values
137+
/// that are not in pattern interleaved.
138+
Matcher containsStringsInOrder(List<String> pattern) => (dynamic d) {
139+
expect(d, isInstanceOf<List<String>>());
140+
final List<String> input = d as List<String>;
141+
int cursor = 0;
142+
for (final String el in input) {
143+
if (cursor == pattern.length) break;
144+
if (el == pattern[cursor]) {
145+
cursor++;
146+
}
147+
}
148+
if (cursor < pattern.length) {
149+
Expect.fail('Did not find ${pattern[cursor]} in $d}');
150+
}
151+
};

tools/engine_tool/lib/main.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'dart:ffi' as ffi show Abi;
6-
import 'dart:io' as io show Directory, exitCode, stderr;
6+
import 'dart:io' as io show Directory, exitCode, stderr, Platform;
77

88
import 'package:engine_build_configs/engine_build_configs.dart';
99
import 'package:engine_repo_tools/engine_repo_tools.dart';
@@ -26,6 +26,13 @@ void main(List<String> args) async {
2626
return;
2727
}
2828

29+
// Fix the pwd so that shelling out to e.g. 'flutter run' works as expected.
30+
// TODO(johnmccutchan): Is OLDPWD portable? Probably not.
31+
final String? oldPwd = io.Platform.environment['OLDPWD'];
32+
if (oldPwd != null) {
33+
io.Directory.current = oldPwd;
34+
}
35+
2936
// Find and parse the engine build configs.
3037
final io.Directory buildConfigsDir = io.Directory(p.join(
3138
engine.flutterDir.path,

tools/engine_tool/lib/src/build_utils.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,15 @@ List<Build> runnableBuilds(Environment env, Map<String, BuilderConfig> input) {
4848
return build.canRunOn(env.platform);
4949
});
5050
}
51+
52+
/// Validates the list of builds.
53+
/// Calls assert.
54+
void debugCheckBuilds(List<Build> builds) {
55+
final Set<String> names = <String>{};
56+
57+
for (final Build build in builds) {
58+
assert(!names.contains(build.name),
59+
'More than one build has the name ${build.name}');
60+
names.add(build.name);
61+
}
62+
}

tools/engine_tool/lib/src/commands/build_command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class BuildCommand extends CommandBase {
1717
required Map<String, BuilderConfig> configs,
1818
}) {
1919
builds = runnableBuilds(environment, configs);
20+
debugCheckBuilds(builds);
2021
// Add options here that are common to all queries.
2122
argParser.addOption(
2223
configFlag,

tools/engine_tool/lib/src/commands/command_runner.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import '../environment.dart';
99
import 'build_command.dart';
1010
import 'format_command.dart';
1111
import 'query_command.dart';
12+
import 'run_command.dart';
1213

1314
/// The root command runner.
1415
final class ToolCommandRunner extends CommandRunner<int> {
@@ -24,6 +25,7 @@ final class ToolCommandRunner extends CommandRunner<int> {
2425
),
2526
QueryCommand(environment: environment, configs: configs),
2627
BuildCommand(environment: environment, configs: configs),
28+
RunCommand(environment: environment, configs: configs),
2729
];
2830
commands.forEach(addCommand);
2931
}

0 commit comments

Comments
 (0)