blob: 9e9045b4056eb9f7f32016e97043b22b9ea7df38 [file] [log] [blame]
# Copyright 2024 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/info/info.gni")
import("//build/python/python_action.gni")
import("//build/sdk/config.gni")
import("//build/sdk/sdk_atom.gni")
# Defines an atom for version_history.json.
#
# In practice, there will probably only be one instance of this rule, at
# //sdk:version_history, but we'll give it its own template for tidiness.
#
# Parameters
#
# source (required)
# path to version_history.json to preprocess.
#
# id, category, assert_no_deps
# Forwarded to sdk_atom.
template("sdk_version_history") {
_labels = {
compile = target_name
sdk = "${target_name}_sdk"
}
_files = {
compiled = "${target_out_dir}/${target_name}.json"
}
# Preprocess version_history.json
python_action(_labels.compile) {
forward_variables_from(invoker,
[
"assert_no_deps",
"testonly",
"visibility",
])
binary_label = "//build/sdk/generate_version_history"
deps = [ "//build/info:build_info_files($default_toolchain)" ]
inputs = [
invoker.source,
build_info_files.latest_commit_hash,
]
outputs = [ _files.compiled ]
args = [
"--input",
rebase_path(inputs[0], root_build_dir),
"--latest-commit-hash-file",
rebase_path(inputs[1], root_build_dir),
"--output",
rebase_path(outputs[0], root_build_dir),
]
if (sdk_legacy_unstable_abi_revisions) {
args += [ "--legacy-unstable-abi-revisions" ]
}
}
# SDK metadata.
sdk_atom(_labels.sdk) {
forward_variables_from(invoker,
[
"id",
"category",
"assert_no_deps",
"testonly",
])
meta = {
dest = "version_history.json"
source = _files.compiled
schema = "version_history-22rnd667"
type = "version_history"
}
non_sdk_deps = [ ":${_labels.compile}" ]
}
}