Skip to content

Commit a0ace35

Browse files
jlatusekrestyled-commitsyunhanw-google
authored
Add Pigweed support for android tests, fix related bugs (project-chip#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 <commits@restyled.io> Co-authored-by: Yunhan Wang <yunhanw@google.com>
1 parent f2353ad commit a0ace35

File tree

16 files changed

+300
-209
lines changed

16 files changed

+300
-209
lines changed

.github/workflows/full-android.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ jobs:
8383
"ninja -C out/android-arm64-chip-tool build/chip/java/tests:java_build_test"
8484
- name: Clean out build output
8585
run: rm -rf ./out examples/android/CHIPTool/app/libs/jniLibs/* examples/android/CHIPTool/app/libs/*.jar
86-
# - name: Build Android Studio build (arm64 only)
87-
# run: |
88-
# ./scripts/run_in_build_env.sh \
89-
# "./scripts/build/build_examples.py --target android-androidstudio-arm64-chip-tool build"
86+
- name: Build Android arm64-chip-test
87+
run: |
88+
./scripts/run_in_build_env.sh \
89+
"./scripts/build/build_examples.py --target android-arm64-chip-test build"
90+
- name: Clean out build output
91+
run: rm -rf ./out examples/android/CHIPTest/app/libs/jniLibs/* examples/android/CHIPTest/app/libs/*.jar

examples/android/CHIPTest/.gn

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
import("//args.gni")
25+
}

examples/android/CHIPTest/BUILD.gn

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
18+
import("${build_root}/config/android_abi.gni")
19+
import("${chip_root}/build/chip/chip_build.gni")
20+
import("${chip_root}/build/chip/java/rules.gni")
21+
import("${chip_root}/build/chip/tools.gni")
22+
23+
shared_library("jni") {
24+
output_name = "libCHIPTest"
25+
26+
sources = [ "app/src/main/cpp/CHIPTest-JNI.cpp" ]
27+
28+
deps = [
29+
"${chip_root}/src:tests",
30+
"${chip_root}/src/controller/java",
31+
"${chip_root}/src/controller/java:onboarding_payload",
32+
"${chip_root}/src/lib",
33+
"${chip_root}/src/lib/support",
34+
"${chip_root}/src/lib/support:pw_tests_wrapper",
35+
"${chip_root}/src/lib/support:test_utils",
36+
"${chip_root}/src/lib/support:testing_nlunit",
37+
"${chip_root}/src/lib/support/jsontlv",
38+
"${chip_root}/src/platform",
39+
"${chip_root}/src/platform/android",
40+
"${chip_root}/src/platform/android:java",
41+
"${chip_root}/src/platform/logging:android",
42+
"${chip_root}/src/platform/tests:tests",
43+
"${chip_root}/third_party/inipp",
44+
"${chip_root}/third_party/nlfaultinjection:nlfaultinjection",
45+
]
46+
47+
cflags = [ "-Wconversion" ]
48+
49+
output_dir = "${root_out_dir}/lib/jni/${android_abi}"
50+
51+
ldflags = [ "-Wl,--gc-sections" ]
52+
53+
libs = [ "log" ]
54+
}
55+
56+
android_library("java") {
57+
output_name = "CHIPTest.jar"
58+
59+
deps = [
60+
":android",
61+
"${chip_root}/third_party/android_deps:annotation",
62+
]
63+
64+
data_deps = [
65+
":jni",
66+
"${chip_root}/build/chip/java:shared_cpplib",
67+
]
68+
69+
sources = [ "app/src/main/java/com/tcl/chip/chiptest/TestEngine.java" ]
70+
71+
javac_flags = [ "-Xlint:deprecation" ]
72+
}
73+
74+
java_prebuilt("android") {
75+
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
76+
}
77+
78+
group("default") {
79+
deps = [
80+
":java",
81+
":jni",
82+
]
83+
}

examples/android/CHIPTest/app/build.gradle

+11-14
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ android {
2525

2626
externalNativeBuild {
2727
cmake {
28-
arguments "-DMATTER_SDK_SOURCE_BUILD="+matterSdkSourceBuild \
29-
, "-DMATTER_SDK_BUILD_ROOT="+matterBuildSrcDir \
30-
, "-DMATTER_SDK_UTEST_LIB="+matterUTestLib
28+
targets "default"
3129
}
3230
}
3331
}
@@ -52,23 +50,22 @@ android {
5250
jvmTarget = '1.8'
5351
}
5452

55-
externalNativeBuild {
56-
cmake {
57-
path file('src/main/cpp/CMakeLists.txt')
58-
version '3.10.2'
59-
}
60-
}
61-
6253
buildFeatures {
6354
viewBinding true
6455
}
56+
sourceSets {
57+
main {
58+
jniLibs.srcDirs = ['libs/jniLibs']
59+
java.srcDirs = [
60+
'src/main/java',
61+
'src/main/jni',
62+
]
63+
}
64+
}
6565
}
6666

6767
dependencies {
68-
if(!matterSdkSourceBuild.toBoolean()) {
69-
implementation fileTree(dir: "libs", include: ["*.jar"])
70-
}
71-
68+
implementation fileTree(dir: "libs", include: ["*.jar", "*.so"])
7269
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
7370
implementation 'androidx.core:core-ktx:1.6.0'
7471
implementation 'androidx.appcompat:appcompat:1.3.1'

0 commit comments

Comments
 (0)