diff --git a/build/chip/java/config.gni b/build/chip/java/config.gni index 9c05cd4270f460..eb992744caf8bf 100644 --- a/build/chip/java/config.gni +++ b/build/chip/java/config.gni @@ -16,7 +16,7 @@ java_path = getenv("JAVA_PATH") declare_args() { java_matter_controller_dependent_paths = [] build_java_matter_controller = false - if (java_path != "") { + if (java_path != "" && current_os != "android") { java_matter_controller_dependent_paths += [ "${java_path}/include/" ] if (current_os == "mac") { diff --git a/build/chip/java/rules.gni b/build/chip/java/rules.gni index f6c4cbe6fd456d..caa66aeddf5b29 100644 --- a/build/chip/java/rules.gni +++ b/build/chip/java/rules.gni @@ -127,7 +127,8 @@ template("java_library") { # Compiles the given files into a directory and generates a 'class list' _javac_target_name = target_name + "__javac" - _class_dir = rebase_path(target_out_dir, root_build_dir) + "/classes" + _class_dir = rebase_path(target_out_dir, root_build_dir) + "/" + + target_name + "/classes" _class_list_file = "$target_gen_dir/$target_name.classlist" action(_javac_target_name) { sources = _java_files @@ -284,7 +285,8 @@ template("java_binary") { # Compiles the given files into a directory and generates a 'class list' _javac_target_name = target_name + "__javac" - _class_dir = rebase_path(target_out_dir, root_build_dir) + "/classes" + _class_dir = rebase_path(target_out_dir, root_build_dir) + "/" + + target_name + "/classes" _class_list_file = "$target_gen_dir/$target_name.classlist" action(_javac_target_name) { sources = _java_files @@ -441,7 +443,8 @@ template("kotlin_library") { # Compiles the given files into a directory and generates a 'class list' _kotlinc_target_name = target_name + "__kotlinc" - _class_dir = rebase_path(target_out_dir, root_build_dir) + "/classes" + _class_dir = rebase_path(target_out_dir, root_build_dir) + "/" + + target_name + "/classes" _class_list_file = "$target_gen_dir/$target_name.classlist" action(_kotlinc_target_name) { sources = _kotlin_files @@ -598,7 +601,8 @@ template("kotlin_binary") { # Compiles the given files into a directory and generates a 'class list' _kotlinc_target_name = target_name + "__kotlinc" - _class_dir = rebase_path(target_out_dir, root_build_dir) + "/classes" + _class_dir = rebase_path(target_out_dir, root_build_dir) + "/" + + target_name + "/classes" _class_list_file = "$target_gen_dir/$target_name.classlist" action(_kotlinc_target_name) { sources = _kotlin_files diff --git a/scripts/build/builders/android.py b/scripts/build/builders/android.py index f34f02087c03dc..9fd778eac6c46a 100644 --- a/scripts/build/builders/android.py +++ b/scripts/build/builders/android.py @@ -153,7 +153,8 @@ def validate_build_environment(self): if not ( os.path.isfile(sdk_manager) and os.access(sdk_manager, os.X_OK) ) and not ( - os.path.isfile(new_sdk_manager) and os.access(new_sdk_manager, os.X_OK) + os.path.isfile(new_sdk_manager) and os.access( + new_sdk_manager, os.X_OK) ): raise Exception( "'%s' and '%s' is not executable by the current user" @@ -227,6 +228,7 @@ def copyToSrcAndroid(self): "CHIPController.jar": "src/controller/java/CHIPController.jar", "SetupPayloadParser.jar": "src/setup_payload/java/SetupPayloadParser.jar", "AndroidPlatform.jar": "src/platform/android/AndroidPlatform.jar", + "libCHIPTlv.jar": "src/controller/java/libCHIPTlv.jar", } for jarName in jars.keys(): @@ -267,7 +269,8 @@ def gradlewBuildSrcAndroid(self): # App compilation self._Execute( [ - "%s/examples/android/%s/gradlew" % (self.root, self.app.AppName()), + "%s/examples/android/%s/gradlew" % ( + self.root, self.app.AppName()), "-p", "%s/examples/android/%s" % (self.root, self.app.AppName()), "-PmatterBuildSrcDir=%s" % self.output_dir, @@ -295,7 +298,8 @@ def gradlewBuildExampleAndroid(self): "-PbuildDir=%s/%s" % (self.output_dir, module), ":%s:assembleDebug" % module, ], - title="Building Example %s, module %s" % (self.identifier, module), + title="Building Example %s, module %s" % ( + self.identifier, module), ) else: self._Execute( @@ -303,7 +307,8 @@ def gradlewBuildExampleAndroid(self): "%s/examples/%s/android/App/gradlew" % (self.root, self.app.ExampleName()), "-p", - "%s/examples/%s/android/App/" % (self.root, self.app.ExampleName()), + "%s/examples/%s/android/App/" % (self.root, + self.app.ExampleName()), "-PmatterBuildSrcDir=%s" % self.output_dir, "-PmatterSdkSourceBuild=false", "-PbuildDir=%s" % self.output_dir, @@ -359,7 +364,8 @@ def generate(self): exampleName = self.app.ExampleName() if exampleName is not None: - gn_gen += ["--root=%s/examples/%s/android/" % (self.root, exampleName)] + gn_gen += ["--root=%s/examples/%s/android/" % + (self.root, exampleName)] if self.board.IsIde(): gn_gen += [ @@ -378,7 +384,8 @@ def generate(self): ) if os.path.isfile(new_sdk_manager) and os.access(new_sdk_manager, os.X_OK): self._Execute( - ["bash", "-c", "yes | %s --licenses >/dev/null" % new_sdk_manager], + ["bash", "-c", "yes | %s --licenses >/dev/null" % + new_sdk_manager], title="Accepting NDK licenses @ cmdline-tools", ) else: @@ -414,7 +421,8 @@ def _build(self): # TODO: Android Gradle with module and -PbuildDir= will caused issue, remove -PbuildDir= self._Execute( [ - "%s/examples/android/%s/gradlew" % (self.root, self.app.AppName()), + "%s/examples/android/%s/gradlew" % ( + self.root, self.app.AppName()), "-p", "%s/examples/android/%s" % (self.root, self.app.AppName()), "-PmatterBuildSrcDir=%s" % self.output_dir, @@ -470,7 +478,8 @@ def _build(self): self.root, "examples/", self.app.ExampleName(), "android/App/app/libs" ) - libs = ["libSetupPayloadParser.so", "libc++_shared.so", "libTvApp.so"] + libs = ["libSetupPayloadParser.so", + "libc++_shared.so", "libTvApp.so"] jars = { "SetupPayloadParser.jar": "third_party/connectedhomeip/src/setup_payload/java/SetupPayloadParser.jar", @@ -520,6 +529,9 @@ def build_outputs(self): "CHIPController.jar": os.path.join( self.output_dir, "lib", "src/controller/java/CHIPController.jar" ), + "libCHIPTlv.jar": os.path.join( + self.output_dir, "lib", "src/controller/java/libCHIPTlv.jar" + ), "AndroidPlatform.jar": os.path.join( self.output_dir, "lib", "src/platform/android/AndroidPlatform.jar" ), diff --git a/scripts/build/testdata/dry_run_android-arm64-chip-tool.txt b/scripts/build/testdata/dry_run_android-arm64-chip-tool.txt index 955c3db11689ef..ebd98f24bf2ac8 100644 --- a/scripts/build/testdata/dry_run_android-arm64-chip-tool.txt +++ b/scripts/build/testdata/dry_run_android-arm64-chip-tool.txt @@ -31,5 +31,7 @@ cp {out}/android-arm64-chip-tool/lib/src/setup_payload/java/SetupPayloadParser.j cp {out}/android-arm64-chip-tool/lib/src/platform/android/AndroidPlatform.jar {root}/examples/android/CHIPTool/app/libs/AndroidPlatform.jar +cp {out}/android-arm64-chip-tool/lib/src/controller/java/libCHIPTlv.jar {root}/examples/android/CHIPTool/app/libs/libCHIPTlv.jar + # Building APP android-arm64-chip-tool {root}/examples/android/CHIPTool/gradlew -p {root}/examples/android/CHIPTool -PmatterBuildSrcDir={out}/android-arm64-chip-tool -PmatterSdkSourceBuild=false -PbuildDir={out}/android-arm64-chip-tool assembleDebug diff --git a/scripts/tests/run_java_test.py b/scripts/tests/run_java_test.py index 8f30de2a1c643b..5c6c55ed4f6377 100755 --- a/scripts/tests/run_java_test.py +++ b/scripts/tests/run_java_test.py @@ -88,7 +88,15 @@ def main(app: str, app_args: str, tool_path: str, tool_cluster: str, tool_args: DumpProgramOutputToQueue( log_cooking_threads, Fore.GREEN + "APP " + Style.RESET_ALL, app_process, log_queue) - command = ['java', '-Djava.library.path=' + tool_path + '/lib/jni', '-jar', tool_path + '/bin/java-matter-controller'] + command = ['java', + f'-Djava.library.path={tool_path}/lib/jni', + '-cp', + ':'.join([ + f'{tool_path}/lib/*', + f'{tool_path}/lib/third_party/connectedhomeip/src/controller/java/*', + f'{tool_path}/bin/java-matter-controller', + ]), + 'com.matter.controller.MainKt'] if tool_cluster == 'pairing': logging.info("Testing pairing cluster")