]> source.dussan.org Git - tigervnc.git/commitdiff
Integrate Java TigerVNC Viewer build into CMake build system
authorDRC <dcommander@users.sourceforge.net>
Tue, 4 Oct 2011 04:03:34 +0000 (04:03 +0000)
committerDRC <dcommander@users.sourceforge.net>
Tue, 4 Oct 2011 04:03:34 +0000 (04:03 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4690 3789f03b-4d11-0410-bbf8-ca57d06f2519

CMakeLists.txt
cmake/BuildPackages.cmake
cmake/getdate.bat
java/src/CMakeLists.txt [new file with mode: 0644]
java/src/com/tigervnc/vncviewer/timestamp.in [new file with mode: 0644]
release/maketarball.in

index e330dc6e4ff6c3df3a70fe12660d8e725f7301a6..5bba01f1684fd382504d01e27bc984900b916d86 100644 (file)
@@ -260,6 +260,11 @@ if(NOT FOUND_LIBJPEG_TURBO)
   message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
 endif()
 
+option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE)
+if(BUILD_JAVA)
+  add_subdirectory(java/src)
+endif()
+
 # Check for FLTK
 if(BUILD_NEW_VNCVIEWER)
   set(FLTK_SKIP_FLUID TRUE)
index 1e3dd42c25d7848b0e6b64dbf1a576b044c8601f..100ba05a54c10e9783a1c1eed6c389852b3db8e8 100644 (file)
@@ -77,12 +77,17 @@ if(UNIX)
 
 configure_file(release/maketarball.in release/maketarball)
 
+set(TARBALL_DEPENDS vncviewer vncpasswd vncconfig)
+if(BUILD_JAVA)
+  set(TARBALL_DEPENDS ${TARBALL_DEPENDS} java)
+endif()
+
 add_custom_target(tarball sh release/maketarball
-  DEPENDS vncviewer vncpasswd vncconfig
+  DEPENDS ${TARBALL_DEPENDS}
   SOURCES release/maketarball)
 
 add_custom_target(servertarball sh release/maketarball server
-  DEPENDS vncviewer vncpasswd vncconfig
+  DEPENDS ${TARBALL_DEPENDS}
   SOURCES release/maketarball)
 
 endif() #UNIX
index b4251bbb98dcfb884b567d92ab4d80778362f495..09956baaa2817654124e87d316e331334b8c3977 100644 (file)
@@ -1,3 +1,9 @@
 @echo off
+
+if "%1"=="javadate" date /t & goto end
+if "%1"=="javatime" time /t & goto end
+
 for /f "tokens=1-4 eol=/ DELIMS=/ " %%i in ('date /t') do set BUILD=%%l%%j%%k
 echo %BUILD%
