| # Licensed under the Apache-2.0 license | |
| # SPDX-License-Identifier: Apache-2.0 | |
| module( | |
| name = "openprot", | |
| version = "0.0.1", | |
| ) | |
| bazel_dep(name = "bazel_skylib", version = "1.8.2") | |
| bazel_dep(name = "pigweed") | |
| bazel_dep(name = "platforms", version = "1.0.0") | |
| bazel_dep(name = "rules_rust", version = "0.70.0") | |
| bazel_dep(name = "rules_rust_mdbook", version = "0.70.0") | |
| bazel_dep(name = "rules_platform", version = "0.1.0") | |
| bazel_dep(name = "rules_python", version = "1.8.3") | |
| bazel_dep(name = "ureg") | |
| bazel_dep(name = "caliptra_deps", version = "0.0.0") | |
| local_path_override( | |
| module_name = "caliptra_deps", | |
| path = "third_party/caliptra", | |
| ) | |
| git_override( | |
| module_name = "pigweed", | |
| commit = "e21bf7763475a456efdcc49dafb651ef952b3be1", | |
| remote = "https://pigweed.googlesource.com/pigweed/pigweed", | |
| ) | |
| git_override( | |
| module_name = "ureg", | |
| commit = "4762ed5eef323a4267720a6b6da287c88738f901", | |
| remote = "https://github.com/chipsalliance/caliptra-ureg", | |
| ) | |
| pw_rust = use_extension("@pigweed//pw_toolchain/rust:extensions.bzl", "pw_rust") | |
| pw_rust.toolchain(cipd_tag = "git_revisions:fe5c95d4ae33ec9d7831921e448e2daf8264ea42,7b074fc9362a4a6a5f172dd8936a22fb25eff96b") | |
| use_repo(pw_rust, "pw_rust_toolchains") | |
| register_toolchains( | |
| "@pigweed//pw_toolchain/host_clang:host_cc_toolchain_linux", | |
| "@pigweed//pw_toolchain/host_clang:host_cc_toolchain_macos", | |
| "@pigweed//pw_toolchain/arm_clang:arm_clang_cc_toolchain_cortex-m4", | |
| "@pigweed//pw_toolchain/riscv_clang:riscv_clang_cc_toolchain_rv32imc", | |
| "@pw_rust_toolchains//:all", | |
| ) | |
| crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") | |
| crate.from_cargo( | |
| name = "rust_crates", | |
| cargo_lockfile = "//third_party/crates_io:Cargo.lock", | |
| manifests = ["//third_party/crates_io:Cargo.toml"], | |
| # crate_universe's defaults do not include some embedded triples so the | |
| # triples are listed explicitly. | |
| supported_platform_triples = [ | |
| # Host platforms | |
| "aarch64-unknown-linux-gnu", | |
| "x86_64-unknown-linux-gnu", | |
| "aarch64-apple-darwin", | |
| "x86_64-apple-darwin", | |
| # Target platforms | |
| "riscv32imc-unknown-none-elf", | |
| "thumbv7em-none-eabi", | |
| ], | |
| ) | |
| # mdbook preprocessors for //docs. They are host-only tools, so they get their | |
| # own crate universe instead of joining the firmware crate graph in | |
| # //third_party/crates_io. | |
| crate.from_specs( | |
| name = "rust_mdbook_plugins", | |
| cargo_lockfile = "//third_party/mdbook_plugins:Cargo.lock", | |
| supported_platform_triples = [ | |
| "aarch64-unknown-linux-gnu", | |
| "x86_64-unknown-linux-gnu", | |
| "aarch64-apple-darwin", | |
| "x86_64-apple-darwin", | |
| ], | |
| ) | |
| crate.spec( | |
| package = "mdbook-mermaid", | |
| repositories = ["rust_mdbook_plugins"], | |
| # 0.17 moved to the mdbook 0.5 preprocessor API; the mdbook shipped by | |
| # rules_rust_mdbook is 0.4. | |
| version = "=0.16.2", | |
| ) | |
| crate.spec( | |
| default_features = False, | |
| package = "mdbook", | |
| repositories = ["rust_mdbook_plugins"], | |
| # mdbook-mermaid links the mdbook library for the preprocessor protocol and | |
| # warns at build time when that version differs from the mdbook running it. | |
| # Keep this equal to the mdbook that rules_rust_mdbook ships. | |
| version = "=0.4.44", | |
| ) | |
| crate.annotation( | |
| crate = "mdbook-mermaid", | |
| gen_binaries = ["mdbook-mermaid"], | |
| repositories = ["rust_mdbook_plugins"], | |
| ) | |
| crate.annotation( | |
| # rules_rust appends these to the host C toolchain's CFLAGS. The pigweed | |
| # clang toolchain enables `-Wundef -Werror`, which rejects the `#if` on | |
| # undefined CFG_TARGET_OS_* macros when psm preprocesses its assembly. | |
| build_script_env = {"CFLAGS": "-Wno-undef"}, | |
| crate = "psm", | |
| repositories = ["rust_mdbook_plugins"], | |
| ) | |
| use_repo( | |
| crate, | |
| "rust_caliptra_crates", | |
| "rust_caliptra_crates_host", | |
| "rust_crates", | |
| "rust_mdbook_plugins", | |
| ) | |
| pw_rust_crates_ext = use_extension("@pigweed//pw_build:pw_rust_crates_extension.bzl", "pw_rust_crates_extension") | |
| # Ideally, we shouldn't need to override the pigweed `rust_crates` repo as it | |
| # requires the downstream (openprot) repo adding pigweed cargo deps to its own | |
| # Cargo.toml. This is currently needed to work around a limitation in | |
| # rules_rust and unsupported target triples. | |
| # | |
| # TODO(cfrantz): Remove this override and non-directly referenced crates | |
| # once pigweed has adopted a version of rules_rust that fixes the limitation. | |
| override_repo( | |
| pw_rust_crates_ext, | |
| rust_crates = "rust_crates", | |
| ) | |
| bazel_dep(name = "opentitan_devbundle") | |
| archive_override( | |
| module_name = "opentitan_devbundle", | |
| integrity = "sha256-LGKvET6WY+P4kwrZMSnkBrkqxS1f/ES/rmkPBQmfnwg=", | |
| url = "https://github.com/lowRISC/opentitan/releases/download/devbundle-2026-06-02-1/devbundle.tar.xz", | |
| ) | |
| # Caliptra source repositories — declared via a module_extension in | |
| # third_party/caliptra/extensions.bzl so the git_repository commits | |
| # can be driven by versions.bzl at BUILD load time. bzlmod forbids | |
| # `load()` in MODULE.bazel files directly, but allows it in .bzl | |
| # files that back module extensions — that is how CALIPTRA_VERSIONS | |
| # gets threaded from versions.bzl to the git_repository commits | |
| # here. | |
| # | |
| # A previous attempt to move these declarations via `use_repo_rule` | |
| # from the nested caliptra_deps module rolled back (Task 1.1 of | |
| # cargo_universe.md) because the repos ended up in the nested | |
| # module's namespace, invisible to the overlay BUILD files at | |
| # //third_party/caliptra/caliptra-*:overlay.BUILD. The module | |
| # extension pattern sidesteps that trap: `use_repo` below lifts the | |
| # extension's repos into the root module's namespace, so every | |
| # downstream target sees @caliptra_sw / @caliptra_mcu_sw exactly as | |
| # they did when the declarations were inline. | |
| caliptra_repos_ext = use_extension( | |
| "//third_party/caliptra:extensions.bzl", | |
| "caliptra_repos", | |
| ) | |
| use_repo(caliptra_repos_ext, "caliptra_mcu_sw", "caliptra_sw") | |
| # VCK190 subsystem bitstream matching the caliptra_mcu_sw pin above. URL and | |
| # sha256 are copied from hw/fpga/bitstream_manifests/subsystem.toml at that | |
| # commit; bump them together with the pin. | |
| http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") | |
| http_file( | |
| name = "caliptra_fpga_bitstream", | |
| downloaded_file_path = "caliptra-bitstream.pdi", | |
| sha256 = "bb4892661af8769104694e5bd307a993264460a286437e0d8bc3b2f1de60173d", | |
| urls = ["https://storage.googleapis.com/caliptra-github-ci-bitstreams/v1/a2cd177353b7f06170766f367743b98c900b1d7b/runtime_a2cd177.pdi"], | |
| ) | |
| # caliptra-ss OTP controller memory map, needed by caliptra-hw-model's build | |
| # script (fpga_subsystem). | |
| http_file( | |
| name = "caliptra_ss_otp_ctrl_mmap", | |
| downloaded_file_path = "otp_ctrl_mmap.hjson", | |
| sha256 = "7aa3729ad3b8dacd80134773fcbfa1476a8b8b05d4c340d7ff0190adbedb934b", | |
| urls = ["https://raw.githubusercontent.com/chipsalliance/caliptra-ss/01b0a3528e196f4219d20dd9cbfec3727869d5d9/src/fuse_ctrl/data/otp_ctrl_mmap.hjson"], | |
| ) | |
| nonhermetic_repo = use_repo_rule("//target/earlgrey/tooling/signing:nonhermetic.bzl", "nonhermetic_repo") | |
| nonhermetic_repo(name = "nonhermetic") | |
| # ── AST1060 Peripheral Access Crate (svd2rust-generated) ── | |
| ast1060_pac_ext = use_extension( | |
| "//third_party:ast1060_pac.bzl", | |
| "ast1060_pac_ext", | |
| ) | |
| use_repo(ast1060_pac_ext, "ast1060_pac", "vcell") | |
| hsm = use_extension("//third_party/hsm:extensions.bzl", "hsm") | |
| use_repo(hsm, "cloud_kms_hsm") | |
| # ── lowRISC QEMU (ot-earlgrey machine for earlgrey QEMU tests) ── | |
| # Tag v10.2.0-2026-01-15, sha256 9e97f93b... (locked in third_party/qemu/extensions.bzl). | |
| qemu = use_extension("//third_party/qemu:extensions.bzl", "qemu") | |
| use_repo(qemu, "qemu_opentitan", "qemu_opentitan_src") | |
| # ── Python deps for QEMU tooling scripts (cfggen, flashgen) ── | |
| python = use_extension("@rules_python//python/extensions:python.bzl", "python") | |
| python.toolchain( | |
| is_default = True, | |
| python_version = "3.12", | |
| ) | |
| pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") | |
| pip.parse( | |
| # AMD's Zscaler proxy intercepts TLS to pypi.org with its own cert; skip | |
| # transport verification. Package integrity is still enforced via the | |
| # sha256 hashes in requirements_lock. | |
| extra_pip_args = [ | |
| "--trusted-host", | |
| "pypi.org", | |
| "--trusted-host", | |
| "files.pythonhosted.org", | |
| ], | |
| hub_name = "openprot_python_deps", | |
| python_version = "3.12", | |
| requirements_lock = "//third_party/qemu:requirements.txt", | |
| ) | |
| use_repo(pip, "openprot_python_deps") |