blob: 05958a29b9473fbc3fc8d728cd43923897229a2d [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
import("//build/tracer/tracer.gni")
import("//build/zircon/migrated_targets.gni")
import("version_string.gni")
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
# status of the fuchsia git repository.
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)
_bin_visibility = [
":*",
"//zircon/kernel:*",
]
if (kernel_version_string != "") {
generated_file("version-string.bin") {
visibility = _bin_visibility
outputs = [ kernel_version_string_file ]
contents = kernel_version_string # Not a list so no newline added.
}
} else {
action("version-string.bin") {
visibility = _bin_visibility
script = "git-version-string.sh"
inputs = [
# Regenerate version if HEAD moves
"//.git/HEAD",
# Add "-dirty" suffix as needed
"//.git/index",
]
outputs = [ kernel_version_string_file ]
hermetic_deps = false
args = rebase_path([
kernel_version_string_file,
"//",
],
root_build_dir)
}
}
action("version-string.h") {
visibility = [ ":*" ]
script = "gen-version-string-header.sh"
outputs = [ "$gen_dir/lib/version/version-string.h" ]
deps = [ ":version-string.bin" ]
sources = [ kernel_version_string_file ]
args = rebase_path(sources + outputs, root_build_dir)
}
} else {
zx_library("version") {
sources = [ "version.cc" ]
defines = [ "ARCH=\"$current_cpu\"" ]
public_deps = [ ":version-string.h($default_toolchain)" ]
public_configs = [ ":gen.config" ]
deps = [
"//zircon/kernel/lib/console",
"//zircon/kernel/lib/init",
]
}
config("gen.config") {
visibility = [ ":*" ]
include_dirs = [ gen_dir ]
}
}