blob: b15dc5a42123bde4caea86aec28ae825170d8dac [file] [log] [blame]
# Copyright 2022 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/fuchsia/platform_version.gni")
import("//build/python/python_host_test.gni")
if (is_host) {
python_host_test("update_platform_version_tests") {
enable_mypy = true
main_source = "update_platform_version_tests.py"
sources = [ "update_platform_version.py" ]
}
python_host_test("freeze_in_development_api_level_test") {
enable_mypy = true
main_source = "freeze_in_development_api_level_test.py"
sources = [ "freeze_in_development_api_level.py" ]
}
}
group("tests") {
testonly = true
deps = [
":freeze_in_development_api_level_test($host_toolchain)",
":update_platform_version_tests($host_toolchain)",
]
}
if (bump_api_level) {
# Adds a new in-development API level that is one greater than the highest
# existing numbered API level.
#
# A new ABI revision is generated and associated with the new API level, and
# the golden files used for static compatibility checks are generated.
#
# This target is a tool for managing the platform version. It should only be
# built by an infra bot or a human manually bumping the platform version, as
# it updates several files in the checkout.
#
# To use this tool manually, run the following:
# fx set bringup.x64 --with-host //scripts/versioning:bump_api_level --args=bump_api_level=true
# fx build
action("bump_api_level") {
testonly = true
# Generate the golden files and manifest before updating the platform version.
deps = [ "//sdk:compatibility_testing_goldens($target_toolchain)" ]
script = "//scripts/versioning/update_platform_version.py"
_version_history_file = "//sdk/version_history.json"
_fidl_compatiblity_doc_path =
"//docs/development/testing/ctf/fidl_api_compatibility_testing.md"
_goldens_manifest = "$root_build_dir/compatibility_testing_goldens.json"
_stamp_file = "$target_out_dir/$target_name.status"
# There must be no in-development (unfrozen) API level when adding a new one.
# TODO(https://fxbug.dev/326277078): Replace the logic in this file when
# adding support for "NEXT" as an API level. At that time, numbered API levels
# can no longer be in-development and the "next API level" will always be
# "NEXT".
_max_frozen_api_level = 0
foreach(level, platform_version.frozen_api_levels) {
if (level > _max_frozen_api_level) {
_max_frozen_api_level = level
}
}
assert(platform_version.deprecated_highest_numbered_api_level ==
_max_frozen_api_level,
"The previous API level must be frozen before adding a new one.")
_next_level = platform_version.deprecated_highest_numbered_api_level + 1
args = [
"--stamp-file",
rebase_path(_stamp_file, root_build_dir),
"--root-build-dir",
".",
"--root-source-dir",
rebase_path("//", root_build_dir),
"--sdk-version-history",
rebase_path(_version_history_file, root_build_dir),
"--fidl-compatibility-doc-path",
rebase_path(_fidl_compatiblity_doc_path, root_build_dir),
"--goldens-manifest",
rebase_path(_goldens_manifest, root_build_dir),
"--fuchsia-api-level",
"$_next_level",
]
inputs = [
_version_history_file,
_goldens_manifest,
]
outputs = [ _stamp_file ]
# TODO(https://fxbug.dev/42084512): Automate this.
# TODO(https://fxbug.dev/326277078): Move this to the instructions for
# promoting "NEXT" to a stable API level.
print(
"Before continuing, add `#define FUCHSIA_INTERNAL_LEVEL_${_next_level}_() ${_next_level}` to `//zircon/system/public/zircon/availability_levels.inc`, run `fx build zircon/public/sysroot/sdk:sysroot_sdk_verify_api`, and follow the instructions to update `//zircon/public/sysroot/sdk/sysroot.api`.")
}
}
if (freeze_api_level) {
# Freezes the current in-development API level, marking it stable in
# `//sdk/version_history.json`.
#
# It results in no in-development API level until ":bump_api_level" is run.
#
# This target is a tool for managing the platform version. It should only be
# built by an infra bot or a human manually bumping the platform version, as
# it updates several files in the checkout.
#
# To use this tool manually, run the following:
# fx set bringup.x64 --with-host //scripts/versioning:freeze_api_level --args=freeze_api_level=true
# fx build
action("freeze_api_level") {
testonly = true
script = "//scripts/versioning/freeze_in_development_api_level.py"
_stamp_file = "$target_out_dir/$target_name.status"
_version_history_file = "//sdk/version_history.json"
args = [
"--root-source-dir",
rebase_path("//", root_build_dir),
"--stamp-file",
rebase_path(_stamp_file, root_build_dir),
"--sdk-version-history",
rebase_path(_version_history_file, root_build_dir),
]
inputs = [ _version_history_file ]
outputs = [ _stamp_file ]
}
}