BUILD.bazel 1.7 KB

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