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")
|
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/gen")
|
||||||
endif()
|
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("${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp")
|
||||||
ocv_module_include_directories("${OpenCV_SOURCE_DIR}/include")
|
ocv_module_include_directories("${OpenCV_SOURCE_DIR}/include")
|
||||||
|
|
||||||
@ -69,7 +75,7 @@ macro(glob_more_specific_sources _type _root _output)
|
|||||||
elseif(${_type} STREQUAL "CPP")
|
elseif(${_type} STREQUAL "CPP")
|
||||||
set(_masks "${_root}/src/cpp/*.cpp")
|
set(_masks "${_root}/src/cpp/*.cpp")
|
||||||
elseif(${_type} STREQUAL "JAVA")
|
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")
|
elseif(${_type} STREQUAL "AIDL")
|
||||||
set(_masks "${_root}/src/java/*.aidl")
|
set(_masks "${_root}/src/java/*.aidl")
|
||||||
endif()
|
endif()
|
||||||
@ -257,22 +263,49 @@ endforeach()
|
|||||||
# step 3: copy files to destination
|
# step 3: copy files to destination
|
||||||
set(step3_input_files ${generated_java_sources} ${handwritten_java_sources} ${handwritten_aidl_sources})
|
set(step3_input_files ${generated_java_sources} ${handwritten_java_sources} ${handwritten_aidl_sources})
|
||||||
set(copied_files "")
|
set(copied_files "")
|
||||||
|
set(java_src_dir "${OpenCV_BINARY_DIR}/src")
|
||||||
foreach(java_file ${step3_input_files})
|
foreach(java_file ${step3_input_files})
|
||||||
get_filename_component(java_file_name "${java_file}" NAME)
|
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 "-jdoc.java" ".java" java_file_name "${java_file_name}")
|
||||||
string(REPLACE "+" "/" java_file_name "${java_file_name}")
|
if(EXISTS "${java_file}")
|
||||||
set(output_name "${OpenCV_BINARY_DIR}/src/org/opencv/${java_file_name}")
|
file(STRINGS "${java_file}" PACKAGE_STR LIMIT_COUNT 1 REGEX "package.*;$")
|
||||||
add_custom_command(OUTPUT "${output_name}"
|
else()
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_file}" "${output_name}"
|
set(PACKAGE_STR "")
|
||||||
MAIN_DEPENDENCY "${java_file}"
|
endif()
|
||||||
DEPENDS ${step1_depends} ${generated_java_sources} ${handwritten_java_sources}
|
if(PACKAGE_STR)
|
||||||
COMMENT "Generating src/org/opencv/${java_file_name}"
|
list(GET PACKAGE_STR 0 package_name)
|
||||||
)
|
string(REGEX REPLACE "^package[ ]+" "" package_name "${package_name}")
|
||||||
list(APPEND copied_files "${output_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)
|
if(ANDROID)
|
||||||
get_filename_component(install_subdir "${java_file_name}" PATH)
|
get_filename_component(install_subdir "${output_name}" PATH)
|
||||||
install(FILES "${output_name}" DESTINATION "${JAVA_INSTALL_ROOT}/src/org/opencv/${install_subdir}" COMPONENT java)
|
install(FILES "${java_src_dir}/${output_name}" DESTINATION "${JAVA_INSTALL_ROOT}/src/${install_subdir}" COMPONENT java)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@ -334,12 +367,6 @@ endif(ANDROID AND ANDROID_EXECUTABLE)
|
|||||||
|
|
||||||
set(step3_depends ${step2_depends} ${step3_input_files} ${copied_files})
|
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")
|
file(MAKE_DIRECTORY "${OpenCV_BINARY_DIR}/bin")
|
||||||
|
|
||||||
# step 4: build jar
|
# step 4: build jar
|
||||||
|
@ -82,7 +82,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
|
|||||||
// Using OpenCV Manager for initialization;
|
// Using OpenCV Manager for initialization;
|
||||||
|
|
||||||
Log("Internal OpenCV library not found. 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) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
|
@ -82,6 +82,17 @@ public class OpenCVLoader
|
|||||||
*/
|
*/
|
||||||
public static final String OPENCV_VERSION_3_2_0 = "3.2.0";
|
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").
|
* 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.
|
* @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 class OpenCVNativeLoader implements OpenCVInterface {
|
||||||
|
|
||||||
public void init() {
|
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.");
|
Logger.getLogger("org.opencv.osgi").log(Level.INFO, "Successfully loaded OpenCV native library.");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.opencv</groupId>
|
<groupId>org.opencv</groupId>
|
||||||
<artifactId>opencv-parent</artifactId>
|
<artifactId>opencv-parent</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.opencv</groupId>
|
<groupId>org.opencv</groupId>
|
||||||
<artifactId>opencv-it</artifactId>
|
<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.
|
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";
|
private static final String KARAF_VERSION = "4.0.6";
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class DeployOpenCVTest {
|
|||||||
mavenBundle()
|
mavenBundle()
|
||||||
.groupId("org.opencv")
|
.groupId("org.opencv")
|
||||||
.artifactId("opencv")
|
.artifactId("opencv")
|
||||||
.version("3.2.0"),
|
.version("3.3.0"),
|
||||||
logLevel(LogLevelOption.LogLevel.INFO)
|
logLevel(LogLevelOption.LogLevel.INFO)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class DeployOpenCVTest {
|
|||||||
public void testOpenCVNativeLibraryLoadSuccess() {
|
public void testOpenCVNativeLibraryLoadSuccess() {
|
||||||
|
|
||||||
Iterable<PaxLoggingEvent> loggingEvents = logService.getEvents();
|
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);
|
TestCase.assertTrue("Could not determine if OpenCV library successfully loaded from the logs.", loadSuccessful);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.opencv</groupId>
|
<groupId>org.opencv</groupId>
|
||||||
<artifactId>opencv-parent</artifactId>
|
<artifactId>opencv-parent</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.opencv</groupId>
|
<groupId>org.opencv</groupId>
|
||||||
<artifactId>opencv</artifactId>
|
<artifactId>opencv</artifactId>
|
||||||
@ -89,21 +89,6 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</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>
|
<execution>
|
||||||
<id>check-execstack</id>
|
<id>check-execstack</id>
|
||||||
<phase>process-classes</phase>
|
<phase>process-classes</phase>
|
||||||
@ -115,7 +100,7 @@
|
|||||||
<executable>bash</executable>
|
<executable>bash</executable>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>execstack_check</argument>
|
<argument>execstack_check</argument>
|
||||||
<argument>${build.directory}/lib/libopencv_java320.so</argument>
|
<argument>${build.directory}/lib/libopencv_java${lib.version.string}.so</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
@ -190,10 +175,12 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<rules>
|
<rules>
|
||||||
<requireEnvironmentVariable>
|
<requireEnvironmentVariable>
|
||||||
|
<level>WARN</level>
|
||||||
<variableName>ANT_HOME</variableName>
|
<variableName>ANT_HOME</variableName>
|
||||||
<message>$ANT_HOME is not set. Build may fail.</message>
|
<message>$ANT_HOME is not set. Build may fail.</message>
|
||||||
</requireEnvironmentVariable>
|
</requireEnvironmentVariable>
|
||||||
<requireEnvironmentVariable>
|
<requireEnvironmentVariable>
|
||||||
|
<level>WARN</level>
|
||||||
<variableName>JAVA_HOME</variableName>
|
<variableName>JAVA_HOME</variableName>
|
||||||
<message>$JAVA_HOME is not set. Build WILL fail.</message>
|
<message>$JAVA_HOME is not set. Build WILL fail.</message>
|
||||||
</requireEnvironmentVariable>
|
</requireEnvironmentVariable>
|
||||||
@ -245,6 +232,7 @@
|
|||||||
<version>3.4.1-b2</version>
|
<version>3.4.1-b2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
<id>cmake-generate</id>
|
<id>cmake-generate</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>generate</goal>
|
<goal>generate</goal>
|
||||||
@ -255,15 +243,18 @@
|
|||||||
<generator>Unix Makefiles</generator>
|
<generator>Unix Makefiles</generator>
|
||||||
<options>
|
<options>
|
||||||
<option>-DBUILD_SHARED_LIBS:BOOL=OFF</option>
|
<option>-DBUILD_SHARED_LIBS:BOOL=OFF</option>
|
||||||
|
<option>-DWITH_CUDA=OFF</option>
|
||||||
</options>
|
</options>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
<id>cmake-compile</id>
|
<id>cmake-compile</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compile</goal>
|
<goal>compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<target>opencv_java</target>
|
||||||
<projectDirectory>../../../build</projectDirectory>
|
<projectDirectory>../../../build</projectDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -20,8 +20,10 @@ red=$'\e[1;31m'
|
|||||||
green=$'\e[1;32m'
|
green=$'\e[1;32m'
|
||||||
end=$'\e[0m'
|
end=$'\e[0m'
|
||||||
echo "${green}[INFO] Checking that the native library executable stack flag is NOT set.${end}"
|
echo "${green}[INFO] Checking that the native library executable stack flag is NOT set.${end}"
|
||||||
execstack -c $1
|
BINARY=execstack
|
||||||
execstack -q $1 | grep -o ^-
|
$BINARY --help > /dev/null || BINARY=/usr/sbin/execstack
|
||||||
|
$BINARY -c $1
|
||||||
|
$BINARY -q $1 | grep -o ^-
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo
|
echo
|
||||||
echo "${red}[ERROR] The Executable Flag could not be cleared on the library $1.${end}"
|
echo "${red}[ERROR] The Executable Flag could not be cleared on the library $1.${end}"
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.opencv</groupId>
|
<groupId>org.opencv</groupId>
|
||||||
<artifactId>opencv-parent</artifactId>
|
<artifactId>opencv-parent</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>OpenCV Parent POM</name>
|
<name>OpenCV Parent POM</name>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>License Agreement For Open Source Computer Vision Library (3-clause BSD License)</name>
|
<name>License Agreement For Open Source Computer Vision Library (3-clause BSD License)</name>
|
||||||
<url></url>
|
<url>http://opencv.org/license.html</url>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<url>http://opencv.org/</url>
|
<url>http://opencv.org/</url>
|
||||||
@ -29,8 +29,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
|
<nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
|
||||||
<pax.exam.version>4.8.0</pax.exam.version>
|
<pax.exam.version>4.8.0</pax.exam.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
|
Loading…
Reference in New Issue
Block a user