Skip to content

Commit 7bdc9e0

Browse files
committed
reorder properties, add constant which has the asset graph path
1 parent 5750c63 commit 7bdc9e0

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

lib/src/generate/build_impl.dart

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import '../builder/build_step_impl.dart';
2424
import '../builder/builder.dart';
2525
import '../logging/logging.dart';
2626
import '../package_graph/package_graph.dart';
27+
import '../util/constants.dart';
2728
import 'build_result.dart';
2829
import 'exceptions.dart';
2930
import 'input_set.dart';
@@ -32,24 +33,26 @@ import 'phase.dart';
3233

3334
/// Class which manages running builds.
3435
class BuildImpl {
35-
AssetGraph _assetGraph;
36-
AssetGraph get assetGraph => _assetGraph;
37-
38-
final AssetReader _reader;
39-
final AssetWriter _writer;
40-
final PackageGraph _packageGraph;
36+
final AssetId _assetGraphId;
4137
final List<List<BuildAction>> _buildActions;
4238
final _inputsByPackage = <String, Set<AssetId>>{};
43-
bool _buildRunning = false;
4439
final _logger = new Logger('Build');
40+
final PackageGraph _packageGraph;
41+
final AssetReader _reader;
42+
final AssetWriter _writer;
4543

44+
AssetGraph _assetGraph;
45+
AssetGraph get assetGraph => _assetGraph;
46+
bool _buildRunning = false;
4647
bool _isFirstBuild = true;
4748

4849
BuildImpl(BuildOptions options, PhaseGroup phaseGroup)
49-
: _reader = options.reader,
50-
_writer = options.writer,
50+
: _assetGraphId =
51+
new AssetId(options.packageGraph.root.name, assetGraphPath),
52+
_buildActions = phaseGroup.buildActions,
5153
_packageGraph = options.packageGraph,
52-
_buildActions = phaseGroup.buildActions;
54+
_reader = options.reader,
55+
_writer = options.writer;
5356

5457
/// Runs a build
5558
///
@@ -166,10 +169,6 @@ class BuildImpl {
166169
return result;
167170
}
168171

169-
/// Asset containing previous asset dependency graph.
170-
AssetId get _assetGraphId =>
171-
new AssetId(_packageGraph.root.name, '.dart_tool/build/asset_graph.json');
172-
173172
/// Reads in the [assetGraph] from disk.
174173
Future<AssetGraph> _readAssetGraph() async {
175174
if (!await _reader.hasInput(_assetGraphId)) return new AssetGraph();
@@ -360,7 +359,7 @@ class BuildImpl {
360359

361360
stdout.writeln('\n\nFound ${conflictingOutputs.length} declared outputs '
362361
'which already exist on disk. This is likely because the'
363-
'`.dart_tool/build` folder was deleted, or you are submitting generated '
362+
'`$cacheDir` folder was deleted, or you are submitting generated '
364363
'files to your source repository.');
365364
var done = false;
366365
while (!done) {

lib/src/generate/watch_impl.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import '../asset_graph/graph.dart';
1313
import '../asset_graph/node.dart';
1414
import '../logging/logging.dart';
1515
import '../package_graph/package_graph.dart';
16+
import '../util/constants.dart';
1617
import 'build_impl.dart';
1718
import 'build_result.dart';
1819
import 'directory_watcher_factory.dart';
@@ -228,7 +229,7 @@ class WatchImpl {
228229

229230
/// Checks if we should skip a watch event for this [id].
230231
bool _shouldSkipInput(AssetId id, ChangeType type) {
231-
if (id.path.contains('.dart_tool/build/')) return true;
232+
if (id.path.contains(cacheDir)) return true;
232233
var node = _assetGraph.get(id);
233234
return node is GeneratedAssetNode && type != ChangeType.REMOVE;
234235
}

lib/src/util/constants.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// Relative path to the asset graph from the root package dir.
6+
const assetGraphPath = '$cacheDir/asset_graph.json';
7+
8+
/// Relative path to the cache directory from the root package dir.
9+
const cacheDir = '.dart_tool/build';

test/common/common.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import 'in_memory_reader.dart';
1313
import 'in_memory_writer.dart';
1414
import 'matchers.dart';
1515

16+
export 'package:build/src/util/constants.dart';
17+
1618
export 'assets.dart';
1719
export 'copy_builder.dart';
1820
export 'fake_watcher.dart';
@@ -24,8 +26,6 @@ export 'matchers.dart';
2426
export 'stub_reader.dart';
2527
export 'stub_writer.dart';
2628

27-
final String assetGraphPath = '.dart_tool/build/asset_graph.json';
28-
2929
Future wait(int milliseconds) =>
3030
new Future.delayed(new Duration(milliseconds: milliseconds));
3131

0 commit comments

Comments
 (0)