Skip to content

Commit

Permalink
reorder properties, add constant which has the asset graph path
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Mar 10, 2016
1 parent 5750c63 commit 7bdc9e0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
29 changes: 14 additions & 15 deletions lib/src/generate/build_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import '../builder/build_step_impl.dart';
import '../builder/builder.dart';
import '../logging/logging.dart';
import '../package_graph/package_graph.dart';
import '../util/constants.dart';
import 'build_result.dart';
import 'exceptions.dart';
import 'input_set.dart';
Expand All @@ -32,24 +33,26 @@ import 'phase.dart';

/// Class which manages running builds.
class BuildImpl {
AssetGraph _assetGraph;
AssetGraph get assetGraph => _assetGraph;

final AssetReader _reader;
final AssetWriter _writer;
final PackageGraph _packageGraph;
final AssetId _assetGraphId;
final List<List<BuildAction>> _buildActions;
final _inputsByPackage = <String, Set<AssetId>>{};
bool _buildRunning = false;
final _logger = new Logger('Build');
final PackageGraph _packageGraph;
final AssetReader _reader;
final AssetWriter _writer;

AssetGraph _assetGraph;
AssetGraph get assetGraph => _assetGraph;
bool _buildRunning = false;
bool _isFirstBuild = true;

BuildImpl(BuildOptions options, PhaseGroup phaseGroup)
: _reader = options.reader,
_writer = options.writer,
: _assetGraphId =
new AssetId(options.packageGraph.root.name, assetGraphPath),
_buildActions = phaseGroup.buildActions,
_packageGraph = options.packageGraph,
_buildActions = phaseGroup.buildActions;
_reader = options.reader,
_writer = options.writer;

/// Runs a build
///
Expand Down Expand Up @@ -166,10 +169,6 @@ class BuildImpl {
return result;
}

/// Asset containing previous asset dependency graph.
AssetId get _assetGraphId =>
new AssetId(_packageGraph.root.name, '.dart_tool/build/asset_graph.json');

/// Reads in the [assetGraph] from disk.
Future<AssetGraph> _readAssetGraph() async {
if (!await _reader.hasInput(_assetGraphId)) return new AssetGraph();
Expand Down Expand Up @@ -360,7 +359,7 @@ class BuildImpl {

stdout.writeln('\n\nFound ${conflictingOutputs.length} declared outputs '
'which already exist on disk. This is likely because the'
'`.dart_tool/build` folder was deleted, or you are submitting generated '
'`$cacheDir` folder was deleted, or you are submitting generated '
'files to your source repository.');
var done = false;
while (!done) {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/generate/watch_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../asset_graph/graph.dart';
import '../asset_graph/node.dart';
import '../logging/logging.dart';
import '../package_graph/package_graph.dart';
import '../util/constants.dart';
import 'build_impl.dart';
import 'build_result.dart';
import 'directory_watcher_factory.dart';
Expand Down Expand Up @@ -228,7 +229,7 @@ class WatchImpl {

/// Checks if we should skip a watch event for this [id].
bool _shouldSkipInput(AssetId id, ChangeType type) {
if (id.path.contains('.dart_tool/build/')) return true;
if (id.path.contains(cacheDir)) return true;
var node = _assetGraph.get(id);
return node is GeneratedAssetNode && type != ChangeType.REMOVE;
}
Expand Down
9 changes: 9 additions & 0 deletions lib/src/util/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2016, 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.

/// Relative path to the asset graph from the root package dir.
const assetGraphPath = '$cacheDir/asset_graph.json';

/// Relative path to the cache directory from the root package dir.
const cacheDir = '.dart_tool/build';
4 changes: 2 additions & 2 deletions test/common/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import 'in_memory_reader.dart';
import 'in_memory_writer.dart';
import 'matchers.dart';

export 'package:build/src/util/constants.dart';

export 'assets.dart';
export 'copy_builder.dart';
export 'fake_watcher.dart';
Expand All @@ -24,8 +26,6 @@ export 'matchers.dart';
export 'stub_reader.dart';
export 'stub_writer.dart';

final String assetGraphPath = '.dart_tool/build/asset_graph.json';

Future wait(int milliseconds) =>
new Future.delayed(new Duration(milliseconds: milliseconds));

Expand Down

0 comments on commit 7bdc9e0

Please sign in to comment.