Skip to content

Commit

Permalink
add --strong-null-safety flag to the kernel worker
Browse files Browse the repository at this point in the history
Bug:#43091
Change-Id: I716d2ea6cf1c95be3911c32b1b2958788fe917ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159183
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
  • Loading branch information
jakemac53 authored and commit-bot@chromium.org committed Aug 19, 2020
1 parent 5e551dd commit 1522a86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 11 additions & 3 deletions pkg/front_end/lib/src/api_unstable/bazel_worker.dart
Expand Up @@ -25,6 +25,8 @@ import '../api_prototype/file_system.dart' show FileSystem;

import '../api_prototype/front_end.dart' show CompilerResult;

import '../base/nnbd_mode.dart' show NnbdMode;

import '../base/processed_options.dart' show ProcessedOptions;

import '../kernel_generator_impl.dart' show generateKernel;
Expand All @@ -50,6 +52,8 @@ export '../api_prototype/standard_file_system.dart' show StandardFileSystem;
export '../api_prototype/terminal_color_support.dart'
show printDiagnosticMessage;

export '../base/nnbd_mode.dart' show NnbdMode;

export '../fasta/kernel/utils.dart' show serializeComponent;

export 'compiler_state.dart' show InitializedCompilerState;
Expand All @@ -72,7 +76,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
bool outlineOnly,
Map<String, String> environmentDefines,
{bool trackNeededDillLibraries: false,
bool verbose: false}) async {
bool verbose: false,
NnbdMode nnbdMode: NnbdMode.Weak}) async {
List<Component> outputLoadedAdditionalDills =
new List<Component>(additionalDills.length);
Map<ExperimentalFlag, bool> experimentalFlags = parseExperimentalFlags(
Expand All @@ -94,7 +99,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
omitPlatform: true,
trackNeededDillLibraries: trackNeededDillLibraries,
environmentDefines: environmentDefines,
verbose: verbose);
verbose: verbose,
nnbdMode: nnbdMode);
}

Future<InitializedCompilerState> initializeCompiler(
Expand All @@ -108,6 +114,7 @@ Future<InitializedCompilerState> initializeCompiler(
Iterable<String> experiments,
Map<String, String> environmentDefines, {
bool verbose: false,
NnbdMode nnbdMode: NnbdMode.Weak,
}) async {
// TODO(sigmund): use incremental compiler when it supports our use case.
// Note: it is common for the summary worker to invoke the compiler with the
Expand All @@ -125,7 +132,8 @@ Future<InitializedCompilerState> initializeCompiler(
..experimentalFlags = parseExperimentalFlags(
parseExperimentalArguments(experiments),
onError: (e) => throw e)
..verbose = verbose;
..verbose = verbose
..nnbdMode = nnbdMode;

ProcessedOptions processedOpts = new ProcessedOptions(options: options);

Expand Down
12 changes: 9 additions & 3 deletions utils/bazel/kernel_worker.dart
Expand Up @@ -144,7 +144,8 @@ final summaryArgsParser = new ArgParser()
..addMultiOption('enable-experiment',
help: 'Enable a language experiment when invoking the CFE.')
..addMultiOption('define', abbr: 'D')
..addFlag('verbose', defaultsTo: false);
..addFlag('verbose', defaultsTo: false)
..addFlag('sound-null-safety', defaultsTo: false);

class ComputeKernelResult {
final bool succeeded;
Expand Down Expand Up @@ -187,6 +188,9 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
var sources = (parsedArgs['source'] as List<String>).map(_toUri).toList();
var excludeNonSources = parsedArgs['exclude-non-sources'] as bool;

var nnbdMode = parsedArgs['sound-null-safety'] as bool
? fe.NnbdMode.Strong
: fe.NnbdMode.Weak;
var summaryOnly = parsedArgs['summary-only'] as bool;
var trackWidgetCreation = parsedArgs['track-widget-creation'] as bool;

Expand Down Expand Up @@ -294,7 +298,8 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
summaryOnly,
environmentDefines,
trackNeededDillLibraries: recordUsedInputs,
verbose: verbose);
verbose: verbose,
nnbdMode: nnbdMode);
} else {
state = await fe.initializeCompiler(
// TODO(sigmund): pass an old state once we can make use of it.
Expand All @@ -307,7 +312,8 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
fileSystem,
parsedArgs['enable-experiment'] as List<String>,
environmentDefines,
verbose: verbose);
verbose: verbose,
nnbdMode: nnbdMode);
}

void onDiagnostic(fe.DiagnosticMessage message) {
Expand Down

0 comments on commit 1522a86

Please sign in to comment.