# Copyright Materialize, Inc. and contributors. All rights reserved. # # Use of this software is governed by the Business Source License # included in the LICENSE file at the root of this repository. # # As of the Change Date specified in that file, in accordance with # the Business Source License, use of this software will be governed # by the Apache License, Version 2.0. load(":build_info.bzl", "gen_build_info") """ This BUILD file ties together all the pieces related to getting the current workspace status/build info. The process works in the following way: 1. Bazel invokes `workspace_status.py` via the `--workspace_status_command` argument defined in our `.bazelrc`. This python script is what gets the current git hash, and Bazel then writes it out to a file. 2. The 'gen_rust_module' target, (which is a `py_binary`), allows us to call the `gen_rust_module.py` script. This python script generates a Rust file with the static variables created in step 1. 3. The `gen_build_info` rule (which we define in 'build_info.bzl') gets access to the Bazel created files in step 1, and then calls the python script from step 2, providing these paths as arguments. This rule also defines the generated Rust file as output, so Bazel can track it and other rules can depend on it. 4. Crates like `mz-build-info` can then depend on the 'gen_build_info' target in this BUILD file, to get access to the generated Rust file. """ py_binary( name = "gen_rust_module", srcs = ["gen_rust_module.py"], ) gen_build_info( name = "gen_build_info", rust_file = "build_info.rs", visibility = ["//visibility:public"], ) config_setting( name = "stamped", values = {"stamp": "true"}, )