Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bin/et
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ PLATFORM="${OS}-${CPU}"
DART_SDK_DIR="${ENGINE_DIR}/prebuilts/${PLATFORM}/dart-sdk"
DART="${DART_SDK_DIR}/bin/dart"

cd "${ENGINE_DIR}/tools/engine_tool"

if [ ! -d ".dart_tool" ]; then
if [ ! -d "${ENGINE_DIR}/tools/engine_tool/.dart_tool" ]; then
echo "You must run 'gclient sync -D' before using this tool."
exit 1
fi

"${DART}" --disable-dart-dev bin/et.dart "$@"
"${DART}" --disable-dart-dev "${ENGINE_DIR}/tools/engine_tool/bin/et.dart" "$@"
118 changes: 118 additions & 0 deletions ci/builders/local_engine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"builds": [
{
"drone_dimensions": [
"os=Mac-13",
"os=Linux"
Comment on lines +5 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LUCI recipes understand a | for specifying that either is okay. For example:

"os=Mac-12|Mac-13",

Hadn't added support for it since it wasn't needed, yet, but parsing that would go here: https://github.com/flutter/engine/blob/main/tools/pkg/engine_build_configs/lib/src/build_config.dart#L805.

Suggested change
"os=Mac-13",
"os=Linux"
"os=Mac-13|Linux",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do this in a follow on CL.

],
"gn": [
"--runtime-mode",
"debug",
"--android",
"--android-cpu=arm64",
"--no-stripped",
"--enable-impeller-vulkan",
"--no-lto"
],
"name": "android_debug_arm64",
"ninja": {
"config": "android_debug_arm64",
"targets": []
}
},
{
"drone_dimensions": [
"os=Mac-13",
"os=Linux"
],
"gn": [
"--runtime-mode",
"profile",
"--android",
"--android-cpu=arm64",
"--no-stripped",
"--enable-impeller-vulkan",
"--no-lto"
],
"name": "android_profile_arm64",
"ninja": {
"config": "android_profile_arm64",
"targets": []
}
},
{
"drone_dimensions": [
"os=Mac-13",
"os=Linux"
],
"gn": [
"--runtime-mode",
"release",
"--android",
"--android-cpu=arm64",
"--no-stripped",
"--enable-impeller-vulkan",
"--no-lto"
],
"name": "android_release_arm64",
"ninja": {
"config": "android_release_arm64",
"targets": []
}
},
{
"drone_dimensions": [
"os=Mac-13",
"os=Linux"
],
"gn": [
"--runtime-mode",
"debug",
"--no-stripped",
"--enable-impeller-vulkan",
"--no-lto"
],
"name": "host_debug",
"ninja": {
"config": "host_debug",
"targets": []
}
},
{
"drone_dimensions": [
"os=Mac-13",
"os=Linux"
],
"gn": [
"--runtime-mode",
"profile",
"--no-stripped",
"--enable-impeller-vulkan",
"--no-lto"
],
"name": "host_profile",
"ninja": {
"config": "host_profile",
"targets": []
}
},
{
"drone_dimensions": [
"os=Mac-13",
"os=Linux"
],
"gn": [
"--runtime-mode",
"release",
"--no-stripped",
"--enable-impeller-vulkan",
"--no-lto"
],
"name": "host_release",
"ninja": {
"config": "host_release",
"targets": []
}
}
]
}
78 changes: 49 additions & 29 deletions testing/litetest/lib/src/matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void isNotEmpty(dynamic d) {
/// Gives a [Matcher] that asserts that the value being matched is within
/// `tolerance` of `value`.
Matcher closeTo(num value, num tolerance) => (dynamic actual) {
Expect.approxEquals(value, actual as num, tolerance);
};
Expect.approxEquals(value, actual as num, tolerance);
};

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

/// A [Matcher] that matches non-zero values.
void isNonZero(dynamic d) {
Expand All @@ -90,44 +90,64 @@ void throwsRangeError(dynamic d) {
/// Gives a [Matcher] that asserts that the value being matched is a [String]
/// that contains `s` as a substring.
Matcher contains(String s) => (dynamic d) {
expect(d, isInstanceOf<String>());
Expect.contains(s, d as String);
};
expect(d, isInstanceOf<String>());
Expect.contains(s, d as String);
};

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

/// Gives a matcher that asserts that the value being matched is a [String] that
/// starts with `s`.
Matcher startsWith(String s) => (dynamic d) {
expect(d, isInstanceOf<String>());
final String h = d as String;
if (!h.startsWith(s)) {
Expect.fail('Expected "$h" to start with "$s"');
}
};
expect(d, isInstanceOf<String>());
final String h = d as String;
if (!h.startsWith(s)) {
Expect.fail('Expected "$h" to start with "$s"');
}
};

/// Gives a matcher that asserts that the value being matched is a [String] that
/// ends with `s`.
Matcher endsWith(String s) => (dynamic d) {
expect(d, isInstanceOf<String>());
final String h = d as String;
if (!h.endsWith(s)) {
Expect.fail('Expected "$h" to end with "$s"');
}
};
expect(d, isInstanceOf<String>());
final String h = d as String;
if (!h.endsWith(s)) {
Expect.fail('Expected "$h" to end with "$s"');
}
};

