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

Commit dc69440

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 0db468f commit dc69440

File tree

14 files changed

+546
-124
lines changed

14 files changed

+546
-124
lines changed

bin/et

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ PLATFORM="${OS}-${CPU}"
5858
DART_SDK_DIR="${ENGINE_DIR}/prebuilts/${PLATFORM}/dart-sdk"
5959
DART="${DART_SDK_DIR}/bin/dart"
6060

61-
cd "${ENGINE_DIR}/tools/engine_tool"
62-
63-
if [ ! -d ".dart_tool" ]; then
61+
if [ ! -d "${ENGINE_DIR}/tools/engine_tool/.dart_tool" ]; then
6462
echo "You must run 'gclient sync -D' before using this tool."
6563
exit 1
6664
fi
6765

68-
"${DART}" --disable-dart-dev bin/et.dart "$@"
66+
"${DART}" --disable-dart-dev "${ENGINE_DIR}/tools/engine_tool/bin/et.dart" "$@"

ci/builders/local_engine.json

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
}
22+
},
23+
{
24+
"drone_dimensions": [
25+
"os=Mac-13",
26+
"os=Linux"
27+
],
28+
"gn": [
29+
"--runtime-mode",
30+
"profile",
31+
"--android",
32+
"--android-cpu=arm64",
33+
"--no-stripped",
34+
"--enable-impeller-vulkan",
35+
"--no-lto"
36+
],
37+
"name": "android_profile_arm64",
38+
"ninja": {
39+
"config": "android_profile_arm64",
40+
"targets": []
41+
}
42+
},
43+
{
44+
"drone_dimensions": [
45+
"os=Mac-13",
46+
"os=Linux"
47+
],
48+
"gn": [
49+
"--runtime-mode",
50+
"release",
51+
"--android",
52+
"--android-cpu=arm64",
53+
"--no-stripped",
54+
"--enable-impeller-vulkan",
55+
"--no-lto"
56+
],
57+
"name": "android_release_arm64",
58+
"ninja": {
59+
"config": "android_release_arm64",
60+
"targets": []
61+
}
62+
},
63+
{
64+
"drone_dimensions": [
65+
"os=Mac-13",
66+
"os=Linux"
67+
],
68+
"gn": [
69+
"--runtime-mode",
70+
"debug",
71+
"--no-stripped",
72+
"--enable-impeller-vulkan",
73+
"--no-lto"
74+
],
75+
"name": "host_debug",
76+
"ninja": {
77+
"config": "host_debug",
78+
"targets": []
79+
}
80+
},
81+
{
82+
"drone_dimensions": [
83+
"os=Mac-13",
84+
"os=Linux"
85+
],
86+
"gn": [
87+
"--runtime-mode",
88+
"profile",
89+
"--no-stripped",
90+
"--enable-impeller-vulkan",
91+
"--no-lto"
92+
],
93+
"name": "host_profile",
94+
"ninja": {
95+
"config": "host_profile",
96+
"targets": []
97+
}
98+
},
99+
{
100+
"drone_dimensions": [
101+
"os=Mac-13",
102+
"os=Linux"
103+
],
104+
"gn": [
105+
"--runtime-mode",
106+
"release",
107+
"--no-stripped",
108+
"--enable-impeller-vulkan",
109+
"--no-lto"
110+
],
111+
"name": "host_release",
112+
"ninja": {
113+
"config": "host_release",
114+
"targets": []
115+
}
116+
}
117+
]
118+
}

testing/litetest/lib/src/matchers.dart

Lines changed: 49 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,64 @@ 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 the 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) {
144+
break;
145+
}
146+
if (el == pattern[cursor]) {
147+
cursor++;
148+
}
149+
}
150+
if (cursor < pattern.length) {
151+
Expect.fail('Did not find ${pattern[cursor]} in $d}');
152+
}
153+
};

tools/engine_tool/lib/main.dart

Lines changed: 11 additions & 9 deletions
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, Platform, exitCode, stderr;
77

88
import 'package:engine_build_configs/engine_build_configs.dart';
99
import 'package:engine_repo_tools/engine_repo_tools.dart';
@@ -19,7 +19,7 @@ void main(List<String> args) async {
1919
// Find the engine repo.
2020
final Engine engine;
2121
try {
22-
engine = Engine.findWithin();
22+
engine = Engine.findWithin(p.dirname(io.Platform.script.toFilePath()));
2323
} catch (e) {
2424
io.stderr.writeln(e);
2525
io.exitCode = 1;
@@ -51,15 +51,17 @@ void main(List<String> args) async {
5151
io.exitCode = 1;
5252
}
5353

54+
Environment environment = Environment(
55+
abi: ffi.Abi.current(),
56+
engine: engine,
57+
platform: const LocalPlatform(),
58+
processRunner: ProcessRunner(),
59+
logger: Logger(),
60+
);
61+
5462
// Use the Engine and BuildConfig collection to build the CommandRunner.
5563
final ToolCommandRunner runner = ToolCommandRunner(
56-
environment: Environment(
57-
abi: ffi.Abi.current(),
58-
engine: engine,
59-
platform: const LocalPlatform(),
60-
processRunner: ProcessRunner(),
61-
logger: Logger(),
62-
),
64+
environment: environment,
6365
configs: configs,
6466
);
6567

tools/engine_tool/lib/src/build_utils.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:engine_build_configs/engine_build_configs.dart';
66

77
import 'environment.dart';
8+
import 'logger.dart';
89

910
/// A function that returns true or false when given a [BuilderConfig] and its
1011
/// name.
@@ -48,3 +49,59 @@ List<Build> runnableBuilds(Environment env, Map<String, BuilderConfig> input) {
4849
return build.canRunOn(env.platform);
4950
});
5051
}
52+
53+
/// Validates the list of builds.
54+
/// Calls assert.
55+
void debugCheckBuilds(List<Build> builds) {
56+
final Set<String> names = <String>{};
57+
58+
for (final Build build in builds) {
59+
assert(!names.contains(build.name),
60+
'More than one build has the name ${build.name}');
61+
names.add(build.name);
62+
}
63+
}
64+
65+
/// Build the build target in the environment.
66+
Future<int> runBuild(Environment environment, Build build) async {
67+
final BuildRunner buildRunner = BuildRunner(
68+
platform: environment.platform,
69+
processRunner: environment.processRunner,
70+
abi: environment.abi,
71+
engineSrcDir: environment.engine.srcDir,
72+
build: build,
73+
runTests: false,
74+
);
75+
76+
Spinner? spinner;
77+
void handler(RunnerEvent event) {
78+
switch (event) {
79+
case RunnerStart():
80+
environment.logger.status('$event ', newline: false);
81+
spinner = environment.logger.startSpinner();
82+
case RunnerProgress(done: true):
83+
spinner?.finish();
84+
spinner = null;
85+
environment.logger.clearLine();
86+
environment.logger.status(event);
87+
case RunnerProgress(done: false):
88+
{
89+
spinner?.finish();
90+
spinner = null;
91+
final String percent = '${event.percent.toStringAsFixed(1)}%';
92+
final String fraction = '(${event.completed}/${event.total})';
93+
final String prefix = '[${event.name}] $percent $fraction ';
94+
final String what = event.what;
95+
environment.logger.clearLine();
96+
environment.logger.status('$prefix$what', newline: false, fit: true);
97+
}
98+
default:
99+
spinner?.finish();
100+
spinner = null;
101+
environment.logger.status(event);
102+
}
103+
}
104+
105+
final bool buildResult = await buildRunner.run(handler);
106+
return buildResult ? 0 : 1;
107+
}

0 commit comments

Comments
 (0)