1load("@rules_rust//rust:defs.bzl", "rust_binary") 2 3package(default_visibility = ["//visibility:public"]) 4 5rust_binary( 6 name = "version_reporter", 7 srcs = ["src/main.rs"], 8 rustc_env_files = [":generate_rustc_env_file"], 9) 10 11# See https://docs.bazel.build/versions/master/user-manual.html#workspace_status for more information. 12genrule( 13 name = "generate_rustc_env_file", 14 outs = ["rustc_env_file"], 15 cmd = "echo \"CARGO_PKG_VERSION=0.1.0-$$(awk '$$1 == \"BUILD_TIMESTAMP\" {print $$2}' bazel-out/volatile-status.txt)\" > $@", 16 stamp = True, 17) 18