Skip to content

Commit

Permalink
Add Pigweed support for android tests, fix related bugs (project-chip…
Browse files Browse the repository at this point in the history
…#32704)

* Add pigweed support for android example

* Fix ChipTest-JNI to use gn

* Fix gradle script

* Use new configuration for android in build_example

* Fix java src/controller java add missing data model

* set C++17 in cmake - i think it will be useless but I will leave it right now

* Add gn build support for ChipTest on Android platform

* Fix android app build

* Make app works on real device

* Update .so name, link logging library

* Add support for PW testing

* Restore dry run android

* Fix android stack lock

* Build android chip-tests

* Add command launcher support for android

* Make platform test on android run

* Add pw_test_wrapper for all platform

* Cleanup pr modifications

* Clean .idea files

* Remove commented out code

* Remove test code

* Restyled by clang-format

* Restyled by autopep8

* Add JniLocalReferenceScope

Remove ThrowError and N2J_Error - these function operate on env
variable and are trying to trow an exception using it but, were called only when env was nullptr

* Fix CHIP_DEVICE_CONFIG_DYNAMIC_SERVER macro

* Fix dry run test for android chip tool

* Add controller_config target to correctly setup CHIP_DEVICE_CONFIG_DYNAMIC_SERVER

* Remove .idea files

* Date update

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Yunhan Wang <[email protected]>
  • Loading branch information
3 people authored Mar 29, 2024
1 parent f2353ad commit a0ace35
Show file tree
Hide file tree
Showing 16 changed files with 300 additions and 209 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/full-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ jobs:
"ninja -C out/android-arm64-chip-tool build/chip/java/tests:java_build_test"
- name: Clean out build output
run: rm -rf ./out examples/android/CHIPTool/app/libs/jniLibs/* examples/android/CHIPTool/app/libs/*.jar
# - name: Build Android Studio build (arm64 only)
# run: |
# ./scripts/run_in_build_env.sh \
# "./scripts/build/build_examples.py --target android-androidstudio-arm64-chip-tool build"
- name: Build Android arm64-chip-test
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target android-arm64-chip-test build"
- name: Clean out build output
run: rm -rf ./out examples/android/CHIPTest/app/libs/jniLibs/* examples/android/CHIPTest/app/libs/*.jar
25 changes: 25 additions & 0 deletions examples/android/CHIPTest/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2024 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")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
import("//args.gni")
}
83 changes: 83 additions & 0 deletions examples/android/CHIPTest/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright (c) 2024 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_root}/config/android_abi.gni")
import("${chip_root}/build/chip/chip_build.gni")
import("${chip_root}/build/chip/java/rules.gni")
import("${chip_root}/build/chip/tools.gni")

shared_library("jni") {
output_name = "libCHIPTest"

sources = [ "app/src/main/cpp/CHIPTest-JNI.cpp" ]

deps = [
"${chip_root}/src:tests",
"${chip_root}/src/controller/java",
"${chip_root}/src/controller/java:onboarding_payload",
"${chip_root}/src/lib",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:pw_tests_wrapper",
"${chip_root}/src/lib/support:test_utils",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/lib/support/jsontlv",
"${chip_root}/src/platform",
"${chip_root}/src/platform/android",
"${chip_root}/src/platform/android:java",
"${chip_root}/src/platform/logging:android",
"${chip_root}/src/platform/tests:tests",
"${chip_root}/third_party/inipp",
"${chip_root}/third_party/nlfaultinjection:nlfaultinjection",
]

cflags = [ "-Wconversion" ]

output_dir = "${root_out_dir}/lib/jni/${android_abi}"

ldflags = [ "-Wl,--gc-sections" ]

libs = [ "log" ]
}

android_library("java") {
output_name = "CHIPTest.jar"

deps = [
":android",
"${chip_root}/third_party/android_deps:annotation",
]

data_deps = [
":jni",
"${chip_root}/build/chip/java:shared_cpplib",
]

sources = [ "app/src/main/java/com/tcl/chip/chiptest/TestEngine.java" ]

javac_flags = [ "-Xlint:deprecation" ]
}

java_prebuilt("android") {
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
}

group("default") {
deps = [
":java",
":jni",
]
}
25 changes: 11 additions & 14 deletions examples/android/CHIPTest/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ android {

externalNativeBuild {
cmake {
arguments "-DMATTER_SDK_SOURCE_BUILD="+matterSdkSourceBuild \
, "-DMATTER_SDK_BUILD_ROOT="+matterBuildSrcDir \
, "-DMATTER_SDK_UTEST_LIB="+matterUTestLib
targets "default"
}
}
}
Expand All @@ -52,23 +50,22 @@ android {
jvmTarget = '1.8'
}

externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version '3.10.2'
}
}

buildFeatures {
viewBinding true
}
sourceSets {
main {
jniLibs.srcDirs = ['libs/jniLibs']
java.srcDirs = [
'src/main/java',
'src/main/jni',
]
}
}
}

dependencies {
if(!matterSdkSourceBuild.toBoolean()) {
implementation fileTree(dir: "libs", include: ["*.jar"])
}

implementation fileTree(dir: "libs", include: ["*.jar", "*.so"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
Expand Down
Loading

0 comments on commit a0ace35

Please sign in to comment.