blob: 79ec4dac6fc1df6e4d38b52eb8bad800a8861c98 [file] [edit]
# Copyright 2026 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
module(
name = "examples",
version = "0.0.1",
)
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_platform", version = "0.1.0")
bazel_dep(name = "rules_python", version = "1.8.3")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "zephyr-bazel")
bazel_dep(name = "protobuf", version = "33.4")
include("//:pigweed_dep.MODULE.bazel")
# Module overrides
# ================
local_path_override(
module_name = "zephyr-bazel",
path = "..",
)
# Configure Pigweed to use zephyr-bazel
# =====================================
pw_zephyr_config = use_extension("@pigweed//zephyr/config:pw_zephyr_config.bzl", "pw_zephyr_config")
override_repo(
pw_zephyr_config,
kconfig = "zephyr_kconfig",
zephyr = "zephyr",
zephyr_version = "zephyr_version",
)
# Toolchain registration
# ======================
# Register Pigweed's C++ toolchains.
register_toolchains(
"@pigweed//pw_toolchain/host_clang:host_cc_toolchain_linux",
"@pigweed//pw_toolchain/host_clang:host_cc_toolchain_macos",
"@zephyr-bazel//toolchain/xtensa:xtensa_gcc_cc_dc233c",
"@zephyr-bazel//toolchain/arm:cortex-m_gcc_cc_cortex-m4",
"@zephyr-bazel//toolchain/arm:cortex-m_gcc_cc_cortex-m7",
"@zephyr-bazel//toolchain/arm:cortex-m_gcc_cc_cortex-m33",
"@zephyr-bazel//toolchain/arc:arc_gcc_cc",
"@zephyr-bazel//toolchain/arm64:arm64_gcc_cc",
"@zephyr-bazel//toolchain/mips:mips_gcc_cc",
"@zephyr-bazel//toolchain/riscv:riscv_gcc_cc",
"@zephyr-bazel//toolchain/rx:rx_gcc_cc",
"@zephyr-bazel//toolchain/sparc:sparc_gcc_cc",
"@zephyr-bazel//toolchain/x86:x86_gcc_cc",
dev_dependency = True,
)
# Register native_sim execution platform, so it can be used for tests.
register_execution_platforms(
"@zephyr//boards/native/native_sim:native",
)
# Zephyr setup
# ============
zephyr_patch = use_extension("@zephyr-bazel//:setup.bzl", "zephyr_patch_file")
zephyr_patch.checkout(
# The autoroller is broken. Manually update on 2026-5-8.
commit = "684c9e8f32e4373a21098559f748f06915f950c9",
patches = [
"//patches/zephyr:0001-dts-bindings-adc-Add-Atmosic-ADC-gain-values.patch",
"//patches/zephyr:0002-cortex-m-systick-add-sys-clock-correct.patch",
],
)
# Get access to the patched zephyr repo.
use_repo(zephyr_patch, "zephyr", "zephyr_version")
inject_repo(zephyr_patch, "hal_nordic")
inject_repo(zephyr_patch, "hal_atmel")
inject_repo(zephyr_patch, "hal_xtensa")
inject_repo(zephyr_patch, "cmsis_6")
inject_repo(zephyr_patch, "openair")
new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
new_git_repository(
name = "cmsis_6",
build_file = "@zephyr-bazel//modules:cmsis_6.BUILD",
commit = "30a859f44ef8ab4dc8f84b03ed586fd16ccf9d74",
remote = "https://github.com/zephyrproject-rtos/CMSIS_6.git",
)
new_git_repository(
name = "hal_atmel",
build_file = "@zephyr-bazel//modules:hal_atmel.BUILD",
commit = "56d60ebc909ad065bf6554cee73487969857614b",
remote = "https://github.com/zephyrproject-rtos/hal_atmel.git",
)
new_git_repository(
name = "hal_nordic",
build_file = "@zephyr-bazel//modules:hal_nordic.BUILD",
commit = "44fd3d44b15cb75f80a25b4679f91d2787e28664",
remote = "https://github.com/zephyrproject-rtos/hal_nordic.git",
)
new_git_repository(
name = "hal_xtensa",
build_file = "@zephyr-bazel//modules:hal_xtensa.BUILD",
commit = "3cc9e3a9360be5c96c956dce84064b85439b6769",
remote = "https://github.com/zephyrproject-rtos/hal_xtensa.git",
)
new_git_repository(
name = "openair",
build_file = "@zephyr-bazel//modules:openair.BUILD",
commit = "bbcce66481a2b082a4c195bc11ab1f2298c4fefb",
remote = "https://github.com/atmosic/openair",
patches = [
"//patches/openair:0001-add-full-name-to-boards.patch",
],
patch_args = ["-p1"],
)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
# Only set when you have multiple toolchain versions.
is_default = True,
python_version = "3.11",
)
use_repo(python, "pythons_hub")
# Pip dependencies are provided by zephyr-bazel
zephyr_setup = use_extension("@zephyr-bazel//:setup.bzl", "zephyr_setup")
zephyr_setup.env(
apps_dirs = ["//:MODULE.bazel"],
boards_dirs = [
"@openair//:BUILD.bazel",
],
manual_boards = [
"nrf52833dk/nrf52833",
"native_sim/native",
"qemu_arc/qemu_arc_em",
"qemu_cortex_a53/qemu_cortex_a53",
"qemu_leon3/leon3",
"qemu_malta/qemu_malta/be",
"qemu_riscv32/qemu_virt_riscv32",
"qemu_rx/r5f562n8",
"qemu_x86_64/atom",
],
modules = [
"@hal_atmel//:zephyr/module.yml",
"@hal_xtensa//:zephyr/module.yml",
"@openair//:zephyr/module.yml",
"@pigweed//zephyr:module.yml",
],
)
use_repo(
zephyr_setup,
"zephyr_index",
"zephyr_kconfig",
"zephyr_state",
)
zephyr_setup_apps = use_extension("@zephyr-bazel//:setup.bzl", "zephyr_setup_apps")
inject_repo(zephyr_setup_apps, "openair")