diff --git a/build_runner/bin/src/commands/generate_build_script.dart b/build_runner/bin/src/commands/generate_build_script.dart index 25418513c..15ddc0893 100644 --- a/build_runner/bin/src/commands/generate_build_script.dart +++ b/build_runner/bin/src/commands/generate_build_script.dart @@ -33,7 +33,12 @@ class GenerateBuildScript extends Command { var buildScript = await generateBuildScript(); File(scriptLocation) ..createSync(recursive: true) - ..writeAsStringSync(buildScript); + ..writeAsStringSync(buildScript.script); + File(scriptDepsPath) + ..createSync(recursive: true) + ..writeAsStringSync( + '$scriptLocation: ${buildScript.dependencyPaths.join(' ')}', + ); print(p.absolute(scriptLocation)); return 0; } diff --git a/build_runner/lib/src/build_script_generate/bootstrap.dart b/build_runner/lib/src/build_script_generate/bootstrap.dart index dd82680a1..9134c85de 100644 --- a/build_runner/lib/src/build_script_generate/bootstrap.dart +++ b/build_runner/lib/src/build_script_generate/bootstrap.dart @@ -26,31 +26,29 @@ import 'build_script_generate.dart'; /// Returns the exit code from running the build script. /// /// If an exit code of 75 is returned, this function should be re-ran. +/// +/// Pass [script] to override the default build script for testing. Future generateAndRun( List args, { List? experiments, Logger? logger, - Future Function() generateBuildScript = generateBuildScript, void Function(Object error, StackTrace stackTrace) handleUncaughtError = _defaultHandleUncaughtError, + GeneratedScript? script, }) { return buildLog.runWithLoggerDisplay( logger, - () => _generateAndRun( - args, - experiments, - generateBuildScript, - handleUncaughtError, - ), + () => + _generateAndRun(args, experiments, handleUncaughtError, script: script), ); } Future _generateAndRun( List args, List? experiments, - Future Function() generateBuildScript, - void Function(Object error, StackTrace stackTrace) handleUncaughtError, -) async { + void Function(Object error, StackTrace stackTrace) handleUncaughtError, { + GeneratedScript? script, +}) async { experiments ??= []; ReceivePort? exitPort; ReceivePort? errorPort; @@ -72,12 +70,17 @@ Future _generateAndRun( if (buildScript.existsSync()) { oldContents = buildScript.readAsStringSync(); } - var newContents = await generateBuildScript(); + var newContents = script ?? await generateBuildScript(); // Only trigger a build script update if necessary. - if (newContents != oldContents) { + if (newContents.script != oldContents) { buildScript ..createSync(recursive: true) - ..writeAsStringSync(newContents); + ..writeAsStringSync(newContents.script); + File(scriptDepsPath) + ..createSync(recursive: true) + ..writeAsStringSync( + '$scriptLocation: ${newContents.dependencyPaths.join(' ')}', + ); // Delete the kernel file so it will be rebuilt. final kernelFile = File(scriptKernelLocation); if (kernelFile.existsSync()) { @@ -183,7 +186,7 @@ Future _createKernelIfNeeded(List experiments) async { } } - if (!kernelFile.existsSync()) { + if (!kernelFile.existsSync() || true) { final client = await FrontendServerClient.start( scriptLocation, scriptKernelCachedLocation, @@ -196,9 +199,11 @@ Future _createKernelIfNeeded(List experiments) async { var hadErrors = false; buildLog.doing('Compiling the build script.'); try { + if (kernelCacheFile.existsSync()) kernelCacheFile.deleteSync(); final result = await client.compile(); + buildLog.debug(result.jsSourcesOutput.toString()); + buildLog.debug('built ${kernelCacheFile.path}'); hadErrors = result.errorCount > 0 || !kernelCacheFile.existsSync(); - // Note: We're logging all output with a single log call to keep // annotated source spans intact. final logOutput = result.compilerOutputLines.join('\n'); diff --git a/build_runner/lib/src/build_script_generate/build_script_generate.dart b/build_runner/lib/src/build_script_generate/build_script_generate.dart index 600869bf2..13b4da3cb 100644 --- a/build_runner/lib/src/build_script_generate/build_script_generate.dart +++ b/build_runner/lib/src/build_script_generate/build_script_generate.dart @@ -17,6 +17,7 @@ import '../package_graph/build_config_overrides.dart'; import 'builder_ordering.dart'; const scriptLocation = '$entryPointDir/build.dart'; +const scriptDepsPath = '$entryPointDir/build.dart.deps'; const scriptKernelLocation = '$scriptLocation$scriptKernelSuffix'; const scriptKernelSuffix = '.dill'; const scriptKernelCachedLocation = @@ -25,7 +26,7 @@ const scriptKernelCachedSuffix = '.cached'; final _lastShortFormatDartVersion = Version(3, 6, 0); -Future generateBuildScript() async { +Future generateBuildScript() async { buildLog.doing('Generating the build script.'); final info = await findBuildScriptOptions(); final builders = info.builderApplications; @@ -55,14 +56,15 @@ Future generateBuildScript() async { // the host<->isolate relationship changed in a breaking way, for example // if command line args or messages passed via sendports have changed // in a breaking way. - return DartFormatter(languageVersion: _lastShortFormatDartVersion).format( - ''' + final script = DartFormatter( + languageVersion: _lastShortFormatDartVersion, + ).format(''' // @dart=${_lastShortFormatDartVersion.major}.${_lastShortFormatDartVersion.minor} // ignore_for_file: directives_ordering // build_runner >=2.4.16 ${library.accept(emitter)} -''', - ); +'''); + return GeneratedScript(script: script, dependencyPaths: info.inputs); } on FormatterException { buildLog.error( 'Generated build script could not be parsed. ' @@ -195,13 +197,20 @@ Future findBuildScriptOptions({ _applyPostProcessBuilder(builder), ]; - return BuildScriptInfo(applications); + final inputs = []; + for (final package in packageGraph.allPackages.values) { + inputs.add('${package.path}/build.yaml'); + } + inputs.sort(); + + return BuildScriptInfo(inputs, applications); } class BuildScriptInfo { + final List inputs; final Iterable builderApplications; - BuildScriptInfo(this.builderApplications); + BuildScriptInfo(this.inputs, this.builderApplications); } /// A method forwarding to `run`. @@ -409,3 +418,10 @@ extension ConvertToExpression on Object? { } } } + +class GeneratedScript { + String script; + List dependencyPaths; + + GeneratedScript({required this.script, required this.dependencyPaths}); +} diff --git a/build_runner/lib/src/compiler/compiler.dart b/build_runner/lib/src/compiler/compiler.dart new file mode 100644 index 000000000..12129bce8 --- /dev/null +++ b/build_runner/lib/src/compiler/compiler.dart @@ -0,0 +1,73 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. 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:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:convert/convert.dart'; +import 'package:crypto/crypto.dart'; + +void main(List arguments) async { + await Compiler().compile(arguments[0]); +} + +class Compiler { + Future compile(String path) async { + final depfilePath = '$path.deps'; + final digestFilePath = '$path.digest'; + + final depfile = File(depfilePath); + final digestFile = File(digestFilePath); + + if (depfile.existsSync() && digestFile.existsSync()) { + final expectedDigest = digestFile.readAsStringSync(); + final actualDigest = computeDigest(parseDepfile(depfilePath)); + if (expectedDigest == actualDigest) { + print('Input digests matched, nothing to do.'); + return; + } else { + print( + 'Input digests changed from $expectedDigest to $actualDigest, rebuild.', + ); + } + } + + final result = await Process.run('dart', [ + 'compile', + 'kernel', + path, + '--depfile', + depfilePath, + ]); + if (result.exitCode != 0) { + print('Compile failed: ${result.stdout} ${result.stderr}'); + exit(1); + } + final deps = parseDepfile(depfilePath); + final digest = computeDigest(deps); + digestFile.writeAsStringSync(digest); + + //unawaited(dill.then((result) => print(result.stdout))); + } + + List parseDepfile(String depfilePath) { + // TODO(davidmorgan): handle spaces, they seem to be backslash escaped. + final result = + File(depfilePath).readAsStringSync().split(' ').skip(1).toList(); + // File ends in a newline. + result.last = result.last.substring(0, result.last.length - 1); + return result; + } + + String computeDigest(Iterable deps) { + final digestSink = AccumulatorSink(); + final result = md5.startChunkedConversion(digestSink); + for (final dep in deps) { + result.add(File(dep).readAsBytesSync()); + } + result.close(); + return base64.encode(digestSink.events.first.bytes); + } +} diff --git a/build_runner/lib/src/compiler/compiler.exe b/build_runner/lib/src/compiler/compiler.exe new file mode 100755 index 000000000..bf7d8aa1b Binary files /dev/null and b/build_runner/lib/src/compiler/compiler.exe differ diff --git a/build_runner/lib/src/compiler/external_build_step.dart b/build_runner/lib/src/compiler/external_build_step.dart new file mode 100644 index 000000000..dab829926 --- /dev/null +++ b/build_runner/lib/src/compiler/external_build_step.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. 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:convert'; +import 'dart:io'; + +import 'package:convert/convert.dart'; +import 'package:crypto/crypto.dart'; + +class ExternalBuildStep { + List inputPaths; + String outputPath; + + ExternalBuildStep({required this.inputPaths, required this.outputPath}); + + String get depsPath => '$outputPath.deps'; + String get digestsPath => '$outputPath.digests'; + + bool needsToRun() { + if (!File(depsPath).existsSync()) return true; + if (!File(outputPath).existsSync()) return true; + if (!File(digestsPath).existsSync()) return true; + + final digests = computeDigests(); + final oldDigests = File(digestsPath).readAsStringSync(); + return digests != oldDigests; + } + + void stamp() { + // TODO(davidmorgan): spaces. + File(depsPath).writeAsStringSync('$outputPath: ${inputPaths.join(' ')}'); + File(digestsPath).writeAsStringSync(computeDigests()); + } + + String computeDigests() => ''' +inputs digest: ${_computeDigest(inputPaths)} +output digest: ${_computeDigest([outputPath])} +'''; + + String _computeDigest(Iterable deps) { + final digestSink = AccumulatorSink(); + final result = md5.startChunkedConversion(digestSink); + for (final dep in deps) { + result.add(File(dep).readAsBytesSync()); + } + result.close(); + return base64.encode(digestSink.events.first.bytes); + } +} diff --git a/build_runner/lib/src/daemon/daemon_builder.dart b/build_runner/lib/src/daemon/daemon_builder.dart index 1c9be5913..c1e39144c 100644 --- a/build_runner/lib/src/daemon/daemon_builder.dart +++ b/build_runner/lib/src/daemon/daemon_builder.dart @@ -77,11 +77,8 @@ class BuildRunnerDaemonBuilder implements DaemonBuilder { (change) => AssetChange(AssetId.parse(change.path), change.type), ) .toList(); - - if (!_buildOptions.skipBuildScriptCheck && - _buildSeries.buildScriptUpdates!.hasBeenUpdated( - changes.map((change) => change.id).toSet(), - )) { + // ignore_for_file: dead_code + if (!_buildOptions.skipBuildScriptCheck && false) { if (!_buildScriptUpdateCompleter.isCompleted) { _buildScriptUpdateCompleter.complete(); } diff --git a/build_runner/lib/src/generate/watch_impl.dart b/build_runner/lib/src/generate/watch_impl.dart index 00440715a..5899522f6 100644 --- a/build_runner/lib/src/generate/watch_impl.dart +++ b/build_runner/lib/src/generate/watch_impl.dart @@ -257,9 +257,8 @@ class WatchImpl implements BuildState { _expectedDeletes.clear(); if (!options.skipBuildScriptCheck) { - if (build.buildScriptUpdates!.hasBeenUpdated( - mergedChanges.keys.toSet(), - )) { + // ignore_for_file: dead_code + if (false) { _terminateCompleter.complete(); buildLog.error('Terminating builds due to build script update.'); return BuildResult( diff --git a/build_runner/pubspec.yaml b/build_runner/pubspec.yaml index 9cf7cdddf..c646c0b83 100644 --- a/build_runner/pubspec.yaml +++ b/build_runner/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: build_daemon: ^4.0.0 build_runner_core: '9.2.1-wip' code_builder: ^4.2.0 + convert: ^3.1.2 crypto: ^3.0.0 dart_style: '>=2.3.7 <4.0.0' frontend_server_client: ">=3.0.0 <5.0.0" diff --git a/build_runner/test/build_script_generate/bootstrap_test.dart b/build_runner/test/build_script_generate/bootstrap_test.dart index 27fbb17cb..2e565876b 100644 --- a/build_runner/test/build_script_generate/bootstrap_test.dart +++ b/build_runner/test/build_script_generate/bootstrap_test.dart @@ -28,8 +28,7 @@ void main() { test('writes dill', () async { await generateAndRun( [], - generateBuildScript: - () async => ''' + script: ''' import 'dart:isolate'; import 'package:build_runner/src/build_script_generate/build_process_state.dart'; @@ -55,9 +54,9 @@ void main(_, [SendPort? sendPort]) async { '''; buildProcessState.isolateExitCode = 6; - await generateAndRun([], generateBuildScript: () async => script); + await generateAndRun([], script: script); expect(buildProcessState.isolateExitCode, 7); - await generateAndRun([], generateBuildScript: () async => script); + await generateAndRun([], script: script); expect(buildProcessState.isolateExitCode, 8); }); @@ -65,8 +64,7 @@ void main(_, [SendPort? sendPort]) async { expect( await generateAndRun( [], - generateBuildScript: - () async => ''' + script: ''' import 'dart:isolate'; import 'package:build_runner/src/build_script_generate/build_process_state.dart'; @@ -84,8 +82,7 @@ void main(_, [SendPort? sendPort]) async { expect( await generateAndRun( [], - generateBuildScript: - () async => ''' + script: ''' import 'dart:isolate'; import 'package:build_runner/src/build_script_generate/build_process_state.dart'; @@ -109,8 +106,7 @@ void main(_, [SendPort? sendPort]) async { expect( await generateAndRun( [], - generateBuildScript: - () async => ''' + script: ''' import 'dart:isolate'; import 'package:build_runner/src/build_script_generate/build_process_state.dart'; @@ -132,8 +128,7 @@ void main(_, [SendPort? sendPort]) async { expect( await generateAndRun( [], - generateBuildScript: - () async => ''' + script: ''' import 'dart:isolate'; import 'package:build_runner/src/build_script_generate/build_process_state.dart'; @@ -156,8 +151,7 @@ void main(_, [SendPort? sendPort]) async { await expectLater( generateAndRun( [], - generateBuildScript: () async { - return ''' + script: ''' import 'dart:isolate'; import 'package:build_runner/src/build_script_generate/build_process_state.dart'; @@ -165,8 +159,7 @@ void main(_, [SendPort? sendPort]) async { await buildProcessState.receive(sendPort); throw 'expected error'; } -'''; - }, +''', handleUncaughtError: (err, trace) { error = err; stackTrace = trace; diff --git a/build_runner/test/build_script_generate/experiments_test.dart b/build_runner/test/build_script_generate/experiments_test.dart index 2b81fde92..65421d79a 100644 --- a/build_runner/test/build_script_generate/experiments_test.dart +++ b/build_runner/test/build_script_generate/experiments_test.dart @@ -17,8 +17,7 @@ void main() { final exitCode = await generateAndRun( [], experiments: ['records'], - generateBuildScript: () async { - return ''' + script: ''' // @dart=3.0 import 'dart:io'; import 'dart:isolate'; @@ -30,8 +29,7 @@ void main() { buildProcessState.isolateExitCode = (x.\$2); buildProcessState.send(sendPort); } - '''; - }, + ''', logger: logger, ); expect(exitCode, 2); diff --git a/build_runner_core/lib/src/changes/build_script_updates.dart b/build_runner_core/lib/src/changes/build_script_updates.dart deleted file mode 100644 index b68039476..000000000 --- a/build_runner_core/lib/src/changes/build_script_updates.dart +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// for details. 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:async'; -import 'dart:mirrors'; - -import 'package:build/build.dart'; -import 'package:collection/collection.dart'; -import 'package:meta/meta.dart'; -import 'package:path/path.dart' as p; - -import '../asset_graph/graph.dart'; -import '../logging/build_log.dart'; -import '../package_graph/package_graph.dart'; - -/// Functionality for detecting if the build script itself or any of its -/// transitive imports have changed. -abstract class BuildScriptUpdates { - /// Checks if the current running program has been updated, based on - /// [updatedIds]. - bool hasBeenUpdated(Set updatedIds); - - /// Creates a [BuildScriptUpdates] object, using [reader] to ensure that - /// the [assetGraph] is tracking digests for all transitive sources. - /// - /// If [disabled] is `true` then all checks are skipped and - /// [hasBeenUpdated] will always return `false`. - static Future create( - AssetReader reader, - PackageGraph packageGraph, - AssetGraph assetGraph, { - bool disabled = false, - }) async { - if (disabled) return _NoopBuildScriptUpdates(); - return _MirrorBuildScriptUpdates.create(reader, packageGraph, assetGraph); - } -} - -/// Uses mirrors to find all transitive imports of the current script. -class _MirrorBuildScriptUpdates implements BuildScriptUpdates { - final Set _allSources; - final bool _supportsIncrementalRebuilds; - - _MirrorBuildScriptUpdates._( - this._supportsIncrementalRebuilds, - this._allSources, - ); - - static Future create( - AssetReader reader, - PackageGraph packageGraph, - AssetGraph graph, - ) async { - var supportsIncrementalRebuilds = true; - Set allSources; - try { - allSources = - _urisForThisScript - .map((id) => idForUri(id, packageGraph)) - .nonNulls - .toSet(); - var missing = allSources.firstWhereOrNull((id) => !graph.contains(id)); - if (missing != null) { - supportsIncrementalRebuilds = false; - buildLog.warning( - '$missing was not found in the asset graph, ' - 'incremental builds will not work. This probably means you ' - 'don\'t have your dependencies specified fully in your ' - 'pubspec.yaml.', - ); - } else { - // Make sure we are tracking changes for all ids in [allSources]. - for (var id in allSources) { - final node = graph.get(id)!; - if (node.digest == null) { - final digest = await reader.digest(id); - graph.updateNode(id, (nodeBuilder) { - nodeBuilder.digest = digest; - }); - } - } - } - } on ArgumentError // ignore: avoid_catching_errors - catch (_) { - supportsIncrementalRebuilds = false; - allSources = {}; - } - return _MirrorBuildScriptUpdates._(supportsIncrementalRebuilds, allSources); - } - - static Iterable get _urisForThisScript => - currentMirrorSystem().libraries.keys; - - /// Checks if the current running program has been updated, based on - /// [updatedIds]. - @override - bool hasBeenUpdated(Set updatedIds) { - if (!_supportsIncrementalRebuilds) return true; - return updatedIds.intersection(_allSources).isNotEmpty; - } -} - -/// Always returns false for [hasBeenUpdated], used when we want to skip -/// the build script checks. -class _NoopBuildScriptUpdates implements BuildScriptUpdates { - @override - bool hasBeenUpdated(void _) => false; -} - -/// Attempts to return an [AssetId] for [uri]. -/// -/// Returns `null` if the uri should be ignored, or throws an [ArgumentError] -/// if the [uri] is not recognized. -@visibleForTesting -AssetId? idForUri(Uri uri, PackageGraph packageGraph) { - switch (uri.scheme) { - case 'dart': - // TODO: check for sdk updates! - break; - case 'package': - var parts = uri.pathSegments; - return AssetId( - parts[0], - p.url.joinAll(['lib', ...parts.getRange(1, parts.length)]), - ); - case 'file': - final package = packageGraph.asPackageConfig.packageOf( - Uri.file(p.canonicalize(uri.toFilePath())), - ); - if (package == null) { - throw ArgumentError( - 'The uri $uri could not be resolved to a package in the current ' - 'package graph. Do you have a dependency on the package ' - 'containing this uri?', - ); - } - // The `AssetId` constructor normalizes this path to a URI style. - var relativePath = p.relative( - uri.toFilePath(), - from: package.root.toFilePath(), - ); - return AssetId(package.name, relativePath); - case 'data': - // Test runner uses a `data` scheme, don't invalidate for those. - if (uri.path.contains('package:test')) break; - continue unsupported; - case 'http': - continue unsupported; - unsupported: - default: - throw ArgumentError( - 'Unsupported uri scheme `${uri.scheme}` found for ' - 'library in build script.\n' - 'This probably means you are running in an unsupported ' - 'context, such as in an isolate or via `dart run`.\n' - 'Full uri was: $uri.', - ); - } - return null; -} diff --git a/build_runner_core/lib/src/generate/build_definition.dart b/build_runner_core/lib/src/generate/build_definition.dart index 021c22904..5a02ee3d1 100644 --- a/build_runner_core/lib/src/generate/build_definition.dart +++ b/build_runner_core/lib/src/generate/build_definition.dart @@ -14,7 +14,6 @@ import '../asset/writer.dart'; import '../asset_graph/exceptions.dart'; import '../asset_graph/graph.dart'; import '../asset_graph/graph_loader.dart'; -import '../changes/build_script_updates.dart'; import '../environment/build_environment.dart'; import '../logging/build_log.dart'; import '../util/constants.dart'; @@ -27,7 +26,6 @@ import 'options.dart'; // not a build definition. class BuildDefinition { final AssetGraph assetGraph; - final BuildScriptUpdates? buildScriptUpdates; /// Whether this is a build starting from no previous state or outputs. final bool cleanBuild; @@ -39,12 +37,7 @@ class BuildDefinition { /// the current build having an incompatible change. final Map? updates; - BuildDefinition._( - this.assetGraph, - this.buildScriptUpdates, - this.cleanBuild, - this.updates, - ); + BuildDefinition._(this.assetGraph, this.cleanBuild, this.updates); static Future prepareWorkspace( BuildEnvironment environment, @@ -77,7 +70,6 @@ class _Loader { var cacheDirSources = await assetTracker.findCacheDirSources(); var internalSources = await assetTracker.findInternalSources(); - BuildScriptUpdates? buildScriptUpdates; Map? updates; var cleanBuild = true; if (assetGraph != null) { @@ -90,17 +82,8 @@ class _Loader { cacheDirSources, internalSources, ); - buildScriptUpdates = await BuildScriptUpdates.create( - _environment.reader, - _options.packageGraph, - assetGraph, - disabled: _options.skipBuildScriptCheck, - ); - - var buildScriptUpdated = - !_options.skipBuildScriptCheck && - buildScriptUpdates.hasBeenUpdated(updates.keys.toSet()); - if (buildScriptUpdated) { + // ignore_for_file: dead_code + if (false) { buildLog.fullBuildBecause(FullBuildReason.incompatibleScript); var deletedSourceOutputs = await assetGraph.deleteOutputs( _options.packageGraph, @@ -115,7 +98,6 @@ class _Loader { inputSources.removeAll(deletedSourceOutputs); assetGraph = null; - buildScriptUpdates = null; updates = null; cleanBuild = true; } @@ -137,13 +119,6 @@ class _Loader { buildLog.error(e.toString()); throw const CannotBuildException(); } - buildScriptUpdates = await BuildScriptUpdates.create( - _environment.reader, - _options.packageGraph, - assetGraph, - disabled: _options.skipBuildScriptCheck, - ); - conflictingOutputs = assetGraph.outputs .where((n) => n.package == _options.packageGraph.root.name) @@ -171,12 +146,7 @@ class _Loader { await _initialBuildCleanup(conflictingOutputs, _environment.writer); } - return BuildDefinition._( - assetGraph, - buildScriptUpdates, - cleanBuild, - updates, - ); + return BuildDefinition._(assetGraph, cleanBuild, updates); } /// Deletes the generated output directory. diff --git a/build_runner_core/lib/src/generate/build_series.dart b/build_runner_core/lib/src/generate/build_series.dart index 169240893..b63e31f7b 100644 --- a/build_runner_core/lib/src/generate/build_series.dart +++ b/build_runner_core/lib/src/generate/build_series.dart @@ -12,7 +12,6 @@ import 'package:watcher/watcher.dart'; import '../asset/finalized_reader.dart'; import '../asset/writer.dart'; import '../asset_graph/graph.dart'; -import '../changes/build_script_updates.dart'; import '../environment/build_environment.dart'; import '../logging/build_log.dart'; import '../package_graph/apply_builders.dart'; @@ -39,7 +38,6 @@ import 'options.dart'; class BuildSeries { final BuildEnvironment environment; final AssetGraph assetGraph; - final BuildScriptUpdates? buildScriptUpdates; final BuildOptions options; final BuildPhases buildPhases; @@ -66,7 +64,6 @@ class BuildSeries { BuildSeries._( this.environment, this.assetGraph, - this.buildScriptUpdates, this.options, this.buildPhases, this.finalizedReader, @@ -173,7 +170,6 @@ class BuildSeries { var build = BuildSeries._( environment, buildDefinition.assetGraph, - buildDefinition.buildScriptUpdates, options, buildPhases, finalizedReader, diff --git a/build_runner_core/test/changes/build_script_updates_test.dart b/build_runner_core/test/changes/build_script_updates_test.dart deleted file mode 100644 index ecac172e0..000000000 --- a/build_runner_core/test/changes/build_script_updates_test.dart +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:build/build.dart'; -import 'package:build_runner_core/src/changes/build_script_updates.dart'; -import 'package:build_runner_core/src/package_graph/package_graph.dart'; -import 'package:package_config/package_config_types.dart'; -import 'package:test/test.dart'; - -void main() { - group('idForUri', () { - late final PackageGraph packageGraph; - setUpAll(() async { - final rootPackage = PackageNode( - 'a', - '/a/', - DependencyType.path, - LanguageVersion(3, 0), - isRoot: true, - ); - final dependency = PackageNode( - 'b', - '/b/', - DependencyType.path, - LanguageVersion(3, 0), - ); - rootPackage.dependencies.add(dependency); - packageGraph = PackageGraph.fromRoot(rootPackage); - }); - - test('dart: uris return null', () { - expect(idForUri(Uri.parse('dart:io'), packageGraph), isNull); - }); - - test('package: uris can be converted', () { - expect( - idForUri(Uri.parse('package:a/a.dart'), packageGraph), - AssetId('a', 'lib/a.dart'), - ); - }); - - test('file: uris can be looked up', () { - expect( - idForUri(Uri.file('/a/lib/a.dart'), packageGraph), - AssetId('a', 'lib/a.dart'), - ); - expect( - idForUri(Uri.file('/b/b.dart'), packageGraph), - AssetId('b', 'b.dart'), - ); - }); - test('data: arent supported unless they are from the test runner', () { - expect( - () => idForUri( - Uri.parse('data:text/plain;charset=UTF-8,foo'), - packageGraph, - ), - throwsA(isA()), - ); - expect( - idForUri( - Uri.parse('data:text/plain;charset=UTF-8,package:test'), - packageGraph, - ), - null, - ); - }); - - test('http: uris are not supported', () { - expect( - () => idForUri(Uri.parse('http://google.com'), packageGraph), - throwsA(isA()), - ); - }); - }); -}