mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #28159 from asmorkalov:as/java_cleaners
Introduce option to generate Java code with finalize() or Cleaners interface #28159 Closes https://github.com/opencv/opencv/issues/22260 Replaces https://github.com/opencv/opencv/pull/23467 The PR introduce configuration option to generate Java code with Cleaner interface for Java 9+ and old-fashion finalize() method for old Java and Android. Mat class and derivatives are manually written. The PR introduce 2 base classes for it depending on the generator configuration. Pros: 1. No need to implement complex and error prone cleaner on library side. 2. No new CMake templates, easier to modify code in IDE. Cons: 1. More generator branches and different code for modern desktop and Android. TODO: - [x] Add Java version check to cmake - [x] Use Cleaners for ANDROID API 33+ ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
7ca9d9ce03
commit
c03734475f
@@ -62,6 +62,24 @@ ocv_bindings_generator_populate_preprocessor_definitions(
|
||||
opencv_preprocessor_defs
|
||||
)
|
||||
|
||||
if(OPENCV_JAVA_CLEANING_API)
|
||||
if(OPENCV_JAVA_CLEANING_API STREQUAL "finalize")
|
||||
set(opencv_supported_cleaners "false")
|
||||
elseif(OPENCV_JAVA_CLEANING_API STREQUAL "cleaner")
|
||||
set(opencv_supported_cleaners "true")
|
||||
else()
|
||||
message(FATAL_ERROR "OPENCV_JAVA_CLEANING_API should be one of \"finalize\" or \"cleaner\"")
|
||||
endif()
|
||||
else()
|
||||
if(ANDROID OR (Java_VERSION VERSION_LESS 9))
|
||||
message(STATUS "Set Cleaners to False")
|
||||
set(opencv_supported_cleaners "false")
|
||||
else()
|
||||
message(STATUS "Set Cleaners to True")
|
||||
set(opencv_supported_cleaners "true")
|
||||
endif()
|
||||
endif(OPENCV_JAVA_CLEANING_API)
|
||||
|
||||
set(CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/gen_java.json")
|
||||
set(__config_str
|
||||
"{
|
||||
@@ -74,7 +92,8 @@ ${opencv_preprocessor_defs}
|
||||
},
|
||||
\"files_remap\": [
|
||||
${__remap_config}
|
||||
]
|
||||
],
|
||||
\"support_cleaners\": ${opencv_supported_cleaners}
|
||||
}
|
||||
")
|
||||
if(EXISTS "${CONFIG_FILE}")
|
||||
|
||||
Reference in New Issue
Block a user