Skip to content

Commit a6b28df

Browse files
sigmundchcommit-bot@chromium.org
authored andcommitted
Move the use of 'multi-root' out of the FE
Change-Id: If26e4da18d4379041927e100e471a381f5979126 Reviewed-on: https://dart-review.googlesource.com/30600 Commit-Queue: Sigmund Cherem <[email protected]> Reviewed-by: Jake Macdonald <[email protected]>
1 parent a144e26 commit a6b28df

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

pkg/dev_compiler/lib/src/kernel/command.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import 'dart:io';
88

99
import 'package:args/args.dart';
1010
import 'package:dev_compiler/src/kernel/target.dart';
11+
import 'package:front_end/src/api_prototype/physical_file_system.dart';
1112
import 'package:front_end/src/api_unstable/ddc.dart' as fe;
13+
import 'package:front_end/src/multi_root_file_system.dart';
1214
import 'package:kernel/core_types.dart';
1315
import 'package:kernel/kernel.dart';
1416
import 'package:path/path.dart' as path;
@@ -122,12 +124,24 @@ Future<CompilerResult> _compile(List<String> args,
122124
}
123125
}
124126

127+
// To make the output .dill agnostic of the current working directory,
128+
// we use a custom-uri scheme for all app URIs (these are files outside the
129+
// lib folder). The following [FileSystem] will resolve those references to
130+
// the correct location and keeps the real file location hidden from the
131+
// front end.
132+
// TODO(sigmund): technically we don't need a "multi-root" file system,
133+
// because we are providing a single root, the alternative here is to
134+
// implement a new file system with a single root instead.
135+
var fileSystem = new MultiRootFileSystem(
136+
'org-dartlang-app', [Uri.base], PhysicalFileSystem.instance);
137+
125138
compilerState = await fe.initializeCompiler(
126139
compilerState,
127140
path.toUri(sdkSummaryPath),
128141
path.toUri(packageFile),
129142
summaryUris,
130-
new DevCompilerTarget());
143+
new DevCompilerTarget(),
144+
fileSystem: fileSystem);
131145
fe.DdcResult result = await fe.compile(compilerState, inputs, errorHandler);
132146
if (result == null || !succeeded) {
133147
return new CompilerResult(compilerState, false);

pkg/front_end/lib/src/api_unstable/ddc.dart

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import 'dart:async' show Future;
66

7+
import 'package:front_end/src/api_prototype/file_system.dart';
78
import 'package:front_end/src/api_prototype/physical_file_system.dart';
89
import 'package:front_end/src/base/processed_options.dart';
910
import 'package:front_end/src/kernel_generator_impl.dart';
10-
import 'package:front_end/src/multi_root_file_system.dart';
1111
import 'package:kernel/kernel.dart' show Program;
1212
import 'package:kernel/target/targets.dart' show Target;
1313

@@ -30,7 +30,8 @@ Future<InitializedCompilerState> initializeCompiler(
3030
Uri sdkSummary,
3131
Uri packagesFile,
3232
List<Uri> inputSummaries,
33-
Target target) async {
33+
Target target,
34+
{FileSystem fileSystem}) async {
3435
inputSummaries.sort((a, b) => a.toString().compareTo(b.toString()));
3536
bool listEqual(List<Uri> a, List<Uri> b) {
3637
if (a.length != b.length) return false;
@@ -59,23 +60,12 @@ Future<InitializedCompilerState> initializeCompiler(
5960
return oldState;
6061
}
6162

62-
// To make the output .dill agnostic of the current working directory,
63-
// we use a custom-uri scheme for all app URIs (these are files outside the
64-
// lib folder). The following [FileSystem] will resolve those references to
65-
// the correct location and keeps the real file location hidden from the
66-
// front end.
67-
// TODO(sigmund): technically we don't need a "multi-root" file system,
68-
// because we are providing a single root, the alternative here is to
69-
// implement a new file system with a single root instead.
70-
var fileSystem = new MultiRootFileSystem(
71-
'org-dartlang-app', [Uri.base], PhysicalFileSystem.instance);
72-
7363
CompilerOptions options = new CompilerOptions()
7464
..sdkSummary = sdkSummary
7565
..packagesFileUri = packagesFile
7666
..inputSummaries = inputSummaries
7767
..target = target
78-
..fileSystem = fileSystem
68+
..fileSystem = fileSystem ?? PhysicalFileSystem.instance
7969
..chaseDependencies = true
8070
..reportMessages = true;
8171

0 commit comments

Comments
 (0)