blob: ee227cf1cf4c064d5c06b43cc04af72001c2518d [file] [log] [blame]
# 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")
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",
"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",
"DeviceAttestationDelegateBridge.cpp",
"DeviceAttestationDelegateBridge.h",
]
deps = [
"${chip_root}/src/controller/data_model",
"${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_java_generated_api) {
defines += [ "USE_JAVA_TLV_ENCODE_DECODE" ]
sources += [
"CHIPDefaultCallbacks.cpp",
"CHIPDefaultCallbacks.h",
"CHIPTLVValueDecoder-JNI.cpp",
"zap-generated/CHIPAttributeTLVValueDecoder.cpp",
"zap-generated/CHIPClustersWrite-JNI.cpp",
"zap-generated/CHIPEventTLVValueDecoder.cpp",
"zap-generated/CHIPInvokeCallbacks.cpp",
"zap-generated/CHIPInvokeCallbacks.h",
"zap-generated/CHIPReadCallbacks.cpp",
]
deps += [ "${chip_root}/src/controller/data_model:java-jni-sources" ]
}
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
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" ]
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" ]
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 = "libCHIPTlv.jar"
sources = [
"src/chip/tlv/Element.kt",
"src/chip/tlv/TlvReader.kt",
"src/chip/tlv/TlvWriter.kt",
"src/chip/tlv/tags.kt",
"src/chip/tlv/types.kt",
"src/chip/tlv/utils.kt",
"src/chip/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/chip/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/chip/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/chip/tlv/TlvReadWriteTest.kt" ]
kotlinc_flags = [ "-Xlint:deprecation" ]
}
kotlin_library("jsontlv") {
output_name = "libCHIPJson.jar"
deps = [
":tlv",
"${chip_root}/third_party/java_deps:gson",
"${chip_root}/third_party/java_deps:protobuf-java",
]
sources = [
"src/chip/jsontlv/JsonToTlv.kt",
"src/chip/jsontlv/TlvToJson.kt",
"src/chip/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/chip/jsontlv/JsonToTlvToJsonTest.kt" ]
kotlinc_flags = [ "-Xlint:deprecation" ]
}
kotlin_library("onboarding_payload") {
output_name = "OnboardingPayload.jar"
deps = [ ":tlv" ]
sources = [
"src/chip/onboardingpayload/Base38.kt",
"src/chip/onboardingpayload/CommissioningFlow.kt",
"src/chip/onboardingpayload/DiscoveryCapability.kt",
"src/chip/onboardingpayload/ManualOnboardingPayloadGenerator.kt",
"src/chip/onboardingpayload/ManualOnboardingPayloadParser.kt",
"src/chip/onboardingpayload/OnboardingPayload.kt",
"src/chip/onboardingpayload/OnboardingPayloadParser.kt",
"src/chip/onboardingpayload/OptionalQRCodeInfo.kt",
"src/chip/onboardingpayload/QRCodeBasicOnboardingPayloadGenerator.kt",
"src/chip/onboardingpayload/QRCodeOnboardingPayloadGenerator.kt",
"src/chip/onboardingpayload/QRCodeOnboardingPayloadParser.kt",
"src/chip/onboardingpayload/VendorId.kt",
"src/chip/onboardingpayload/Verhoeff.kt",
"src/chip/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/chip/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/chip/onboardingpayload/QRCodeTest.kt" ]
kotlinc_flags = [ "-Xlint:deprecation" ]
}
group("unit_tests") {
deps = [
":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("java") {
output_name = "CHIPController.jar"
deps = [
":tlv",
"${chip_root}/third_party/java_deps:annotation",
]
data_deps = [ ":jni" ]
sources = [
"generated/java/chip/devicecontroller/ClusterIDMapping.java",
"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/ChipIdLookup.java",
"src/chip/devicecontroller/ControllerParams.java",
"src/chip/devicecontroller/DeviceAttestationDelegate.java",
"src/chip/devicecontroller/DiscoveredDevice.java",
"src/chip/devicecontroller/GetConnectedDeviceCallbackJni.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/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/EndpointState.java",
"src/chip/devicecontroller/model/EventState.java",
"src/chip/devicecontroller/model/InvokeElement.java",
"src/chip/devicecontroller/model/NodeState.java",
]
if (matter_enable_java_generated_api) {
sources += [
"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/ChipTLVValueDecoder.java",
"zap-generated/chip/devicecontroller/ChipClusters.java",
"zap-generated/chip/devicecontroller/ChipEventStructs.java",
"zap-generated/chip/devicecontroller/ChipStructs.java",
"zap-generated/chip/devicecontroller/ClusterInfoMapping.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"
}
}