blob: 1505eaa9eae27d328dc564a39053051a603de477 [file]
# 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.16")
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/arc:arc_gcc_cc",
"@zephyr-bazel//toolchain/arm64:arm64_gcc_cc",
dev_dependency = True,
)
# Zephyr setup
# ============
zephyr_patch = use_extension("@zephyr-bazel//:setup.bzl", "zephyr_patch_file")
zephyr_patch.checkout(
# The autoroller is broken. Manually update on 2025-12-12.
commit = "3568e1b6d5cdd51a6b964a2a1d6d29200fea2056",
)
# 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")
new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
new_git_repository(
name = "hal_nordic",
build_file = "@zephyr-bazel//modules:hal_nordic.BUILD",
commit = "7858281d843468fe53c829995fb63f45a227387a",
remote = "https://github.com/zephyrproject-rtos/hal_nordic.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_xtensa",
build_file = "@zephyr-bazel//modules:hal_xtensa.BUILD",
commit = "3cc9e3a9360be5c96c956dce84064b85439b6769",
remote = "https://github.com/zephyrproject-rtos/hal_xtensa.git",
)
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",
)
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 = [],
manual_boards = [
"nrf52833dk/nrf52833",
"native_sim",
"qemu_arc/qemu_arc_em",
"qemu_cortex_a53",
],
modules = [
"@hal_atmel//:zephyr/module.yml",
"@hal_xtensa//: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")