blob: 76de66311996a19c0ed59d2610571358cb67c055 [file] [log] [blame]
# Copyright (c) 2020 Project CHIP 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
#
# http://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/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/python.gni")
import("${chip_root}/build/chip/python_wheel.gni")
import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/src/controller/flags.gni")
import("${chip_root}/src/data-model-providers/codegen/model.gni")
import("${chip_root}/src/platform/python.gni")
import("${chip_root}/src/system/system.gni")
import("${dir_pw_unit_test}/test.gni")
if (current_os == "mac") {
import("${build_root}/config/mac/mac_sdk.gni")
}
config("controller_wno_deprecate") {
cflags = [ "-Wno-deprecated-declarations" ]
}
shared_library("ChipDeviceCtrl") {
if (chip_support_commissioning_in_controller) {
output_name = "_ChipDeviceCtrl"
} else {
output_name = "_ChipServer"
}
output_dir = "${target_out_dir}/matter"
include_dirs = [ "." ]
sources = [
"matter/setup_payload/Generator.cpp",
"matter/setup_payload/Parser.cpp",
]
sources += [ "matter/native/CommonStackInit.cpp" ]
defines = []
if (chip_support_commissioning_in_controller) {
sources += [
"ChipCommissionableNodeController-ScriptBinding.cpp",
"ChipDeviceController-Discovery.cpp",
"ChipDeviceController-IssueNocChain.cpp",
"ChipDeviceController-ScriptBinding.cpp",
"ChipDeviceController-ScriptDevicePairingDelegate.cpp",
"ChipDeviceController-ScriptDevicePairingDelegate.h",
"ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.cpp",
"ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.h",
"ChipDeviceController-StorageDelegate.cpp",
"ChipDeviceController-StorageDelegate.h",
"JsonTlv.cpp",
"OpCredsBinding.cpp",
"matter/bdx/bdx-transfer.cpp",
"matter/bdx/bdx-transfer.h",
"matter/bdx/bdx.cpp",
"matter/bdx/test-bdx-transfer-server.cpp",
"matter/bdx/test-bdx-transfer-server.h",
"matter/clusters/attribute.cpp",
"matter/clusters/command.cpp",
"matter/commissioning/PlaceholderOperationalCredentialsIssuer.h",
"matter/credentials/cert.cpp",
"matter/credentials/cert.h",
"matter/crypto/p256keypair.cpp",
"matter/crypto/p256keypair.h",
"matter/discovery/NodeResolution.cpp",
"matter/fault_injection/FaultInjection.cpp",
"matter/icd/PyChipCheckInDelegate.cpp",
"matter/icd/PyChipCheckInDelegate.h",
"matter/interaction_model/Delegate.cpp",
"matter/interaction_model/Delegate.h",
"matter/internal/ChipThreadWork.cpp",
"matter/internal/ChipThreadWork.h",
"matter/internal/CommissionerImpl.cpp",
"matter/logging/LoggingFilter.cpp",
"matter/logging/LoggingRedirect.cpp",
"matter/native/ChipMainLoopWork.h",
"matter/native/PyChipError.cpp",
"matter/native/PyChipError.h",
"matter/tracing/TracingSetup.cpp",
"matter/utils/DeviceProxyUtils.cpp",
]
if (chip_support_webrtc_python_bindings) {
sources += [
"matter/webrtc/RTCClient.cpp",
"matter/webrtc/WebRTC.cpp",
"matter/webrtc/WebRTC.h",
"matter/webrtc/WebRTCTransportCluster.cpp",
]
}
defines += [ "CHIP_CONFIG_MAX_ACTIVE_TCP_CONNECTIONS=20" ]
defines += [ "CHIP_CONFIG_MAX_GROUPS_PER_FABRIC=50" ]
defines += [ "CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC=50" ]
if (chip_python_supports_stack_locking) {
sources += [ "matter/native/ChipMainLoopWork_StackLock.cpp" ]
} else {
sources += [ "matter/native/ChipMainLoopWork_WorkSchedule.cpp" ]
}
} else {
sources += [
"matter/server/Options.cpp",
"matter/server/Options.h",
"matter/server/ServerInit.cpp",
]
}
if (chip_enable_ble) {
if (current_os == "linux") {
sources += [ "matter/ble/LinuxImpl.cpp" ]
} else if (current_os == "mac") {
sources += [
"matter/ble/darwin/AdapterListing.mm",
"matter/ble/darwin/Scanning.mm",
]
cflags = [ "-fobjc-arc" ]
} else {
assert(false, "No BLE implementation available for the current OS.")
}
}
public_deps = [
"${chip_root}/src/app",
"${chip_root}/src/app/icd/client:handler",
"${chip_root}/src/app/server",
"${chip_root}/src/credentials:default_attestation_verifier",
"${chip_root}/src/credentials:test_dac_revocation_delegate",
"${chip_root}/src/lib",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/dnssd",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support/jsontlv",
"${chip_root}/src/platform",
"${chip_root}/src/platform/logging:default",
"${chip_root}/src/setup_payload",
"${chip_root}/src/transport",
]
if (chip_support_webrtc_python_bindings) {
public_deps += [
"${chip_root}/src/controller/webrtc:chip_webrtc",
"${chip_root}/third_party/libdatachannel:libdatachannel",
]
include_dirs += [
"${chip_root}/src/controller/webrtc/",
"${chip_root}/third_party/libdatachannel/repo/include",
]
}
if (chip_support_commissioning_in_controller) {
public_deps += [
"${chip_root}/src/credentials:file_attestation_trust_store",
"${chip_root}/src/lib/support:testing",
"${chip_root}/src/tracing/json",
"${chip_root}/src/tracing/perfetto",
"${chip_root}/src/tracing/perfetto:file_output",
"${chip_root}/third_party/jsoncpp",
]
deps = [
"${chip_root}/src/tracing/perfetto:event_storage",
"${chip_root}/src/tracing/perfetto:simple_initialization",
]
if (chip_build_controller_dynamic_server) {
defines += [ "CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES=1" ]
deps += [ "${chip_root}/src/controller:nodatamodel" ]
# Temporary dependency: InteractionModelEngine NEEDS a codegen data model instance
# defined and application is supposed to provide it. This adds the sources
# in the same way "data_model" implementations do
#
# DynamicDispatcher in src/app:interaction-model implements the actual required
# ember callbacks in this case...
sources += codegen_data_model_SOURCES
public_deps += codegen_data_model_PUBLIC_DEPS
} else {
public_deps += [ "${chip_root}/src/controller/data_model" ]
}
} else {
public_deps += [ "$chip_data_model" ]
}
configs += [ ":controller_wno_deprecate" ]
}
matter_python_wheel_action("matter-core") {
py_manifest_files = [
{
src_dir = "."
sources = [
"matter/CertificateAuthority.py",
"matter/ChipBleBase.py",
"matter/ChipBleUtility.py",
"matter/ChipBluezMgr.py",
"matter/ChipCommissionableNodeCtrl.py",
"matter/ChipStack.py",
"matter/FabricAdmin.py",
"matter/MatterTlvJson.py",
"matter/__init__.py",
"matter/bdx/Bdx.py",
"matter/bdx/BdxProtocol.py",
"matter/bdx/BdxTransfer.py",
"matter/bdx/__init__.py",
"matter/ble/__init__.py",
"matter/ble/commissioning/__init__.py",
"matter/ble/get_adapters.py",
"matter/ble/library_handle.py",
"matter/ble/scan_devices.py",
"matter/ble/types.py",
"matter/clusters/Attribute.py",
"matter/clusters/Command.py",
"matter/clusters/__init__.py",
"matter/commissioning/__init__.py",
"matter/commissioning/commissioning_flow_blocks.py",
"matter/commissioning/pase.py",
"matter/configuration/__init__.py",
"matter/credentials/__init__.py",
"matter/credentials/cert.py",
"matter/crypto/__init__.py",
"matter/crypto/fabric.py",
"matter/crypto/p256keypair.py",
"matter/discovery/__init__.py",
"matter/discovery/library_handle.py",
"matter/discovery/types.py",
"matter/exceptions/__init__.py",
"matter/fault_injection/__init__.py",
"matter/interaction_model/__init__.py",
"matter/interaction_model/delegate.py",
"matter/internal/__init__.py",
"matter/internal/commissioner.py",
"matter/internal/thread.py",
"matter/internal/types.py",
"matter/logging/__init__.py",
"matter/logging/library_handle.py",
"matter/logging/types.py",
"matter/native/__init__.py",
"matter/setup_payload/__init__.py",
"matter/setup_payload/setup_payload.py",
"matter/storage/__init__.py",
"matter/tracing/__init__.py",
"matter/utils/CommissioningBuildingBlocks.py",
"matter/utils/__init__.py",
"matter/yaml/__init__.py",
"matter/yaml/data_model_lookup.py",
"matter/yaml/errors.py",
"matter/yaml/format_converter.py",
"matter/yaml/runner.py",
]
if (chip_support_webrtc_python_bindings) {
sources += [
"matter/webrtc/__init__.py",
"matter/webrtc/async_websocket_client.py",
"matter/webrtc/browser_peer_connection.py",
"matter/webrtc/browser_webrtc_client.py",
"matter/webrtc/command.py",
"matter/webrtc/libdatachannel_peer_connection.py",
"matter/webrtc/libdatachannel_webrtc_client.py",
"matter/webrtc/library_handle.py",
"matter/webrtc/types.py",
"matter/webrtc/utils.py",
"matter/webrtc/webrtc_manager.py",
]
}
if (chip_support_commissioning_in_controller) {
sources += [ "matter/ChipDeviceCtrl.py" ]
} else {
sources += [ "matter/server/__init__.py" ]
}
},
{
src_dir = target_out_dir
if (chip_support_commissioning_in_controller) {
sources = [ "${target_out_dir}/matter/_ChipDeviceCtrl.so" ]
} else {
sources = [ "${target_out_dir}/matter/_ChipServer.so" ]
}
},
{
src_dir = "//"
sources = [ "//LICENSE" ]
},
]
inputs = []
py_packages = [
"matter",
"matter.bdx",
"matter.ble",
"matter.ble.commissioning",
"matter.configuration",
"matter.commissioning",
"matter.clusters",
"matter.credentials",
"matter.crypto",
"matter.utils",
"matter.discovery",
"matter.exceptions",
"matter.internal",
"matter.interaction_model",
"matter.logging",
"matter.yaml",
"matter.native",
"matter.clusters",
"matter.setup_payload",
"matter.storage",
"matter.tracing",
"matter.fault_injection",
]
if (chip_support_webrtc_python_bindings) {
py_packages += [ "matter.webrtc" ]
}
if (!chip_support_commissioning_in_controller) {
py_packages += [ "matter.server" ]
}
py_package_reqs = [
"coloredlogs",
"construct",
"cryptography",
"dacite",
"deprecation",
"ecdsa",
"ipdb",
"matter-clusters",
"pyyaml",
"rich",
]
if (current_cpu == "x64") {
cpu_tag = "x86_64"
} else if (current_cpu == "arm64" && current_os == "linux") {
cpu_tag = "aarch64"
} else if (current_cpu == "arm" && current_os == "linux") {
cpu_tag = "armv7l"
} else {
cpu_tag = current_cpu
}
if (current_os == "mac") {
py_platform_tag = string_replace(
string_replace(mac_deployment_target, "macos", "macosx."),
".",
"_")
} else {
py_platform_tag = current_os
}
py_platform_tag = py_platform_tag + "_" + cpu_tag
if (chip_support_commissioning_in_controller) {
lib_name = "_ChipDeviceCtrl.so"
} else {
lib_name = "_ChipServer.so"
}
py_package_name = "${chip_python_package_prefix}-core"
public_deps = [ ":ChipDeviceCtrl" ]
output_name = "${py_package_name}-${chip_python_version}-cp37-abi3-${py_platform_tag}.whl"
}
matter_python_wheel_action("matter-clusters") {
py_manifest_files = [
{
src_dir = "."
sources = [
"matter/ChipUtility.py",
"matter/clusters/CHIPClusters.py",
"matter/clusters/ClusterObjects.py",
"matter/clusters/Objects.py",
"matter/clusters/TestObjects.py",
"matter/clusters/Types.py",
"matter/clusters/enum.py",
"matter/tlv/__init__.py",
"matter/tlv/tlvlist.py",
]
},
{
src_dir = "//"
sources = [ "//LICENSE" ]
},
]
inputs = []
py_packages = [
"matter",
"matter.clusters",
"matter.tlv",
]
py_package_reqs = [
"aenum",
"dacite",
]
py_package_name = "${chip_python_package_prefix}-clusters"
py_platform_tag = "any"
output_name = "${py_package_name}-${chip_python_version}-py3-none-${py_platform_tag}.whl"
}
matter_python_wheel_action("matter-repl") {
py_scripts = [ "matter-repl.py" ]
py_manifest_files = [
{
src_dir = "."
sources = [
"matter/ChipBluezMgr.py",
"matter/ChipCoreBluetoothMgr.py",
"matter/ReplStartup.py",
]
sources += py_scripts
},
{
src_dir = "//"
sources = [ "//LICENSE" ]
},
]
inputs = []
py_packages = [ "matter" ]
py_package_reqs = [
"coloredlogs",
#
# IPython 7.30.0 has a bug which results in the use of await ... failing on some platforms (see https://github.com/ipython/ipython/pull/13269)
# For now, let's just avoid that version.
#
# IPython 8.1.0 has a bug which causes issues: https://github.com/ipython/ipython/issues/13554
#
#
"ipython!=8.1.0",
"rich",
"ipykernel",
"pyobjc-framework-corebluetooth ; sys_platform==\"darwin\"",
"dbus-python==1.2.18 ; sys_platform==\"linux\"",
"pygobject==3.50.0 ; sys_platform==\"linux\"",
"matter-core",
]
py_package_name = "${chip_python_package_prefix}-repl"
py_platform_tag = "any"
data_deps = [
":matter-clusters",
":matter-core",
]
output_name = "${py_package_name}-${chip_python_version}-py3-none-${py_platform_tag}.whl"
}