From 3de2ddee0923a9eabdf4f1be05dd6709ab6fc920 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 19 May 2026 20:55:22 -0700 Subject: [PATCH] Reapply "Switch on building devtools from source when building the Dart SDK" This reverts commit 2a93a26d91b62b34e2697c2db11033b912545f19, which a change to use `defined` so that the GN script does not crash in Flutter. Fixes flutter/devtools#9786 See go/moving-devtools-to-dart-sdk-2025. In this change, we make the source of devtools be configurable, in actions like build_sdk. If `build_devtools_from_sources` is true, we build local devtools, and if false, we continue to use the prebuilt sources. This may be an intermediate step, while we test out building devtools from source. Or it may be permanently be a choice, if we keep building with CIPD. Change-Id: I9d509b07971942f2c4884224a6efda9001522bd4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502120 Reviewed-by: Alexander Thomas Commit-Queue: Samuel Rawlins --- sdk/BUILD.gn | 11 +++++++++-- tools/build_devtools.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 1e36d240f8f..e1bbe7d6f83 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -13,6 +13,7 @@ # or ":copy_libraries" may delete/overwrite your addition, and the build will # fail. +import("../build/config/gclient_args.gni") import("../build/dart/copy_tree.gni") import("../build/executable_suffix.gni") import("../sdk_args.gni") @@ -310,7 +311,8 @@ copy_tree("copy_prebuilt_devtools") { # This action compiles the devtools app from sources. action("build_devtools") { - output = "$root_out_dir/$dart_sdk_output/web/devtools_app" + visibility = [ ":create_common_sdk" ] + output = "$root_out_dir/$dart_sdk_output/bin/resources/devtools" outputs = [ output ] script = "../tools/build_devtools.py" args = [ @@ -897,7 +899,6 @@ group("create_common_sdk") { ":copy_headers", ":copy_libraries_specification", ":copy_license", - ":copy_prebuilt_devtools", ":copy_readme", ":copy_sdk_packages_yaml", ":copy_vm_dill_files", @@ -907,6 +908,12 @@ group("create_common_sdk") { ":write_version_file", ] + if (defined(build_devtools_from_sources) && build_devtools_from_sources) { + public_deps += [ ":build_devtools" ] + } else { + public_deps += [ ":copy_prebuilt_devtools" ] + } + # We do not support AOT on ia32 and should therefore not add the # dart native compilation files since there is no AOT compiler/runtime # available. diff --git a/tools/build_devtools.py b/tools/build_devtools.py index 3400f4b75a6..2739f578d8a 100755 --- a/tools/build_devtools.py +++ b/tools/build_devtools.py @@ -93,6 +93,7 @@ def main(): elif os.path.exists(args.output): os.remove(args.output) shutil.copytree(build_dir, args.output) + shutil.rmtree(build_dir) print('DevTools build successful.') return 0