Unverified Commit 60730a97 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

pass --skip-build-script-checks and remove module usage (#28343)

parent e5ceabfd
# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config # Read about `build.yaml` at https://pub.dartlang.org/packages/build_config
builders: builders:
flutter:
import: "package:build_modules/builders.dart"
builder_factories:
- metaModuleBuilderFactoryForPlatform('flutter')
- metaModuleCleanBuilderFactoryForPlatform('flutter')
- moduleBuilderFactoryForPlatform('flutter')
applies_builders: ["build_modules|module_cleanup"]
build_extensions:
$lib$:
- .flutter.meta_module.raw
- .flutter.meta_module.clean
.dart:
- .flutter.module
auto_apply: all_packages
required_inputs: [".dart", ".module.library"]
kernel: kernel:
import: "package:flutter_build/flutter_build.dart" import: "package:flutter_build/flutter_build.dart"
builder_factories: builder_factories:
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:build_modules/build_modules.dart';
import 'package:build/build.dart'; import 'package:build/build.dart';
import 'package:package_config/packages_file.dart' as packages_file; import 'package:package_config/packages_file.dart' as packages_file;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
...@@ -16,6 +14,7 @@ import 'package:path/path.dart' as path; ...@@ -16,6 +14,7 @@ import 'package:path/path.dart' as path;
const String _kFlutterDillOutputExtension = '.app.dill'; const String _kFlutterDillOutputExtension = '.app.dill';
const String _kPackagesExtension = '.packages'; const String _kPackagesExtension = '.packages';
const String _kMultirootScheme = 'org-dartlang-app';
/// A builder which creates a kernel and packages file for a Flutter app. /// A builder which creates a kernel and packages file for a Flutter app.
/// ///
...@@ -85,28 +84,13 @@ class FlutterKernelBuilder implements Builder { ...@@ -85,28 +84,13 @@ class FlutterKernelBuilder implements Builder {
@override @override
Future<void> build(BuildStep buildStep) async { Future<void> build(BuildStep buildStep) async {
// Do not resolve dependencies if this does not correspond to the main // Do not resolve dependencies if this does not correspond to the main
// entrypoint. // entrypoint. Do not generate kernel if it has been disabled.
if (!mainPath.contains(buildStep.inputId.path)) { if (!mainPath.contains(buildStep.inputId.path) || disabled) {
return; return;
} }
final AssetId outputId = buildStep.inputId.changeExtension(_kFlutterDillOutputExtension); final AssetId outputId = buildStep.inputId.changeExtension(_kFlutterDillOutputExtension);
final AssetId packagesOutputId = buildStep.inputId.changeExtension(_kPackagesExtension); final AssetId packagesOutputId = buildStep.inputId.changeExtension(_kPackagesExtension);
// Use modules to verify dependencies are sound.
final AssetId moduleId = buildStep.inputId.changeExtension(moduleExtension(DartPlatform.flutter));
final Module module = Module.fromJson(json.decode(await buildStep.readAsString(moduleId)));
try {
await module.computeTransitiveDependencies(buildStep);
} on MissingModulesException catch (err) {
log.shout(err);
return;
}
// Do not generate kernel if it has been disabled.
if (disabled) {
return;
}
// Create a scratch space file that can be read/written by the frontend server. // Create a scratch space file that can be read/written by the frontend server.
// It is okay to hard-code these file names because we will copy them back // It is okay to hard-code these file names because we will copy them back
// from the temp directory at the end of the build step. // from the temp directory at the end of the build step.
...@@ -122,7 +106,7 @@ class FlutterKernelBuilder implements Builder { ...@@ -122,7 +106,7 @@ class FlutterKernelBuilder implements Builder {
// Note: currently we only replace the root package with a multiroot // Note: currently we only replace the root package with a multiroot
// scheme. To support codegen on arbitrary packages we will need to do // scheme. To support codegen on arbitrary packages we will need to do
// this for each dependency. // this for each dependency.
final String newPackagesContents = oldPackagesContents.replaceFirst('$packageName:lib/', '$packageName:$multiRootScheme:/'); final String newPackagesContents = oldPackagesContents.replaceFirst('$packageName:lib/', '$packageName:$_kMultirootScheme:/');
await packagesFile.writeAsString(newPackagesContents); await packagesFile.writeAsString(newPackagesContents);
String absoluteMainPath; String absoluteMainPath;
if (path.isAbsolute(mainPath)) { if (path.isAbsolute(mainPath)) {
...@@ -167,7 +151,7 @@ class FlutterKernelBuilder implements Builder { ...@@ -167,7 +151,7 @@ class FlutterKernelBuilder implements Builder {
'--filesystem-root', '--filesystem-root',
generatedRoot, generatedRoot,
'--filesystem-scheme', '--filesystem-scheme',
multiRootScheme, _kMultirootScheme,
]); ]);
if (extraFrontEndOptions != null) { if (extraFrontEndOptions != null) {
arguments.addAll(extraFrontEndOptions); arguments.addAll(extraFrontEndOptions);
...@@ -175,7 +159,7 @@ class FlutterKernelBuilder implements Builder { ...@@ -175,7 +159,7 @@ class FlutterKernelBuilder implements Builder {
final Uri mainUri = _PackageUriMapper.findUri( final Uri mainUri = _PackageUriMapper.findUri(
absoluteMainPath, absoluteMainPath,
packagesFile.path, packagesFile.path,
multiRootScheme, _kMultirootScheme,
<String>[normalRoot, generatedRoot], <String>[normalRoot, generatedRoot],
); );
arguments.add(mainUri?.toString() ?? absoluteMainPath); arguments.add(mainUri?.toString() ?? absoluteMainPath);
......
...@@ -7,38 +7,26 @@ environment: ...@@ -7,38 +7,26 @@ environment:
dependencies: dependencies:
# To update these, use "flutter update-packages --force-upgrade". # To update these, use "flutter update-packages --force-upgrade".
build: 1.1.1 build: 1.1.1
build_modules: 1.0.8
package_config: 1.0.5 package_config: 1.0.5
path: 1.6.2 path: 1.6.2
analyzer: 0.35.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" analyzer: 0.35.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
bazel_worker: 0.1.20 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
build_config: 0.3.1+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fixnum: 0.10.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
front_end: 0.1.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" front_end: 0.1.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
graphs: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.13.3+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" html: 0.13.3+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
json_annotation: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
kernel: 0.3.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" kernel: 0.3.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
protobuf: 0.13.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pubspec_parse: 0.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
scratch_space: 0.0.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.5.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -50,4 +38,4 @@ dartdoc: ...@@ -50,4 +38,4 @@ dartdoc:
# Exclude this package from the hosted API docs. # Exclude this package from the hosted API docs.
nodoc: true nodoc: true
# PUBSPEC CHECKSUM: 3267 # PUBSPEC CHECKSUM: 6ccf
...@@ -72,6 +72,7 @@ class BuildRunner extends CodeGenerator { ...@@ -72,6 +72,7 @@ class BuildRunner extends CodeGenerator {
'--packages=$scriptPackagesPath', '--packages=$scriptPackagesPath',
buildScript, buildScript,
'build', 'build',
'--skip-build-script-check',
'--define', 'flutter_build|kernel=disabled=$disableKernelGeneration', '--define', 'flutter_build|kernel=disabled=$disableKernelGeneration',
'--define', 'flutter_build|kernel=aot=$aot', '--define', 'flutter_build|kernel=aot=$aot',
'--define', 'flutter_build|kernel=linkPlatformKernelIn=$linkPlatformKernelIn', '--define', 'flutter_build|kernel=linkPlatformKernelIn=$linkPlatformKernelIn',
...@@ -157,9 +158,11 @@ class BuildRunner extends CodeGenerator { ...@@ -157,9 +158,11 @@ class BuildRunner extends CodeGenerator {
stringBuffer.writeln('name: flutter_tool'); stringBuffer.writeln('name: flutter_tool');
stringBuffer.writeln('dependencies:'); stringBuffer.writeln('dependencies:');
final YamlMap builders = await flutterProject.builders; final YamlMap builders = await flutterProject.builders;
for (String name in builders.keys) { if (builders != null) {
final YamlNode node = builders[name]; for (String name in builders.keys) {
stringBuffer.writeln(' $name: $node'); final YamlNode node = builders[name];
stringBuffer.writeln(' $name: $node');
}
} }
stringBuffer.writeln(' build_runner: any'); stringBuffer.writeln(' build_runner: any');
stringBuffer.writeln(' flutter_build:'); stringBuffer.writeln(' flutter_build:');
...@@ -217,6 +220,7 @@ class BuildRunner extends CodeGenerator { ...@@ -217,6 +220,7 @@ class BuildRunner extends CodeGenerator {
'--packages=$scriptPackagesPath', '--packages=$scriptPackagesPath',
buildScript, buildScript,
'daemon', 'daemon',
'--skip-build-script-check',
'--define', 'flutter_build|kernel=disabled=false', '--define', 'flutter_build|kernel=disabled=false',
'--define', 'flutter_build|kernel=aot=false', '--define', 'flutter_build|kernel=aot=false',
'--define', 'flutter_build|kernel=linkPlatformKernelIn=$linkPlatformKernelIn', '--define', 'flutter_build|kernel=linkPlatformKernelIn=$linkPlatformKernelIn',
...@@ -251,18 +255,22 @@ class _BuildRunnerCodegenDaemon implements CodegenDaemon { ...@@ -251,18 +255,22 @@ class _BuildRunnerCodegenDaemon implements CodegenDaemon {
final File packagesFile; final File packagesFile;
@override @override
final File dillFile; final File dillFile;
@override
CodegenStatus get lastStatus => _lastStatus;
CodegenStatus _lastStatus;
@override @override
Stream<CodegenStatus> get buildResults => buildDaemonClient.buildResults.map((build.BuildResults results) { Stream<CodegenStatus> get buildResults => buildDaemonClient.buildResults.map((build.BuildResults results) {
if (results.results.first.status == BuildStatus.failed) { if (results.results.first.status == BuildStatus.failed) {
return CodegenStatus.Failed; return _lastStatus = CodegenStatus.Failed;
} }
if (results.results.first.status == BuildStatus.started) { if (results.results.first.status == BuildStatus.started) {
return CodegenStatus.Started; return _lastStatus = CodegenStatus.Started;
} }
if (results.results.first.status == BuildStatus.succeeded) { if (results.results.first.status == BuildStatus.succeeded) {
return CodegenStatus.Succeeded; return _lastStatus = CodegenStatus.Succeeded;
} }
_lastStatus = null;
return null; return null;
}); });
......
...@@ -134,6 +134,8 @@ abstract class CodegenDaemon { ...@@ -134,6 +134,8 @@ abstract class CodegenDaemon {
/// Whether the previously enqueued build was successful. /// Whether the previously enqueued build was successful.
Stream<CodegenStatus> get buildResults; Stream<CodegenStatus> get buildResults;
CodegenStatus get lastStatus;
/// Starts a new build. /// Starts a new build.
void startBuild(); void startBuild();
...@@ -265,11 +267,12 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler { ...@@ -265,11 +267,12 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler {
@override @override
Future<CompilerOutput> recompile(String mainPath, List<String> invalidatedFiles, {String outputPath, String packagesFilePath}) async { Future<CompilerOutput> recompile(String mainPath, List<String> invalidatedFiles, {String outputPath, String packagesFilePath}) async {
_codegenDaemon.startBuild(); if (_codegenDaemon.lastStatus != CodegenStatus.Succeeded && _codegenDaemon.lastStatus != CodegenStatus.Failed) {
final CodegenStatus status = await _codegenDaemon.buildResults.firstWhere((CodegenStatus status) { await _codegenDaemon.buildResults.firstWhere((CodegenStatus status) {
return status ==CodegenStatus.Succeeded || status == CodegenStatus.Failed; return status ==CodegenStatus.Succeeded || status == CodegenStatus.Failed;
}); });
if (status == CodegenStatus.Failed) { }
if (_codegenDaemon.lastStatus == CodegenStatus.Failed) {
printError('Codegeneration failed, halting build.'); printError('Codegeneration failed, halting build.');
} }
// Delete this file so that the frontend_server can handle multi-root. // Delete this file so that the frontend_server can handle multi-root.
......
...@@ -51,7 +51,7 @@ dependencies: ...@@ -51,7 +51,7 @@ dependencies:
code_builder: 3.2.0 code_builder: 3.2.0
build: 1.1.1 build: 1.1.1
build_modules: 1.0.8 build_modules: 1.0.8
build_daemon: 0.4.0 build_daemon: 0.4.1
async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
bazel_worker: 0.1.20 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" bazel_worker: 0.1.20 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -115,4 +115,4 @@ dartdoc: ...@@ -115,4 +115,4 @@ dartdoc:
# Exclude this package from the hosted API docs. # Exclude this package from the hosted API docs.
nodoc: true nodoc: true
# PUBSPEC CHECKSUM: 43e3 # PUBSPEC CHECKSUM: e6e4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment