[bazel] Sort certain things when compiling in incremental mode (take 2)
Not doing it can lead to the same input producing "different" outputs.
Note that this is a follow-up to cdcec63569
where I forgot about the incremental summary-only case.
Change-Id: Idf76c3839f46c468a62350968b353be7235d91b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118287
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
96b8401cfc
commit
ff778d1cb4
@@ -337,22 +337,12 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
||||
incrementalComponent.problemsAsJson = null;
|
||||
incrementalComponent.mainMethod = null;
|
||||
target.performOutlineTransformations(incrementalComponent);
|
||||
makeStable(incrementalComponent);
|
||||
return Future.value(fe.serializeComponent(incrementalComponent,
|
||||
includeSources: false, includeOffsets: false));
|
||||
}
|
||||
|
||||
// Make sure the output is stable.
|
||||
incrementalComponent.libraries.sort((l1, l2) {
|
||||
return "${l1.fileUri}".compareTo("${l2.fileUri}");
|
||||
});
|
||||
incrementalComponent.problemsAsJson?.sort();
|
||||
incrementalComponent.computeCanonicalNames();
|
||||
for (Library library in incrementalComponent.libraries) {
|
||||
library.additionalExports.sort((Reference r1, Reference r2) {
|
||||
return "${r1.canonicalName}".compareTo("${r2.canonicalName}");
|
||||
});
|
||||
library.problemsAsJson?.sort();
|
||||
}
|
||||
makeStable(incrementalComponent);
|
||||
|
||||
return Future.value(fe.serializeComponent(incrementalComponent,
|
||||
filter: excludeNonSources
|
||||
@@ -394,6 +384,22 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
||||
return new ComputeKernelResult(succeeded, state);
|
||||
}
|
||||
|
||||
/// Make sure the output is stable by sorting libraries and additional exports.
|
||||
void makeStable(Component c) {
|
||||
// Make sure the output is stable.
|
||||
c.libraries.sort((l1, l2) {
|
||||
return "${l1.fileUri}".compareTo("${l2.fileUri}");
|
||||
});
|
||||
c.problemsAsJson?.sort();
|
||||
c.computeCanonicalNames();
|
||||
for (Library library in c.libraries) {
|
||||
library.additionalExports.sort((Reference r1, Reference r2) {
|
||||
return "${r1.canonicalName}".compareTo("${r2.canonicalName}");
|
||||
});
|
||||
library.problemsAsJson?.sort();
|
||||
}
|
||||
}
|
||||
|
||||
/// Extends the DevCompilerTarget to transform outlines to meet the requirements
|
||||
/// of summaries in bazel and package-build.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user