Skip to content

Commit

Permalink
cmake and packaging support for java binding
Browse files Browse the repository at this point in the history
  • Loading branch information
jkfindeisen committed Apr 3, 2018
1 parent abed7f7 commit 42b8321
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 39 deletions.
20 changes: 15 additions & 5 deletions Gpufit/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ add_subdirectory( adapter )

# Java package

set( build_directory "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Java-Gpufit" )
set( binary $<TARGET_FILE:Gpufit> )
set( build_directory "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/java" )
set( java_directory "${CMAKE_CURRENT_SOURCE_DIR}/gpufit" )
set( binary_files
"$<TARGET_FILE:Gpufit>"
"$<TARGET_FILE:GpufitJNI>"
"${java_directory}/build/libs/Gpufit-1.1.0.jar"
"${CMAKE_CURRENT_SOURCE_DIR}/README.txt"
)

add_custom_target( JAVA_PACKAGE
add_custom_target( JAVA_PACKAGE ALL
COMMAND ${CMAKE_COMMAND} -E
remove_directory ${build_directory}
COMMAND ${CMAKE_COMMAND} -E
make_directory ${build_directory}
COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${binary} ${build_directory}
chdir ${java_directory} gradlew.bat build
COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${binary_files} ${build_directory}
COMMAND ${CMAKE_COMMAND} -E
copy_directory "${java_directory}/src/test/java/com/github/gpufit" ${build_directory}
)
set_property( TARGET JAVA_PACKAGE PROPERTY FOLDER CMakePredefinedTargets )
add_dependencies( JAVA_PACKAGE Gpufit )
add_dependencies( JAVA_PACKAGE Gpufit GpufitJNI )
71 changes: 37 additions & 34 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@
# Creating a binary package
# Creating a binary package/release

The binary package bundles different builds outputs into a single distributable binary package containing the Gpufit dll,
the performance comparison example, the Matlab bindings and the Python bindings.
the performance comparison example, the Matlab, Python and Java bindings and the documentation.

## Calling the script
Follow this step by step recipe to create a Windows binary package.

create_package.bat %1 %2 %3

with
## Set/Update the version number

- %1 is the BUILD_BASE_PATH (the path containing the various (see below) CMake generated Visual Studio projects)

- %2 is the VERSION (e.g. 1.0.0)

- %3 is the SOURCE_BASE_PATH (the path containing the sources)
Unfortunately the version has to be updated in various places.

The output is a folder (BUILD_BASE_PATH/Gpufit-VERSION) which is also zipped if 7-Zip is available.
- CmakeLists.txt (project( Gpufit VERSION 1.0.0 ))
- docs/conf.py (release = u'1.0.0')
- docs/epilog.txt (.. |GF_version| replace:: 1.0.0)
- Gpufit/matlab/gpufit_version.m
- Gpufit/python/pygpufit/version.py
- calling the packaging script (create_package.bat %1 1.0.0 %3)
- package/sdk_readme.txt, (also specify CUDA version used for build there)
- Gpufit/java/gpufit/build.gradle (version `1.0.0`)
- Gpufit/java/gpufit/src/main/java/com/github/gpufit/Gpufit.java (String VERSION = "1.0.0";)

## Requirements
Push to Github afterwards (you can add a Git tag).

Note: The script has no way of checking that the requirements are fulfilled!
## Convert Documentation from restructured text to html/latex

See also [Build from sources](http://Gpufit.readthedocs.io/en/latest/installation.html#build-from-sources) for instructions.
Use documentation_create_latex.bat in this folder or do it manually using sphinx and docs/make.bat.

CMake
## Use CMAKE to generate the project

- CUDA_ARCHITECTURE must be set to All (it is by default)

- CUDA toolkit 8.0/9.0 is used for all builds (must be installed before)

- Build directory for MSVC14 Win64 is BUILD_BASE_PATH/VC14x64-8.0

- Build directory for MSVC14 Win32 is BUILD_BASE_PATH/VC14x32-8.0
- Matlab, Python, Java, Latex (e.g. Miktex) must be available

- Matlab and Python must be available
See also [Build from sources](http://Gpufit.readthedocs.io/en/latest/installation.html#build-from-sources) for instructions.

Build
## Build for Win32 and Win64

- Configuration RelWithDebInfo is used for all builds!
Everything should run through and the tests should execute successfully. Also run the Gpufit_Cpufit_Performance_Comparison.

- Configuration RelWithDebInfo is used for all builds!
- With MSVC14 Win64 build target PYTHON_WHEEL, MATLAB_GPUFIT_PACKAGE and the Gpufit_Cpufit_Performance_Comparison example

- With MSVC14 Win32 build target PYTHON_WHEEL, MATLAB_GPUFIT_PACKAGE and the Gpufit_Cpufit_Performance_Comparison example
- SOURCE_BASE_PATH\docs\_build\latex\Gpufit.pdf will be created from Gpufit.tex at the same location

Documentation
## Run the examples for the Bindings

- An up-to-date version of the documentation must exist at SOURCE_BASE_PATH\docs\_build\latex\Gpufit.pdf (must be created before).
In Matlab, Python and Java.

## Setting the version number
## Call the assemble script

Unfortunately the version has to be updated in various places.
create_package.bat %1 %2 %3

- CmakeLists.txt (project( Gpufit VERSION 1.0.0 ))
- docs/conf.py (release = u'1.0.0')
- docs/epilog.txt (.. |GF_version| replace:: 1.0.0)
- Gpufit/matlab/gpufit_version.m
- Gpufit/python/pygpufit/version.py
- calling the packaging script (create_package.bat %1 1.0.0 %3)
- package/sdk_readme.txt, also CUDA version inside
with

- %1 is the BUILD_BASE_PATH (the path containing the various (see below) CMake generated Visual Studio projects)

- %2 is the VERSION (e.g. 1.0.0)

- %3 is the SOURCE_BASE_PATH (the path containing the sources)

The output is a folder (BUILD_BASE_PATH/Gpufit-VERSION) which is also zipped if 7-Zip is available.

## Retrieve the hash for the current commit in GIT

Expand Down
17 changes: 17 additions & 0 deletions package/create_package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ set PERFORMANCE_TEST_INSTALL=%ROOT_INSTALL%\gpufit_performance_test
set PYTHON_INSTALL=%ROOT_INSTALL%\python
set x32_MATLAB_INSTALL=%ROOT_INSTALL%\matlab32
set x64_MATLAB_INSTALL=%ROOT_INSTALL%\matlab64
set x32_JAVA_INSTALL=%ROOT_INSTALL%\java32
set x64_JAVA_INSTALL=%ROOT_INSTALL%\java64
set SDK_INSTALL_ROOT=%ROOT_INSTALL%\gpufit_sdk

set x64_BUILD=%BUILD_BASE%\VC14x64-8.0\RelWithDebInfo
Expand All @@ -67,6 +69,9 @@ set x32_PYTHON_BUILD=%x32_BUILD%\pyGpufit\dist
set x64_MATLAB_BUILD=%x64_BUILD%\matlab
set x32_MATLAB_BUILD=%x32_BUILD%\matlab

set x64_JAVA_BUILD=%x64_BUILD%\java
set x32_JAVA_BUILD=%x32_BUILD%\java

set EXAMPLES_SOURCE=%SOURCE_BASE%\examples
set PYTHON_SOURCE=%SOURCE_BASE%\Gpufit\python
set MATLAB_SOURCE=%SOURCE_BASE%\Gpufit\matlab
Expand Down Expand Up @@ -137,6 +142,18 @@ mkdir "%x64_MATLAB_INSTALL%"
xcopy "%x64_MATLAB_BUILD%" "%x64_MATLAB_INSTALL%" /q
xcopy "%MATLAB_SOURCE%\examples" "%x64_MATLAB_INSTALL%\examples" /i /q

REM copy Java 32 bit

echo collect java32
mkdir "%x32_JAVA_INSTALL%"
xcopy "%x32_JAVA_BUILD%" "%x32_JAVA_INSTALL%" /q

REM copy Java 64 bit

echo collect java64
mkdir "%x64_JAVA_INSTALL%"
xcopy "%x64_JAVA_BUILD%" "%x64_JAVA_INSTALL%" /q

REM copy SDK_INSTALL_ROOT

echo collect SDK
Expand Down
8 changes: 8 additions & 0 deletions package/documentation_create_latex.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
REM adapt next line to include Scripts folder of your Python distribution
SET PATH=%PATH%;C:\Miniconda3\Scripts
cd "..\docs"
rmdir /s /q "_build"
call make.bat html
call make.bat latex
pause

0 comments on commit 42b8321

Please sign in to comment.