[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 <davidmorgan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2019-08-22 11:15:19 +00:00 committed by commit-bot@chromium.org
parent 88c0c11612
commit 3f0f66cabc
3 changed files with 37 additions and 3 deletions

View file

@ -393,6 +393,7 @@ Future<CompilerResult> compile(ParsedArguments args,
if (args.isKernel) {
return kernel_compiler.compile(args.rest,
compilerState: previousResult?.kernelState,
isWorker: args.isWorker,
useIncrementalCompiler: args.useIncrementalCompiler,
inputDigests: inputDigests);
} else {

View file

@ -36,11 +36,13 @@ const _binaryName = 'dartdevc -k';
/// Returns `true` if the program compiled without any fatal errors.
Future<CompilerResult> compile(List<String> args,
{fe.InitializedCompilerState compilerState,
bool isWorker = false,
bool useIncrementalCompiler = false,
Map<Uri, List<int>> inputDigests}) async {
try {
return await _compile(args,
compilerState: compilerState,
isWorker: isWorker,
useIncrementalCompiler: useIncrementalCompiler,
inputDigests: inputDigests);
} catch (error, stackTrace) {
@ -69,6 +71,7 @@ String _usageMessage(ArgParser ddcArgParser) =>
Future<CompilerResult> _compile(List<String> args,
{fe.InitializedCompilerState compilerState,
bool isWorker = false,
bool useIncrementalCompiler = false,
Map<Uri, List<int>> inputDigests}) async {
// TODO(jmesserly): refactor options to share code with dartdevc CLI.
@ -255,6 +258,20 @@ Future<CompilerResult> _compile(List<String> args,
experiments: experiments,
environmentDefines: declaredVariables);
} else {
// If digests weren't given and if not in worker mode, create fake data and
// ensure we don't have a previous state (as that wouldn't be safe with
// fake input digests).
if (!isWorker && (inputDigests == null || inputDigests.isEmpty)) {
oldCompilerState = null;
inputDigests ??= {};
if (!compileSdk) {
inputDigests[sourcePathToUri(sdkSummaryPath)] = const [0];
}
for (Uri uri in summaryModules.keys) {
inputDigests[uri] = const [0];
}
}
doneInputSummaries = List<Component>(summaryModules.length);
compilerState = await fe.initializeIncrementalCompiler(
oldCompilerState,

View file

@ -244,13 +244,29 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
fe.InitializedCompilerState state;
bool usingIncrementalCompiler = false;
bool recordUsedInputs = parsedArgs["used-inputs"] != null;
if (parsedArgs['use-incremental-compiler'] && isWorker) {
if (parsedArgs['use-incremental-compiler']) {
usingIncrementalCompiler = true;
/// Build a map of uris to digests.
final inputDigests = <Uri, List<int>>{};
for (var input in inputs) {
inputDigests[_toUri(input.path)] = input.digest;
if (inputs != null) {
for (var input in inputs) {
inputDigests[_toUri(input.path)] = input.digest;
}
}
// If digests weren't given and if not in worker mode, create fake data and
// ensure we don't have a previous state (as that wouldn't be safe with
// fake input digests).
if (!isWorker && inputDigests.isEmpty) {
previousState = null;
inputDigests[_toUri(parsedArgs['dart-sdk-summary'])] = const [0];
for (Uri uri in summaryInputs) {
inputDigests[uri] = const [0];
}
for (Uri uri in linkedInputs) {
inputDigests[uri] = const [0];
}
}
// TODO(sigmund): add support for experiments with the incremental compiler.