]> granicus.if.org Git - libjpeg-turbo/commitdiff
Include TurboJPEG/OSS Java wrapper JAR in Windows distribution packages
authorDRC <dcommander@users.sourceforge.net>
Fri, 1 Apr 2011 11:13:11 +0000 (11:13 +0000)
committerDRC <dcommander@users.sourceforge.net>
Fri, 1 Apr 2011 11:13:11 +0000 (11:13 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@553 632fc199-4ca6-4c93-a231-07263d6284db

CMakeLists.txt
java/CMakeLists.txt [new file with mode: 0644]
java/Makefile.am
release/libjpeg-turbo.nsi.in

index edf00a30a9f6b816a97988c4bb50af046b570879..8f8c75f088bc82ae647622670c5adc4dbec01812 100644 (file)
@@ -58,14 +58,14 @@ else()
   message(STATUS "Arithmetic decoding support disabled")
 endif()
 
-if(NOT DEFINED WITH_JNI)
-  set(WITH_JNI 0)
+if(NOT DEFINED WITH_JAVA)
+  set(WITH_JAVA 0)
 endif()
 
-if(WITH_JNI)
-  message(STATUS "TurboJPEG/OSS JNI wrapper enabled")
+if(WITH_JAVA)
+  message(STATUS "TurboJPEG/OSS Java wrapper enabled")
 else()
-  message(STATUS "TurboJPEG/OSS JNI wrapper disabled")
+  message(STATUS "TurboJPEG/OSS Java wrapper disabled")
 endif()
 
 set(JPEG_LIB_VERSION 62)
@@ -115,12 +115,9 @@ configure_file(win/config.h.in config.h)
 
 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
 
-if(WITH_JNI)
-  include(CheckIncludeFiles)
-  check_include_files(jni.h HAVE_JNI_H)
-  if(NOT HAVE_JNI_H)
-    message(FATAL_ERROR "Cannot find jni.h.  Be sure to add the Java include directories to the INCLUDE environment variable (MSVC) or the CPATH environment variable (GCC).")
-  endif()
+if(WITH_JAVA)
+  find_package(Java)
+  find_package(JNI)
 endif()
 
 
@@ -163,6 +160,10 @@ else()
   message(STATUS "Not using SIMD acceleration")
 endif()
 
+if(WITH_JAVA)
+  add_subdirectory(java)
+endif()
+
 add_subdirectory(sharedlib)
 
 add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
@@ -174,8 +175,9 @@ if(WITH_SIMD)
 endif()
 
 set(TURBOJPEG_SOURCES turbojpegl.c transupp.c)
-if(WITH_JNI)
+if(WITH_JAVA)
   set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
+  include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
 endif()
 
 add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
@@ -231,7 +233,19 @@ add_executable(wrjpgcom rdjpgcom.c)
 # Tests
 #
 
+if(MSVC_IDE)
+  set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
+else()
+  set(OBJDIR "")
+endif()
+
 enable_testing()
+if(WITH_JAVA)
+add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
+add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
+add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
+add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
+endif()
 add_test(jpegut jpegut)
 add_test(jpegut-yuv jpegut -yuv)
 add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
@@ -349,6 +363,10 @@ if(64BIT)
   set(INST_DEFS ${INST_DEFS} -DWIN64)
 endif()
 
+if(WITH_JAVA)
+  set(INST_DEFS ${INST_DEFS} -DJAVA)
+endif()
+
 if(MSVC_IDE)
   set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=$(OutDir)\\")
 else()
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b676ce8
--- /dev/null
@@ -0,0 +1,45 @@
+set(JAR_FILE turbojpeg.jar)
+set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.MF)
+
+set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ
+  org/libjpegturbo/turbojpeg/TJCompressor
+  org/libjpegturbo/turbojpeg/TJDecompressor
+  org/libjpegturbo/turbojpeg/TJTransform
+  org/libjpegturbo/turbojpeg/TJTransformer
+  TJUnitTest
+  TJExample)
+
+if(MSVC_IDE)
+  set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/$(OutDir)")
+else()
+  set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
+endif()
+
+set(JAVA_SOURCES "")
+set(JAVA_CLASSES "")
+set(JAVA_CLASSES_FULL "")
+foreach(class ${JAVA_CLASSNAMES})
+  set(JAVA_SOURCES ${JAVA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${class}.java)
+  set(JAVA_CLASSES ${JAVA_CLASSES} ${class}.class)
+  set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL} ${OBJDIR}/${class}.class)
+endforeach()
+
+if(MSVC_IDE)
+  set(JAVA_CLASSES ${JAVA_CLASSES}
+    org/libjpegturbo/turbojpeg/TJ$ScalingFactor.class)
+else()
+  set(JAVA_CLASSES ${JAVA_CLASSES}
+    org/libjpegturbo/turbojpeg/TJ$$ScalingFactor.class)
+endif()
+
+add_custom_command(OUTPUT ${JAVA_CLASSES_FULL} DEPENDS ${JAVA_SOURCES}
+  COMMAND ${JAVA_COMPILE} -d ${OBJDIR} ARGS ${JAVA_SOURCES})
+
+add_custom_command(OUTPUT ${JAR_FILE} DEPENDS ${JAVA_CLASSES_FULL}
+  ${MANIFEST_FILE}
+  COMMAND ${JAVA_ARCHIVE} cfm ${JAR_FILE} ${MANIFEST_FILE} ${JAVA_CLASSES}
+  WORKING_DIRECTORY ${OBJDIR})
+
+add_custom_target(java ALL DEPENDS ${JAR_FILE})
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${JAR_FILE} DESTINATION classes)
index 9afa74cdece610dfa4d9ca100b2f0ba1af3aff27..7615442f7b3199bbb26ce9eef4f30c7f9aed5620 100644 (file)
@@ -44,4 +44,4 @@ uninstall-local:
 
 endif
 
