| # Copyright (c) 2020-2023 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("${chip_root}/build/chip/java/config.gni") |
| import("${chip_root}/build/chip/java/rules.gni") |
| import("${chip_root}/build/chip/tests.gni") |
| import("${chip_root}/src/app/common_flags.gni") |
| import("${chip_root}/src/platform/device.gni") |
| |
| if (!matter_enable_java_compilation) { |
| import("${build_root}/config/android_abi.gni") |
| } |
| |
| shared_library("jni") { |
| output_name = "libCHIPController" |
| |
| if (current_os == "mac") { |
| output_extension = "dylib" |
| } |
| |
| defines = [] |
| |
| # Temporary while we have circular dependencies between codegen.py and zap |
| # generated files |
| check_includes = false |
| |
| sources = [ |
| "AndroidCallbacks-JNI.cpp", |
| "AndroidCallbacks.cpp", |
| "AndroidCallbacks.h", |
| "AndroidClusterExceptions.cpp", |
| "AndroidClusterExceptions.h", |
| "AndroidCommissioningWindowOpener.cpp", |
| "AndroidCommissioningWindowOpener.h", |
| "AndroidConnectionFailureExceptions.cpp", |
| "AndroidConnectionFailureExceptions.h", |
| "AndroidControllerExceptions.cpp", |
| "AndroidControllerExceptions.h", |
| "AndroidCurrentFabricRemover.cpp", |
| "AndroidCurrentFabricRemover.h", |
| "AndroidDeviceControllerWrapper.cpp", |
| "AndroidDeviceControllerWrapper.h", |
| "AndroidOperationalCredentialsIssuer.cpp", |
| "AndroidOperationalCredentialsIssuer.h", |
| "AttestationTrustStoreBridge.cpp", |
| "AttestationTrustStoreBridge.h", |
| "BaseCHIPCluster-JNI.cpp", |
| "CHIPAttributeTLVValueDecoder.h", |
| "CHIPDeviceController-JNI.cpp", |
| "CHIPEventTLVValueDecoder.h", |
| "DeviceAttestationDelegateBridge.cpp", |
| "DeviceAttestationDelegateBridge.h", |
| "GroupDeviceProxy.h", |
| ] |
| |
| deps = [ |
| "${chip_root}/src/app/icd/client:handler", |
| "${chip_root}/src/app/icd/client:manager", |
| "${chip_root}/src/credentials:default_attestation_verifier", |
| "${chip_root}/src/inet", |
| "${chip_root}/src/lib", |
| "${chip_root}/src/lib/support/jsontlv", |
| "${chip_root}/src/platform", |
| ] |
| |
| if (matter_enable_tlv_decoder_api) { |
| defines += [ "USE_JAVA_TLV_ENCODE_DECODE" ] |
| |
| sources += [ |
| "CHIPTLVValueDecoder-JNI.cpp", |
| "zap-generated/CHIPAttributeTLVValueDecoder.cpp", |
| "zap-generated/CHIPEventTLVValueDecoder.cpp", |
| ] |
| } |
| |
| if (chip_build_controller_dynamic_server) { |
| sources += [ |
| "BdxOTASender.cpp", |
| "BdxOTASender.h", |
| "OTAProviderDelegateBridge.cpp", |
| "OTAProviderDelegateBridge.h", |
| ] |
| |
| defines += [ |
| "CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES=1", |
| "CHIP_DEVICE_CONFIG_DYNAMIC_SERVER", |
| ] |
| |
| deps += [ "${chip_root}/src/controller:nodatamodel" ] |
| } |
| |
| if (matter_enable_java_compilation) { |
| defines += [ "JAVA_MATTER_CONTROLLER_TEST" ] |
| |
| sources += [ |
| "${chip_root}/src/controller/ExamplePersistentStorage.cpp", |
| "${chip_root}/src/controller/ExamplePersistentStorage.h", |
| ] |
| |
| include_dirs = java_matter_controller_dependent_paths |
| include_dirs += [ "${chip_root}/zzz_generated/controller-clusters" ] |
| |
| deps += [ "${chip_root}/third_party/inipp" ] |
| |
| if (current_os == "mac") { |
| deps += [ "${chip_root}/src/platform/Darwin" ] |
| } else { |
| deps += [ "${chip_root}/src/platform/Linux" ] |
| } |
| |
| cflags = [ |
| "-Wno-unknown-pragmas", |
| "-Wconversion", |
| ] |
| |
| output_dir = "${root_out_dir}/lib/jni" |
| } else { |
| deps += [ "${chip_root}/src/platform/android" ] |
| |
| output_dir = "${root_out_dir}/lib/jni/${android_abi}" |
| } |
| |
| if (current_os == "mac") { |
| ldflags = [ "-Wl,-dead_strip" ] |
| } else { |
| ldflags = [ "-Wl,--gc-sections" ] |
| } |
| |
| public_configs = [ "${chip_root}/src:includes" ] |
| } |
| |
| if (chip_link_tests) { |
| shared_library("jni_for_test") { |
| sources = [ "AndroidCallbacks-ForTestJNI.cpp" ] |
| output_name = "libCHIPForTestController" |
| |
| public_configs = [ "${chip_root}/src:includes" ] |
| |
| deps = [ |
| ":jni", |
| "${chip_root}/src/messaging/tests:helpers", |
| ] |
| |
| if (matter_enable_java_compilation) { |
| defines = [ "JAVA_MATTER_CONTROLLER_TEST" ] |
| include_dirs = java_matter_controller_dependent_paths |
| if (current_os == "mac") { |
| deps += [ "${chip_root}/src/platform/Darwin" ] |
| } else { |
| deps += [ "${chip_root}/src/platform/Linux" ] |
| } |
| |
| cflags = [ |
| "-Wno-unknown-pragmas", |
| "-Wconversion", |
| ] |
| |
| output_dir = "${root_out_dir}/lib/jni" |
| } else { |
| deps += [ "${chip_root}/src/platform/android" ] |
| |
| output_dir = "${root_out_dir}/lib/jni/${android_abi}" |
| } |
| |
| ldflags = [ "-Wl,--gc-sections" ] |
| } |
| } |
| |
| kotlin_library("tlv") { |
| output_name = "libMatterTlv.jar" |
| |
| sources = [ |
| "src/matter/tlv/Element.kt", |
| "src/matter/tlv/TlvReader.kt", |
| "src/matter/tlv/TlvWriter.kt", |
| "src/matter/tlv/tags.kt", |
| "src/matter/tlv/types.kt", |
| "src/matter/tlv/utils.kt", |
| "src/matter/tlv/values.kt", |
| ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("tlv_reader_test") { |
| output_name = "TlvReaderTest.jar" |
| |
| deps = [ |
| ":tlv", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ "tests/matter/tlv/TlvReaderTest.kt" ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("tlv_writer_test") { |
| output_name = "TlvWriterTest.jar" |
| |
| deps = [ |
| ":tlv", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ "tests/matter/tlv/TlvWriterTest.kt" ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("tlv_read_write_test") { |
| output_name = "TlvReadWriteTest.jar" |
| |
| deps = [ |
| ":tlv", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:kotlin-test", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ "tests/matter/tlv/TlvReadWriteTest.kt" ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("jsontlv") { |
| output_name = "libMatterJson.jar" |
| |
| deps = [ |
| ":tlv", |
| "${chip_root}/third_party/java_deps:gson", |
| "${chip_root}/third_party/java_deps:protobuf-java", |
| ] |
| |
| sources = [ |
| "src/matter/jsontlv/JsonToTlv.kt", |
| "src/matter/jsontlv/TlvToJson.kt", |
| "src/matter/jsontlv/types.kt", |
| ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("json_to_tlv_to_json_test") { |
| output_name = "JsonToTlvToJsonTest.jar" |
| |
| deps = [ |
| ":jsontlv", |
| "${chip_root}/third_party/java_deps:gson", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:kotlin-test", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ "tests/matter/jsontlv/JsonToTlvToJsonTest.kt" ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("onboarding_payload") { |
| output_name = "OnboardingPayload.jar" |
| |
| deps = [ ":tlv" ] |
| |
| sources = [ |
| "src/matter/onboardingpayload/Base38.kt", |
| "src/matter/onboardingpayload/CommissioningFlow.kt", |
| "src/matter/onboardingpayload/DiscoveryCapability.kt", |
| "src/matter/onboardingpayload/ManualOnboardingPayloadGenerator.kt", |
| "src/matter/onboardingpayload/ManualOnboardingPayloadParser.kt", |
| "src/matter/onboardingpayload/OnboardingPayload.kt", |
| "src/matter/onboardingpayload/OnboardingPayloadParser.kt", |
| "src/matter/onboardingpayload/OptionalQRCodeInfo.kt", |
| "src/matter/onboardingpayload/QRCodeBasicOnboardingPayloadGenerator.kt", |
| "src/matter/onboardingpayload/QRCodeOnboardingPayloadGenerator.kt", |
| "src/matter/onboardingpayload/QRCodeOnboardingPayloadParser.kt", |
| "src/matter/onboardingpayload/VendorId.kt", |
| "src/matter/onboardingpayload/Verhoeff.kt", |
| "src/matter/onboardingpayload/Verhoeff10.kt", |
| ] |
| } |
| |
| kotlin_library("onboardingpayload_manual_code_test") { |
| output_name = "OnboardingPayloadManualCodeTest.jar" |
| |
| deps = [ |
| ":onboarding_payload", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ "tests/matter/onboardingpayload/ManualCodeTest.kt" ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("onboardingpayload_qr_code_test") { |
| output_name = "OnboardingPayloadQRCodeTest.jar" |
| |
| deps = [ |
| ":onboarding_payload", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ "tests/matter/onboardingpayload/QRCodeTest.kt" ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("chipcluster") { |
| import( |
| "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni") |
| |
| output_name = "CHIPClusters.jar" |
| |
| deps = [ ":tlv" ] |
| |
| sources = structs_sources |
| sources += eventstructs_sources |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("chipcluster_test") { |
| output_name = "CHIPClustersTest.jar" |
| |
| deps = [ |
| ":chipcluster", |
| ":tlv", |
| "${chip_root}/third_party/java_deps:junit-4", |
| "${chip_root}/third_party/java_deps:truth", |
| ] |
| |
| sources = [ |
| "tests/chip/devicecontroller/cluster/ChipClusterEventStructTest.kt", |
| "tests/chip/devicecontroller/cluster/ChipClusterStructTest.kt", |
| ] |
| |
| kotlinc_flags = [ "-Xlint:deprecation" ] |
| } |
| |
| kotlin_library("kotlin_matter_controller") { |
| import( |
| "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/files.gni") |
| |
| output_name = "KotlinMatterController.jar" |
| |
| deps = [ |
| ":java", |
| ":tlv", |
| "${chip_root}/third_party/java_deps:annotation", |
| ] |
| |
| sources = [ |
| "src/matter/controller/CompletionListenerAdapter.kt", |
| "src/matter/controller/ControllerParams.kt", |
| "src/matter/controller/InteractionClient.kt", |
| "src/matter/controller/MatterController.kt", |
| "src/matter/controller/MatterControllerException.kt", |
| "src/matter/controller/MatterControllerImpl.kt", |
| "src/matter/controller/Messages.kt", |
| "src/matter/controller/OperationalKeyConfig.kt", |
| "src/matter/controller/SubscriptionStates.kt", |
| "src/matter/controller/model/Paths.kt", |
| "src/matter/controller/model/States.kt", |
| ] |
| |
| sources += matter_structs_sources |
| sources += matter_eventstructs_sources |
| sources += matter_clusters_sources |
| |
| if (matter_enable_java_compilation) { |
| deps += [ |
| "${chip_root}/third_party/java_deps:json", |
| "${chip_root}/third_party/java_deps:kotlin-stdlib", |
| "${chip_root}/third_party/java_deps:kotlinx-coroutines-core-jvm", |
| "${chip_root}/third_party/java_deps/stub_src", |
| ] |
| } else { |
| deps += [ ":android" ] |
| } |
| } |
| |
| group("unit_tests") { |
| deps = [ |
| ":chipcluster_test", |
| ":json_to_tlv_to_json_test", |
| ":onboardingpayload_manual_code_test", |
| ":onboardingpayload_qr_code_test", |
| ":tlv_read_write_test", |
| ":tlv_reader_test", |
| ":tlv_writer_test", |
| ] |
| } |
| |
| android_library("chipclusterID") { |
| output_name = "CHIPClusterID.jar" |
| |
| sources = [ |
| "generated/java/chip/devicecontroller/ClusterIDMapping.java", |
| "src/chip/devicecontroller/ChipIdLookup.java", |
| ] |
| |
| javac_flags = [ |
| "-Xlint:deprecation", |
| "-parameters", # Store infomation about method parameters |
| ] |
| } |
| |
| android_library("java") { |
| output_name = "CHIPController.jar" |
| |
| deps = [ |
| ":chipcluster", |
| ":chipclusterID", |
| ":jsontlv", |
| ":tlv", |
| "${chip_root}/third_party/java_deps:annotation", |
| ] |
| |
| data_deps = [ ":jni" ] |
| |
| sources = [ |
| "src/chip/devicecontroller/AttestationInfo.java", |
| "src/chip/devicecontroller/AttestationTrustStoreDelegate.java", |
| "src/chip/devicecontroller/CSRInfo.java", |
| "src/chip/devicecontroller/ChipClusterException.java", |
| "src/chip/devicecontroller/ChipCommandType.java", |
| "src/chip/devicecontroller/ChipDeviceController.java", |
| "src/chip/devicecontroller/ChipDeviceControllerException.java", |
| "src/chip/devicecontroller/ConnectionFailureException.java", |
| "src/chip/devicecontroller/ControllerParams.java", |
| "src/chip/devicecontroller/DeviceAttestationDelegate.java", |
| "src/chip/devicecontroller/DiscoveredDevice.java", |
| "src/chip/devicecontroller/GetConnectedDeviceCallbackJni.java", |
| "src/chip/devicecontroller/GroupKeySecurityPolicy.java", |
| "src/chip/devicecontroller/ICDClientInfo.java", |
| "src/chip/devicecontroller/ICDDeviceInfo.java", |
| "src/chip/devicecontroller/ICDRegistrationInfo.java", |
| "src/chip/devicecontroller/InvokeCallback.java", |
| "src/chip/devicecontroller/InvokeCallbackJni.java", |
| "src/chip/devicecontroller/KeypairDelegate.java", |
| "src/chip/devicecontroller/NetworkCredentials.java", |
| "src/chip/devicecontroller/NetworkLocation.java", |
| "src/chip/devicecontroller/OTAProviderDelegate.java", |
| "src/chip/devicecontroller/OpenCommissioningCallback.java", |
| "src/chip/devicecontroller/OperationalKeyConfig.java", |
| "src/chip/devicecontroller/PaseVerifierParams.java", |
| "src/chip/devicecontroller/ReportCallback.java", |
| "src/chip/devicecontroller/ReportCallbackJni.java", |
| "src/chip/devicecontroller/ResubscriptionAttemptCallback.java", |
| "src/chip/devicecontroller/SubscriptionEstablishedCallback.java", |
| "src/chip/devicecontroller/ThreadScanResult.java", |
| "src/chip/devicecontroller/UnpairDeviceCallback.java", |
| "src/chip/devicecontroller/WiFiScanResult.java", |
| "src/chip/devicecontroller/WriteAttributesCallback.java", |
| "src/chip/devicecontroller/WriteAttributesCallbackJni.java", |
| "src/chip/devicecontroller/model/AttributeState.java", |
| "src/chip/devicecontroller/model/AttributeWriteRequest.java", |
| "src/chip/devicecontroller/model/ChipAttributePath.java", |
| "src/chip/devicecontroller/model/ChipEventPath.java", |
| "src/chip/devicecontroller/model/ChipPathId.java", |
| "src/chip/devicecontroller/model/ClusterState.java", |
| "src/chip/devicecontroller/model/DataVersionFilter.java", |
| "src/chip/devicecontroller/model/EndpointState.java", |
| "src/chip/devicecontroller/model/EventState.java", |
| "src/chip/devicecontroller/model/InvokeElement.java", |
| "src/chip/devicecontroller/model/NodeState.java", |
| ] |
| |
| if (matter_enable_tlv_decoder_api) { |
| sources += [ "src/chip/devicecontroller/ChipTLVValueDecoder.java" ] |
| } |
| |
| if (matter_enable_java_generated_api) { |
| sources += [ |
| "generated/java/chip/devicecontroller/ChipClusters.java", |
| "generated/java/chip/devicecontroller/ChipEventStructs.java", |
| "generated/java/chip/devicecontroller/ChipStructs.java", |
| "generated/java/chip/devicecontroller/ClusterInfoMapping.java", |
| "generated/java/chip/devicecontroller/ClusterReadMapping.java", |
| "generated/java/chip/devicecontroller/ClusterWriteMapping.java", |
| "src/chip/clusterinfo/ClusterCommandCallback.java", |
| "src/chip/clusterinfo/ClusterInfo.java", |
| "src/chip/clusterinfo/CommandParameterInfo.java", |
| "src/chip/clusterinfo/CommandResponseInfo.java", |
| "src/chip/clusterinfo/DelegatedClusterCallback.java", |
| "src/chip/clusterinfo/InteractionInfo.java", |
| "src/chip/devicecontroller/ChipTLVType.java", |
| ] |
| } |
| |
| if (matter_enable_java_compilation) { |
| deps += [ |
| "${chip_root}/third_party/java_deps:json", |
| "${chip_root}/third_party/java_deps/stub_src", |
| ] |
| } else { |
| deps += [ ":android" ] |
| |
| data_deps += [ "${chip_root}/build/chip/java:shared_cpplib" ] |
| } |
| |
| javac_flags = [ |
| "-Xlint:deprecation", |
| "-parameters", # Store infomation about method parameters |
| ] |
| |
| # TODO: add classpath support (we likely need to add something like |
| # ..../platforms/android-26/android.jar to access BLE items) |
| } |
| |
| if (chip_link_tests) { |
| android_library("java_for_test") { |
| output_name = "CHIPControllerForTest.jar" |
| |
| deps = [ "${chip_root}/third_party/java_deps:annotation" ] |
| |
| data_deps = [ |
| ":jni", |
| ":jni_for_test", |
| ] |
| |
| sources = [ |
| "src/chip/devicecontroller/GetConnectedDeviceCallbackForTestJni.java", |
| ] |
| |
| if (matter_enable_java_compilation) { |
| deps += [ |
| "${chip_root}/third_party/java_deps:json", |
| "${chip_root}/third_party/java_deps/stub_src", |
| ] |
| } else { |
| deps += [ ":android" ] |
| |
| data_deps += [ "${chip_root}/build/chip/java:shared_cpplib" ] |
| } |
| |
| javac_flags = [ "-Xlint:deprecation" ] |
| |
| # TODO: add classpath support (we likely need to add something like |
| # ..../platforms/android-26/android.jar to access BLE items) |
| } |
| |
| android_library("tests") { |
| output_name = "CHIPControllerTests.jar" |
| |
| deps = [ |
| ":java_for_test", |
| "${chip_root}/src/messaging/tests/java", |
| "${chip_root}/third_party/java_deps:annotation", |
| ] |
| |
| data_deps = [ |
| ":jni", |
| ":jni_for_test", |
| "${chip_root}/src/messaging/tests/java:jni", |
| ] |
| |
| sources = |
| [ "tests/chip/devicecontroller/GetConnectedDeviceCallbackJniTest.java" ] |
| |
| if (matter_enable_java_compilation) { |
| deps += [ |
| "${chip_root}/third_party/java_deps:json", |
| "${chip_root}/third_party/java_deps/stub_src", |
| ] |
| } else { |
| deps += [ ":android" ] |
| |
| data_deps += [ "${chip_root}/build/chip/java:shared_cpplib" ] |
| } |
| |
| javac_flags = [ "-Xlint:deprecation" ] |
| |
| # TODO: add classpath support (we likely need to add something like |
| # ..../platforms/android-26/android.jar to access BLE items) |
| } |
| } |
| |
| if (!matter_enable_java_compilation) { |
| java_prebuilt("android") { |
| jar_path = "${android_sdk_root}/platforms/android-26/android.jar" |
| } |
| } |