blob: f69803b360c932ac2b97e1c027a469c818fe8b74 [file] [log] [blame]
# Copyright 2019 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.
# Build targets for constructing CIPD release archives.
assert(is_fuchsia)
import("//build/cipd/cipd.gni")
import("//build/config/chrome_build.gni")
import("//build/util/process_version.gni")
import("//third_party/fuchsia-sdk/sdk/build/build_id_dir.gni")
import("//third_party/fuchsia-sdk/sdk/build/cipd.gni")
# gn binary location.
if (host_os == "mac") {
_gn_path = "//buildtools/mac/gn"
} else if (host_os == "linux") {
_gn_path = "//buildtools/linux64/gn"
}
if (is_chrome_branded) {
package_base_path = "chrome_internal/fuchsia"
} else {
package_base_path = "chromium/fuchsia"
}
# Extracts the numeric Chrome build ID and writes it to a file in the output
# directory.
#
# To check out the repository on the commit where the build ID was generated,
# simply call `git checkout <build-id>`, and Git will check out the commit
# associated with the <build-id> tag.
process_version("build_id") {
template_file = "build_id.template"
sources = [ "//chrome/VERSION" ]
output = "${target_gen_dir}/build_id.txt"
process_only = true
}
if (target_cpu == "x64") {
targetarch = "amd64"
} else {
targetarch = "arm64"
}
# Prepares a CIPD archive, produces a corresponding LICENSE file and generates
# a manifest file.
#
# Parameters:
# package_basename: Determines the package basename in CIPD. Only required if
# |package_relative_path| is not specified
# package_relative_path: Specify the package location relative to the fuchsia/
# CIPD subdirectory. Defaults to a package name
# based on |package_basename|.
# description: Sets the "description" field in CIPD package definition.
#
# Optional parameters used directly by fuchsia_cipd_package template:
# "install_mode",
# "sources",
# "data",
# "data_deps"
# "deps",
# "testonly",
template("cipd_archive") {
forward_variables_from(invoker,
[
"package_basename",
"package_relative_path",
"description",
"install_mode",
"sources",
"data",
"data_deps",
"deps",
"testonly",
])
assert(
(defined(package_basename) && !defined(package_relative_path)) ||
(!defined(package_basename) && defined(package_relative_path)),
"only one of \"package_basename\" and \"package_relative_path\" should be set")
# Produces a consolidated license file.
action("${target_name}_license") {
_license_path = "${target_gen_dir}/${target_name}/LICENSE"
_invoker_dir = get_label_info(":${invoker.target_name}", "dir")
_license_target = "${_invoker_dir}:${invoker.target_name}"
script = "//tools/licenses.py"
inputs = [ "$_gn_path" ]
outputs = [ _license_path ]
args = [
"license_file",
rebase_path(_license_path, root_build_dir),
"--gn-target",
_license_target,
"--gn-out-dir",
".",
]
}
if (!defined(deps)) {
deps = []
}
deps += [ ":${target_name}_license" ]
if (!defined(sources)) {
sources = []
}
sources += get_target_outputs(":${target_name}_license")
fuchsia_cipd_package(target_name) {
if (!defined(package_relative_path)) {
package_relative_path = "${package_basename}-$targetarch"
}
package = "${package_base_path}/${package_relative_path}"
if (!defined(package_definition_name)) {
package_definition_name = "${target_name}.yaml"
}
# Always use absolute path.
use_absolute_root_path = true
}
}
cipd_archive("webrunner") {
package_basename = "webrunner"
description = "Prebuilt Chrome and Web Runner binaries for Fuchsia."
deps = [
"//fuchsia/engine:web_engine",
"//fuchsia/engine:web_engine_with_webui",
"//fuchsia/runners:web_runner_pkg",
]
sources = [
"${root_gen_dir}/fuchsia/engine/web_engine/web_engine.far",
"${root_gen_dir}/fuchsia/engine/web_engine_with_webui/web_engine_with_webui.far",
"${root_gen_dir}/fuchsia/runners/web_runner/web_runner.far",
]
}
cipd_archive("castrunner") {
package_basename = "castrunner"
description = "Prebuilt Cast application Runner binaries for Fuchsia."
deps = [ "//fuchsia/runners:cast_runner_pkg" ]
sources = [ "${root_gen_dir}/fuchsia/runners/cast_runner/cast_runner.far" ]
}
cipd_archive("http") {
package_basename = "http"
description = "Prebuilt HTTP service binary for Fuchsia."
deps = [ "//fuchsia/http:http_pkg" ]
sources = [ "${root_gen_dir}/fuchsia/http/http/http.far" ]
}
cipd_archive("web_engine_shell") {
package_basename = "web_engine_shell"
description = "Simple command-line embedder for WebEngine."
testonly = true
deps = [ "//fuchsia/engine:web_engine_shell_pkg" ]
sources =
[ "${root_gen_dir}/fuchsia/engine/web_engine_shell/web_engine_shell.far" ]
}
_stripped_chromedriver_file = "${root_out_dir}/clang_x64/stripped/chromedriver"
action("strip_chromedriver_binary") {
testonly = true
prog_name = "${root_out_dir}/clang_x64/chromedriver"
deps = [ "//chrome/test/chromedriver:chromedriver($host_toolchain)" ]
script = "//build/gn_run_binary.py"
sources = [
"//buildtools/third_party/eu-strip/bin/eu-strip",
prog_name,
]
outputs = [ _stripped_chromedriver_file ]
args = [
rebase_path("//buildtools/third_party/eu-strip/bin/eu-strip",
root_build_dir),
"-o",
rebase_path(_stripped_chromedriver_file, root_build_dir),
rebase_path(prog_name, root_build_dir),
]
visibility = [ ":*" ]
}
cipd_archive("chromedriver") {
package_relative_path = "chromedriver/\${os}-\${arch}"
description = "Prebuilt Chromedriver binary for Fuchsia host."
install_mode = "copy"
deps = [ ":strip_chromedriver_binary" ]
testonly = true
sources = [ _stripped_chromedriver_file ]
}
group("test_packages_for_deps") {
testonly = true
public_deps = [
"//base:base_unittests_pkg",
"//fuchsia/runners:cast_runner_integration_tests_pkg",
"//fuchsia/runners:web_runner_integration_tests_pkg",
"//ipc:ipc_tests_pkg",
"//media:media_unittests_pkg",
"//mojo:mojo_unittests_pkg",
"//skia:skia_unittests_pkg",
"//third_party/blink/common:blink_common_unittests_pkg",
]
}
cipd_archive("tests") {
_manifest_path = "${target_gen_dir}/test_manifest.json"
package_basename = "tests"
description = "Prebuilt Chromium tests for Fuchsia."
testonly = true
deps = [ ":test_packages_for_deps" ]
far_sources = [
"${root_gen_dir}/base/base_unittests/base_unittests.far",
"${root_gen_dir}/fuchsia/runners/cast_runner_integration_tests/cast_runner_integration_tests.far",
"${root_gen_dir}/fuchsia/runners/web_runner_integration_tests/web_runner_integration_tests.far",
"${root_gen_dir}/ipc/ipc_tests/ipc_tests.far",
"${root_gen_dir}/media/media_unittests/media_unittests.far",
"${root_gen_dir}/mojo/mojo_unittests/mojo_unittests.far",
"${root_gen_dir}/skia/skia_unittests/skia_unittests.far",
"${root_gen_dir}/third_party/blink/common/blink_common_unittests/blink_common_unittests.far",
]
# Build a JSON manifest of the tests and include it in the archive.
_manifest_contents = []
foreach(source, far_sources) {
package_name = get_path_info(source, "name")
_manifest_contents += [
{
package = package_name
component_name = package_name
},
]
}
write_file(_manifest_path, _manifest_contents, "json")
sources = far_sources + [ _manifest_path ]
}
# Construct a consolidated directory of debugging symbols using the GNU
# .build_id structure for CIPD archival.
_build_ids_target = "debug_symbol_directory"
_debug_symbols_archive_name = "debug_symbols"
_debug_symbols_outdir =
"${target_gen_dir}/${_debug_symbols_archive_name}/${_build_ids_target}"
build_id_dir(_build_ids_target) {
testonly = true
build_id_dirs = [
"${root_gen_dir}/fuchsia/engine/web_engine",
"${root_gen_dir}/fuchsia/runners/cast_runner",
"${root_gen_dir}/fuchsia/runners/web_runner",
]
output_path = _debug_symbols_outdir
deps = [
":test_packages_for_deps",
"//fuchsia/engine:web_engine",
"//fuchsia/runners:cast_runner_pkg",
"//fuchsia/runners:web_runner_pkg",
]
}
fuchsia_cipd_package(_debug_symbols_archive_name) {
testonly = true
package = "${package_base_path}/debug-symbols-${targetarch}"
package_root = _debug_symbols_outdir
package_definition_name = "${target_name}.yaml"
package_definition_dir = "${target_gen_dir}/${target_name}"
description = "Debugging symbols for prebuilt binaries from Chromium."
use_absolute_root_path = true
directories = [ "." ]
deps = [ ":${_build_ids_target}" ]
}
cipd_archive("clear_key_cdm") {
package_basename = "libclearkeycdm"
description = "Prebuilt libclearkeycdm.so binary for Fuchsia."
testonly = true
deps = [ "//media/cdm/library_cdm/clear_key_cdm:clear_key_cdm" ]
sources = [ "${root_out_dir}/lib/libclearkeycdm.so" ]
}
group("cipd") {
# Must be testonly because debug symbols depends on test package symbols.
testonly = true
deps = [
":castrunner",
":chromedriver",
":clear_key_cdm",
":debug_symbols",
":http",
":tests",
":web_engine_shell",
":webrunner",
]
}