blob: 0bc239a55b08e4339164172a489717253386f271 [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.
load("@pigweed//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("@rules_rust_bindgen//:defs.bzl", "rust_bindgen_library")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "pw_sync_spinlock_backend_freertos_config_header",
hdrs = [
"pw_sync_spinlock_backend_freertos_config.h",
],
target_compatible_with = [
"//pw_build/constraints/rtos:freertos",
],
deps = [
"//pw_sync_freertos:config",
],
)
rust_bindgen_library(
name = "pw_sync_spinlock_backend_freertos_config",
bindgen_flags = [
"--rust-edition",
"2021",
"--use-core",
"--raw-line",
"#![no_std]",
"--raw-line",
"#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]",
],
cc_lib = ":pw_sync_spinlock_backend_freertos_config_header",
clang_flags = [
"-x",
"c++",
"-Wno-pragma-once-outside-header",
"-Wno-unused-const-variable",
],
edition = "2021",
header = "pw_sync_spinlock_backend_freertos_config.h",
merge_cc_lib_objects_into_rlib = False,
target_compatible_with = [
"//pw_build/constraints/rtos:freertos",
],
)
rust_library(
name = "pw_sync_spinlock_core",
srcs = [
"pw_sync_spinlock_core.rs",
],
edition = "2021",
)
rust_library(
name = "pw_sync_spinlock",
srcs = [
"pw_sync_spinlock.rs",
],
edition = "2021",
deps = [
":pw_sync_spinlock_backend",
":pw_sync_spinlock_core",
],
)
rust_library(
name = "pw_sync_spinlock_backend_std",
srcs = [
"pw_sync_spinlock_backend_std.rs",
],
crate_name = "pw_sync_spinlock_backend",
edition = "2021",
target_compatible_with = incompatible_with_mcu(),
deps = [
":pw_sync_spinlock_core",
],
)
rust_library(
name = "pw_sync_spinlock_backend_freertos",
srcs = [
"pw_sync_spinlock_backend_freertos.rs",
],
crate_name = "pw_sync_spinlock_backend",
edition = "2021",
target_compatible_with = ["//pw_build/constraints/rtos:freertos"],
deps = [
":pw_sync_spinlock_backend_freertos_config",
":pw_sync_spinlock_core",
"//pw_assert/rust:pw_assert",
"//third_party/freertos/freertos_sys",
],
)
label_flag(
name = "pw_sync_spinlock_backend",
build_setting_default = ":pw_sync_spinlock_backend_std",
visibility = ["//visibility:public"],
)
rust_test(
name = "pw_sync_spinlock_test",
srcs = [
"pw_sync_spinlock_test.rs",
],
edition = "2021",
target_compatible_with = incompatible_with_mcu(),
deps = [
":pw_sync_spinlock",
],
)