|
| 1 | +# Copyright (c) 2024 Project CHIP Authors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://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, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import("//build_overrides/chip.gni") |
| 16 | +import("//build_overrides/pigweed.gni") |
| 17 | + |
| 18 | +import("$dir_pw_build/python.gni") |
| 19 | +import("${chip_root}/src/system/system.gni") |
| 20 | + |
| 21 | +declare_args() { |
| 22 | + chip_python_version = "0.0" |
| 23 | + chip_python_package_prefix = "chip" |
| 24 | + chip_python_supports_stack_locking = chip_system_config_locking != "none" |
| 25 | +} |
| 26 | + |
| 27 | +template("chip_python_wheel_action") { |
| 28 | + _dist_dir = "${root_out_dir}/controller/python" |
| 29 | + |
| 30 | + _py_manifest_file = "${target_gen_dir}/${target_name}.py_manifest.json" |
| 31 | + |
| 32 | + pw_python_action(target_name) { |
| 33 | + script = "build-chip-wheel.py" |
| 34 | + forward_variables_from(invoker, "*") |
| 35 | + |
| 36 | + _py_manifest_files_rebased = [] |
| 37 | + foreach(_manifest_entry, py_manifest_files) { |
| 38 | + inputs += _manifest_entry.sources |
| 39 | + _py_manifest_files_rebased += [ |
| 40 | + { |
| 41 | + src_dir = rebase_path(_manifest_entry.src_dir, |
| 42 | + get_path_info(_py_manifest_file, "dir")) |
| 43 | + sources = |
| 44 | + rebase_path(_manifest_entry.sources, _manifest_entry.src_dir) |
| 45 | + }, |
| 46 | + ] |
| 47 | + } |
| 48 | + |
| 49 | + if (defined(invoker.py_scripts)) { |
| 50 | + _py_scripts = invoker.py_scripts |
| 51 | + } else { |
| 52 | + _py_scripts = [] |
| 53 | + } |
| 54 | + |
| 55 | + _py_manifest = { |
| 56 | + files = _py_manifest_files_rebased |
| 57 | + packages = py_packages |
| 58 | + scripts = _py_scripts |
| 59 | + package_reqs = py_package_reqs |
| 60 | + } |
| 61 | + |
| 62 | + write_file(_py_manifest_file, _py_manifest, "json") |
| 63 | + |
| 64 | + args = [ |
| 65 | + "--package_name", |
| 66 | + py_package_name, |
| 67 | + "--build_number", |
| 68 | + chip_python_version, |
| 69 | + "--build_dir", |
| 70 | + rebase_path("${target_gen_dir}/${target_name}.py_build", root_build_dir), |
| 71 | + "--dist_dir", |
| 72 | + rebase_path(_dist_dir, root_build_dir), |
| 73 | + "--manifest", |
| 74 | + rebase_path(_py_manifest_file, root_build_dir), |
| 75 | + "--plat-name", |
| 76 | + py_platform_tag, |
| 77 | + ] |
| 78 | + |
| 79 | + if (defined(invoker.lib_name)) { |
| 80 | + args += [ |
| 81 | + "--lib-name", |
| 82 | + lib_name, |
| 83 | + ] |
| 84 | + } |
| 85 | + |
| 86 | + outputs = [ "${_dist_dir}/$output_name" ] |
| 87 | + } |
| 88 | +} |
0 commit comments