Skip to content

Commit dd2ae29

Browse files
committed
Merge pull request #5 from flutter/gen_entry
Gen entry
2 parents cefe912 + 074539a commit dd2ae29

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

tool/grind.dart

+28-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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.
44

5+
import 'dart:io';
6+
57
import 'package:grinder/grinder.dart';
68

79
main(List<String> args) => grind(args);
@@ -11,17 +13,40 @@ analyze() {
1113
return new PubApp.global('tuneup').runAsync(['check']);
1214
}
1315

14-
@DefaultTask()
16+
@Task()
1517
build() async {
1618
// dart ../../dev_compiler/bin/dev_compiler.dart -oweb/ddc web/entry.dart
1719

1820
await new DevCompiler().compileAsync(
1921
getFile('web/entry.dart'), getDir('web/ddc'));
2022

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();
2237

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);
2348
}
2449

25-
@Task()
50+
@DefaultTask()
2651
@Depends(analyze, build)
2752
bot() => null;

web/entry_all.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
global.dart_utils = require('./ddc/dev_compiler/runtime/dart_utils.js');
22
global.dart_library = require('./ddc/dev_compiler/runtime/dart_library.js');
33

4-
//require('./ddc/dev_compiler/runtime/harmony_feature_check.js');
5-
64
require('./ddc/atom_flutter_dev/flutter_dev.js');
75
require('./ddc/atom_flutter_dev/src/atom.js');
86
require('./ddc/dev_compiler/runtime/dart/_classes.js');

0 commit comments

Comments
 (0)