Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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.

import 'dart:io';

import 'package:grinder/grinder.dart';

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

@DefaultTask()
@Task()
build() async {
// dart ../../dev_compiler/bin/dev_compiler.dart -oweb/ddc web/entry.dart

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

// TODO: Generate web/entry_all.js by traversing the web/ddc output directory.
// Generate web/entry_all.js by traversing the web/ddc output directory.
Directory ddcDir = getDir('web/ddc');
List<File> files = ddcDir.listSync(followLinks: false, recursive: true)
.where((entity) => entity is File && entity.path.endsWith('.js'))
.toList();

files.removeWhere((file) => file.path.endsWith('dart_utils.js'));
files.removeWhere((file) => file.path.endsWith('dart_library.js'));
files.removeWhere((file) => file.path.endsWith('harmony_feature_check.js'));

List<String> paths = files
.map((file) => file.path)
.map((path) => path.replaceAll('web/ddc/', './ddc/'))
.toList();

File entryJsFile = getFile('web/entry_all.js');
String contents = '''
global.dart_utils = require('./ddc/dev_compiler/runtime/dart_utils.js');
global.dart_library = require('./ddc/dev_compiler/runtime/dart_library.js');

${paths.map((path) => "require('${path}');").join('\n')}

dart_library.start('entry');
''';
entryJsFile.writeAsStringSync(contents);
}

@Task()
@DefaultTask()
@Depends(analyze, build)
bot() => null;
2 changes: 0 additions & 2 deletions web/entry_all.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
global.dart_utils = require('./ddc/dev_compiler/runtime/dart_utils.js');
global.dart_library = require('./ddc/dev_compiler/runtime/dart_library.js');

//require('./ddc/dev_compiler/runtime/harmony_feature_check.js');

require('./ddc/atom_flutter_dev/flutter_dev.js');
require('./ddc/atom_flutter_dev/src/atom.js');
require('./ddc/dev_compiler/runtime/dart/_classes.js');
Expand Down