• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/python.gni")
18import("$dir_pw_build/python_dist.gni")
19import("$dir_pw_build/python_gn_args.gni")
20import("$dir_pw_build/python_venv.gni")
21import("$dir_pw_docgen/docs.gni")
22import("$dir_pw_unit_test/test.gni")
23
24pw_doc_group("docs") {
25  inputs = [ "doc_resources/pw_env_setup_output.png" ]
26  sources = [ "docs.rst" ]
27}
28
29pw_python_group("core_pigweed_python_packages") {
30  python_deps = [
31    "$dir_pw_allocator/py",
32    "$dir_pw_arduino_build/py",
33    "$dir_pw_bloat/py",
34    "$dir_pw_build/py",
35    "$dir_pw_build_info/py",
36    "$dir_pw_build_mcuxpresso/py",
37    "$dir_pw_chrono/py",
38    "$dir_pw_cli/py",
39    "$dir_pw_compilation_testing/py",
40    "$dir_pw_console/py",
41    "$dir_pw_cpu_exception_cortex_m/py",
42    "$dir_pw_docgen/py",
43    "$dir_pw_doctor/py",
44    "$dir_pw_env_setup/py",
45    "$dir_pw_hdlc/py",
46    "$dir_pw_ide/py",
47    "$dir_pw_log:protos.python",
48    "$dir_pw_log_tokenized/py",
49    "$dir_pw_metric/py",
50    "$dir_pw_module/py",
51    "$dir_pw_package/py",
52    "$dir_pw_presubmit/py",
53    "$dir_pw_protobuf/py",
54    "$dir_pw_protobuf_compiler/py",
55    "$dir_pw_rpc/py",
56    "$dir_pw_snapshot/py:pw_snapshot",
57    "$dir_pw_snapshot/py:pw_snapshot_metadata",
58    "$dir_pw_software_update/py",
59    "$dir_pw_status/py",
60    "$dir_pw_stm32cube_build/py",
61    "$dir_pw_symbolizer/py",
62    "$dir_pw_system/py",
63    "$dir_pw_thread/py",
64    "$dir_pw_thread_freertos/py",
65    "$dir_pw_tls_client/py",
66    "$dir_pw_tokenizer/py",
67    "$dir_pw_toolchain/py",
68    "$dir_pw_trace/py",
69    "$dir_pw_trace_tokenized/py",
70    "$dir_pw_transfer/py",
71    "$dir_pw_unit_test/py",
72    "$dir_pw_watch/py",
73  ]
74}
75pw_python_group("python") {
76  python_deps = [
77    ":core_pigweed_python_packages",
78
79    # This target creates and installs Python package named 'pigweed' including
80    # every package listed in :core_pigweed_python_packages
81    ":pip_install_pigweed_package",
82
83    # Standalone scripts
84    # These targets are included here in order to ensure they are linted.
85    "$dir_pw_hdlc/rpc_example:example_script",
86    "$dir_pw_rpc/py:python_client_cpp_server_test",
87    "$dir_pw_third_party/fuchsia:generate_fuchsia_patch",
88    "$dir_pw_third_party/nanopb:generate_nanopb_proto",
89    "$dir_pw_unit_test:test_group_metadata_test",
90  ]
91}
92
93pw_python_venv("pigweed_build_venv") {
94  path = "$root_build_dir/python-venv"
95  source_packages = [ ":core_pigweed_python_packages" ]
96}
97
98# Python packages for supporting specific targets.
99pw_python_pip_install("target_support_packages") {
100  packages = [
101    "$dir_pigweed/targets/lm3s6965evb_qemu/py",
102    "$dir_pigweed/targets/stm32f429i_disc1/py",
103  ]
104  editable = true
105}
106
107# This target is responsible for building the Python source uploaded to PyPI:
108# https://pypi.org/project/pigweed/
109pw_python_distribution("pypi_pigweed_python_source_tree") {
110  packages = [ ":core_pigweed_python_packages" ]
111  generate_setup_cfg = {
112    common_config_file = "pypi_common_setup.cfg"
113  }
114  extra_files = [
115    "$dir_pigweed/LICENSE > LICENSE",
116    "$dir_pigweed/README.md > README.md",
117    "pypi_pyproject.toml > pyproject.toml",
118  ]
119}
120
121# This target is creates the 'pigweed' Python package installed to the user's
122# dev environment. It's similar to the source tree for PyPI but it appends the
123# current date to the version so pip will consider it more up to date than the
124# one in PyPI.
125pw_python_distribution("generate_pigweed_python_package") {
126  packages = [ ":core_pigweed_python_packages" ]
127
128  generate_setup_cfg = {
129    common_config_file = "pypi_common_setup.cfg"
130    append_date_to_version = true
131    include_default_pyproject_file = true
132  }
133  extra_files = [
134    "$dir_pigweed/LICENSE > LICENSE",
135    "$dir_pigweed/README.md > README.md",
136  ]
137}
138
139# This pip installs the generate_pigweed_python_package into the user venv.
140pw_python_pip_install("pip_install_pigweed_package") {
141  packages = [ ":generate_pigweed_python_package" ]
142}
143
144# The next three targets are not built by default but demonstrate how to
145# generate Python distributions with only a subset of Python packages
146# included. The result could be bundled into PyOxidizer or distributed as a
147# standalone wheel.
148
149# To create this wheel run:
150#   ninja -C out pw_env_setup:generate_pw_env_setup_distribution.wheel
151# The resulting wheel is available in
152#   out/obj/pw_env_setup/generate_pw_env_setup_distribution._build_wheel/
153pw_python_distribution("generate_pw_env_setup_distribution") {
154  packages = [ "$dir_pw_env_setup/py" ]
155  generate_setup_cfg = {
156    common_config_file = "pypi_common_setup.cfg"
157  }
158  extra_files = [
159    "$dir_pigweed/LICENSE > LICENSE",
160    "$dir_pigweed/README.md > README.md",
161    "pypi_pyproject.toml > pyproject.toml",
162  ]
163}
164
165# To create this wheel run:
166#   ninja -C out pw_env_setup:generate_pw_system_distribution.wheel
167# The resulting wheel is available in
168#   out/obj/pw_env_setup/generate_pw_system_distribution._build_wheel/
169pw_python_distribution("generate_pw_system_distribution") {
170  packages = [ "$dir_pw_system/py" ]
171  generate_setup_cfg = {
172    common_config_file = "pypi_common_setup.cfg"
173  }
174  extra_files = [
175    "$dir_pigweed/LICENSE > LICENSE",
176    "$dir_pigweed/README.md > README.md",
177    "pypi_pyproject.toml > pyproject.toml",
178  ]
179}
180
181pw_python_group("hdlc_proto_rpc_python_packages") {
182  python_deps = [
183    "$dir_pw_hdlc/py",
184    "$dir_pw_protobuf_compiler/py",
185    "$dir_pw_rpc/py",
186    "$dir_pw_tokenizer/py",
187  ]
188}
189
190# To create this wheel run:
191#   ninja -C out pw_env_setup:generate_hdlc_proto_rpc_tokenizer_distribution.wheel
192# The resulting wheel is available in
193#   out/obj/pw_env_setup/generate_hdlc_proto_rpc_tokenizer_distribution._build_wheel/
194pw_python_distribution("generate_hdlc_proto_rpc_tokenizer_distribution") {
195  packages = [ ":hdlc_proto_rpc_python_packages" ]
196
197  generate_setup_cfg = {
198    common_config_file = "pypi_common_setup.cfg"
199    append_date_to_version = true
200  }
201  extra_files = [
202    "$dir_pigweed/LICENSE > LICENSE",
203    "$dir_pigweed/README.md > README.md",
204    "pypi_pyproject.toml > pyproject.toml",
205  ]
206}
207
208if (current_toolchain != default_toolchain) {
209  pw_test_group("tests") {
210  }
211}
212