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