/// Gives a matcher that asserts that the value being matched is a [String] that
/// regexp matches with `pattern`.
Matcher hasMatch(String pattern) => (dynamic d) {
expect(d, isInstanceOf<String>());
final String h = d as String;
final RegExp regExp = RegExp(pattern);
if (!regExp.hasMatch(h)) {
Expect.fail('Expected "$h" to match with "$pattern"');
}
};
expect(d, isInstanceOf<String>());
final String h = d as String;
final RegExp regExp = RegExp(pattern);
if (!regExp.hasMatch(h)) {
Expect.fail('Expected "$h" to match with "$pattern"');
}
};

/// Gives a matcher that asserts that the value being matched is a List<String>
/// that contains the entries in `pattern` in order. There may be values
/// that are not in the pattern interleaved.
Matcher containsStringsInOrder(List<String> pattern) => (dynamic d) {
expect(d, isInstanceOf<List<String>>());
final List<String> input = d as List<String>;
int cursor = 0;
for (final String el in input) {
if (cursor == pattern.length) {
break;
}
if (el == pattern[cursor]) {
cursor++;
}
}
if (cursor < pattern.length) {
Expect.fail('Did not find ${pattern[cursor]} in $d}');
}
};
20 changes: 11 additions & 9 deletions tools/engine_tool/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

import 'dart:ffi' as ffi show Abi;
import 'dart:io' as io show Directory, exitCode, stderr;
import 'dart:io' as io show Directory, Platform, exitCode, stderr;

import 'package:engine_build_configs/engine_build_configs.dart';
import 'package:engine_repo_tools/engine_repo_tools.dart';
Expand All @@ -19,7 +19,7 @@ void main(List<String> args) async {
// Find the engine repo.
final Engine engine;
try {
engine = Engine.findWithin();
engine = Engine.findWithin(p.dirname(io.Platform.script.toFilePath()));
} catch (e) {
io.stderr.writeln(e);
io.exitCode = 1;
Expand Down Expand Up @@ -51,15 +51,17 @@ void main(List<String> args) async {
io.exitCode = 1;
}

final Environment environment = Environment(
abi: ffi.Abi.current(),
engine: engine,
platform: const LocalPlatform(),
processRunner: ProcessRunner(),
logger: Logger(),
);

// Use the Engine and BuildConfig collection to build the CommandRunner.
final ToolCommandRunner runner = ToolCommandRunner(
environment: Environment(
abi: ffi.Abi.current(),
engine: engine,
platform: const LocalPlatform(),
processRunner: ProcessRunner(),
logger: Logger(),
),
environment: environment,
configs: configs,
);

Expand Down
57 changes: 57 additions & 0 deletions tools/engine_tool/lib/src/build_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:engine_build_configs/engine_build_configs.dart';

import 'environment.dart';
import 'logger.dart';

/// A function that returns true or false when given a [BuilderConfig] and its
/// name.
Expand Down Expand Up @@ -48,3 +49,59 @@ List<Build> runnableBuilds(Environment env, Map<String, BuilderConfig> input) {
return build.canRunOn(env.platform);
});
}

/// Validates the list of builds.
/// Calls assert.
void debugCheckBuilds(List<Build> builds) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is what https://github.com/flutter/engine/blob/main/tools/pkg/engine_build_configs/bin/check.dart#L91 is checking, which we run on CI here: https://github.com/flutter/engine/blob/main/ci/builders/linux_unopt.json#L96.

Do you get the errors you expect from that script if you intentionally introduce some duplicates?

final Set<String> names = <String>{};

for (final Build build in builds) {
assert(!names.contains(build.name),
'More than one build has the name ${build.name}');
names.add(build.name);
}
}

/// Build the build target in the environment.
Future<int> runBuild(Environment environment, Build build) async {
final BuildRunner buildRunner = BuildRunner(
platform: environment.platform,
processRunner: environment.processRunner,
abi: environment.abi,
engineSrcDir: environment.engine.srcDir,
build: build,
runTests: false,
);

Spinner? spinner;
void handler(RunnerEvent event) {
switch (event) {
case RunnerStart():
environment.logger.status('$event ', newline: false);
spinner = environment.logger.startSpinner();
case RunnerProgress(done: true):
spinner?.finish();
spinner = null;
environment.logger.clearLine();
environment.logger.status(event);
case RunnerProgress(done: false):
{
spinner?.finish();
spinner = null;
final String percent = '${event.percent.toStringAsFixed(1)}%';
final String fraction = '(${event.completed}/${event.total})';
final String prefix = '[${event.name}] $percent $fraction ';
final String what = event.what;
environment.logger.clearLine();
environment.logger.status('$prefix$what', newline: false, fit: true);
}
default:
spinner?.finish();
spinner = null;
environment.logger.status(event);
}
}

final bool buildResult = await buildRunner.run(handler);
return buildResult ? 0 : 1;
}
Loading