+
+:end
diff --git a/java/src/CMakeLists.txt b/java/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dc9d287
--- /dev/null
@@ -0,0 +1,99 @@
+find_package(Java)
+
+set(DEFAULT_JAVACFLAGS "-target 1.5")
+set(JAVACFLAGS ${DEFAULT_JAVACFLAGS} CACHE STRING
+  "Java compiler flags (Default: ${DEFAULT_JAVACFLAGS})")
+message(STATUS "Java compiler flags = ${JAVACFLAGS}")
+
+set(CLASSPATH com/tigervnc/vncviewer)
+set(JAVA_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${CLASSPATH})
+set(JAVA_BINDIR ${CMAKE_CURRENT_BINARY_DIR}/${CLASSPATH})
+
+if(MSVC)
+  execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmake/getdate.bat" "javadate"
+    OUTPUT_VARIABLE JAVA_DATE)
+  execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmake/getdate.bat" "javatime"
+    OUTPUT_VARIABLE JAVA_TIME)
+else()
+  execute_process(COMMAND "date" "+%b %d %Y" OUTPUT_VARIABLE JAVA_DATE)
+  execute_process(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE JAVA_TIME)
+endif()
+string(REGEX REPLACE "\n" "" JAVA_DATE ${JAVA_DATE})
+string(REGEX REPLACE "\n" "" JAVA_TIME ${JAVA_TIME})
+
+set(JAVA_CLASSNAMES
+  CConn
+  ClipboardDialog
+  DesktopWindow
+  Dialog
+  F8Menu
+  OptionsDialogCallback
+  PasswdDialog
+  PixelBufferImage
+  OptionsDialog
+  ServerDialog
+  UserPrefs
+  VncViewer)
+
+if(MSVC_IDE)
+  set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/$(OutDir)")
+else()
+  set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
+endif()
+
+set(JAVA_SOURCES "")
+set(JAVA_CLASSES_FULL "")
+foreach(class ${JAVA_CLASSNAMES})
+  set(JAVA_SOURCES ${JAVA_SOURCES} ${JAVA_SRCDIR}/${class}.java)
+  set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL}
+    ${OBJDIR}/${CLASSPATH}/${class}.class)
+endforeach()
+
+file(GLOB DEPEND_SOURCES
+  ${CMAKE_CURRENT_SOURCE_DIR}/com/tigervnc/rfb/*.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/com/tigervnc/rdr/*.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/com/jcraft/jzlib/*.java)
+
+string(REGEX REPLACE " " ";" JAVACFLAGS "${JAVACFLAGS}")
+add_custom_command(OUTPUT ${JAVA_CLASSES_FULL}
+  DEPENDS ${JAVA_SOURCES} ${DEPEND_SOURCES}
+  COMMAND ${JAVA_COMPILE}
+  ARGS ${JAVACFLAGS} -cp ${CMAKE_CURRENT_SOURCE_DIR} -d ${OBJDIR} ${JAVA_SOURCES})
+
+configure_file(${CLASSPATH}/timestamp.in ${CLASSPATH}/timestamp)
+
+add_custom_command(OUTPUT ${JAVA_BINDIR}/tigervnc.png
+  COMMAND ${CMAKE_COMMAND} -E copy_if_different
+    ${JAVA_SRCDIR}/tigervnc.png ${JAVA_BINDIR}/tigervnc.png
+  DEPENDS ${JAVA_SRCDIR}/tigervnc.png)
+
+add_custom_command(OUTPUT ${JAVA_BINDIR}/tigervnc.ico
+  COMMAND ${CMAKE_COMMAND} -E copy_if_different
+    ${JAVA_SRCDIR}/tigervnc.ico ${JAVA_BINDIR}/tigervnc.ico
+  DEPENDS ${JAVA_SRCDIR}/tigervnc.ico)
+
+add_custom_command(OUTPUT VncViewer.jar
+  DEPENDS ${JAVA_CLASSES_FULL}
+    ${JAVA_SRCDIR}/MANIFEST.MF
+    ${JAVA_BINDIR}/timestamp
+    ${JAVA_BINDIR}/tigervnc.png
+    ${JAVA_BINDIR}/tigervnc.ico
+  COMMAND ${JAVA_ARCHIVE}
+  ARGS cfm VncViewer.jar
+    ${JAVA_SRCDIR}/MANIFEST.MF
+    com/tigervnc/vncviewer/timestamp
+    com/tigervnc/vncviewer/*.class
+    com/tigervnc/rfb/*.class
+    com/tigervnc/rdr/*.class
+    com/jcraft/jzlib/*.class
+    com/tigervnc/vncviewer/tigervnc.png
+    com/tigervnc/vncviewer/tigervnc.ico
+  WORKING_DIRECTORY ${OBJDIR})
+
+add_custom_target(java ALL DEPENDS VncViewer.jar)
+
+install(FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/VncViewer.jar
+  ${JAVA_SRCDIR}/README
+  ${JAVA_SRCDIR}/index.vnc
+  DESTINATION vnc/classes)
diff --git a/java/src/com/tigervnc/vncviewer/timestamp.in b/java/src/com/tigervnc/vncviewer/timestamp.in
new file mode 100644 (file)
index 0000000..5f6326a
--- /dev/null
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Main-Class: com.tigervnc.vncviewer.VncViewer
+Package-Date: @JAVA_DATE@
+Package-Time: @JAVA_TIME@
index 40af2584f7fefa10ab871e0a72298ea19fe13d4f..81d40e4642f4402a7dc16f396df1c39224f8a9c8 100644 (file)
@@ -45,16 +45,9 @@ mkdir -p $OUTDIR/man/man1
 
 make DESTDIR=$TMPDIR/inst install
 if [ $SERVER = 1 ]; then
-       pushd $SRCDIR/java/src/com/tigervnc/vncviewer
-       make
-       popd
        install -m 755 ./xorg.build/bin/Xvnc $OUTDIR/bin/
        install -m 644 ./xorg.build/man/man1/Xvnc.1 $OUTDIR/man/man1/Xvnc.1
        install -m 644 ./xorg.build/man/man1/Xserver.1 $OUTDIR/man/man1/Xserver.1
-       mkdir -p $OUTDIR/vnc/classes/
-       install -m 644 $SRCDIR/java/src/com/tigervnc/vncviewer/index.vnc $OUTDIR/vnc/classes/
-       install -m 644 $SRCDIR/java/src/com/tigervnc/vncviewer/VncViewer.jar $OUTDIR/vnc/classes/
-       install -m 644 $SRCDIR/java/src/com/tigervnc/vncviewer/README $OUTDIR/vnc/classes/
        mkdir -p $OUTDIR/lib/dri/
        install -m 755 ./xorg.build/lib/dri/swrast_dri.so $OUTDIR/lib/dri/
 fi