2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
+ import 'dart:io' ;
6
+
5
7
import 'package:grinder/grinder.dart' ;
6
8
7
9
main (List <String > args) => grind (args);
@@ -11,17 +13,40 @@ analyze() {
11
13
return new PubApp .global ('tuneup' ).runAsync (['check' ]);
12
14
}
13
15
14
- @DefaultTask ()
16
+ @Task ()
15
17
build () async {
16
18
// dart ../../dev_compiler/bin/dev_compiler.dart -oweb/ddc web/entry.dart
17
19
18
20
await new DevCompiler ().compileAsync (
19
21
getFile ('web/entry.dart' ), getDir ('web/ddc' ));
20
22
21
- // TODO: Generate web/entry_all.js by traversing the web/ddc output directory.
23
+ // Generate web/entry_all.js by traversing the web/ddc output directory.
24
+ Directory ddcDir = getDir ('web/ddc' );
25
+ List <File > files = ddcDir.listSync (followLinks: false , recursive: true )
26
+ .where ((entity) => entity is File && entity.path.endsWith ('.js' ))
27
+ .toList ();
28
+
29
+ files.removeWhere ((file) => file.path.endsWith ('dart_utils.js' ));
30
+ files.removeWhere ((file) => file.path.endsWith ('dart_library.js' ));
31
+ files.removeWhere ((file) => file.path.endsWith ('harmony_feature_check.js' ));
32
+
33
+ List <String > paths = files
34
+ .map ((file) => file.path)
35
+ .map ((path) => path.replaceAll ('web/ddc/' , './ddc/' ))
36
+ .toList ();
22
37
38
+ File entryJsFile = getFile ('web/entry_all.js' );
39
+ String contents = '''
40
+ global.dart_utils = require('./ddc/dev_compiler/runtime/dart_utils.js');
41
+ global.dart_library = require('./ddc/dev_compiler/runtime/dart_library.js');
42
+
43
+ ${paths .map ((path ) => "require('${path }');" ).join ('\n ' )}
44
+
45
+ dart_library.start('entry');
46
+ ''' ;
47
+ entryJsFile.writeAsStringSync (contents);
23
48
}
24
49
25
- @Task ()
50
+ @DefaultTask ()
26
51
@Depends (analyze, build)
27
52
bot () => null ;
0 commit comments