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