diff --git a/build/chip/java/config.gni b/build/chip/java/config.gni index 626d7b00e2a669..9c05cd4270f460 100644 --- a/build/chip/java/config.gni +++ b/build/chip/java/config.gni @@ -17,10 +17,16 @@ declare_args() { java_matter_controller_dependent_paths = [] build_java_matter_controller = false if (java_path != "") { - java_matter_controller_dependent_paths += [ - "${java_path}/include/", - "${java_path}/include/linux/", - ] + java_matter_controller_dependent_paths += [ "${java_path}/include/" ] + + if (current_os == "mac") { + java_matter_controller_dependent_paths += + [ "${java_path}/include/darwin/" ] + } else { + java_matter_controller_dependent_paths += + [ "${java_path}/include/linux/" ] + } + build_java_matter_controller = true } } diff --git a/src/controller/data_model/BUILD.gn b/src/controller/data_model/BUILD.gn index de4f3413075332..af701eb6fd43f1 100644 --- a/src/controller/data_model/BUILD.gn +++ b/src/controller/data_model/BUILD.gn @@ -199,7 +199,11 @@ if (current_os == "android" || build_java_matter_controller) { ] if (build_java_matter_controller) { - deps += [ "${chip_root}/src/platform/Linux" ] + if (current_os == "mac") { + deps += [ "${chip_root}/src/platform/Darwin" ] + } else { + deps += [ "${chip_root}/src/platform/Linux" ] + } } else { deps += [ "${chip_root}/src/platform/android" ] } diff --git a/src/controller/java/BUILD.gn b/src/controller/java/BUILD.gn index 70f2b136747ae1..add8ee2f9630f9 100644 --- a/src/controller/java/BUILD.gn +++ b/src/controller/java/BUILD.gn @@ -25,6 +25,10 @@ if (!build_java_matter_controller) { shared_library("jni") { output_name = "libCHIPController" + if (current_os == "mac") { + output_extension = "dylib" + } + sources = [ "AndroidCallbacks-JNI.cpp", "AndroidCallbacks.cpp", @@ -54,12 +58,7 @@ shared_library("jni") { "zap-generated/CHIPReadCallbacks.cpp", "zap-generated/CHIPReadCallbacks.h", ] - if (build_java_matter_controller) { - sources += [ - "${chip_root}/src/controller/ExamplePersistentStorage.cpp", - "${chip_root}/src/controller/ExamplePersistentStorage.h", - ] - } + deps = [ "${chip_root}/src/controller/data_model", "${chip_root}/src/controller/data_model:java-jni-sources", @@ -70,13 +69,22 @@ shared_library("jni") { "${chip_root}/src/platform", ] - public_configs = [ "${chip_root}/src:includes" ] - 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" ] - deps += [ "${chip_root}/src/platform/Linux" ] + if (current_os == "mac") { + deps += [ "${chip_root}/src/platform/Darwin" ] + } else { + deps += [ "${chip_root}/src/platform/Linux" ] + } cflags = [ "-Wno-unknown-pragmas" ] @@ -87,7 +95,13 @@ shared_library("jni") { output_dir = "${root_out_dir}/lib/jni/${android_abi}" } - ldflags = [ "-Wl,--gc-sections" ] + if (current_os == "mac") { + ldflags = [ "-Wl,-dead_strip" ] + } else { + ldflags = [ "-Wl,--gc-sections" ] + } + + public_configs = [ "${chip_root}/src:includes" ] } if (chip_link_tests) { @@ -105,8 +119,11 @@ if (chip_link_tests) { if (build_java_matter_controller) { defines = [ "JAVA_MATTER_CONTROLLER_TEST" ] include_dirs = java_matter_controller_dependent_paths - - deps += [ "${chip_root}/src/platform/Linux" ] + if (current_os == "mac") { + deps += [ "${chip_root}/src/platform/Darwin" ] + } else { + deps += [ "${chip_root}/src/platform/Linux" ] + } cflags = [ "-Wno-unknown-pragmas" ]