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

Side by Side Diff: lib/src/runner/runtime_utils.dart

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « lib/src/runner/file_utils.dart ('k') | lib/src/runner/v8_runner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 /// JS runtime files utilities used by dartdevrun.
6
7 import 'dart:async';
8 import 'dart:io';
9
10 import 'package:path/path.dart';
11
12 import '../compiler.dart' show defaultRuntimeFiles;
13 import '../options.dart';
14 import 'file_utils.dart';
15
16 /// In node.js / io.js, these modules need to be aliased globally
17 /// (e.g. `var foo = require('./path/to/foo.js')`).
18 /// TODO(ochafik): Investigate alternative module / alias patterns.
19 const _ALIASED_RUNTIME_FILES = const {'dart_library.js': 'dart_library',};
20
21 /// If [path] is a runtime file with an alias, returns that alias, otherwise
22 /// returns null.
23 String getRuntimeFileAlias(CompilerOptions options, File file) =>
24 file.absolute.path.startsWith(_getRuntimeDir(options).absolute.path)
25 ? _ALIASED_RUNTIME_FILES[basename(file.path)]
26 : null;
27
28 Directory _getRuntimeDir(CompilerOptions options) => new Directory(
29 join(options.codegenOptions.outputDir, 'dev_compiler', 'runtime'));
30
31 Future<List<File>> listOutputFiles(CompilerOptions options) async {
32 List<File> files =
33 await listJsFiles(new Directory(options.codegenOptions.outputDir));
34
35 var runtimePath = _getRuntimeDir(options).absolute.path;
36 isRuntimeFile(File file) => file.path.startsWith(runtimePath);
37
38 final maxIndex = defaultRuntimeFiles.length;
39 getPriorityIndex(File file) {
40 if (!isRuntimeFile(file)) return maxIndex;
41 int i = defaultRuntimeFiles.indexOf(basename(file.path));
42 return i < 0 ? maxIndex : i;
43 }
44 return files
45 ..sort((File a, File b) {
46 int pa = getPriorityIndex(a), pb = getPriorityIndex(b);
47 return pa != pb ? (pa - pb) : a.path.compareTo(b.path);
48 });
49 }
50
51 /// TODO(ochafik): Split / reuse [AbstractCompiler.getModuleName].
52 String getMainModuleName(CompilerOptions options) =>
53 basename(withoutExtension(options.inputs.single));
OLDNEW
« no previous file with comments | « lib/src/runner/file_utils.dart ('k') | lib/src/runner/v8_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698