[opencv] 115/251: java: update source files processing, maven stuff

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:33 UTC 2017


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.

commit 2360291c3ebf43c542271dc8082c2444aff10633
Author: Alexander Alekhin <alexander.alekhin at intel.com>
Date:   Wed Jul 19 15:08:11 2017 +0300

    java: update source files processing, maven stuff
---
 modules/java/CMakeLists.txt                        | 63 +++++++++++++++-------
 .../src/org/opencv/test/OpenCVTestRunner.java      |  2 +-
 ...nCVLoader.java => android+OpenCVLoader.java.in} | 11 ++++
 modules/java/generator/src/java/android+sync.py    |  7 ---
 ...Loader.java => osgi+OpenCVNativeLoader.java.in} |  2 +-
 platforms/maven/opencv-it/pom.xml                  |  2 +-
 .../java/org/opencv/osgi/DeployOpenCVTest.java     |  6 +--
 platforms/maven/opencv/pom.xml                     | 25 +++------
 platforms/maven/opencv/scripts/execstack_check     |  6 ++-
 platforms/maven/pom.xml                            |  8 +--
 10 files changed, 78 insertions(+), 54 deletions(-)

diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt
index 11628d4..74bc0ef 100644
--- a/modules/java/CMakeLists.txt
+++ b/modules/java/CMakeLists.txt
@@ -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
diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
index 22f1229..d5c1ecd 100644
--- a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
+++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
@@ -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 {
diff --git a/modules/java/generator/src/java/android+OpenCVLoader.java b/modules/java/generator/src/java/android+OpenCVLoader.java.in
similarity index 91%
rename from modules/java/generator/src/java/android+OpenCVLoader.java
rename to modules/java/generator/src/java/android+OpenCVLoader.java.in
index a84a49e..8f8cd05 100644
--- a/modules/java/generator/src/java/android+OpenCVLoader.java
+++ b/modules/java/generator/src/java/android+OpenCVLoader.java.in
@@ -83,6 +83,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 at .@OPENCV_VERSION_MINOR at .@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.
      */
diff --git a/modules/java/generator/src/java/android+sync.py b/modules/java/generator/src/java/android+sync.py
deleted file mode 100755
index ed78537..0000000
--- a/modules/java/generator/src/java/android+sync.py
+++ /dev/null
@@ -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));
diff --git a/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java b/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java.in
similarity index 90%
rename from modules/java/generator/src/java/osgi+OpenCVNativeLoader.java
rename to modules/java/generator/src/java/osgi+OpenCVNativeLoader.java.in
index 5ab9847..77e290b 100644
--- a/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java
+++ b/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java.in
@@ -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 at LIB_NAME_SUFIX@");
         Logger.getLogger("org.opencv.osgi").log(Level.INFO, "Successfully loaded OpenCV native library.");
     }
 }
diff --git a/platforms/maven/opencv-it/pom.xml b/platforms/maven/opencv-it/pom.xml
index caeaa7b..c1522a2 100644
--- a/platforms/maven/opencv-it/pom.xml
+++ b/platforms/maven/opencv-it/pom.xml
@@ -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>
diff --git a/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java b/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java
index 71c1f3b..be05ba6 100644
--- a/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java
+++ b/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java
@@ -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);
 
diff --git a/platforms/maven/opencv/pom.xml b/platforms/maven/opencv/pom.xml
index 23b65c2..e3e424b 100644
--- a/platforms/maven/opencv/pom.xml
+++ b/platforms/maven/opencv/pom.xml
@@ -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>
@@ -90,21 +90,6 @@
                         </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>
                         <goals>
@@ -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>
diff --git a/platforms/maven/opencv/scripts/execstack_check b/platforms/maven/opencv/scripts/execstack_check
index f40db09..04faeff 100755
--- a/platforms/maven/opencv/scripts/execstack_check
+++ b/platforms/maven/opencv/scripts/execstack_check
@@ -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}"
diff --git a/platforms/maven/pom.xml b/platforms/maven/pom.xml
index 15aba5f..dd8c824 100644
--- a/platforms/maven/pom.xml
+++ b/platforms/maven/pom.xml
@@ -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>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list