Skip to content

Commit fb25862

Browse files
authored
Remove build->build_runner_core dependency (#4172)
* Move runBuilder to build_runner_core. * Move implementation to build_runner_core. * Remove unused deps.
1 parent a4a26ca commit fb25862

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+265
-216
lines changed

build/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## 3.0.3-wip
22

3+
- Deprecate `runBuilder`. It has been moved to `package:build_runner_core` and
4+
will be deleted from `package:build`. Please note: the currently supported
5+
ways to run builders are using `build_runner` on the command line or
6+
`build_test` in tests. If you need ongoing support for a different way to run
7+
builders please get in touch at
8+
https://github.com/dart-lang/build/discussions.
39
- Use `build_runner_core` 9.3.1.
410

511
## 3.0.2

build/lib/build.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export 'src/asset/exceptions.dart';
77
export 'src/asset/id.dart';
88
export 'src/asset/reader.dart';
99
export 'src/asset/writer.dart';
10-
export 'src/builder/build_step.dart' hide NoOpStageTracker;
10+
export 'src/builder/build_step.dart';
1111
export 'src/builder/builder.dart';
1212
export 'src/builder/exceptions.dart';
1313
export 'src/builder/file_deleting_builder.dart' show FileDeletingBuilder;

build/lib/src/builder/build_step.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,3 @@ abstract class BuildStep implements AssetReader, AssetWriter {
139139
abstract class StageTracker {
140140
T trackStage<T>(String label, T Function() action, {bool isExternal = false});
141141
}
142-
143-
class NoOpStageTracker implements StageTracker {
144-
static const StageTracker instance = NoOpStageTracker._();
145-
146-
@override
147-
T trackStage<T>(
148-
String label,
149-
T Function() action, {
150-
bool isExternal = false,
151-
}) => action();
152-
153-
const NoOpStageTracker._();
154-
}
Lines changed: 24 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
4-
import 'dart:isolate';
54

6-
import 'package:build_runner_core/build_runner_core.dart';
75
// ignore: implementation_imports
8-
import 'package:build_runner_core/src/generate/build_step_impl.dart';
9-
// ignore: implementation_imports
10-
import 'package:build_runner_core/src/generate/single_step_reader_writer.dart';
6+
import 'package:build_runner_core/src/generate/run_builder.dart'
7+
as build_runner_core;
118
import 'package:logging/logging.dart';
129
import 'package:package_config/package_config.dart';
1310

@@ -17,24 +14,17 @@ import '../asset/reader.dart';
1714
import '../asset/writer.dart';
1815
import '../builder/build_step.dart';
1916
import '../builder/builder.dart';
20-
import '../builder/logging.dart';
2117
import '../resource/resource.dart';
22-
import 'expected_outputs.dart';
2318

24-
/// Run [builder] with each asset in [inputs] as the primary input.
25-
///
26-
/// Builds for all inputs are run asynchronously and ordering is not guaranteed.
27-
/// The [log] instance inside the builds will be scoped to [logger] which is
28-
/// defaulted to a [Logger] name 'runBuilder'.
29-
///
30-
/// If a [resourceManager] is provided it will be used and it will not be
31-
/// automatically disposed of (its up to the caller to dispose of it later). If
32-
/// one is not provided then one will be created and disposed at the end of
33-
/// this function call.
34-
///
35-
/// If [reportUnusedAssetsForInput] is provided then all calls to
36-
/// `BuildStep.reportUnusedAssets` in [builder] will be forwarded to this
37-
/// function with the associated primary input.
19+
@Deprecated('''
20+
This method has moved to `package:build_runner_core` and will be
21+
deleted from `package:build`.
22+
23+
The currently supported ways to run builders are using `build_runner`
24+
on the command line or `build_test` in tests. If you need ongoing
25+
support for a different way to run builders please get in touch at
26+
https://github.com/dart-lang/build/discussions.
27+
''')
3828
Future<void> runBuilder(
3929
Builder builder,
4030
Iterable<AssetId> inputs,
@@ -43,95 +33,19 @@ Future<void> runBuilder(
4333
Resolvers? resolvers, {
4434
Logger? logger,
4535
ResourceManager? resourceManager,
46-
StageTracker stageTracker = NoOpStageTracker.instance,
36+
StageTracker? stageTracker,
4737
void Function(AssetId input, Iterable<AssetId> assets)?
4838
reportUnusedAssetsForInput,
4939
PackageConfig? packageConfig,
50-
}) async {
51-
var shouldDisposeResourceManager = resourceManager == null;
52-
final resources = resourceManager ?? ResourceManager();
53-
logger ??= Logger('runBuilder');
54-
55-
PackageConfig? transformedConfig;
56-
57-
Future<PackageConfig> loadPackageConfig() async {
58-
if (transformedConfig != null) return transformedConfig!;
59-
60-
var config = packageConfig;
61-
if (config == null) {
62-
final uri = await Isolate.packageConfig;
63-
64-
if (uri == null) {
65-
throw UnsupportedError(
66-
'Isolate running the build does not have a package config and no '
67-
'fallback has been provided',
68-
);
69-
}
70-
71-
config = await loadPackageConfigUri(uri);
72-
}
73-
74-
return transformedConfig = config.transformToAssetUris();
75-
}
76-
77-
//TODO(nbosch) check overlapping outputs?
78-
Future<void> buildForInput(AssetId input) async {
79-
var outputs = expectedOutputs(builder, input);
80-
if (outputs.isEmpty) return;
81-
var buildStep = BuildStepImpl(
82-
input,
83-
outputs,
84-
// If there a build running, `assetReader` and `assetWriter` are already a
85-
// `SingleStepReaderWriter` instance integrated with the build; the `from`
86-
// factory just passes it through.
87-
//
88-
// If there is no build running, this creates a fake build step.
89-
SingleStepReaderWriter.from(reader: assetReader, writer: assetWriter),
90-
resolvers,
91-
resources,
92-
loadPackageConfig,
93-
stageTracker: stageTracker,
94-
reportUnusedAssets:
95-
reportUnusedAssetsForInput == null
96-
? null
97-
: (assets) => reportUnusedAssetsForInput(input, assets),
98-
);
99-
try {
100-
await builder.build(buildStep);
101-
} finally {
102-
await buildStep.complete();
103-
}
104-
}
105-
106-
await BuildLogLogger.scopeLogAsync(
107-
() => Future.wait(inputs.map(buildForInput)),
108-
logger,
109-
);
110-
111-
if (shouldDisposeResourceManager) {
112-
await resources.disposeAll();
113-
await resources.beforeExit();
114-
}
115-
}
116-
117-
extension on Package {
118-
static final _lib = Uri.parse('lib/');
119-
120-
Package transformToAssetUris() {
121-
return Package(
122-
name,
123-
Uri(scheme: 'asset', pathSegments: [name, '']),
124-
packageUriRoot: _lib,
125-
extraData: extraData,
126-
languageVersion: languageVersion,
127-
);
128-
}
129-
}
130-
131-
extension on PackageConfig {
132-
PackageConfig transformToAssetUris() {
133-
return PackageConfig([
134-
for (final package in packages) package.transformToAssetUris(),
135-
], extraData: extraData);
136-
}
137-
}
40+
}) => build_runner_core.runBuilder(
41+
builder,
42+
inputs,
43+
assetReader,
44+
assetWriter,
45+
resolvers,
46+
logger: logger,
47+
resourceManager: resourceManager,
48+
stageTracker: stageTracker,
49+
reportUnusedAssetsForInput: reportUnusedAssetsForInput,
50+
packageConfig: packageConfig,
51+
);

build/lib/src/internal.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,3 @@
77
library;
88

99
export 'builder/logging.dart';
10-
export 'library_cycle_graph/asset_deps.dart';
11-
export 'library_cycle_graph/asset_deps_loader.dart';
12-
export 'library_cycle_graph/library_cycle.dart';
13-
export 'library_cycle_graph/library_cycle_graph.dart';
14-
export 'library_cycle_graph/library_cycle_graph_loader.dart';
15-
export 'library_cycle_graph/phased_asset_deps.dart';
16-
export 'library_cycle_graph/phased_reader.dart';
17-
export 'library_cycle_graph/phased_value.dart';
18-
export 'state/asset_finder.dart';
19-
export 'state/asset_path_provider.dart';
20-
export 'state/filesystem.dart';
21-
export 'state/filesystem_cache.dart';
22-
export 'state/generated_asset_hider.dart';
23-
export 'state/reader_state.dart';
24-
export 'state/reader_writer.dart';

build/pubspec.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ dependencies:
1111
analyzer: '>=7.4.0 <9.0.0'
1212
async: ^2.5.0
1313
build_runner_core: '9.3.1-wip'
14-
built_collection: ^5.1.1
15-
built_value: ^8.9.5
1614
convert: ^3.0.0
1715
crypto: ^3.0.0
1816
glob: ^2.0.0
19-
graphs: ^2.2.0
2017
logging: ^1.0.0
21-
meta: ^1.16.0
2218
package_config: ^2.1.0
2319
path: ^1.8.0
2420

build_resolvers/lib/src/analysis_driver_model.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import 'dart:async';
77
// ignore: implementation_imports
88
import 'package:analyzer/src/clients/build_resolvers/build_resolvers.dart';
99
import 'package:build/build.dart';
10-
// ignore: implementation_imports
11-
import 'package:build/src/internal.dart';
1210
import 'package:build_runner_core/build_runner_core.dart';
1311
// ignore: implementation_imports
1412
import 'package:build_runner_core/src/generate/build_step_impl.dart';

build_runner/lib/src/watcher/change_filter.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import 'dart:async';
55

66
import 'package:build/build.dart';
7-
// ignore: implementation_imports
8-
import 'package:build/src/internal.dart';
97
import 'package:build_runner_core/build_runner_core.dart';
108
// ignore: implementation_imports
119
import 'package:build_runner_core/src/asset_graph/graph.dart';

build_runner_core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## 9.3.1-wip
22

3+
- Move `runBuilder` to here from `package:build`. Please note that all of
4+
`build_runner_core` is intended to be internal to `build_runner`: the
5+
supported ways to run builders are `build_runner` on the command line and
6+
`build_test` in tests. If you need ongoing support for a different way to run
7+
builders please get in touch at
8+
https://github.com/dart-lang/build/discussions.
39
- Use `build_runner` 2.7.1.
410
- Remove `overrideGeneratedOutputDirectory`, `pubBinary`.
511

build_runner_core/lib/build_runner_core.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ export 'src/generate/exceptions.dart'
1717
BuildScriptChangedException,
1818
CannotBuildException;
1919
export 'src/generate/finalized_assets_view.dart' show FinalizedAssetsView;
20+
export 'src/generate/input_tracker.dart';
2021
export 'src/generate/performance_tracker.dart'
2122
show BuildPerformance, BuildPhasePerformance, BuilderActionPerformance;
23+
export 'src/generate/run_builder.dart';
24+
export 'src/library_cycle_graph/asset_deps_loader.dart';
25+
export 'src/library_cycle_graph/library_cycle_graph_loader.dart';
26+
export 'src/library_cycle_graph/phased_asset_deps.dart';
2227
export 'src/logging/build_log.dart';
2328
export 'src/logging/build_log_configuration.dart';
2429
export 'src/logging/build_log_logger.dart';
@@ -40,6 +45,12 @@ export 'src/package_graph/apply_builders.dart'
4045
export 'src/package_graph/apply_builders.dart';
4146
export 'src/package_graph/package_graph.dart';
4247
export 'src/package_graph/target_graph.dart';
48+
export 'src/state/asset_finder.dart';
49+
export 'src/state/asset_path_provider.dart';
50+
export 'src/state/filesystem.dart';
51+
export 'src/state/filesystem_cache.dart';
52+
export 'src/state/generated_asset_hider.dart';
53+
export 'src/state/reader_state.dart';
4354
export 'src/util/constants.dart'
4455
show
4556
assetGraphPath,

0 commit comments

Comments
 (0)