blob: 2672f4e25e206994c2f37806aa1a57952c2bcbf8 [file] [log] [blame]
# Copyright 2020 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/rust/rustc_library.gni")
# Since the version only depends on the source checkout and not the toolchain,
# we only need to generate the version info file once per build.
out_dir = get_label_info(".($default_toolchain)", "target_out_dir")
base_output_file = "$out_dir/ffx_version_info.txt"
rebased_output_file = rebase_path(base_output_file)
rebased_build_version = rebase_path(build_info_files.version)
config("env") {
rustenv = [
"FFX_VERSION_INFO=$rebased_output_file",
"BUILD_VERSION=$rebased_build_version",
]
}
if (current_toolchain == default_toolchain) {
action("gen_version_info") {
script = "//src/developer/ffx/core/version/build/gn_write_version_info.sh"
args = [
rebase_path(rebased_output_file),
rebase_path("//integration/.git"),
]
sources = [
"//integration/.git/HEAD",
"//integration/.git/index",
]
inputs =
[ "//src/developer/ffx/core/version/build/gn_write_version_info.sh" ]
outputs = [ base_output_file ]
}
}
rustc_library("lib") {
name = "ffx_build_version"
with_unit_tests = true
configs += [ ":env" ]
non_rust_deps = [
":gen_version_info($default_toolchain)",
"//build/info:latest-commit-date",
]
deps =
[ "//sdk/fidl/fuchsia.developer.bridge:fuchsia.developer.bridge-rustc" ]
sources = [ "src/lib.rs" ]
inputs = [
"$rebased_output_file",
"$rebased_build_version",
]
}
group("tests") {
testonly = true
deps = [ ":lib_test($host_toolchain)" ]
}