1 # Copyright (c) 2020 Project CHIP Authors
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 import("//build_overrides/build.gni")
16 import("//build_overrides/chip.gni")
17 import("//build_overrides/pigweed.gni")
19 import("$dir_pw_build/python.gni")
21 import("${chip_root}/build/chip/tools.gni")
22 import("${chip_root}/src/platform/device.gni")
23 import("${dir_pw_unit_test}/test.gni")
25 if (current_os == "mac") {
26 import("${build_root}/config/mac/mac_sdk.gni")
29 config("controller_wno_deprecate") {
30 cflags = [ "-Wno-deprecated-declarations" ]
33 shared_library("ChipDeviceCtrl") {
34 output_name = "_ChipDeviceCtrl"
35 output_dir = "${target_out_dir}/chip"
36 include_dirs = [ "." ]
39 "ChipDeviceController-ScriptBinding.cpp",
40 "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.cpp",
41 "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.h",
42 "ChipDeviceController-ScriptDevicePairingDelegate.cpp",
43 "ChipDeviceController-ScriptDevicePairingDelegate.h",
44 "ChipDeviceController-StorageDelegate.cpp",
45 "ChipDeviceController-StorageDelegate.h",
46 "chip/clusters/CHIPClusters.cpp",
47 "chip/internal/ChipThreadWork.cpp",
48 "chip/internal/ChipThreadWork.h",
49 "chip/internal/CommissionerImpl.cpp",
50 "chip/logging/LoggingRedirect.cpp",
51 "chip/native/StackInit.cpp",
54 if (chip_enable_ble) {
55 if (current_os == "linux") {
56 sources += [ "chip/ble/LinuxImpl.cpp" ]
57 } else if (current_os == "mac") {
59 "chip/ble/darwin/AdapterListing.mm",
60 "chip/ble/darwin/Scanning.mm",
63 assert(false, "No BLE implementation available for the current OS.")
68 "${chip_root}/src/app",
69 "${chip_root}/src/controller",
70 "${chip_root}/src/lib",
71 "${chip_root}/src/lib/core",
72 "${chip_root}/src/lib/support",
73 "${chip_root}/src/platform",
74 "${chip_root}/src/transport",
76 allow_circular_includes_from = [ "${chip_root}/src/controller" ]
77 configs += [ ":controller_wno_deprecate" ]
80 pw_python_action("python") {
81 script = "build-chip-wheel.py"
83 _py_manifest_files = [
87 "chip-device-ctrl.py",
89 "chip/ChipBleBase.py",
90 "chip/ChipBleUtility.py",
91 "chip/ChipBluezMgr.py",
92 "chip/ChipCoreBluetoothMgr.py",
93 "chip/ChipDeviceCtrl.py",
95 "chip/ChipUtility.py",
97 "chip/ble/__init__.py",
98 "chip/ble/commissioning/__init__.py",
99 "chip/ble/get_adapters.py",
100 "chip/ble/library_handle.py",
101 "chip/ble/scan_devices.py",
103 "chip/clusters/CHIPClusters.py",
104 "chip/clusters/__init__.py",
105 "chip/configuration/__init__.py",
106 "chip/exceptions/__init__.py",
107 "chip/internal/__init__.py",
108 "chip/internal/commissioner.py",
109 "chip/internal/thread.py",
110 "chip/internal/types.py",
111 "chip/logging/__init__.py",
112 "chip/logging/library_handle.py",
113 "chip/logging/types.py",
114 "chip/native/__init__.py",
115 "chip/tlv/__init__.py",
119 src_dir = target_out_dir
120 sources = [ "${target_out_dir}/chip/_ChipDeviceCtrl.so" ]
124 sources = [ "//LICENSE" ]
128 _py_manifest_file = "${target_gen_dir}/${target_name}.py_manifest.json"
131 _py_manifest_files_rebased = []
132 foreach(_manifest_entry, _py_manifest_files) {
133 inputs += _manifest_entry.sources
134 _py_manifest_files_rebased += [
136 src_dir = rebase_path(_manifest_entry.src_dir,
137 get_path_info(_py_manifest_file, "dir"))
138 sources = rebase_path(_manifest_entry.sources, _manifest_entry.src_dir)
144 files = _py_manifest_files_rebased
147 write_file(_py_manifest_file, _py_manifest, "json")
149 _dist_dir = "${root_out_dir}/controller/python"
151 if (current_cpu == "x64") {
153 } else if (current_cpu == "arm64") {
156 cpu_tag = current_cpu
159 if (current_os == "mac") {
160 platform_tag = "macosx_" + string_replace(mac_deployment_target, ".", "_")
162 platform_tag = current_os
165 platform_tag = platform_tag + "_" + cpu_tag
167 tags = "cp37-abi3-" + platform_tag
175 rebase_path("${target_gen_dir}/${target_name}.py_build", root_build_dir),
177 rebase_path(_dist_dir, root_build_dir),
179 rebase_path(_py_manifest_file, root_build_dir),
184 public_deps = [ ":ChipDeviceCtrl" ]
186 output_name = "chip-0.0-${tags}.whl"
187 outputs = [ "${_dist_dir}/$output_name" ]