blob: f8e819c2389dcd10edaaf71ce0eeabdf5436cd9c [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 = "zephyr-bazel",
version = "0.0.1",
)
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "gperf", version = "3.1.bcr.1")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_python", version = "1.8.3")
# Pigweed is used to ensure that builds use the same toolchains
include("//:pigweed_dep.MODULE.bazel")
pw_cxx_toolchain = use_extension("@pigweed//pw_toolchain/cc:pw_cxx_toolchain.bzl", "pw_cxx_toolchain")
use_repo(pw_cxx_toolchain, "llvm_toolchain")
cipd_ext = use_extension("@pigweed//pw_env_setup/bazel/cipd:defs.bzl", "cipd")
use_repo(cipd_ext, linux_sysroot = "pigweed.linux_sysroot")
xcode_sdk_repository = use_repo_rule("@pigweed//pw_toolchain:xcode.bzl", "xcode_sdk_repository")
xcode_sdk_repository(
name = "macos_sysroot",
build_file = "@pigweed//pw_toolchain/host_clang:macos_sysroot.BUILD",
)
# Toolchain registration
# ======================
# Register Pigweed's C++ toolchains.
register_toolchains(
"//toolchain:all",
"@pigweed//pw_toolchain/host_clang:host_cc_toolchain_linux",
"@pigweed//pw_toolchain/host_clang:host_cc_toolchain_macos",
dev_dependency = True,
)
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "zephyr_sdk_xtensa_dc233c",
build_file = "//toolchain/xtensa:zephyr_sdk_xtensa_dc233c.BUILD",
sha256 = "db5f408c8eccd43fae4dd01ff99dbbb179773132fb239059ef8f836e4a335cd0",
strip_prefix = "xtensa-dc233c_zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/toolchain_linux-x86_64_xtensa-dc233c_zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_arm",
build_file = "//toolchain/arm:zephyr_sdk_arm.BUILD",
sha256 = "1b61084fe12076a3639aa2d028b5258f41eb3d0f7d46a16264949e1d213f1915",
strip_prefix = "arm-zephyr-eabi",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz"],
)
http_archive(
name = "zephyr_sdk_arc",
build_file = "//toolchain/arc:zephyr_sdk_arc.BUILD",
sha256 = "f3b627b591a5f5eb86eb8918da2e410bdfa1dd1318de77fb70a6ea4719487370",
strip_prefix = "arc-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_arc-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_arm64",
build_file = "//toolchain/arm64:zephyr_sdk_arm64.BUILD",
sha256 = "d3c3790cad0b7fe579dc892d7f5e84e07f67008f04f1334ed6f95a3db3f4e608",
strip_prefix = "aarch64-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_aarch64-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_mips",
build_file = "//toolchain/mips:zephyr_sdk_mips.BUILD",
sha256 = "0b6c51f8771da434a338763eb4c764410b14a47c60fe0f9f9f9cea7f9d6e6b23",
strip_prefix = "mips-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_mips-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_riscv",
build_file = "//toolchain/riscv:zephyr_sdk_riscv.BUILD",
sha256 = "45995599378db070e5cc3849f32f84bd214d98844d8edca93e13cd72d2dbc50c",
strip_prefix = "riscv64-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_riscv64-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_rx",
build_file = "//toolchain/rx:zephyr_sdk_rx.BUILD",
sha256 = "ed4637044bb01f4bc726692aa71aec7ff81a043f1ad3b57c657653f47a333ec3",
strip_prefix = "rx-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_rx-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_sparc",
build_file = "//toolchain/sparc:zephyr_sdk_sparc.BUILD",
sha256 = "b377081ad2f213db832aad00f6d07bce37a1d3dc4b7d8b72e5a93aabdf4a77e1",
strip_prefix = "sparc-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_sparc-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_x86",
build_file = "//toolchain/x86:zephyr_sdk_x86.BUILD",
sha256 = "035f99f3f2f635fe2ea01ec133f550d7f7ea47409547a9013cc6750aa765eb37",
strip_prefix = "x86_64-zephyr-elf",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/toolchain_linux-x86_64_x86_64-zephyr-elf.tar.xz"],
)
http_archive(
name = "zephyr_sdk_llvm",
urls = ["https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v1.0.1/zephyr-sdk-1.0.1_linux-x86_64_llvm.tar.xz"],
sha256 = "13b96230c90025105ec9bdc914b1ccb6c4b319f68a44518ec4e86ef293f3dce8",
strip_prefix = "zephyr-sdk-1.0.1",
build_file = "//toolchain/llvm:zephyr_sdk_llvm.BUILD",
)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
use_repo(python, "pythons_hub")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "zephyr_bazel_pip_deps",
python_version = "3.11",
requirements_lock = "//scripts:requirements-lock.txt",
)
pip.parse(
hub_name = "zephyr_bazel_pip_deps",
python_version = "3.12",
requirements_lock = "//scripts:requirements-lock.txt",
)
use_repo(pip, "zephyr_bazel_pip_deps")
zephyr_patch_file = use_extension("//:setup.bzl", "zephyr_patch_file")
zephyr_patch_file.checkout(
# The autoroller is broken. Manually update on 2025-12-12.
commit = "3568e1b6d5cdd51a6b964a2a1d6d29200fea2056",
)
use_repo(zephyr_patch_file, "zephyr", "zephyr_version")
zephyr_setup = use_extension("//:setup.bzl", "zephyr_setup")
zephyr_setup.env(
apps_dirs = ["//:examples"],
boards_dirs = ["@zephyr//boards"],
)
use_repo(
zephyr_setup,
"zephyr_index",
"zephyr_kconfig",
"zephyr_state",
)
zephyr_setup_apps = use_extension("//:setup.bzl", "zephyr_setup_apps")
# No tags needed, it reads from @zephyr_state