[dart2js] Add '--no-summary' to compute_kernel.

Change-Id: Ie3493137794c95f5061ed7d2918568127c5e15ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221220
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/compiler/tool/modular_test_suite.dart b/pkg/compiler/tool/modular_test_suite.dart
index fa6b531..9257730 100644
--- a/pkg/compiler/tool/modular_test_suite.dart
+++ b/pkg/compiler/tool/modular_test_suite.dart
@@ -267,10 +267,9 @@
   @override
   List<DataId> get moduleDataNeeded => const [];
 
-  // TODO(joshualitt): we need a --no-summary argument to cfe.
   @override
   List<String> get stepArguments =>
-      ['--target', 'dart2js', '--no-summary-only'];
+      ['--target', 'dart2js', '--no-summary', '--no-summary-only'];
 
   @override
   DataId get inputData => dillSummaryId;
diff --git a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
index 7d167c4..217bb40 100644
--- a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
+++ b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
@@ -137,8 +137,9 @@
 
 Future<CompilerResult> _compile(InitializedCompilerState compilerState,
     List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler,
-    {bool? summaryOnly, bool includeOffsets: true}) {
-  summaryOnly ??= true;
+    {bool? buildSummary, bool? buildComponent, bool includeOffsets: true}) {
+  buildSummary ??= true;
+  buildComponent ??= true;
   CompilerOptions options = compilerState.options;
   options..onDiagnostic = diagnosticMessageHandler;
 
@@ -147,8 +148,8 @@
   processedOpts.inputs.addAll(inputs);
 
   return generateKernel(processedOpts,
-      buildSummary: summaryOnly,
-      buildComponent: !summaryOnly,
+      buildSummary: buildSummary,
+      buildComponent: buildComponent,
       includeOffsets: includeOffsets);
 }
 
@@ -157,15 +158,18 @@
     {bool includeOffsets: false}) async {
   CompilerResult result = await _compile(
       compilerState, inputs, diagnosticMessageHandler,
-      summaryOnly: true, includeOffsets: includeOffsets);
+      buildSummary: true,
+      buildComponent: false,
+      includeOffsets: includeOffsets);
   return result.summary;
 }
 
 Future<Component?> compileComponent(InitializedCompilerState compilerState,
-    List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler) async {
+    List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler,
+    {bool buildSummary: true}) async {
   CompilerResult result = await _compile(
       compilerState, inputs, diagnosticMessageHandler,
-      summaryOnly: false);
+      buildSummary: buildSummary, buildComponent: true);
 
   Component? component = result.component;
   if (component != null) {
diff --git a/pkg/frontend_server/lib/compute_kernel.dart b/pkg/frontend_server/lib/compute_kernel.dart
index 9c08de2..ed3ba71 100644
--- a/pkg/frontend_server/lib/compute_kernel.dart
+++ b/pkg/frontend_server/lib/compute_kernel.dart
@@ -57,6 +57,10 @@
       defaultsTo: true,
       negatable: true,
       help: 'Whether to only build summary files.')
+  ..addFlag('summary',
+      defaultsTo: true,
+      negatable: true,
+      help: 'Whether or not to build summary files.')
   ..addOption('target',
       allowed: const [
         'vm',
@@ -138,6 +142,10 @@
       ? fe.NnbdMode.Strong
       : fe.NnbdMode.Weak;
   var summaryOnly = parsedArgs['summary-only'] as bool;
+  var summary = parsedArgs['summary'] as bool;
+  if (summaryOnly && !summary) {
+    throw new ArgumentError('--summary-only conflicts with --no-summary');
+  }
   var trackWidgetCreation = parsedArgs['track-widget-creation'] as bool;
 
   // TODO(sigmund,jakemac): make target mandatory. We allow null to be backwards
@@ -324,8 +332,8 @@
     kernel = await fe.compileSummary(state, sources, onDiagnostic,
         includeOffsets: false);
   } else {
-    Component component =
-        await fe.compileComponent(state, sources, onDiagnostic);
+    Component component = await fe
+        .compileComponent(state, sources, onDiagnostic, buildSummary: summary);
     kernel = fe.serializeComponent(component,
         filter: excludeNonSources
             ? (library) => sources.contains(library.importUri)