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" ]
35 [ "${chip_root}/src/controller/CHIPDeviceController_deprecated.h" ]
38 shared_library("ChipDeviceCtrl") {
39 output_name = "_ChipDeviceCtrl"
40 output_dir = "${target_out_dir}/chip"
41 include_dirs = [ "." ]
44 "ChipDeviceController-ClusterCommands.cpp",
45 "ChipDeviceController-ScriptBinding.cpp",
46 "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.cpp",
47 "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.h",
48 "ChipDeviceController-ScriptDevicePairingDelegate.cpp",
49 "ChipDeviceController-ScriptDevicePairingDelegate.h",
50 "ChipDeviceController-StorageDelegate.cpp",
51 "ChipDeviceController-StorageDelegate.h",
52 "chip/internal/ChipThreadWork.cpp",
53 "chip/internal/ChipThreadWork.h",
54 "chip/internal/CommissionerImpl.cpp",
55 "chip/logging/LoggingRedirect.cpp",
56 "chip/native/StackInit.cpp",
59 if (chip_enable_ble) {
60 if (current_os == "linux") {
61 sources += [ "chip/ble/LinuxImpl.cpp" ]
62 } else if (current_os == "mac") {
64 "chip/ble/darwin/AdapterListing.mm",
65 "chip/ble/darwin/Scanning.mm",
68 assert(false, "No BLE implementation available for the current OS.")
73 "${chip_root}/src/app",
74 "${chip_root}/src/controller",
75 "${chip_root}/src/lib",
76 "${chip_root}/src/lib/core",
77 "${chip_root}/src/lib/support",
78 "${chip_root}/src/platform",
79 "${chip_root}/src/transport",
81 allow_circular_includes_from = [ "${chip_root}/src/controller" ]
82 configs += [ ":controller_wno_deprecate" ]
85 pw_python_action("python") {
86 script = "build-chip-wheel.py"
88 _py_manifest_files = [
92 "chip-device-ctrl.py",
94 "chip/ChipBleBase.py",
95 "chip/ChipBleUtility.py",
96 "chip/ChipBluezMgr.py",
97 "chip/ChipCluster.py",
98 "chip/ChipCoreBluetoothMgr.py",
99 "chip/ChipDeviceCtrl.py",
101 "chip/ChipUtility.py",
103 "chip/configuration/__init__.py",
104 "chip/exceptions/__init__.py",
105 "chip/internal/__init__.py",
106 "chip/internal/commissioner.py",
107 "chip/internal/thread.py",
108 "chip/internal/types.py",
109 "chip/logging/__init__.py",
110 "chip/logging/library_handle.py",
111 "chip/logging/types.py",
112 "chip/native/__init__.py",
113 "chip/tlv/__init__.py",
117 src_dir = target_out_dir
118 sources = [ "${target_out_dir}/chip/_ChipDeviceCtrl.so" ]
122 sources = [ "//LICENSE" ]
126 if (chip_enable_ble) {
127 _py_manifest_files += [
131 "chip/ble/__init__.py",
132 "chip/ble/commissioning/__init__.py",
133 "chip/ble/get_adapters.py",
134 "chip/ble/library_handle.py",
135 "chip/ble/scan_devices.py",
142 _py_manifest_file = "${target_gen_dir}/${target_name}.py_manifest.json"
145 _py_manifest_files_rebased = []
146 foreach(_manifest_entry, _py_manifest_files) {
147 inputs += _manifest_entry.sources
148 _py_manifest_files_rebased += [
150 src_dir = rebase_path(_manifest_entry.src_dir,
151 get_path_info(_py_manifest_file, "dir"))
152 sources = rebase_path(_manifest_entry.sources, _manifest_entry.src_dir)
158 files = _py_manifest_files_rebased
161 write_file(_py_manifest_file, _py_manifest, "json")
163 _dist_dir = "${root_out_dir}/controller/python"
165 if (current_cpu == "x64") {
167 } else if (current_cpu == "arm64") {
170 cpu_tag = current_cpu
173 if (current_os == "mac") {
174 platform_tag = "macosx_" + string_replace(mac_deployment_target, ".", "_")
176 platform_tag = current_os
179 platform_tag = platform_tag + "_" + cpu_tag
181 tags = "cp37-abi3-" + platform_tag
189 rebase_path("${target_gen_dir}/${target_name}.py_build", root_build_dir),
191 rebase_path(_dist_dir, root_build_dir),
193 rebase_path(_py_manifest_file, root_build_dir),
198 public_deps = [ ":ChipDeviceCtrl" ]
200 output_name = "chip-0.0-${tags}.whl"
201 outputs = [ "${_dist_dir}/$output_name" ]