| # Copyright 2020 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| import("//build_overrides/pigweed.gni") |
| |
| import("$dir_pw_build/python.gni") |
| import("$dir_pw_build/python_dist.gni") |
| import("$dir_pw_build/python_gn_args.gni") |
| import("$dir_pw_build/python_venv.gni") |
| import("$dir_pw_docgen/docs.gni") |
| import("$dir_pw_unit_test/test.gni") |
| |
| pw_doc_group("docs") { |
| inputs = [ "doc_resources/pw_env_setup_output.png" ] |
| sources = [ "docs.rst" ] |
| } |
| |
| _pigweed_python_deps = [ |
| # Python packages |
| "$dir_pw_allocator/py", |
| "$dir_pw_arduino_build/py", |
| "$dir_pw_bloat/py", |
| "$dir_pw_build/py", |
| "$dir_pw_build_info/py", |
| "$dir_pw_build_mcuxpresso/py", |
| "$dir_pw_cli/py", |
| "$dir_pw_compilation_testing/py", |
| "$dir_pw_console/py", |
| "$dir_pw_cpu_exception_cortex_m/py", |
| "$dir_pw_docgen/py", |
| "$dir_pw_doctor/py", |
| "$dir_pw_env_setup/py", |
| "$dir_pw_hdlc/py", |
| "$dir_pw_log:protos.python", |
| "$dir_pw_log_tokenized/py", |
| "$dir_pw_metric/py", |
| "$dir_pw_module/py", |
| "$dir_pw_package/py", |
| "$dir_pw_presubmit/py", |
| "$dir_pw_protobuf/py", |
| "$dir_pw_protobuf_compiler/py", |
| "$dir_pw_rpc/py", |
| "$dir_pw_snapshot/py:pw_snapshot", |
| "$dir_pw_snapshot/py:pw_snapshot_metadata", |
| "$dir_pw_software_update/py", |
| "$dir_pw_status/py", |
| "$dir_pw_stm32cube_build/py", |
| "$dir_pw_symbolizer/py", |
| "$dir_pw_system/py", |
| "$dir_pw_thread/py", |
| "$dir_pw_tls_client/py", |
| "$dir_pw_tokenizer/py", |
| "$dir_pw_toolchain/py", |
| "$dir_pw_trace/py", |
| "$dir_pw_trace_tokenized/py", |
| "$dir_pw_transfer/py", |
| "$dir_pw_unit_test/py", |
| "$dir_pw_watch/py", |
| ] |
| |
| pw_python_group("python") { |
| python_deps = _pigweed_python_deps |
| if (pw_build_USE_NEW_PYTHON_BUILD) { |
| # This target creates and installs Python package named 'pigweed' including |
| # every package listed in _pigweed_python_deps. |
| python_deps += [ ":pip_install_pigweed_package" ] |
| } |
| python_deps += [ |
| # Standalone scripts |
| "$dir_pw_hdlc/rpc_example:example_script", |
| "$dir_pw_rpc/py:python_client_cpp_server_test", |
| "$dir_pw_third_party/nanopb:generate_nanopb_proto", |
| "$dir_pw_transfer/py:python_cpp_transfer_test", |
| |
| # TODO(b/232800695): Remove when all projects are on the new Python build. |
| # Python requirements for CIPD packages that don't have dedicated modules. |
| ":renode_requirements", |
| ] |
| } |
| |
| if (pw_build_USE_NEW_PYTHON_BUILD) { |
| pw_python_venv("pigweed_build_venv") { |
| path = "$root_build_dir/python-venv" |
| constraints = pw_build_PIP_CONSTRAINTS |
| requirements = pw_build_PIP_REQUIREMENTS |
| source_packages = _pigweed_python_deps |
| } |
| |
| # TODO(tonymd): Remove this target after this CL lands and rolls to all projects. |
| group("install_3p_deps") { |
| public_deps = [ pw_build_PYTHON_BUILD_VENV ] |
| } |
| } else { |
| group("pigweed_build_venv") { |
| } |
| group("install_3p_deps") { |
| } |
| } |
| |
| # Python packages for supporting specific targets. |
| if (pw_build_USE_NEW_PYTHON_BUILD) { |
| pw_internal_pip_install("target_support_packages") { |
| packages = [ |
| "$dir_pigweed/targets/lm3s6965evb_qemu/py", |
| "$dir_pigweed/targets/stm32f429i_disc1/py", |
| ] |
| editable = true |
| } |
| } else { |
| pw_python_group("target_support_packages") { |
| python_deps = [ |
| "$dir_pigweed/targets/lm3s6965evb_qemu/py", |
| "$dir_pigweed/targets/stm32f429i_disc1/py", |
| ] |
| } |
| } |
| |
| # TODO(b/232800695): Remove when all projects are on the new Python build. |
| pw_python_requirements("renode_requirements") { |
| requirements = [ |
| "psutil", |
| "pyyaml", |
| "robotframework==3.1", |
| ] |
| } |
| |
| # This target creates a Python source tree with some included bazel build files. |
| pw_create_python_source_tree("build_pigweed_python_source_tree") { |
| packages = _pigweed_python_deps |
| include_tests = true |
| extra_files = [ |
| "$dir_pigweed/pw_build/py/BUILD.bazel > pw_build/BUILD.bazel", |
| "$dir_pigweed/pw_cli/py/BUILD.bazel > pw_cli/BUILD.bazel", |
| "$dir_pigweed/pw_hdlc/py/BUILD.bazel > pw_hdlc/BUILD.bazel", |
| "$dir_pigweed/pw_protobuf/py/BUILD.bazel > pw_protobuf/BUILD.bazel", |
| "$dir_pigweed/pw_protobuf_compiler/py/BUILD.bazel > pw_protobuf_compiler/BUILD.bazel", |
| "$dir_pigweed/pw_rpc/py/BUILD.bazel > pw_rpc/BUILD.bazel", |
| "$dir_pigweed/pw_status/py/BUILD.bazel > pw_status/BUILD.bazel", |
| ] |
| } |
| |
| # This target is responsible for building the Python source uploaded to PyPI: |
| # https://pypi.org/project/pigweed/ |
| pw_create_python_source_tree("pypi_pigweed_python_source_tree") { |
| packages = _pigweed_python_deps |
| generate_setup_cfg = { |
| common_config_file = "pypi_common_setup.cfg" |
| } |
| extra_files = [ |
| "$dir_pigweed/LICENSE > LICENSE", |
| "$dir_pigweed/README.md > README.md", |
| "pypi_pyproject.toml > pyproject.toml", |
| ] |
| } |
| |
| pw_create_python_source_tree("pypi_pw_env_setup") { |
| packages = [ "$dir_pw_env_setup/py" ] |
| generate_setup_cfg = { |
| common_config_file = "pypi_common_setup.cfg" |
| } |
| extra_files = [ |
| "$dir_pigweed/LICENSE > LICENSE", |
| "$dir_pigweed/README.md > README.md", |
| "pypi_pyproject.toml > pyproject.toml", |
| ] |
| } |
| |
| pw_create_python_source_tree("pypi_pw_system") { |
| packages = [ "$dir_pw_system/py" ] |
| generate_setup_cfg = { |
| common_config_file = "pypi_common_setup.cfg" |
| } |
| extra_files = [ |
| "$dir_pigweed/LICENSE > LICENSE", |
| "$dir_pigweed/README.md > README.md", |
| "pypi_pyproject.toml > pyproject.toml", |
| ] |
| } |
| |
| if (pw_build_USE_NEW_PYTHON_BUILD) { |
| # This target is creates the 'pigweed' Python package installed to the user's |
| # dev environment. It's similar to the source tree for PyPI but it appends the |
| # current date to the version so pip will consider it more up to date than the |
| # one in PyPI. |
| pw_create_python_source_tree("generate_pigweed_python_package") { |
| packages = _pigweed_python_deps |
| public_deps = _pigweed_python_deps |
| |
| generate_setup_cfg = { |
| common_config_file = "pypi_common_setup.cfg" |
| append_date_to_version = true |
| } |
| extra_files = [ |
| "$dir_pigweed/LICENSE > LICENSE", |
| "$dir_pigweed/README.md > README.md", |
| "pypi_pyproject.toml > pyproject.toml", |
| ] |
| } |
| |
| _hdlc_proto_rpc_tokenizer = [ |
| "$dir_pw_hdlc/py", |
| "$dir_pw_protobuf_compiler/py", |
| "$dir_pw_rpc/py", |
| "$dir_pw_tokenizer/py", |
| ] |
| |
| # Create a Python distributeable with just pw_hdlc, pw_protobuf_compiler, |
| # pw_rpc, pw_tokenizer and their dependencies. |
| pw_create_python_source_tree( |
| "generate_pigweed_python_package_with_only_hdlc_proto_rpc_tokenizer") { |
| packages = _hdlc_proto_rpc_tokenizer |
| public_deps = _hdlc_proto_rpc_tokenizer |
| |
| generate_setup_cfg = { |
| common_config_file = "pypi_common_setup.cfg" |
| append_date_to_version = true |
| } |
| extra_files = [ |
| "$dir_pigweed/LICENSE > LICENSE", |
| "$dir_pigweed/README.md > README.md", |
| "pypi_pyproject.toml > pyproject.toml", |
| ] |
| } |
| |
| # This pip installs the generate_pigweed_python_package |
| pw_internal_pip_install("pip_install_pigweed_package") { |
| packages = [ ":generate_pigweed_python_package" ] |
| } |
| } |
| |
| pw_test_group("tests") { |
| } |