• 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_python//python:defs.bzl", "py_library")
16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
18load("//pw_build:python.bzl", "pw_py_binary", "pw_py_test")
19
20package(default_visibility = ["//visibility:public"])
21
22py_library(
23    name = "pw_sensor",
24    srcs = [
25        "pw_sensor/__init__.py",
26        "pw_sensor/constants_generator.py",
27        "pw_sensor/sensor_desc.py",
28        "pw_sensor/validator.py",
29    ],
30    data = [
31        ":base_schemas",
32        ":pw_sensor/templates/cpp_constants.jinja",
33    ],
34    imports = ["."],
35    deps = [
36        "@python_packages//jinja2",
37        "@python_packages//jsonschema",
38        "@python_packages//pyyaml",
39    ],
40)
41
42pw_py_binary(
43    name = "constants_generator",
44    srcs = [
45        "pw_sensor/constants_generator.py",
46    ],
47    data = [
48        ":pw_sensor/templates/cpp_constants.jinja",
49    ],
50    imports = ["."],
51    deps = [
52        ":pw_sensor",
53        "@python_packages//jinja2",
54        "@python_packages//pyyaml",
55    ],
56)
57
58pw_py_binary(
59    name = "sensor_desc",
60    srcs = ["pw_sensor/sensor_desc.py"],
61    imports = ["."],
62    deps = [
63        ":pw_sensor",
64        "@python_packages//pyyaml",
65    ],
66)
67
68filegroup(
69    name = "base_schemas",
70    srcs = [
71        "pw_sensor/dependency_schema.json",
72        "pw_sensor/metadata_schema.json",
73        "pw_sensor/resolved_schema.json",
74    ],
75)
76
77pw_py_test(
78    name = "validator_test",
79    srcs = ["validator_test.py"],
80    deps = [
81        ":pw_sensor",
82        "@python_packages//jsonschema",
83        "@python_packages//pyyaml",
84    ],
85)
86
87sphinx_docs_library(
88    name = "docs",
89    srcs = [
90        "docs.rst",
91    ],
92    target_compatible_with = incompatible_with_mcu(),
93)
94