Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: pkg/barback/lib/transformer.dart

Issue 16854005: First pass at build dependency graph for barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 library barback.generator;
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:pathos/path.dart' as pathos;
11
12 import 'barback.dart';
13
14 /// A [Transformer] represents a processor that takes in one or more input
15 /// assets and uses them to generate one or more output assets.
16 ///
17 /// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate
18 /// files are all examples of transformers. To define your own transformation
19 /// step, extend (or implement) this class.
20 abstract class Transformer {
21 /// Returns `true` if [input] can be a primary input for this transformer.
22 ///
23 /// While a transformer can read from multiple input files, one must be the
24 /// "primary" input. This asset determines whether the transformation should
25 /// be run at all. If the primary input is removed, the transformer will no
26 /// longer be run.
27 ///
28 /// A concrete example is dart2js. When you run dart2js, it will traverse
29 /// all of the imports in your Dart source files and use the contents of all
30 /// of those to generate the final JS. However you still run dart2js "on" a
31 /// single file: the entrypoint Dart file that has your `main()` method.
32 /// This entrypoint file would be the primary input.
33 Future<bool> isPrimary(AssetId input);
34
35 /// Run this transformer on on the primary input specified by [transform].
36 ///
37 /// The [transform] is used by the [Transformer] for two purposes (in
38 /// addition to accessing the primary input). It can call `getInput()` to
39 /// request additional input assets. It also calls `addOutput()` to provide
40 /// generated assets back to the system. Either can be called multiple times,
41 /// in any order.
42 ///
43 /// In other words, a Transformer's job is to find all inputs for a
44 /// transform, starting at the primary input, then generate all output assets
45 /// and yield them back to the transform.
46 Future apply(Transform transform);
47
48 String toString() => runtimeType.toString().replaceAll("Transformer", "");
49 }
50
51 /// While a [Transformer] represents a *kind* of transformation, this defines
52 /// one specific usage of it on a set of files. This ephemeral object exists
53 /// only during an actual transform application to to facilitate communication
nweiz 2013/06/18 23:14:46 "to to" -> "to"
Bob Nystrom 2013/06/20 00:23:59 Done.
54 /// between the [Transformer] and the code hosting the transformation. It lets
55 /// the [Transformer] access inputs and generate outputs.
56 abstract class Transform {
57 /// Gets the ID of the primary input for this transformation. While a
58 /// transformation can use multiple input assets, one must be a special
59 /// "primary" asset. This will be the "entrypoint" or "main" input file for
60 /// a transformation.
61 ///
62 /// For example, with a dart2js transform, the primary input would be the
63 /// entrypoint Dart file. All of the other Dart files that that imports
64 /// would be secondary inputs.
65 AssetId get primaryId;
66
67 /// Gets the asset for the primary input.
68 Future<Asset> get primaryInput => getInput(primaryId);
69
70 /// Gets the asset for for an input [id]. If an input with that ID cannot be
71 /// found, throws an [AssetNotFoundException].
72 Future<Asset> getInput(AssetId id);
73
74 /// Stores [output] as the output created by this transformation for asset
75 /// [id]. A transformation can output as many assets as it wants.
76 void addOutput(AssetId id, Asset output);
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698