This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Adds a Dart library for loading and parsing build configs #45390
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,6 +239,6 @@ | |
| } | ||
| } | ||
| ], | ||
| "generators": [], | ||
| "generators": {}, | ||
| "archives": [] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; | ||
| 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
24
tools/pkg/engine_build_configs/lib/engine_build_configs.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 😀