blob: a7477257cab2d4db8dc787177edbbe958107080c [file] [log] [blame]
# Copyright 2021 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config.gni")
import("//build/packages/prebuilt_package_with_flavors.gni")
import("//src/chromium/build_args.gni")
# Generates a prebuilt_package_with_flavors target which allows choosing which flavor to use for
# Chromium packages.
#
# Parameters
#
# prebuilt_archive_base_path (required)
# [path]: Base path for the prebuilt archive.
#
# custom_package_path (required)
# [path]: The path to the package inside a custom chromium build output directory.
#
# package_name (optional)
# Name of the prebuilt package, defaults to template's target name
#
# selections (optional)
# [list] Flavor choice. This allows flavor to be changed based on other build args. See
# //build/packages/prebuilt_package_with_flavors.gni
#
# deps (optional)
# testonly (optional)
# visibility (optional)
# Usual GN meanings.
#
template("generate_package_flavors") {
assert(defined(invoker.prebuilt_archive_base_path),
"A prebuilt archive base path must be specified")
assert(defined(invoker.custom_package_path),
"A custom package path must be specified")
prebuilt_package_with_flavors("${target_name}_pkg") {
forward_variables_from(invoker,
[
"deps",
"selections",
"testonly",
"visibility",
"package_name",
"repository",
])
if (defined(invoker.package_name)) {
package_name = invoker.package_name
} else {
package_name = invoker.target_name
}
visibility = [ ":${invoker.target_name}" ]
default = "release"
flavors = [
{
name = "release"
archive = "${invoker.prebuilt_archive_base_path}/arch/$target_cpu/${package_name}.far"
production_safe = true
},
{
name = "canary"
archive = "${invoker.prebuilt_archive_base_path}_latest/arch/$target_cpu/${package_name}.far"
production_safe = true
},
{
name = "custom"
archive = "${chromium_build_dir}${invoker.custom_package_path}"
},
]
}
}
# Generates a config for Chromium packages. See //build/config.gni for
# documentation of the parameters below.
template("generate_config") {
config_data("${target_name}_config") {
forward_variables_from(invoker,
[
"for_pkg",
"outputs",
"sources",
"testonly",
])
visibility = [ ":${invoker.target_name}" ]
}
}
# Helper template that generates a prebuilt_package_with_flavors target and
# a config_data target for a given Chromium package. List of parameters is
# the combined parameters in the generate_config and generate_flavors templates.
template("generate_package_flavors_and_config") {
generate_package_flavors(target_name) {
forward_variables_from(invoker,
[
"custom_package_path",
"prebuilt_archive_base_path",
"selections",
"testonly",
"repository",
])
}
generate_config(target_name) {
forward_variables_from(invoker,
[
"for_pkg",
"outputs",
"sources",
"testonly",
])
}
}