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
4 changes: 4 additions & 0 deletions ci/builders/linux_unopt.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"language": "dart",
"name": "test: Lint android host",
"script": "flutter/tools/android_lint/bin/main.dart"
},
{
"name": "Check build configs",
"script": "flutter/ci/check_build_configs.sh"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion ci/builders/mac_android_aot_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@
}
}
],
"generators": [],
"generators": {},
"archives": []
}
41 changes: 41 additions & 0 deletions ci/check_build_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

set -e

# Needed because if it is set, cd may print the path it changed to.
unset CDPATH

# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
# link at a time, and then cds into the link destination and find out where it
# ends up.
#
# The function is enclosed in a subshell to avoid changing the working directory
# of the caller.
function follow_links() (
cd -P "$(dirname -- "$1")"
file="$PWD/$(basename -- "$1")"
while [[ -h "$file" ]]; do
cd -P "$(dirname -- "$file")"
file="$(readlink -- "$file")"
cd -P "$(dirname -- "$file")"
file="$PWD/$(basename -- "$file")"
done
echo "$file"
)

SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")")
SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)"
FLUTTER_DIR="$(cd "$SCRIPT_DIR/.."; pwd -P)"
DART_BIN="${SRC_DIR}/third_party/dart/tools/sdks/dart-sdk/bin"
DART="${DART_BIN}/dart"

cd "$SCRIPT_DIR"
"$DART" \
--disable-dart-dev \
"$SRC_DIR/flutter/tools/pkg/engine_build_configs/bin/check.dart" \
"$SRC_DIR"

20 changes: 20 additions & 0 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,25 @@ def gather_build_bucket_golden_scraper_tests(build_dir):
)


def gather_engine_build_configs_tests(build_dir):
test_dir = os.path.join(
BUILDROOT_DIR, 'flutter', 'tools', 'pkg', 'engine_build_configs'
)
dart_tests = glob.glob('%s/*_test.dart' % test_dir)
for dart_test_file in dart_tests:
opts = [
'--disable-dart-dev',
dart_test_file,
]
yield EngineExecutableTask(
build_dir,
os.path.join('dart-sdk', 'bin', 'dart'),
None,
flags=opts,
cwd=test_dir
)


def gather_engine_repo_tools_tests(build_dir):
test_dir = os.path.join(
BUILDROOT_DIR, 'flutter', 'tools', 'pkg', 'engine_repo_tools'
Expand Down Expand Up @@ -1269,6 +1288,7 @@ def main():
tasks += list(gather_githooks_tests(build_dir))
tasks += list(gather_clang_tidy_tests(build_dir))
tasks += list(gather_build_bucket_golden_scraper_tests(build_dir))
tasks += list(gather_engine_build_configs_tests(build_dir))
tasks += list(gather_engine_repo_tools_tests(build_dir))
tasks += list(gather_api_consistency_tests(build_dir))
tasks += list(gather_path_ops_tests(build_dir))
Expand Down
5 changes: 5 additions & 0 deletions tools/pkg/engine_build_configs/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: ../../../analysis_options.yaml

linter:
rules:
public_member_api_docs: false
67 changes: 67 additions & 0 deletions tools/pkg/engine_build_configs/bin/check.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io' as io;

import 'package:engine_build_configs/engine_build_configs.dart';
import 'package:engine_repo_tools/engine_repo_tools.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! 😀

import 'package:path/path.dart' as p;

// Usage:
// $ dart bin/check.dart [/path/to/engine/src]

void main(List<String> args) {
final String? engineSrcPath;
if (args.isNotEmpty) {
engineSrcPath = args[0];
} else {
engineSrcPath = null;
}

// Find the engine repo.
final Engine engine;
try {
engine = Engine.findWithin(engineSrcPath);
} catch (e) {
io.stderr.writeln(e);
io.exitCode = 1;
return;
}

// Find and parse the engine build configs.
final io.Directory buildConfigsDir = io.Directory(p.join(
engine.flutterDir.path, 'ci', 'builders',
));
final BuildConfigLoader loader = BuildConfigLoader(
buildConfigsDir: buildConfigsDir,
);

// Treat it as an error if no build configs were found. The caller likely
// expected to find some.
final Map<String, BuildConfig> configs = loader.configs;
if (configs.isEmpty) {
io.stderr.writeln(
'Error: No build configs found under ${buildConfigsDir.path}',
);
io.exitCode = 1;
return;
}
if (loader.errors.isNotEmpty) {
loader.errors.forEach(io.stderr.writeln);
io.exitCode = 1;
}

// Check the parsed build configs for validity.
for (final String name in configs.keys) {
final BuildConfig buildConfig = configs[name]!;
final List<String> buildConfigErrors = buildConfig.check(name);
if (buildConfigErrors.isNotEmpty) {
io.stderr.writeln('Errors in ${buildConfig.path}:');
io.exitCode = 1;
}
for (final String error in buildConfigErrors) {
io.stderr.writeln(' $error');
}
}
}
24 changes: 24 additions & 0 deletions tools/pkg/engine_build_configs/lib/engine_build_configs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// This is a library for parsing the Engine CI configurations that live under
/// flutter/ci/builders. They describe how CI builds, tests, archives, and
/// uploads the engine to cloud storage. The documentation and spec for the
/// format is at:
///
/// https://github.com/flutter/engine/blob/main/ci/builders/README.md
///
/// The code in this library is *not* used by CI to run these configurations.
/// Rather, that code executes these configs on CI is part of the "engine_v2"
/// recipes at:
///
/// https://cs.opensource.google/flutter/recipes/+/main:recipes/engine_v2
///
/// This library exposes two main classes, [BuildConfigLoader], which reads and
/// loads all build configurations under a directory, and [BuildConfig], which
/// is the Dart representation of a single build configuration.
library;

export 'src/build_config.dart';
export 'src/build_config_loader.dart';
Loading