Index: runtime/observatory/BUILD.gn |
diff --git a/runtime/observatory/BUILD.gn b/runtime/observatory/BUILD.gn |
index 5058eed80c26854096b03f541a929d7435b98d50..4978c1ab6b6d374c74d48f160a4cdcbd2a0cebae 100644 |
--- a/runtime/observatory/BUILD.gn |
+++ b/runtime/observatory/BUILD.gn |
@@ -2,6 +2,8 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+import("../../utils/invoke_dart.gni") |
+ |
# Currently paths here are hard coded for convenience in building Mojo/Flutter. |
declare_args() { |
# Specify the path to a host compatible version of the Dart SDK. |
@@ -10,9 +12,40 @@ declare_args() { |
# Specify the path to a host compatible version of pub. |
# This is used to compile the Observatory frontend sources. |
+ # |
+ # The observatory build tool searches for pub first using this GN arg, then |
+ # for the checked-in SDK, and if that doesn't work, it uses the dart_bootstrap |
+ # built as part of the build to invoke pub. If this arg is set to a non-empty |
+ # string, we assume that there is no need for dart_bootstrap. If it is set to |
+ # "", then we assume that there may be a need for dart_bootstrap. |
dart_host_pub_exe = rebase_path("$dart_host_sdk/bin/pub") |
} |
+# Construct arguments to the observatory tool for finding pub. |
+pub_build_deps = [] |
+pub_build_args = [] |
+if (dart_host_pub_exe != "") { |
+ pub_build_args = [ |
+ "--pub-executable", |
+ dart_host_pub_exe, |
+ ] |
+} else { |
+ pub_build_deps += [ "../bin:dart_bootstrap($host_toolchain)" ] |
+ |
+ dart_out_dir = |
+ get_label_info("../bin:dart_bootstrap($host_toolchain)", "root_out_dir") |
+ dart_bootstrap = |
+ rebase_path("$dart_out_dir/dart_bootstrap$dart_executable_suffix") |
+ |
+ pub_build_args = [ |
+ "--sdk=True", |
+ "--dart-executable", |
+ dart_bootstrap, |
+ ] |
+} |
+ |
+current_dir = rebase_path(".", "//") |
+ |
# Helper build rules for packaging the Dart observatory resources. |
observatory_sources_gypi = |
exec_script("../../tools/gypi_to_gn.py", |
@@ -28,30 +61,25 @@ copy("copy_observatory") { |
} |
action("write_observatory_pubspec_yaml") { |
- deps = [ |
- ":copy_observatory", |
- ] |
- |
- script = "../../tools/observatory_tool.py" |
+ deps = [ ":copy_observatory" ] + pub_build_deps |
inputs = [ |
rebase_path("pubspec.yaml"), |
] |
- current_dir = rebase_path(".", "//") |
- args = [ |
- "--silent=True", |
- "--pub-executable", |
- dart_host_pub_exe, |
- "--directory", |
- rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
- "--command", |
- "rewrite", |
- rebase_path("../observatory/pubspec.yaml"), |
- rebase_path("$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml"), |
- "../../third_party/", |
- rebase_path("../../third_party/"), |
- ] |
+ script = "../../tools/observatory_tool.py" |
+ args = |
+ pub_build_args + [ |
+ "--silent=True", |
+ "--directory", |
+ rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
+ "--command", |
+ "rewrite", |
+ rebase_path("../observatory/pubspec.yaml"), |
+ rebase_path("$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml"), |
+ "../../third_party/", |
+ rebase_path("../../third_party/"), |
+ ] |
outputs = [ |
"$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml", |
@@ -59,29 +87,23 @@ action("write_observatory_pubspec_yaml") { |
} |
action("copy_observatory_deps") { |
- deps = [ |
- ":write_observatory_pubspec_yaml", |
- ] |
- |
- script = "../../tools/observatory_tool.py" |
+ deps = [ ":write_observatory_pubspec_yaml" ] + pub_build_deps |
- current_dir = rebase_path(".", "//") |
inputs = [ |
- script, |
"$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml", |
] |
- args = [ |
- "--silent=True", |
- "--pub-executable", |
- dart_host_pub_exe, |
- "--stamp", |
- rebase_path("$root_gen_dir/observatory_copy/$current_dir/packages.stamp"), |
- "--directory", |
- rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
- "--command", |
- "get", |
- ] |
+ script = "../../tools/observatory_tool.py" |
+ args = pub_build_args + [ |
+ "--silent=True", |
+ "--stamp", |
+ rebase_path( |
+ "$root_gen_dir/observatory_copy/$current_dir/packages.stamp"), |
+ "--directory", |
+ rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
+ "--command", |
+ "get", |
+ ] |
outputs = [ |
"$root_gen_dir/observatory_copy/$current_dir/packages.stamp", |
@@ -89,34 +111,27 @@ action("copy_observatory_deps") { |
} |
action("pub_build_observatory") { |
- current_dir = rebase_path(".", "//") |
+ deps = [ |
+ ":copy_observatory", |
+ ":copy_observatory_deps", |
+ ] + pub_build_deps |
+ |
sources = rebase_path(observatory_sources_gypi.sources, |
"", |
"$root_gen_dir/observatory_copy/$current_dir") |
- deps = [ |
- ":copy_observatory", |
- ":copy_observatory_deps", |
- ] |
+ inputs = |
+ sources + [ "$root_gen_dir/observatory_copy/$current_dir/packages.stamp" ] |
script = "../../tools/observatory_tool.py" |
- |
- inputs = [ |
- script, |
- "$root_gen_dir/observatory_copy/$current_dir/packages.stamp", |
- ] |
- inputs += sources |
- |
- args = [ |
- "--silent=True", |
- "--pub-executable", |
- dart_host_pub_exe, |
- "--directory", |
- rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
- "--command", |
- "build", |
- rebase_path("$root_out_dir/observatory/build"), |
- ] |
+ args = pub_build_args + [ |
+ "--silent=True", |
+ "--directory", |
+ rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
+ "--command", |
+ "build", |
+ rebase_path("$root_out_dir/observatory/build"), |
+ ] |
outputs = [ |
"$root_out_dir/observatory/build/web/main.dart.js", |
@@ -124,9 +139,7 @@ action("pub_build_observatory") { |
} |
action("deploy_observatory") { |
- deps = [ |
- ":pub_build_observatory", |
- ] |
+ deps = [ ":pub_build_observatory" ] + pub_build_deps |
script = "../../tools/observatory_tool.py" |
@@ -135,15 +148,13 @@ action("deploy_observatory") { |
"$root_out_dir/observatory/build/web/main.dart.js", |
] |
- args = [ |
- "--silent=True", |
- "--pub-executable", |
- dart_host_pub_exe, |
- "--directory", |
- rebase_path("$root_out_dir/observatory"), |
- "--command", |
- "deploy", |
- ] |
+ args = pub_build_args + [ |
+ "--silent=True", |
+ "--directory", |
+ rebase_path("$root_out_dir/observatory"), |
+ "--command", |
+ "deploy", |
+ ] |
outputs = [ |
"$root_out_dir/observatory/deployed/web/main.dart.js", |
@@ -164,16 +175,15 @@ template("observatory_archive") { |
":deploy_observatory", |
] |
- script = "../tools/create_archive.py" |
- |
inputs = [ |
- script, |
"$root_out_dir/observatory/deployed/web/main.dart.js", |
] |
inner_namespace = invoker.inner_namespace |
outer_namespace = invoker.outer_namespace |
output_name = target_name |
+ |
+ script = "../tools/create_archive.py" |
args = [ |
"--output", |
rebase_path("$root_gen_dir/observatory/${output_name}.cc"), |