• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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
22licenses(["notice"])
23
24py_library(
25    name = "pw_build",
26    srcs = [
27        "pw_build/__init__.py",
28        "pw_build/bazel_query.py",
29        "pw_build/bazel_to_gn.py",
30        "pw_build/build_recipe.py",
31        "pw_build/collect_wheels.py",
32        "pw_build/copy_and_patch.py",
33        "pw_build/copy_from_cipd.py",
34        "pw_build/create_gn_venv.py",
35        "pw_build/create_python_tree.py",
36        "pw_build/error.py",
37        "pw_build/exec.py",
38        "pw_build/file_prefix_map.py",
39        "pw_build/generate_cc_blob_library.py",
40        "pw_build/generate_modules_lists.py",
41        "pw_build/generate_python_package.py",
42        "pw_build/generate_python_package_gn.py",
43        "pw_build/generate_python_requirements.py",
44        "pw_build/generate_python_wheel.py",
45        "pw_build/generate_python_wheel_cache.py",
46        "pw_build/generate_report.py",
47        "pw_build/generated_tests.py",
48        "pw_build/gn_resolver.py",
49        "pw_build/gn_target.py",
50        "pw_build/gn_writer.py",
51        "pw_build/host_tool.py",
52        "pw_build/merge_profraws.py",
53        "pw_build/mirror_tree.py",
54        "pw_build/nop.py",
55        "pw_build/pip_install_python_deps.py",
56        "pw_build/python_package.py",
57        "pw_build/python_runner.py",
58        "pw_build/runfiles_manager.py",
59        "pw_build/wrap_ninja.py",
60        "pw_build/zip.py",
61    ],
62    imports = ["."],
63    deps = [
64        "//pw_cli/py:pw_cli",
65        "//pw_config_loader/py:pw_config_loader",
66        "//pw_presubmit/py:pw_presubmit",
67    ],
68)
69
70py_library(
71    name = "pw_project_builder",
72    srcs = [
73        "pw_build/project_builder.py",
74        "pw_build/project_builder_argparse.py",
75        "pw_build/project_builder_context.py",
76        "pw_build/project_builder_prefs.py",
77        "pw_build/project_builder_presubmit_runner.py",
78    ],
79    imports = ["."],
80    deps = [
81        ":pw_build",
82    ],
83)
84
85py_library(
86    name = "python_runfiles",
87    srcs = ["pw_build/python_runfiles.py"],
88    imports = ["."],
89)
90
91pw_py_binary(
92    name = "generate_cc_blob_library",
93    srcs = [
94        "pw_build/generate_cc_blob_library.py",
95    ],
96)
97
98pw_py_binary(
99    name = "copy_and_patch",
100    srcs = ["pw_build/copy_and_patch.py"],
101    deps = ["@python_packages//patch"],
102)
103
104pw_py_binary(
105    name = "pigweed_upstream_build",
106    srcs = ["pw_build/pigweed_upstream_build.py"],
107    deps = [
108        ":pw_project_builder",
109        "//pw_watch/py:pw_watch",
110    ],
111)
112
113pw_py_binary(
114    name = "project_builder",
115    srcs = ["pw_build/project_builder.py"],
116    deps = [
117        ":pw_project_builder",
118    ],
119)
120
121pw_py_test(
122    name = "bazel_query_test",
123    size = "small",
124    srcs = [
125        "bazel_query_test.py",
126    ],
127    deps = [
128        ":pw_build",
129    ],
130)
131
132pw_py_test(
133    name = "bazel_to_gn_test",
134    size = "small",
135    srcs = [
136        "bazel_to_gn_test.py",
137    ],
138    deps = [
139        ":pw_build",
140    ],
141)
142
143pw_py_test(
144    name = "create_python_tree_test",
145    size = "small",
146    srcs = [
147        "create_python_tree_test.py",
148    ],
149    # TODO(b/373956968): Bazel support for generated Python packages.
150    tags = ["manual"],
151    deps = [
152        ":pw_build",
153        "@python_packages//parameterized",
154    ],
155)
156
157pw_py_test(
158    name = "file_prefix_map_test",
159    size = "small",
160    srcs = [
161        "file_prefix_map_test.py",
162    ],
163    deps = [
164        ":pw_build",
165    ],
166)
167
168pw_py_test(
169    name = "generate_cc_blob_library_test",
170    size = "small",
171    srcs = [
172        "generate_cc_blob_library_test.py",
173    ],
174    deps = [
175        ":pw_build",
176    ],
177)
178
179pw_py_test(
180    name = "gn_target_test",
181    size = "small",
182    srcs = [
183        "gn_target_test.py",
184    ],
185    deps = [
186        ":pw_build",
187    ],
188)
189
190pw_py_test(
191    name = "gn_writer_test",
192    size = "small",
193    srcs = [
194        "gn_writer_test.py",
195    ],
196    # TODO(b/314139942): Requires GN on the path.
197    tags = ["manual"],
198    deps = [
199        ":pw_build",
200    ],
201)
202
203pw_py_test(
204    name = "python_runner_test",
205    size = "small",
206    srcs = [
207        "python_runner_test.py",
208    ],
209    deps = [
210        ":pw_build",
211    ],
212)
213
214pw_py_test(
215    name = "zip_test",
216    size = "small",
217    srcs = [
218        "zip_test.py",
219    ],
220    deps = [
221        ":pw_build",
222    ],
223)
224
225pw_py_test(
226    name = "py_runfiles_test",
227    size = "small",
228    srcs = [
229        "py_runfiles_test.py",
230    ],
231    deps = [
232        "//pw_build:test_runfile",
233        "//pw_build:test_runfile_remapped",
234        "@pw_build_external_runfile_resource//:black",
235    ],
236)
237
238pw_py_test(
239    name = "runfiles_manager_test",
240    size = "small",
241    srcs = [
242        "runfiles_manager_test.py",
243    ],
244    deps = [
245        ":pw_build",
246        "//pw_build:test_runfile",
247        "//pw_build:test_runfile_remapped",
248        "@pw_build_external_runfile_resource//:black",
249    ],
250)
251
252pw_py_test(
253    name = "build_recipe_test",
254    size = "small",
255    srcs = [
256        "build_recipe_test.py",
257    ],
258    deps = [
259        ":pw_project_builder",
260        "@python_packages//parameterized",
261    ],
262)
263
264pw_py_test(
265    name = "project_builder_prefs_test",
266    size = "small",
267    srcs = [
268        "project_builder_prefs_test.py",
269    ],
270    deps = [
271        ":pw_project_builder",
272        "@python_packages//parameterized",
273    ],
274)
275
276sphinx_docs_library(
277    name = "docs",
278    srcs = [
279        "gn_tests/BUILD.gn",
280        "pw_build/generate_python_wheel_cache.py",
281    ],
282    target_compatible_with = incompatible_with_mcu(),
283)
284