@@ -100,26 +100,15 @@ CompilerOptions setupCompilerOptions(
100
100
int nullSafety,
101
101
List <String > experimentalFlags,
102
102
bool bytecode,
103
- String packageConfig,
104
- String workingDirectory,
103
+ Uri packagesUri,
105
104
List <String > errors) {
106
105
final expFlags = < String > [];
107
106
if (experimentalFlags != null ) {
108
107
for (String flag in experimentalFlags) {
109
108
expFlags.addAll (flag.split ("," ));
110
109
}
111
110
}
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
+
123
112
return new CompilerOptions ()
124
113
..fileSystem = fileSystem
125
114
..target = new VmTarget (new TargetFlags (
@@ -169,7 +158,7 @@ abstract class Compiler {
169
158
final List <String > experimentalFlags;
170
159
final bool bytecode;
171
160
final String packageConfig;
172
- final String workingDirectory;
161
+
173
162
// Code coverage and hot reload are only supported by incremental compiler,
174
163
// which is used if vm-service is enabled.
175
164
final bool supportCodeCoverage;
@@ -187,8 +176,21 @@ abstract class Compiler {
187
176
this .bytecode: false ,
188
177
this .supportCodeCoverage: false ,
189
178
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
+
192
194
options = setupCompilerOptions (
193
195
fileSystem,
194
196
platformKernelPath,
@@ -197,16 +199,8 @@ abstract class Compiler {
197
199
nullSafety,
198
200
experimentalFlags,
199
201
bytecode,
200
- packageConfig,
201
- workingDirectory,
202
+ packagesUri,
202
203
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
- }
210
204
}
211
205
212
206
Future <CompilerResult > compile (Uri script) {
@@ -343,8 +337,7 @@ class IncrementalCompilerWrapper extends Compiler {
343
337
int nullSafety: kNullSafetyOptionUnspecified,
344
338
List <String > experimentalFlags: null ,
345
339
bool bytecode: false ,
346
- String packageConfig: null ,
347
- String workingDirectory: null })
340
+ String packageConfig: null })
348
341
: super (isolateId, fileSystem, platformKernelPath,
349
342
suppressWarnings: suppressWarnings,
350
343
enableAsserts: enableAsserts,
@@ -353,8 +346,7 @@ class IncrementalCompilerWrapper extends Compiler {
353
346
bytecode: bytecode,
354
347
supportHotReload: true ,
355
348
supportCodeCoverage: true ,
356
- packageConfig: packageConfig,
357
- workingDirectory: workingDirectory);
349
+ packageConfig: packageConfig);
358
350
359
351
factory IncrementalCompilerWrapper .forExpressionCompilationOnly (
360
352
Component component,
@@ -365,8 +357,7 @@ class IncrementalCompilerWrapper extends Compiler {
365
357
bool enableAsserts: false ,
366
358
List <String > experimentalFlags: null ,
367
359
bool bytecode: false ,
368
- String packageConfig: null ,
369
- String workingDirectory: null }) {
360
+ String packageConfig: null }) {
370
361
IncrementalCompilerWrapper result = IncrementalCompilerWrapper (
371
362
isolateId, fileSystem, platformKernelPath,
372
363
suppressWarnings: suppressWarnings,
@@ -402,8 +393,7 @@ class IncrementalCompilerWrapper extends Compiler {
402
393
nullSafety: nullSafety,
403
394
experimentalFlags: experimentalFlags,
404
395
bytecode: bytecode,
405
- packageConfig: packageConfig,
406
- workingDirectory: workingDirectory);
396
+ packageConfig: packageConfig);
407
397
408
398
generator.resetDeltaState ();
409
399
Component fullComponent = await generator.compile ();
@@ -434,16 +424,14 @@ class SingleShotCompilerWrapper extends Compiler {
434
424
int nullSafety: kNullSafetyOptionUnspecified,
435
425
List <String > experimentalFlags: null ,
436
426
bool bytecode: false ,
437
- String packageConfig: null ,
438
- String workingDirectory: null })
427
+ String packageConfig: null })
439
428
: super (isolateId, fileSystem, platformKernelPath,
440
429
suppressWarnings: suppressWarnings,
441
430
enableAsserts: enableAsserts,
442
431
nullSafety: nullSafety,
443
432
experimentalFlags: experimentalFlags,
444
433
bytecode: bytecode,
445
- packageConfig: packageConfig,
446
- workingDirectory: workingDirectory);
434
+ packageConfig: packageConfig);
447
435
448
436
@override
449
437
Future <CompilerResult > compileInternal (Uri script) async {
@@ -479,7 +467,6 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
479
467
List <String > experimentalFlags: null ,
480
468
bool bytecode: false ,
481
469
String packageConfig: null ,
482
- String workingDirectory: null ,
483
470
String multirootFilepaths,
484
471
String multirootScheme}) async {
485
472
IncrementalCompilerWrapper compiler = lookupIncrementalCompiler (isolateId);
@@ -493,8 +480,7 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
493
480
if (sourceFiles != null &&
494
481
sourceFiles.length > 0 &&
495
482
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.
498
484
var source = isolateCompilers.entries.first;
499
485
compiler = await source.value.clone (isolateId);
500
486
} else {
@@ -512,8 +498,7 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
512
498
nullSafety: nullSafety,
513
499
experimentalFlags: experimentalFlags,
514
500
bytecode: bytecode,
515
- packageConfig: packageConfig,
516
- workingDirectory: workingDirectory);
501
+ packageConfig: packageConfig);
517
502
}
518
503
isolateCompilers[isolateId] = compiler;
519
504
}
@@ -837,18 +822,20 @@ Future _processLoadRequest(request) async {
837
822
} else if (tag == kDetectNullabilityTag) {
838
823
FileSystem fileSystem = _buildFileSystem (
839
824
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
+ }
840
836
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);
852
839
853
840
// script should only be null for kUpdateSourcesTag.
854
841
assert (script != null );
@@ -874,7 +861,6 @@ Future _processLoadRequest(request) async {
874
861
experimentalFlags: experimentalFlags,
875
862
bytecode: bytecode,
876
863
packageConfig: packageConfig,
877
- workingDirectory: workingDirectory,
878
864
multirootFilepaths: multirootFilepaths,
879
865
multirootScheme: multirootScheme);
880
866
} else {
@@ -888,8 +874,7 @@ Future _processLoadRequest(request) async {
888
874
nullSafety: nullSafety,
889
875
experimentalFlags: experimentalFlags,
890
876
bytecode: bytecode,
891
- packageConfig: packageConfig,
892
- workingDirectory: workingDirectory);
877
+ packageConfig: packageConfig);
893
878
}
894
879
895
880
CompilationResult result;
0 commit comments