xref: /aosp_15_r20/external/pigweed/pw_digital_io_linux/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
16
17package(default_visibility = ["//visibility:public"])
18
19licenses(["notice"])
20
21cc_library(
22    name = "pw_digital_io_linux",
23    srcs = [
24        "digital_io.cc",
25        "log_errno.h",
26        "notifier.cc",
27    ],
28    hdrs = [
29        "public/pw_digital_io_linux/digital_io.h",
30        "public/pw_digital_io_linux/internal/owned_fd.h",
31        "public/pw_digital_io_linux/notifier.h",
32    ],
33    strip_include_prefix = "public",
34    target_compatible_with = ["@platforms//os:linux"],
35    deps = [
36        "//pw_digital_io",
37        "//pw_log",
38        "//pw_result",
39        "//pw_status",
40        "//pw_sync:lock_annotations",
41        "//pw_sync:mutex",
42        "//pw_thread:thread",
43    ],
44)
45
46cc_binary(
47    name = "pw_digital_io_linux_cli",
48    srcs = [
49        "digital_io_cli.cc",
50    ],
51    deps = [
52        ":pw_digital_io_linux",
53        "//pw_build:default_link_extra_lib",
54        "//pw_log",
55    ],
56)
57
58# TODO(b/328262654): Move this to a more appropriate module.
59cc_library(
60    name = "mock_vfs",
61    srcs = [
62        "log_errno.h",
63        "mock_vfs.cc",
64    ],
65    hdrs = ["mock_vfs.h"],
66    target_compatible_with = ["@platforms//os:linux"],
67    deps = [
68        "//pw_assert",
69        "//pw_log",
70    ],
71)
72
73pw_cc_test(
74    name = "digital_io_test",
75    srcs = [
76        "digital_io_test.cc",
77    ],
78    linkopts = [
79        "-Wl,--wrap=close",
80        "-Wl,--wrap=ioctl",
81        "-Wl,--wrap=read",
82    ],
83    deps = [
84        ":mock_vfs",
85        ":pw_digital_io_linux",
86        "//pw_assert",
87        "//pw_log",
88        "//pw_sync:mutex",
89        "//pw_sync:timed_thread_notification",
90        "//pw_thread:thread",
91        "//pw_thread_stl:thread",
92    ],
93)
94
95pw_cc_test(
96    name = "notifier_test",
97    srcs = [
98        "log_errno.h",
99        "notifier_test.cc",
100    ],
101    target_compatible_with = ["@platforms//os:linux"],
102    deps = [
103        ":pw_digital_io_linux",
104        "//pw_assert",
105        "//pw_log",
106        "//pw_sync:counting_semaphore",
107        "//pw_thread:thread",
108        "//pw_thread_stl:thread",
109    ],
110)
111