@@ -100,26 +100,15 @@ CompilerOptions setupCompilerOptions(
100100 int nullSafety,
101101 List <String > experimentalFlags,
102102 bool bytecode,
103- String packageConfig,
104- String workingDirectory,
103+ Uri packagesUri,
105104 List <String > errors) {
106105 final expFlags = < String > [];
107106 if (experimentalFlags != null ) {
108107 for (String flag in experimentalFlags) {
109108 expFlags.addAll (flag.split ("," ));
110109 }
111110 }
112- Uri packagesUri = null ;
113- if (packageConfig != null ) {
114- packagesUri = Uri .parse (packageConfig);
115- if (packagesUri.scheme == '' ) {
116- // Script does not have a scheme, assume that it is a path,
117- // resolve it against the working directory.
118- packagesUri = Uri .directory (workingDirectory).resolveUri (packagesUri);
119- }
120- } else if (Platform .packageConfig != null ) {
121- packagesUri = Uri .parse (Platform .packageConfig);
122- }
111+
123112 return new CompilerOptions ()
124113 ..fileSystem = fileSystem
125114 ..target = new VmTarget (new TargetFlags (
@@ -169,7 +158,7 @@ abstract class Compiler {
169158 final List <String > experimentalFlags;
170159 final bool bytecode;
171160 final String packageConfig;
172- final String workingDirectory;
161+
173162 // Code coverage and hot reload are only supported by incremental compiler,
174163 // which is used if vm-service is enabled.
175164 final bool supportCodeCoverage;
@@ -187,8 +176,21 @@ abstract class Compiler {
187176 this .bytecode: false ,
188177 this .supportCodeCoverage: false ,
189178 this .supportHotReload: false ,
190- this .packageConfig: null ,
191- this .workingDirectory: null }) {
179+ this .packageConfig: null }) {
180+ Uri packagesUri = null ;
181+ if (packageConfig != null ) {
182+ packagesUri = Uri .parse (packageConfig);
183+ } else if (Platform .packageConfig != null ) {
184+ packagesUri = Uri .parse (Platform .packageConfig);
185+ }
186+
187+ if (verbose) {
188+ print ("DFE: Platform.packageConfig: ${Platform .packageConfig }" );
189+ print ("DFE: packagesUri: ${packagesUri }" );
190+ print ("DFE: Platform.resolvedExecutable: ${Platform .resolvedExecutable }" );
191+ print ("DFE: platformKernelPath: ${platformKernelPath }" );
192+ }
193+
192194 options = setupCompilerOptions (
193195 fileSystem,
194196 platformKernelPath,
@@ -197,16 +199,8 @@ abstract class Compiler {
197199 nullSafety,
198200 experimentalFlags,
199201 bytecode,
200- packageConfig,
201- workingDirectory,
202+ packagesUri,
202203 errors);
203-
204- if (verbose) {
205- print ("DFE: Platform.packageConfig: ${Platform .packageConfig }" );
206- print ("DFE: packagesUri: ${options .packagesFileUri }" );
207- print ("DFE: Platform.resolvedExecutable: ${Platform .resolvedExecutable }" );
208- print ("DFE: platformKernelPath: ${platformKernelPath }" );
209- }
210204 }
211205
212206 Future <CompilerResult > compile (Uri script) {
@@ -343,8 +337,7 @@ class IncrementalCompilerWrapper extends Compiler {
343337 int nullSafety: kNullSafetyOptionUnspecified,
344338 List <String > experimentalFlags: null ,
345339 bool bytecode: false ,
346- String packageConfig: null ,
347- String workingDirectory: null })
340+ String packageConfig: null })
348341 : super (isolateId, fileSystem, platformKernelPath,
349342 suppressWarnings: suppressWarnings,
350343 enableAsserts: enableAsserts,
@@ -353,8 +346,7 @@ class IncrementalCompilerWrapper extends Compiler {
353346 bytecode: bytecode,
354347 supportHotReload: true ,
355348 supportCodeCoverage: true ,
356- packageConfig: packageConfig,
357- workingDirectory: workingDirectory);
349+ packageConfig: packageConfig);
358350
359351 factory IncrementalCompilerWrapper .forExpressionCompilationOnly (
360352 Component component,
@@ -365,8 +357,7 @@ class IncrementalCompilerWrapper extends Compiler {
365357 bool enableAsserts: false ,
366358 List <String > experimentalFlags: null ,
367359 bool bytecode: false ,
368- String packageConfig: null ,
369- String workingDirectory: null }) {
360+ String packageConfig: null }) {
370361 IncrementalCompilerWrapper result = IncrementalCompilerWrapper (
371362 isolateId, fileSystem, platformKernelPath,
372363 suppressWarnings: suppressWarnings,
@@ -402,8 +393,7 @@ class IncrementalCompilerWrapper extends Compiler {
402393 nullSafety: nullSafety,
403394 experimentalFlags: experimentalFlags,
404395 bytecode: bytecode,
405- packageConfig: packageConfig,
406- workingDirectory: workingDirectory);
396+ packageConfig: packageConfig);
407397
408398 generator.resetDeltaState ();
409399 Component fullComponent = await generator.compile ();
@@ -434,16 +424,14 @@ class SingleShotCompilerWrapper extends Compiler {
434424 int nullSafety: kNullSafetyOptionUnspecified,
435425 List <String > experimentalFlags: null ,
436426 bool bytecode: false ,
437- String packageConfig: null ,
438- String workingDirectory: null })
427+ String packageConfig: null })
439428 : super (isolateId, fileSystem, platformKernelPath,
440429 suppressWarnings: suppressWarnings,
441430 enableAsserts: enableAsserts,
442431 nullSafety: nullSafety,
443432 experimentalFlags: experimentalFlags,
444433 bytecode: bytecode,
445- packageConfig: packageConfig,
446- workingDirectory: workingDirectory);
434+ packageConfig: packageConfig);
447435
448436 @override
449437 Future <CompilerResult > compileInternal (Uri script) async {
@@ -479,7 +467,6 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
479467 List <String > experimentalFlags: null ,
480468 bool bytecode: false ,
481469 String packageConfig: null ,
482- String workingDirectory: null ,
483470 String multirootFilepaths,
484471 String multirootScheme}) async {
485472 IncrementalCompilerWrapper compiler = lookupIncrementalCompiler (isolateId);
@@ -493,8 +480,7 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
493480 if (sourceFiles != null &&
494481 sourceFiles.length > 0 &&
495482 sourceFiles[1 ] == null ) {
496- // Just use first compiler that should represent main isolate as a source
497- // for cloning.
483+ // Just use first compiler that should represent main isolate as a source for cloning.
498484 var source = isolateCompilers.entries.first;
499485 compiler = await source.value.clone (isolateId);
500486 } else {
@@ -512,8 +498,7 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
512498 nullSafety: nullSafety,
513499 experimentalFlags: experimentalFlags,
514500 bytecode: bytecode,
515- packageConfig: packageConfig,
516- workingDirectory: workingDirectory);
501+ packageConfig: packageConfig);
517502 }
518503 isolateCompilers[isolateId] = compiler;
519504 }
@@ -837,18 +822,20 @@ Future _processLoadRequest(request) async {
837822 } else if (tag == kDetectNullabilityTag) {
838823 FileSystem fileSystem = _buildFileSystem (
839824 sourceFiles, platformKernel, multirootFilepaths, multirootScheme);
825+ Uri packagesUri = null ;
826+ if (packageConfig != null ) {
827+ packagesUri = Uri .parse (packageConfig);
828+ } else if (Platform .packageConfig != null ) {
829+ packagesUri = Uri .parse (Platform .packageConfig);
830+ }
831+ if (packagesUri != null && packagesUri.scheme == '' ) {
832+ // Script does not have a scheme, assume that it is a path,
833+ // resolve it against the working directory.
834+ packagesUri = Uri .directory (workingDirectory).resolveUri (packagesUri);
835+ }
840836 final List <String > errors = < String > [];
841- var options = setupCompilerOptions (
842- fileSystem,
843- platformKernelPath,
844- false ,
845- false ,
846- nullSafety,
847- experimentalFlags,
848- false ,
849- packageConfig,
850- workingDirectory,
851- errors);
837+ var options = setupCompilerOptions (fileSystem, platformKernelPath, false ,
838+ false , nullSafety, experimentalFlags, false , packagesUri, errors);
852839
853840 // script should only be null for kUpdateSourcesTag.
854841 assert (script != null );
@@ -874,7 +861,6 @@ Future _processLoadRequest(request) async {
874861 experimentalFlags: experimentalFlags,
875862 bytecode: bytecode,
876863 packageConfig: packageConfig,
877- workingDirectory: workingDirectory,
878864 multirootFilepaths: multirootFilepaths,
879865 multirootScheme: multirootScheme);
880866 } else {
@@ -888,8 +874,7 @@ Future _processLoadRequest(request) async {
888874 nullSafety: nullSafety,
889875 experimentalFlags: experimentalFlags,
890876 bytecode: bytecode,
891- packageConfig: packageConfig,
892- workingDirectory: workingDirectory);
877+ packageConfig: packageConfig);
893878 }
894879
895880 CompilationResult result;
0 commit comments