blob: fc7af6a8b788af9aa49d1abbbc3ef1e246cee6d3 [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# 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.
# This SDK is used to compile the Observatory frontend sources.
dart_host_sdk = rebase_path("//third_party/dart-sdk/dart-sdk")
# Specify the path to a host compatible version of pub.
# This is used to compile the Observatory frontend sources.
dart_host_pub_exe = rebase_path("$dart_host_sdk/bin/pub")
}
# Helper build rules for packaging the Dart observatory resources.
observatory_sources_gypi =
exec_script("../../tools/gypi_to_gn.py",
[ rebase_path(
"../observatory/observatory_sources.gypi") ],
"scope",
[ "../observatory/observatory_sources.gypi" ])
copy("copy_observatory") {
sources = rebase_path(observatory_sources_gypi.sources,
"",
".")
outputs = [
"$root_gen_dir/observatory_copy/{{source_root_relative_dir}}/{{source_file_part}}",
]
}
action("write_observatory_pubspec_yaml") {
deps = [
":copy_observatory",
]
script = "../../tools/observatory_tool.py"
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/"),
]
outputs = [
"$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml",
]
}
action("copy_observatory_deps") {
deps = [
":write_observatory_pubspec_yaml",
]
script = "../../tools/observatory_tool.py"
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",
]
outputs = [
"$root_gen_dir/observatory_copy/$current_dir/packages.stamp",
]
}
action("pub_build_observatory") {
current_dir = rebase_path(".", "//")
sources =
rebase_path(observatory_sources_gypi.sources,
"",
"$root_gen_dir/observatory_copy/$current_dir")
deps = [
":copy_observatory",
":copy_observatory_deps",
]
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"),
]
outputs = [
"$root_out_dir/observatory/build/web/main.dart.js",
]
}
action("deploy_observatory") {
deps = [
":pub_build_observatory",
]
script = "../../tools/observatory_tool.py"
inputs = [
script,
"$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",
]
outputs = [
"$root_out_dir/observatory/deployed/web/main.dart.js",
]
}
template("observatory_archive") {
assert(defined(invoker.inner_namespace),
"Need inner_namespace in $target_name")
assert(defined(invoker.outer_namespace),
"Need outer_namespace in $target_name")
enable_compression = false
if (defined(invoker.compress) && invoker.compress) {
enable_compression = true
}
action(target_name) {
deps = [
":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
args = [
"--output",
rebase_path("$root_gen_dir/observatory/${output_name}.cc"),
"--tar_output",
rebase_path("$root_gen_dir/observatory/${output_name}.tar"),
"--outer_namespace", outer_namespace,
"--inner_namespace", inner_namespace,
"--name", "observatory_assets_archive",
"--client_root", rebase_path("$root_out_dir/observatory/deployed/web/"),
]
if (enable_compression) {
args += [ "--compress" ]
}
outputs = [
"$root_gen_dir/observatory/${output_name}.cc",
"$root_gen_dir/observatory/${output_name}.tar",
]
}
}
observatory_archive("embedded_archive_observatory") {
outer_namespace = "dart"
inner_namespace = "observatory"
}
source_set("embedded_observatory_archive") {
deps = [
":embedded_archive_observatory",
]
sources = [
rebase_path("$root_gen_dir/observatory/embedded_archive_observatory.cc"),
]
}
observatory_archive("standalone_archive_observatory") {
compress = true
outer_namespace = "dart"
inner_namespace = "bin"
}
source_set("standalone_observatory_archive") {
deps = [
":standalone_archive_observatory",
]
sources = [
rebase_path("$root_gen_dir/observatory/standalone_archive_observatory.cc"),
]
}