blob: afc37ba2f165f0b6432c634f76d14202d89f360f [file] [log] [blame]
# Copyright 2020 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.
# An empty SDK atom.
#
# Should be used in very specific situations where SDK elements are injected in
# SDKs in a way that's not reflected in the build graph. This allows SDK-related
# templates to handle such a target as any other SDK target.
#
# Parameters
# id (optional)
# Identifier of this element within SDKs. Used for API verification.
# See //build/sdk/sdk_atom.gni for information regarding id.
# If this attribute is set, "category" and "type" must be set as well.
# Type: string
#
# category (optional)
# Describes the availability of the element.
# See //build/sdk/sdk_atom.gni for information regarding category.
# If this attribute is set, "id" and "type" must be set as well.
# Type: string
#
# type (optional)
# Describes the type of the element.
# If this attribute is set, "id" and "category" must be set as well.
# Type: string
#
template("sdk_noop_atom") {
meta_target_name = "${target_name}_meta"
meta_file = "${target_gen_dir}/${target_name}.meta.json"
generated_file(meta_target_name) {
contents = {
}
outputs = [ meta_file ]
output_conversion = "json"
}
manifest_file = "${target_gen_dir}/${target_name}.sdk"
# If id, category and type are set, the SDK contents will be API verified by
# checking that all elements are still in the SDK.
if (defined(invoker.id) || defined(invoker.category) ||
defined(invoker.type)) {
assert(defined(invoker.id), "Must define id for API verification.")
assert(defined(invoker.category),
"Must define category for API verification.")
assert(defined(invoker.type), "Must define type for API verification.")
action(target_name) {
depfile = "${manifest_file}.d"
script = "//build/sdk/create_atom_manifest.py"
public_deps = [ ":${meta_target_name}" ]
inputs = [
# Imported by the action's script.
"//build/sdk/sdk_common.py",
]
outputs = [ manifest_file ]
args = [
"--id",
invoker.id,
"--out",
rebase_path(manifest_file, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
"--gn-label",
get_label_info(":${target_name}", "label_with_toolchain"),
"--category",
invoker.category,
"--type",
invoker.type,
"--noop-atom",
]
}
} else {
generated_file(target_name) {
contents = {
atoms = []
ids = []
}
outputs = [ manifest_file ]
output_conversion = "json"
public_deps = [ ":${meta_target_name}" ]
}
}
not_needed(invoker, "*")
}