[ddc] Cleanup old "dartdevc" build targets

Use the new "ddc" targets everywhere and delete
the old targets.

Change-Id: I89d3351006a2c3eb0d1b9d526b868cbb676dce6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315561
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index d3de3f4..1349b4e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -27,7 +27,7 @@
     ":create_sdk",
     ":dart2js",
     ":dartanalyzer",
-    ":dartdevc",
+    ":ddc",
     ":runtime",
   ]
 }
@@ -135,13 +135,13 @@
   deps = [ "utils/dartanalyzer" ]
 }
 
+# TODO(nshahan): Delete after updating the Flutter engine build.
 group("dartdevc") {
-  deps = [ "utils/dartdevc" ]
+  deps = [ "utils/dartdevc:dartdevc_files_stamp" ]
 }
 
 group("ddc") {
-  # TODO(nshahan): Update to the dartdevc snapshot target when it gets moved.
-  deps = [ "utils/ddc:ddc_stable_test" ]
+  deps = [ "utils/ddc:dartdevc" ]
 }
 
 group("analysis_server") {
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
index 8fc1c93..d1af5c7 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
@@ -89,7 +89,7 @@
   /// Must be called when testing a new Dart program.
   ///
   /// Depends on SDK artifacts (such as the sound and unsound dart_sdk.js
-  /// files) generated from the 'dartdevc_test' target.
+  /// files) generated from the 'ddc_stable_test' and 'ddc_canary_test' targets.
   Future<void> initSource(SetupCompilerOptions setup, String source,
       {Map<String, bool> experiments = const {}}) async {
     // Perform setup sanity checks.
diff --git a/pkg/dev_compiler/tool/ddb b/pkg/dev_compiler/tool/ddb
index 8e9ab36..7eb8007 100755
--- a/pkg/dev_compiler/tool/ddb
+++ b/pkg/dev_compiler/tool/ddb
@@ -240,14 +240,6 @@
   var sdkJsPath =
       p.join(buildDir, 'gen', 'utils', 'ddc', compileModeDir, 'sdk', mod);
 
-  if (!canaryFeatures && !Directory(sdkJsPath).existsSync()) {
-    // Fall back on the old location of the build outputs.
-    // TODO(nshahan): Removed after golem has been updated for the new build
-    // targets b/242034355.
-    var suffix = soundNullSafety ? p.join('sound', mod) : p.join('kernel', mod);
-    sdkJsPath = p.join(buildDir, 'gen', 'utils', 'dartdevc', suffix);
-  }
-
   // Print an initial empty line to separate the invocation from the output.
   if (verbose) {
     print('');
diff --git a/pkg/test_runner/lib/src/build_configurations.dart b/pkg/test_runner/lib/src/build_configurations.dart
index 20492c0..63bc644 100644
--- a/pkg/test_runner/lib/src/build_configurations.dart
+++ b/pkg/test_runner/lib/src/build_configurations.dart
@@ -82,8 +82,8 @@
     Compiler.dartk: ['runtime'],
     Compiler.dartkp: ['runtime', 'dart_precompiled_runtime'],
     Compiler.appJitk: ['runtime'],
-    Compiler.fasta: ['create_sdk', 'dartdevc_test', 'kernel_platform_files'],
-    Compiler.ddc: ['dartdevc_test'],
+    Compiler.fasta: ['create_sdk', 'ddc_stable_test', 'kernel_platform_files'],
+    Compiler.ddc: ['ddc_stable_test'],
     Compiler.dart2js: ['create_sdk'],
     Compiler.dart2analyzer: ['create_sdk', 'utils/dartanalyzer'],
     Compiler.specParser: <String>[],
@@ -112,12 +112,12 @@
   if (compiler == Compiler.ddc) {
     if (inner.ddcOptions.contains('--canary')) {
       result
-        ..remove('dartdevc_test')
+        ..remove('ddc_stable_test')
         ..add(inner.useSdk ? 'ddc_canary_test' : 'ddc_canary_test_local');
     } else if (!inner.useSdk) {
       result
-        ..remove('dartdevc_test')
-        ..add('dartdevc_test_local');
+        ..remove('ddc_stable_test')
+        ..add('ddc_stable_test_local');
     }
   }
 
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 653cc6a..f0a6586 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -139,7 +139,7 @@
                         ],
                         [
                           "dartdevc",
-                          "../utils/dartdevc",
+                          "../utils/ddc:dartdevc",
                         ],
                         [
                           "kernel_worker",
@@ -537,7 +537,7 @@
   visibility = [ ":copy_dev_compiler_sdk" ]
   deps = [
     ":copy_libraries",
-    "../utils/dartdevc:dartdevc_platform_sound",
+    "../utils/ddc:ddc_platform",
   ]
   sources = [
     "$root_out_dir/ddc_outline.dill",
@@ -561,9 +561,8 @@
 # Used when running DDC compiled applications.
 copy("copy_dev_compiler_stack_trace_mapper") {
   visibility = [ ":copy_dev_compiler_sdk" ]
-  deps = [ "../utils/dartdevc:stack_trace_mapper" ]
-  dart_out =
-      get_label_info("../utils/dartdevc:stack_trace_mapper", "root_out_dir")
+  deps = [ "../utils/ddc:stack_trace_mapper" ]
+  dart_out = get_label_info("../utils/ddc:stack_trace_mapper", "root_out_dir")
   sources = [ "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js" ]
   outputs = [
     "$root_out_dir/$dart_sdk_output/lib/dev_compiler/web/{{source_file_part}}",
diff --git a/utils/dartdevc/BUILD.gn b/utils/dartdevc/BUILD.gn
index ff1eada..6b065b9 100644
--- a/utils/dartdevc/BUILD.gn
+++ b/utils/dartdevc/BUILD.gn
@@ -1,374 +1,9 @@
-# Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-import("../../build/dart/dart_action.gni")
-import("../../sdk_args.gni")
-import("../../utils/compile_platform.gni")
-import("../application_snapshot.gni")
-import("../create_timestamp.gni")
-
-patched_sdk_dir = "$target_gen_dir/patched_sdk"
-sdk_summary = "$target_gen_dir/ddc_sdk.sum"
-
-sdk_outline_sound_dill = "$root_out_dir/ddc_outline.dill"
-sdk_full_sound_dill = "$root_out_dir/ddc_platform.dill"
-sdk_outline_unsound_dill = "$root_out_dir/ddc_outline_unsound.dill"
-sdk_full_unsound_dill = "$root_out_dir/ddc_platform_unsound.dill"
-
-application_snapshot("dartdevc") {
-  main_dart = "../../pkg/dev_compiler/bin/dartdevc.dart"
-
-  training_args = [
-    "--dart-sdk-summary",
-    rebase_path(sdk_outline_sound_dill),
-    "-o",
-    "dartdevc.js",
-    rebase_path("../../pkg/dev_compiler/bin/dartdevc.dart"),
-  ]
-
-  deps = [ ":dartdevc_platform_sound" ]
-  inputs = [ sdk_outline_sound_dill ]
+# TODO(nshahan): Delete after updating the Flutter engine build.
+group("dartdevc_files_stamp") {
+  deps = [ "../ddc:ddc_files_stamp" ]
 }
 
-sdk_root = "../../sdk"
-
-template("dart2js_compile") {
-  assert(defined(invoker.main), "Must specify the main file")
-  main = invoker.main
-  assert(defined(invoker.out), "Must specify the out file")
-  out = invoker.out
-  abs_main = rebase_path(main)
-  abs_output = rebase_path(out)
-
-  prebuilt_dart_action(target_name) {
-    deps = invoker.deps + [
-             "../compiler:compile_dart2js_platform",
-             "../compiler:compile_dart2js_platform_unsound",
-           ]
-
-    inputs = [
-      "$root_out_dir/dart2js_platform.dill",
-      "$root_out_dir/dart2js_platform_unsound.dill",
-      "$root_out_dir/dart2js_outline.dill",
-      "$root_out_dir/dart2js_outline_unsound.dill",
-    ]
-    outputs = [ out ]
-
-    script = "../../pkg/compiler/lib/src/dart2js.dart"
-
-    packages = "../../.dart_tool/package_config.json"
-
-    vm_args = [ "-Dsdk_hash=$sdk_hash" ]
-
-    args = [
-      "$abs_main",
-      "-m",
-      "--invoker=gn_build",
-      "-o$abs_output",
-      "--no-source-maps",
-      "--platform-binaries=" + rebase_path("$root_out_dir"),
-    ]
-  }
-}
-
-dart2js_compile("stack_trace_mapper") {
-  main = rebase_path("../../pkg/dev_compiler/web/stack_trace_mapper.dart")
-  out = "$root_out_dir/dev_compiler/build/web/dart_stack_trace_mapper.js"
-  deps = [ ":dartdevc_files_stamp" ]
-}
-
-# Builds everything needed to run dartdevc tests using test.dart.
-group("dartdevc_test") {
-  deps = [
-    ":dartdevc",
-    ":dartdevc_kernel_sdk",
-    ":dartdevc_sound_sdk",
-    ":dartdevc_test_kernel_pkg",
-    "../..:create_sdk",
-  ]
-}
-
-# Builds everything needed to run dartdevc tests locally using test.dart without
-# --use-sdk. This is the same as dartdevc_test, but skips things rely on
-# building the Dart VM and create_sdk.
-group("dartdevc_test_local") {
-  deps = [
-    ":dartdevc_kernel_sdk",
-    ":dartdevc_test_kernel_pkg",
-  ]
-}
-
-create_timestamp_file("dartdevc_files_stamp") {
-  path = rebase_path("../../pkg/dev_compiler/lib")
-  output = "$target_gen_dir/dartdevc_files.stamp"
-}
-
-create_timestamp_file("dartdevc_sdk_patch_stamp") {
-  path = rebase_path("$sdk_root/lib/_internal/js_dev_runtime")
-  output = "$target_gen_dir/dartdevc_sdk_patch_stamp.stamp"
-}
-
-# Compiles to JavaScript any package used from tests.
-# TODO(sigmund): generate a js bundle or a module that load these indirectly so
-# we can stop referring to this list of packages explicitly in the test_runner.
-group("dartdevc_test_kernel_pkg") {
-  deps = [
-    ":async_helper_js",
-    ":async_helper_sound_js",
-    ":expect_js",
-    ":expect_sound_js",
-    ":js_js",
-    ":js_sound_js",
-    ":meta_js",
-    ":meta_sound_js",
-  ]
-}
-
-template("dartdevc_kernel_compile") {
-  assert(defined(invoker.package),
-         "Need 'package' in $target_name (the name of the package)")
-  assert(defined(invoker.sound_null_safety),
-         "Need 'sound_null_safety' in $target_name.")
-
-  if (invoker.sound_null_safety) {
-    platform_dep = ":dartdevc_platform_sound"
-    sdk_outline = sdk_outline_sound_dill
-    js_gen_dir = "$target_gen_dir/pkg_sound"
-  } else {
-    platform_dep = ":dartdevc_platform_unsound"
-    sdk_outline = sdk_outline_unsound_dill
-    js_gen_dir = "$target_gen_dir/pkg_kernel"
-  }
-
-  # Other optional invoker parameters:
-  #   * extra_libraries: entrypoints to include in the module as
-  #     "package:package_name/library_name.dart" (the rule implicitly adds
-  #     the default import "package:package_name/package_name.dart").
-  #   * package_dependencies: the name of other packages this package depends
-  #     on. When providing `name`, a separate `dartdevc_kernel_compile` target
-  #     named `${name}_js` must exist.
-  #   * args: additional args to pass to dartdevc
-
-  prebuilt_dart_action(target_name) {
-    script = "../../pkg/dev_compiler/bin/dartdevc.dart"
-    module = invoker.package
-    out_dir = rebase_path("$js_gen_dir")
-    sdk_path = rebase_path(sdk_outline)
-
-    deps = [
-      ":dartdevc_files_stamp",
-      platform_dep,
-    ]
-
-    inputs = [
-      sdk_outline,
-      "$target_gen_dir/dartdevc_files.stamp",
-    ]
-
-    outputs = [
-      "$js_gen_dir/$module.dill",
-      "$js_gen_dir/$module.js",
-    ]
-
-    vm_args = [ "-Dsdk_hash=$sdk_hash" ]
-
-    args = [
-      "--dart-sdk-summary=$sdk_path",
-      "-o$out_dir/$module.js",
-      "package:$module/$module.dart",
-    ]
-
-    if (defined(invoker.extra_libraries)) {
-      foreach(lib, invoker.extra_libraries) {
-        args += [ "package:$module/$lib.dart" ]
-      }
-    }
-
-    if (defined(invoker.package_dependencies)) {
-      foreach(dep, invoker.package_dependencies) {
-        deps += [ ":${dep}_js" ]
-        args += [ "-s$out_dir/$dep.dill" ]
-      }
-    }
-
-    if (defined(invoker.args)) {
-      args += invoker.args
-    }
-
-    if (invoker.sound_null_safety) {
-      args += [ "--sound-null-safety" ]
-    } else {
-      args += [ "--no-sound-null-safety" ]
-    }
-  }
-}
-
-dartdevc_kernel_compile("async_helper_js") {
-  package = "async_helper"
-  sound_null_safety = false
-}
-
-dartdevc_kernel_compile("async_helper_sound_js") {
-  package = "async_helper"
-  sound_null_safety = true
-}
-
-dartdevc_kernel_compile("expect_js") {
-  package = "expect"
-  extra_libraries = [ "minitest" ]
-  sound_null_safety = false
-}
-
-dartdevc_kernel_compile("expect_sound_js") {
-  package = "expect"
-  extra_libraries = [ "minitest" ]
-  sound_null_safety = true
-}
-
-dartdevc_kernel_compile("js_js") {
-  package = "js"
-  extra_libraries = [ "js_util" ]
-  sound_null_safety = false
-}
-
-dartdevc_kernel_compile("js_sound_js") {
-  package = "js"
-  extra_libraries = [ "js_util" ]
-  sound_null_safety = true
-}
-
-dartdevc_kernel_compile("meta_js") {
-  package = "meta"
-  sound_null_safety = false
-}
-
-dartdevc_kernel_compile("meta_sound_js") {
-  package = "meta"
-  sound_null_safety = true
-}
-
-template("compile_dartdevc_platform") {
-  assert(defined(invoker.sound_null_safety),
-         "Need 'sound_null_safety' in $target_name.")
-
-  compile_platform(target_name) {
-    single_root_scheme = "org-dartlang-sdk"
-    single_root_base = rebase_path("$sdk_root/")
-    libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json"
-
-    args = [
-      "--target=dartdevc",
-      "dart:core",
-    ]
-
-    if (invoker.sound_null_safety) {
-      args += [ "--nnbd-strong" ]
-
-      outputs = [
-        sdk_full_sound_dill,
-        sdk_outline_sound_dill,
-      ]
-    } else {
-      args += [ "--nnbd-weak" ]
-
-      outputs = [
-        sdk_full_unsound_dill,
-        sdk_outline_unsound_dill,
-      ]
-    }
-  }
-}
-
-compile_dartdevc_platform("dartdevc_platform_unsound") {
-  sound_null_safety = false
-}
-
-compile_dartdevc_platform("dartdevc_platform_sound") {
-  sound_null_safety = true
-}
-
-# Compiles the DDC SDK's JS code from the platform .dill.
-template("dartdevc_sdk_js") {
-  assert(defined(invoker.sound_null_safety),
-         "Need 'sound_null_safety' in $target_name.")
-
-  if (invoker.sound_null_safety) {
-    platform_dep = ":dartdevc_platform_sound"
-    platform_input = sdk_full_sound_dill
-    js_gen_dir = "$target_gen_dir/sound"
-  } else {
-    platform_dep = ":dartdevc_platform_unsound"
-    platform_input = sdk_full_unsound_dill
-    js_gen_dir = "$target_gen_dir/kernel"
-  }
-
-  prebuilt_dart_action(target_name) {
-    deps = [
-      ":dartdevc_files_stamp",
-      platform_dep,
-    ]
-
-    inputs = [ platform_input ]
-
-    outputs = [
-      "$js_gen_dir/amd/dart_sdk.js",
-      "$js_gen_dir/amd/dart_sdk.js.map",
-      "$js_gen_dir/common/dart_sdk.js",
-      "$js_gen_dir/common/dart_sdk.js.map",
-      "$js_gen_dir/es6/dart_sdk.js",
-      "$js_gen_dir/es6/dart_sdk.js.map",
-      "$js_gen_dir/legacy/dart_sdk.js",
-      "$js_gen_dir/legacy/dart_sdk.js.map",
-    ]
-
-    vm_args = [ "-Dsdk_hash=$sdk_hash" ]
-
-    script = "../../pkg/dev_compiler/bin/dartdevc.dart"
-
-    args = [
-      "--multi-root-scheme",
-      "org-dartlang-sdk",
-      "--multi-root-output-path",
-
-      # This path is intended to point to a version of source files used to
-      # generate the SDK JavaScript modules.
-      # The intention is that the source map locations can be linked to the
-      # orignal source files while running SDK test suites.
-      # These JavaScript files and source maps are no longer packaged into the
-      # released SDK.
-      rebase_path("$target_gen_dir/../../../dart-sdk"),
-      "--modules",
-      "amd",
-      "-o",
-      rebase_path("$js_gen_dir/amd/dart_sdk.js"),
-      "--modules",
-      "common",
-      "-o",
-      rebase_path("$js_gen_dir/common/dart_sdk.js"),
-      "--modules",
-      "es6",
-      "-o",
-      rebase_path("$js_gen_dir/es6/dart_sdk.js"),
-      "--modules",
-      "legacy",
-      "-o",
-      rebase_path("$js_gen_dir/legacy/dart_sdk.js"),
-      rebase_path("$platform_input"),
-    ]
-
-    if (invoker.sound_null_safety) {
-      args += [ "--sound-null-safety" ]
-    } else {
-      args += [ "--no-sound-null-safety" ]
-    }
-  }
-}
-
-dartdevc_sdk_js("dartdevc_kernel_sdk") {
-  sound_null_safety = false
-}
-
-dartdevc_sdk_js("dartdevc_sound_sdk") {
-  sound_null_safety = true
+# TODO(nshahan): Delete after updating the Flutter engine build.
+group("dartdevc_sdk_patch_stamp") {
+  deps = [ "../ddc:ddc_sdk_patch_stamp" ]
 }
diff --git a/utils/ddc/BUILD.gn b/utils/ddc/BUILD.gn
index d742a5d..1ef0216 100644
--- a/utils/ddc/BUILD.gn
+++ b/utils/ddc/BUILD.gn
@@ -3,33 +3,92 @@
 # BSD-style license that can be found in the LICENSE file.
 
 import("../../build/dart/dart_action.gni")
+import("../../utils/compile_platform.gni")
 import("../application_snapshot.gni")
 import("../create_timestamp.gni")
 
-sdk_outline_sound_dill = "$root_out_dir/ddc_outline.dill"
-sdk_full_sound_dill = "$root_out_dir/ddc_platform.dill"
+sdk_outline_dill = "$root_out_dir/ddc_outline.dill"
+sdk_full_dill = "$root_out_dir/ddc_platform.dill"
 sdk_outline_unsound_dill = "$root_out_dir/ddc_outline_unsound.dill"
 sdk_full_unsound_dill = "$root_out_dir/ddc_platform_unsound.dill"
 
+sdk_root = "../../sdk"
+
+application_snapshot("dartdevc") {
+  main_dart = "../../pkg/dev_compiler/bin/dartdevc.dart"
+
+  training_args = [
+    "--dart-sdk-summary",
+    rebase_path(sdk_outline_dill),
+    "-o",
+    "dartdevc.js",
+    rebase_path("../../pkg/dev_compiler/bin/dartdevc.dart"),
+  ]
+
+  deps = [ ":ddc_platform" ]
+  inputs = [ sdk_outline_dill ]
+}
+
+template("dart2js_compile") {
+  assert(defined(invoker.main), "Must specify the main file")
+  main = invoker.main
+  assert(defined(invoker.out), "Must specify the out file")
+  out = invoker.out
+  abs_main = rebase_path(main)
+  abs_output = rebase_path(out)
+
+  prebuilt_dart_action(target_name) {
+    deps = invoker.deps + [
+             "../compiler:compile_dart2js_platform",
+             "../compiler:compile_dart2js_platform_unsound",
+           ]
+
+    inputs = [
+      "$root_out_dir/dart2js_platform.dill",
+      "$root_out_dir/dart2js_platform_unsound.dill",
+      "$root_out_dir/dart2js_outline.dill",
+      "$root_out_dir/dart2js_outline_unsound.dill",
+    ]
+    outputs = [ out ]
+
+    script = "../../pkg/compiler/lib/src/dart2js.dart"
+
+    packages = "../../.dart_tool/package_config.json"
+
+    vm_args = [ "-Dsdk_hash=$sdk_hash" ]
+
+    args = [
+      "$abs_main",
+      "-m",
+      "--invoker=gn_build",
+      "-o$abs_output",
+      "--no-source-maps",
+      "--platform-binaries=" + rebase_path("$root_out_dir"),
+    ]
+  }
+}
+
+dart2js_compile("stack_trace_mapper") {
+  main = rebase_path("../../pkg/dev_compiler/web/stack_trace_mapper.dart")
+  out = "$root_out_dir/dev_compiler/build/web/dart_stack_trace_mapper.js"
+  deps = [ ":ddc_files_stamp" ]
+}
+
 # Builds everything needed to run tests with DDC (stable) using test.dart.
 group("ddc_stable_test") {
   deps = [
+    ":dartdevc",
     ":ddc_stable_test_local",
     "../..:create_sdk",
-
-    # TODO(nshahan): Move the dartdevc snapshot target to this file.
-    "../dartdevc:dartdevc",
   ]
 }
 
 # Builds everything needed to run tests with DDC (canary) using test.dart.
 group("ddc_canary_test") {
   deps = [
+    ":dartdevc",
     ":ddc_canary_test_local",
     "../..:create_sdk",
-
-    # TODO(nshahan): Move the dartdevc snapshot target to this file.
-    "../dartdevc:dartdevc",
   ]
 }
 
@@ -64,6 +123,11 @@
   output = "$target_gen_dir/ddc_files.stamp"
 }
 
+create_timestamp_file("ddc_sdk_patch_stamp") {
+  path = rebase_path("$sdk_root/lib/_internal/js_dev_runtime")
+  output = "$target_gen_dir/ddc_sdk_patch_stamp.stamp"
+}
+
 # Compiles to JavaScript using DDC (stable) all packages imported in tests.
 # TODO(sigmund): generate a js bundle or a module that load these indirectly so
 # we can stop referring to this list of packages explicitly in the test_runner.
@@ -114,11 +178,11 @@
     js_gen_dir = "$target_gen_dir/stable"
   }
   if (invoker.sound_null_safety) {
-    platform_dep = "../dartdevc:dartdevc_platform_sound"
-    sdk_outline = sdk_outline_sound_dill
+    platform_dep = ":ddc_platform"
+    sdk_outline = sdk_outline_dill
     js_gen_dir = "$js_gen_dir/pkg"
   } else {
-    platform_dep = "../dartdevc:dartdevc_platform_unsound"
+    platform_dep = ":ddc_platform_unsound"
     sdk_outline = sdk_outline_unsound_dill
     js_gen_dir = "${js_gen_dir}_unsound/pkg"
   }
@@ -293,6 +357,46 @@
   sound_null_safety = false
 }
 
+template("compile_ddc_platform") {
+  assert(defined(invoker.sound_null_safety),
+         "Need 'sound_null_safety' in $target_name.")
+
+  compile_platform(target_name) {
+    single_root_scheme = "org-dartlang-sdk"
+    single_root_base = rebase_path("$sdk_root/")
+    libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json"
+
+    args = [
+      "--target=dartdevc",
+      "dart:core",
+    ]
+
+    if (invoker.sound_null_safety) {
+      args += [ "--nnbd-strong" ]
+
+      outputs = [
+        sdk_full_dill,
+        sdk_outline_dill,
+      ]
+    } else {
+      args += [ "--nnbd-weak" ]
+
+      outputs = [
+        sdk_full_unsound_dill,
+        sdk_outline_unsound_dill,
+      ]
+    }
+  }
+}
+
+compile_ddc_platform("ddc_platform") {
+  sound_null_safety = true
+}
+
+compile_ddc_platform("ddc_platform_unsound") {
+  sound_null_safety = false
+}
+
 # Compiles the DDC SDK JavaScript modules from the platform .dill file.
 template("ddc_compile_sdk") {
   assert(defined(invoker.sound_null_safety),
@@ -312,11 +416,11 @@
     js_gen_dir = "$target_gen_dir/stable"
   }
   if (invoker.sound_null_safety) {
-    platform_dep = "../dartdevc:dartdevc_platform_sound"
-    platform_input = sdk_full_sound_dill
+    platform_dep = ":ddc_platform"
+    platform_input = sdk_full_dill
     js_gen_dir = "$js_gen_dir/sdk"
   } else {
-    platform_dep = "../dartdevc:dartdevc_platform_unsound"
+    platform_dep = ":ddc_platform_unsound"
     platform_input = sdk_full_unsound_dill
     js_gen_dir = "${js_gen_dir}_unsound/sdk"
   }