• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
16load("@rules_cc//cc:cc_library.bzl", "cc_library")
17load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
18load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
19load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
20
21package(
22    default_visibility = ["//visibility:public"],
23    features = ["-layering_check"],
24)
25
26licenses(["notice"])
27
28cc_library(
29    name = "pw_digital_io_linux",
30    srcs = [
31        "digital_io.cc",
32        "log_errno.h",
33        "notifier.cc",
34    ],
35    hdrs = [
36        "public/pw_digital_io_linux/digital_io.h",
37        "public/pw_digital_io_linux/internal/owned_fd.h",
38        "public/pw_digital_io_linux/notifier.h",
39    ],
40    implementation_deps = ["//pw_assert:check"],
41    strip_include_prefix = "public",
42    target_compatible_with = ["@platforms//os:linux"],
43    deps = [
44        "//pw_digital_io",
45        "//pw_log",
46        "//pw_result",
47        "//pw_status",
48        "//pw_sync:lock_annotations",
49        "//pw_sync:mutex",
50        "//pw_thread:thread",
51        "//pw_thread:thread_core",
52    ],
53)
54
55cc_binary(
56    name = "pw_digital_io_linux_cli",
57    srcs = [
58        "digital_io_cli.cc",
59    ],
60    deps = [
61        ":pw_digital_io_linux",
62        "//pw_build:default_link_extra_lib",
63        "//pw_log",
64    ],
65)
66
67# TODO(b/328262654): Move this to a more appropriate module.
68cc_library(
69    name = "mock_vfs",
70    srcs = [
71        "log_errno.h",
72        "mock_vfs.cc",
73    ],
74    hdrs = ["mock_vfs.h"],
75    implementation_deps = ["//pw_assert:check"],
76    target_compatible_with = ["@platforms//os:linux"],
77    deps = ["//pw_log"],
78)
79
80pw_cc_test(
81    name = "digital_io_test",
82    srcs = [
83        "digital_io_test.cc",
84    ],
85    linkopts = [
86        "-Wl,--wrap=close",
87        "-Wl,--wrap=ioctl",
88        "-Wl,--wrap=read",
89    ],
90    deps = [
91        ":mock_vfs",
92        ":pw_digital_io_linux",
93        "//pw_log",
94        "//pw_sync:mutex",
95        "//pw_sync:timed_thread_notification",
96        "//pw_thread:thread",
97        "//pw_thread_stl:thread",
98    ],
99)
100
101pw_cc_test(
102    name = "notifier_test",
103    srcs = [
104        "log_errno.h",
105        "notifier_test.cc",
106    ],
107    target_compatible_with = ["@platforms//os:linux"],
108    deps = [
109        ":pw_digital_io_linux",
110        "//pw_assert:check",
111        "//pw_log",
112        "//pw_sync:counting_semaphore",
113        "//pw_thread:thread",
114        "//pw_thread_stl:thread",
115    ],
116)
117
118sphinx_docs_library(
119    name = "docs",
120    srcs = [
121        "docs.rst",
122        "//pw_digital_io_linux/examples:docs",
123    ],
124    prefix = "pw_digital_io_linux/",
125    target_compatible_with = incompatible_with_mcu(),
126)
127