mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
java: update source files processing, maven stuff
This commit is contained in:
parent
02829f73e0
commit
2360291c3e
@ -18,6 +18,12 @@ if(EXISTS ${CMAKE_BINARY_DIR}/gen)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/gen")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}")
|
||||
else()
|
||||
set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp")
|
||||
ocv_module_include_directories("${OpenCV_SOURCE_DIR}/include")
|
||||
|
||||
@ -69,7 +75,7 @@ macro(glob_more_specific_sources _type _root _output)
|
||||
elseif(${_type} STREQUAL "CPP")
|
||||
set(_masks "${_root}/src/cpp/*.cpp")
|
||||
elseif(${_type} STREQUAL "JAVA")
|
||||
set(_masks "${_root}/src/java/*.java")
|
||||
set(_masks "${_root}/src/java/*.java" "${_root}/src/java/*.java.in")
|
||||
elseif(${_type} STREQUAL "AIDL")
|
||||
set(_masks "${_root}/src/java/*.aidl")
|
||||
endif()
|
||||
@ -257,22 +263,49 @@ endforeach()
|
||||
# step 3: copy files to destination
|
||||
set(step3_input_files ${generated_java_sources} ${handwritten_java_sources} ${handwritten_aidl_sources})
|
||||
set(copied_files "")
|
||||
set(java_src_dir "${OpenCV_BINARY_DIR}/src")
|
||||
foreach(java_file ${step3_input_files})
|
||||
get_filename_component(java_file_name "${java_file}" NAME)
|
||||
set(__configure 0)
|
||||
if (java_file_name MATCHES "\\.in$")
|
||||
string(REGEX REPLACE "\\.in$" "" java_file_name "${java_file_name}")
|
||||
set(__configure 1)
|
||||
endif()
|
||||
string(REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}")
|
||||
string(REPLACE "+" "/" java_file_name "${java_file_name}")
|
||||
set(output_name "${OpenCV_BINARY_DIR}/src/org/opencv/${java_file_name}")
|
||||
add_custom_command(OUTPUT "${output_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_file}" "${output_name}"
|
||||
MAIN_DEPENDENCY "${java_file}"
|
||||
DEPENDS ${step1_depends} ${generated_java_sources} ${handwritten_java_sources}
|
||||
COMMENT "Generating src/org/opencv/${java_file_name}"
|
||||
)
|
||||
list(APPEND copied_files "${output_name}")
|
||||
if(EXISTS "${java_file}")
|
||||
file(STRINGS "${java_file}" PACKAGE_STR LIMIT_COUNT 1 REGEX "package.*;$")
|
||||
else()
|
||||
set(PACKAGE_STR "")
|
||||
endif()
|
||||
if(PACKAGE_STR)
|
||||
list(GET PACKAGE_STR 0 package_name)
|
||||
string(REGEX REPLACE "^package[ ]+" "" package_name "${package_name}")
|
||||
string(REGEX REPLACE ";$" "" package_name "${package_name}")
|
||||
|
||||
string(REGEX REPLACE ".*\\+" "" java_file_name "${java_file_name}")
|
||||
string(REPLACE "." "/" package_path "${package_name}")
|
||||
set(output_name "${package_path}/${java_file_name}")
|
||||
else()
|
||||
string(REPLACE "+" "/" java_file_name "${java_file_name}")
|
||||
set(output_name "org/opencv/${java_file_name}")
|
||||
endif()
|
||||
if(__configure)
|
||||
configure_file("${java_file}" "${java_src_dir}/${output_name}" @ONLY)
|
||||
elseif(NOT "${java_file}" MATCHES "${OpenCV_BINARY_DIR}/")
|
||||
configure_file("${java_file}" "${java_src_dir}/${output_name}" COPYONLY)
|
||||
else()
|
||||
add_custom_command(OUTPUT "${java_src_dir}/${output_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_file}" "${java_src_dir}/${output_name}"
|
||||
MAIN_DEPENDENCY "${java_file}"
|
||||
DEPENDS "${java_file}"
|
||||
COMMENT "Generating src/${output_name}"
|
||||
)
|
||||
endif()
|
||||
list(APPEND copied_files "${java_src_dir}/${output_name}")
|
||||
|
||||
if(ANDROID)
|
||||
get_filename_component(install_subdir "${java_file_name}" PATH)
|
||||
install(FILES "${output_name}" DESTINATION "${JAVA_INSTALL_ROOT}/src/org/opencv/${install_subdir}" COMPONENT java)
|
||||
get_filename_component(install_subdir "${output_name}" PATH)
|
||||
install(FILES "${java_src_dir}/${output_name}" DESTINATION "${JAVA_INSTALL_ROOT}/src/${install_subdir}" COMPONENT java)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@ -334,12 +367,6 @@ endif(ANDROID AND ANDROID_EXECUTABLE)
|
||||
|
||||
set(step3_depends ${step2_depends} ${step3_input_files} ${copied_files})
|
||||
|
||||
if(ANDROID)
|
||||
set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}")
|
||||
else()
|
||||
set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY "${OpenCV_BINARY_DIR}/bin")
|
||||
|
||||
# step 4: build jar
|
||||
|
@ -82,7 +82,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
|
||||
// Using OpenCV Manager for initialization;
|
||||
|
||||
Log("Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, getContext(), mLoaderCallback);
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION, getContext(), mLoaderCallback);
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
|
@ -82,6 +82,17 @@ public class OpenCVLoader
|
||||
*/
|
||||
public static final String OPENCV_VERSION_3_2_0 = "3.2.0";
|
||||
|
||||
/**
|
||||
* OpenCV Library version 3.3.0.
|
||||
*/
|
||||
public static final String OPENCV_VERSION_3_3_0 = "3.3.0";
|
||||
|
||||
/**
|
||||
* Current OpenCV Library version
|
||||
*/
|
||||
public static final String OPENCV_VERSION = "@OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@";
|
||||
|
||||
|
||||
/**
|
||||
* Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
|
||||
* @return Returns true is initialization of OpenCV was successful.
|
@ -1,7 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
for f in os.listdir("."):
|
||||
shutil.copyfile(f, os.path.join("../../../../../../modules/java/generator/src/java/", "android+" + f));
|
@ -12,7 +12,7 @@ import java.util.logging.Logger;
|
||||
public class OpenCVNativeLoader implements OpenCVInterface {
|
||||
|
||||
public void init() {
|
||||
System.loadLibrary("opencv_java320");
|
||||
System.loadLibrary("opencv_java@LIB_NAME_SUFIX@");
|
||||
Logger.getLogger("org.opencv.osgi").log(Level.INFO, "Successfully loaded OpenCV native library.");
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.opencv</groupId>
|
||||
<artifactId>opencv-parent</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
</parent>
|
||||
<groupId>org.opencv</groupId>
|
||||
<artifactId>opencv-it</artifactId>
|
||||
|
@ -32,7 +32,7 @@ public class DeployOpenCVTest {
|
||||
/*
|
||||
The expected string in Karaf logs when the bundle has deployed and native library loaded.
|
||||
*/
|
||||
private static final String OPEN_CV_SUCCESSFUL_LOAD_STRING = "Successfully loaded OpenCV native library.";
|
||||
private static final String OPENCV_SUCCESSFUL_LOAD_STRING = "Successfully loaded OpenCV native library.";
|
||||
|
||||
private static final String KARAF_VERSION = "4.0.6";
|
||||
|
||||
@ -65,7 +65,7 @@ public class DeployOpenCVTest {
|
||||
mavenBundle()
|
||||
.groupId("org.opencv")
|
||||
.artifactId("opencv")
|
||||
.version("3.2.0"),
|
||||
.version("3.3.0"),
|
||||
logLevel(LogLevelOption.LogLevel.INFO)
|
||||
};
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class DeployOpenCVTest {
|
||||
public void testOpenCVNativeLibraryLoadSuccess() {
|
||||
|
||||
Iterable<PaxLoggingEvent> loggingEvents = logService.getEvents();
|
||||
boolean loadSuccessful = logsContainsMessage(loggingEvents, OPEN_CV_SUCCESSFUL_LOAD_STRING);
|
||||
boolean loadSuccessful = logsContainsMessage(loggingEvents, OPENCV_SUCCESSFUL_LOAD_STRING);
|
||||
|
||||
TestCase.assertTrue("Could not determine if OpenCV library successfully loaded from the logs.", loadSuccessful);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.opencv</groupId>
|
||||
<artifactId>opencv-parent</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
</parent>
|
||||
<groupId>org.opencv</groupId>
|
||||
<artifactId>opencv</artifactId>
|
||||
@ -89,21 +89,6 @@
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>execstack</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<workingDirectory>${build.directory}/lib</workingDirectory>
|
||||
<executable>execstack</executable>
|
||||
<arguments>
|
||||
<argument>-c</argument>
|
||||
<argument>libopencv_java320.so</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>check-execstack</id>
|
||||
<phase>process-classes</phase>
|
||||
@ -115,7 +100,7 @@
|
||||
<executable>bash</executable>
|
||||
<arguments>
|
||||
<argument>execstack_check</argument>
|
||||
<argument>${build.directory}/lib/libopencv_java320.so</argument>
|
||||
<argument>${build.directory}/lib/libopencv_java${lib.version.string}.so</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -190,10 +175,12 @@
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireEnvironmentVariable>
|
||||
<level>WARN</level>
|
||||
<variableName>ANT_HOME</variableName>
|
||||
<message>$ANT_HOME is not set. Build may fail.</message>
|
||||
</requireEnvironmentVariable>
|
||||
<requireEnvironmentVariable>
|
||||
<level>WARN</level>
|
||||
<variableName>JAVA_HOME</variableName>
|
||||
<message>$JAVA_HOME is not set. Build WILL fail.</message>
|
||||
</requireEnvironmentVariable>
|
||||
@ -245,6 +232,7 @@
|
||||
<version>3.4.1-b2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<id>cmake-generate</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
@ -255,15 +243,18 @@
|
||||
<generator>Unix Makefiles</generator>
|
||||
<options>
|
||||
<option>-DBUILD_SHARED_LIBS:BOOL=OFF</option>
|
||||
<option>-DWITH_CUDA=OFF</option>
|
||||
</options>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<id>cmake-compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>opencv_java</target>
|
||||
<projectDirectory>../../../build</projectDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -20,8 +20,10 @@ red=$'\e[1;31m'
|
||||
green=$'\e[1;32m'
|
||||
end=$'\e[0m'
|
||||
echo "${green}[INFO] Checking that the native library executable stack flag is NOT set.${end}"
|
||||
execstack -c $1
|
||||
execstack -q $1 | grep -o ^-
|
||||
BINARY=execstack
|
||||
$BINARY --help > /dev/null || BINARY=/usr/sbin/execstack
|
||||
$BINARY -c $1
|
||||
$BINARY -q $1 | grep -o ^-
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
echo "${red}[ERROR] The Executable Flag could not be cleared on the library $1.${end}"
|
||||
|
@ -3,13 +3,13 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.opencv</groupId>
|
||||
<artifactId>opencv-parent</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>OpenCV Parent POM</name>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>License Agreement For Open Source Computer Vision Library (3-clause BSD License)</name>
|
||||
<url></url>
|
||||
<url>http://opencv.org/license.html</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<url>http://opencv.org/</url>
|
||||
@ -29,8 +29,8 @@
|
||||
<properties>
|
||||
<nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
|
||||
<pax.exam.version>4.8.0</pax.exam.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
|
Loading…
Reference in New Issue
Block a user