| # 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/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 |
| # `kernel_version_git_checkout` and `kernel_version_git_dirty_check` |
| # settings, which see. |
| kernel_version_string = "" |
| |
| # By default the kernel version string is generated based on the full git |
| # revision found by `git rev-parse HEAD` in this checkout directory. |
| kernel_version_git_checkout = "//zircon/.." |
| |
| # If this is true, then the kernel version string generated based on |
| # `kernel_version_git_checkout` also adds a "-dirty" suffix if any files in |
| # the checkout are modified from what's committed in git. |
| kernel_version_git_dirty_check = true |
| } |
| |
| # 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) |
| |
| if (kernel_version_string != "") { |
| generated_file("version-string.bin") { |
| visibility = [ |
| ":*", |
| "//zircon/kernel:*", |
| ] |
| outputs = [ kernel_version_string_file ] |
| contents = kernel_version_string # Not a list so no newline added. |
| } |
| } else { |
| action("version-string.bin") { |
| # TODO(fxbug.dev/68558): figure out why this is failing on bot and remove. |
| hermetic_deps = false |
| |
| visibility = [ |
| ":*", |
| "//zircon/kernel:*", |
| ] |
| script = "git-version-string.sh" |
| outputs = [ kernel_version_string_file ] |
| sources = [ "$kernel_version_git_checkout/.git/HEAD" ] |
| if (kernel_version_git_dirty_check) { |
| sources += [ "$kernel_version_git_checkout/.git/index" ] |
| } |
| args = rebase_path([ |
| kernel_version_string_file, |
| kernel_version_git_checkout, |
| ], |
| root_build_dir) + [ "$kernel_version_git_dirty_check" ] |
| } |
| } |
| |
| action("version-string.h") { |
| all_outputs_fresh = false |
| |
| 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") { |
| kernel = true |
| 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 ] |
| } |
| } |