@@ -310,7 +310,6 @@ class NativeAssetsBuildRunner {
310
310
_HookValidator validator,
311
311
Uri ? resources,
312
312
) async {
313
- final packageConfigUri = packageLayout.packageConfigUri;
314
313
final outDir = input.outputDirectory;
315
314
return await runUnderDirectoriesLock (
316
315
_fileSystem,
@@ -325,7 +324,6 @@ class NativeAssetsBuildRunner {
325
324
input.packageName,
326
325
input.outputDirectory,
327
326
input.packageRoot.resolve ('hook/${hook .scriptName }' ),
328
- packageConfigUri,
329
327
);
330
328
if (hookCompileResult == null ) {
331
329
return null ;
@@ -382,7 +380,6 @@ ${e.message}
382
380
hook,
383
381
input,
384
382
validator,
385
- packageConfigUri,
386
383
resources,
387
384
hookKernelFile,
388
385
hookEnvironment,
@@ -432,7 +429,6 @@ ${e.message}
432
429
Hook hook,
433
430
HookInput input,
434
431
_HookValidator validator,
435
- Uri packageConfigUri,
436
432
Uri ? resources,
437
433
File hookKernelFile,
438
434
Map <String , String > environment,
@@ -458,7 +454,7 @@ ${e.message}
458
454
}
459
455
460
456
final arguments = [
461
- '--packages=${packageConfigUri .toFilePath ()}' ,
457
+ '--packages=${packageLayout . packageConfigUri .toFilePath ()}' ,
462
458
hookKernelFile.path,
463
459
'--config=${inputFile .toFilePath ()}' ,
464
460
if (resources != null ) resources.toFilePath (),
@@ -584,10 +580,12 @@ ${e.message}
584
580
String packageName,
585
581
Uri outputDirectory,
586
582
Uri scriptUri,
587
- Uri packageConfigUri,
588
583
) async {
589
584
// Don't invalidate cache with environment changes.
590
585
final environmentForCaching = < String , String > {};
586
+ final packageConfigHashable =
587
+ outputDirectory.resolve ('../package_config_hashable.json' );
588
+ await _makeHashablePackageConfig (packageConfigHashable);
591
589
final kernelFile = _fileSystem.file (
592
590
outputDirectory.resolve ('../hook.dill' ),
593
591
);
@@ -620,7 +618,6 @@ ${e.message}
620
618
final success = await _compileHookForPackage (
621
619
packageName,
622
620
scriptUri,
623
- packageConfigUri,
624
621
kernelFile,
625
622
depFile,
626
623
);
@@ -629,9 +626,11 @@ ${e.message}
629
626
}
630
627
631
628
final dartSources = await _readDepFile (depFile);
629
+
632
630
final modifiedDuringBuild = await dependenciesHashes.hashDependencies (
633
631
[
634
- ...dartSources,
632
+ ...dartSources.where ((e) => e != packageLayout.packageConfigUri),
633
+ packageConfigHashable,
635
634
// If the Dart version changed, recompile.
636
635
dartExecutable.resolve ('../version' ),
637
636
],
@@ -645,22 +644,31 @@ ${e.message}
645
644
return (kernelFile, dependenciesHashes);
646
645
}
647
646
647
+ Future <void > _makeHashablePackageConfig (Uri uri) async {
648
+ final contents =
649
+ await _fileSystem.file (packageLayout.packageConfigUri).readAsString ();
650
+ final jsonData = jsonDecode (contents) as Map <String , Object ?>;
651
+ jsonData.remove ('generated' );
652
+ final contentsSanitized =
653
+ const JsonEncoder .withIndent (' ' ).convert (jsonData);
654
+ await _fileSystem.file (uri).writeAsString (contentsSanitized);
655
+ }
656
+
648
657
Future <bool > _compileHookForPackage (
649
658
String packageName,
650
659
Uri scriptUri,
651
- Uri packageConfigUri,
652
660
File kernelFile,
653
661
File depFile,
654
662
) async {
655
663
final compileArguments = [
656
664
'compile' ,
657
665
'kernel' ,
658
- '--packages=${packageConfigUri .toFilePath ()}' ,
666
+ '--packages=${packageLayout . packageConfigUri .toFilePath ()}' ,
659
667
'--output=${kernelFile .path }' ,
660
668
'--depfile=${depFile .path }' ,
661
669
scriptUri.toFilePath (),
662
670
];
663
- final workingDirectory = packageConfigUri.resolve ('../' );
671
+ final workingDirectory = packageLayout. packageConfigUri.resolve ('../' );
664
672
final compileResult = await runProcess (
665
673
filesystem: _fileSystem,
666
674
workingDirectory: workingDirectory,
0 commit comments