blob: 3d982bfa925e7d486f969aa10a53178ddac0a169 [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 (!build_java_matter_controller) {
import("${build_root}/config/android_abi.gni")
}
shared_library("jni") {
output_name = "libCHIPController"
if (current_os == "mac") {
output_extension = "dylib"
}
# 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",
"AndroidCurrentFabricRemover.cpp",
"AndroidCurrentFabricRemover.h",
"AndroidDeviceControllerWrapper.cpp",
"AndroidDeviceControllerWrapper.h",
"AndroidOperationalCredentialsIssuer.cpp",
"AndroidOperationalCredentialsIssuer.h",
"AttestationTrustStoreBridge.cpp",
"AttestationTrustStoreBridge.h",
"BaseCHIPCluster-JNI.cpp",
"CHIPAttributeTLVValueDecoder.h",
"CHIPDefaultCallbacks.cpp",
"CHIPDefaultCallbacks.h",
"CHIPDeviceController-JNI.cpp",
"DeviceAttestationDelegateBridge.cpp",
"DeviceAttestationDelegateBridge.h",
"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",
"${chip_root}/src/controller/data_model:java-jni-sources",
"${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 (build_java_matter_controller) {
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 (build_java_matter_controller) {
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" ]
}
shared_library("jni_for_onboarding_payload") {
output_name = "libOnboardingPayload"
if (build_java_matter_controller) {
include_dirs = java_matter_controller_dependent_paths
output_dir = "${root_out_dir}/lib/jni"
} else {
output_dir = "${root_out_dir}/lib/jni/${android_abi}"
}
sources = [ "OnboardingPayloadParser-JNI.cpp" ]
deps = [
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]
}
kotlin_library("onboarding_payload") {
output_name = "OnboardingPayload.jar"
data_deps = [ ":jni_for_onboarding_payload" ]
if (!build_java_matter_controller) {
data_deps += [ "${chip_root}/build/chip/java:shared_cpplib" ]
}
sources = [
"src/chip/onboardingpayload/DiscoveryCapability.kt",
"src/chip/onboardingpayload/OnboardingPayload.kt",
"src/chip/onboardingpayload/OnboardingPayloadParser.kt",
"src/chip/onboardingpayload/OptionalQRCodeInfo.kt",
]
}
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",
"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/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/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/ReportEventCallback.java",
"src/chip/devicecontroller/ReportEventCallbackJni.java",
"src/chip/devicecontroller/ResubscriptionAttemptCallback.java",
"src/chip/devicecontroller/SubscriptionEstablishedCallback.java",
"src/chip/devicecontroller/UnpairDeviceCallback.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",
"zap-generated/chip/devicecontroller/ChipClusters.java",
"zap-generated/chip/devicecontroller/ChipEventStructs.java",
"zap-generated/chip/devicecontroller/ChipIdLookup.java",
"zap-generated/chip/devicecontroller/ChipStructs.java",
"zap-generated/chip/devicecontroller/ClusterInfoMapping.java",
]
if (build_java_matter_controller) {
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 (build_java_matter_controller) {
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 (build_java_matter_controller) {
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 (!build_java_matter_controller) {
java_prebuilt("android") {
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
}
}