Skip to content

Commit 3f0f66c

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[DDC,bazel] Allow no digest when not in worker mode
Change-Id: Id4d2b385bc00e7dc4e20aefea9ba38e4839bbaca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114065 Reviewed-by: David Morgan <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 88c0c11 commit 3f0f66c

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

pkg/dev_compiler/lib/src/compiler/shared_command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ Future<CompilerResult> compile(ParsedArguments args,
393393
if (args.isKernel) {
394394
return kernel_compiler.compile(args.rest,
395395
compilerState: previousResult?.kernelState,
396+
isWorker: args.isWorker,
396397
useIncrementalCompiler: args.useIncrementalCompiler,
397398
inputDigests: inputDigests);
398399
} else {

pkg/dev_compiler/lib/src/kernel/command.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ const _binaryName = 'dartdevc -k';
3636
/// Returns `true` if the program compiled without any fatal errors.
3737
Future<CompilerResult> compile(List<String> args,
3838
{fe.InitializedCompilerState compilerState,
39+
bool isWorker = false,
3940
bool useIncrementalCompiler = false,
4041
Map<Uri, List<int>> inputDigests}) async {
4142
try {
4243
return await _compile(args,
4344
compilerState: compilerState,
45+
isWorker: isWorker,
4446
useIncrementalCompiler: useIncrementalCompiler,
4547
inputDigests: inputDigests);
4648
} catch (error, stackTrace) {
@@ -69,6 +71,7 @@ String _usageMessage(ArgParser ddcArgParser) =>
6971

7072
Future<CompilerResult> _compile(List<String> args,
7173
{fe.InitializedCompilerState compilerState,
74+
bool isWorker = false,
7275
bool useIncrementalCompiler = false,
7376
Map<Uri, List<int>> inputDigests}) async {
7477
// TODO(jmesserly): refactor options to share code with dartdevc CLI.
@@ -255,6 +258,20 @@ Future<CompilerResult> _compile(List<String> args,
255258
experiments: experiments,
256259
environmentDefines: declaredVariables);
257260
} else {
261+
// If digests weren't given and if not in worker mode, create fake data and
262+
// ensure we don't have a previous state (as that wouldn't be safe with
263+
// fake input digests).
264+
if (!isWorker && (inputDigests == null || inputDigests.isEmpty)) {
265+
oldCompilerState = null;
266+
inputDigests ??= {};
267+
if (!compileSdk) {
268+
inputDigests[sourcePathToUri(sdkSummaryPath)] = const [0];
269+
}
270+
for (Uri uri in summaryModules.keys) {
271+
inputDigests[uri] = const [0];
272+
}
273+
}
274+
258275
doneInputSummaries = List<Component>(summaryModules.length);
259276
compilerState = await fe.initializeIncrementalCompiler(
260277
oldCompilerState,

utils/bazel/kernel_worker.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,29 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
244244
fe.InitializedCompilerState state;
245245
bool usingIncrementalCompiler = false;
246246
bool recordUsedInputs = parsedArgs["used-inputs"] != null;
247-
if (parsedArgs['use-incremental-compiler'] && isWorker) {
247+
if (parsedArgs['use-incremental-compiler']) {
248248
usingIncrementalCompiler = true;
249249

250250
/// Build a map of uris to digests.
251251
final inputDigests = <Uri, List<int>>{};
252-
for (var input in inputs) {
253-
inputDigests[_toUri(input.path)] = input.digest;
252+
if (inputs != null) {
253+
for (var input in inputs) {
254+
inputDigests[_toUri(input.path)] = input.digest;
255+
}
256+
}
257+
258+
// If digests weren't given and if not in worker mode, create fake data and
259+
// ensure we don't have a previous state (as that wouldn't be safe with
260+
// fake input digests).
261+
if (!isWorker && inputDigests.isEmpty) {
262+
previousState = null;
263+
inputDigests[_toUri(parsedArgs['dart-sdk-summary'])] = const [0];
264+
for (Uri uri in summaryInputs) {
265+
inputDigests[uri] = const [0];
266+
}
267+
for (Uri uri in linkedInputs) {
268+
inputDigests[uri] = const [0];
269+
}
254270
}
255271

256272
// TODO(sigmund): add support for experiments with the incremental compiler.

0 commit comments

Comments
 (0)