blob: 471cfd0ccc31b89ffe78370b838066cdca09449d [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
declare_args() {
# Version string embedded in the kernel for `zx_system_get_version_string`.
# If set to the default "", a string is generated based on the fuchsia.git
# revision of the checkout.
kernel_version_string = ""
}
# The version string depends solely on the source and doesn't vary across
# machines or toolchains, so generate it only once.
gen_dir = get_label_info(".($default_toolchain)", "target_gen_dir")
if (current_toolchain == default_toolchain) {
assert(gen_dir == target_gen_dir)
version_string_file = "$gen_dir/version-string.inc"
if (kernel_version_string != "") {
generated_file("version-string") {
visibility = [ ":*" ]
outputs = [ version_string_file ]
contents = [
"// Generated by $zx/kernel/lib/version/BUILD.gn. DO NOT EDIT!",
"constexpr char kVersionString[] = ",
" \"${kernel_version_string}\";",
]
}
} else {
action("version-string") {
visibility = [ ":*" ]
script = "git-version-string.sh"
outputs = [ version_string_file ]
depfile = "$target_gen_dir/git-version-string.d"
args = rebase_path([
version_string_file,
depfile,
"$zx/../.git",
],
root_build_dir)
}
}
} else {
zx_library("version") {
kernel = true
sources = [ "version.cc" ]
defines = [ "ARCH=\"$current_cpu\"" ]
include_dirs = [ gen_dir ]
deps = [
":version-string($default_toolchain)",
"$zx/kernel/lib/console",
]
}
}