From a9335cfa230e619876c98eb071076e0efb37bb44 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 1 Jun 2026 12:11:40 -0700 Subject: [PATCH] [build] Inform GN of copy_tree's destination directory. This will make GN notice conflicting copy_tree destinations. It may also fix a race when two copy_tree's with a common parent directory create that parent directory. Change-Id: I1783ea170f0390d4026123ed43c00cd15eb0b1c5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508241 Reviewed-by: Alexander Aprelev Commit-Queue: Ryan Macnak Reviewed-by: Samuel Rawlins --- build/dart/copy_tree.gni | 5 ++++- sdk/BUILD.gn | 40 +++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/build/dart/copy_tree.gni b/build/dart/copy_tree.gni index 2ab0638e98f..b6b7105e820 100644 --- a/build/dart/copy_tree.gni +++ b/build/dart/copy_tree.gni @@ -53,7 +53,10 @@ template("copy_tree") { ] } - outputs = [ stampfile ] + outputs = [ + stampfile, + dest, + ] script = "$_dart_root/tools/copy_tree.py" args = common_args } diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 39a5e6939ca..8983904a1ff 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -296,25 +296,27 @@ copy_tree("copy_dartdoc_resources") { exclude = "{}" } -# This rule copies the pre-built DevTools application to -# bin/resources/devtools/ -copy_tree("copy_prebuilt_devtools") { - visibility = [ ":create_common_sdk" ] - source = "../third_party/devtools/web" - dest = "$root_out_dir/$dart_sdk_output/bin/resources/devtools" - exclude = "{}" -} - -# This action compiles the devtools app from sources. -action("build_devtools") { - visibility = [ ":create_common_sdk" ] - output = "$root_out_dir/$dart_sdk_output/bin/resources/devtools" - outputs = [ output ] - script = "../tools/build_devtools.py" - args = [ - "--output", - rebase_path(output, root_build_dir), - ] +if (defined(build_devtools_from_sources) && build_devtools_from_sources) { + # This action compiles the devtools app from sources. + action("build_devtools") { + visibility = [ ":create_common_sdk" ] + output = "$root_out_dir/$dart_sdk_output/bin/resources/devtools" + outputs = [ output ] + script = "../tools/build_devtools.py" + args = [ + "--output", + rebase_path(output, root_build_dir), + ] + } +} else { + # This rule copies the pre-built DevTools application to + # bin/resources/devtools/ + copy_tree("copy_prebuilt_devtools") { + visibility = [ ":create_common_sdk" ] + source = "../third_party/devtools/web" + dest = "$root_out_dir/$dart_sdk_output/bin/resources/devtools" + exclude = "{}" + } } # This loop generates rules to copy libraries to lib/