-EXTRA_DIST = MANIFEST.MF ${JAVASOURCES} ${JNIHEADERS} doc
+EXTRA_DIST = MANIFEST.MF ${JAVASOURCES} ${JNIHEADERS} doc CMakeLists.txt
index 6eb4bae6bd6e55df2d203e250227c8f6ce63e9cc..576e66850d084a1d3a05b8b04bdf35e8b25fce8e 100755 (executable)
@@ -62,6 +62,10 @@ Section "@CMAKE_PROJECT_NAME@ SDK for @INST_PLATFORM@ (required)"
        File "@CMAKE_BINARY_DIR@\${BUILDDIR}turbojpeg-static.lib"
        File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}jpeg.lib"
        File "@CMAKE_BINARY_DIR@\${BUILDDIR}jpeg-static.lib"
+!endif
+!ifdef JAVA
+       SetOutPath $INSTDIR\classes
+       File "@CMAKE_BINARY_DIR@\java\${BUILDDIR}turbojpeg.jar"
 !endif
        SetOutPath $INSTDIR\include
        File "@CMAKE_BINARY_DIR@\jconfig.h"
@@ -112,6 +116,9 @@ Section "Uninstall"
        Delete $INSTDIR\lib\jpeg-static.lib
        Delete $INSTDIR\lib\turbojpeg.lib
        Delete $INSTDIR\lib\turbojpeg-static.lib
+!endif
+!ifdef JAVA
+       Delete $INSTDIR\classes\turbojpeg.jar
 !endif
        Delete $INSTDIR\bin\cjpeg.exe
        Delete $INSTDIR\bin\djpeg.exe
@@ -135,6 +142,9 @@ Section "Uninstall"
        RMDir "$INSTDIR\include"
        RMDir "$INSTDIR\lib"
        RMDir "$INSTDIR\doc"
+!ifdef JAVA
+       RMDir "$INSTDIR\classes"
+!endif
        RMDir "$INSTDIR\bin"
        RMDir "$INSTDIR"