Skip to content

Commit 42b8321

Browse files
committed
cmake and packaging support for java binding
1 parent abed7f7 commit 42b8321

File tree

4 files changed

+77
-39
lines changed

4 files changed

+77
-39
lines changed

Gpufit/java/CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,26 @@ add_subdirectory( adapter )
1313

1414
# Java package
1515

16-
set( build_directory "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Java-Gpufit" )
17-
set( binary $<TARGET_FILE:Gpufit> )
16+
set( build_directory "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/java" )
17+
set( java_directory "${CMAKE_CURRENT_SOURCE_DIR}/gpufit" )
18+
set( binary_files
19+
"$<TARGET_FILE:Gpufit>"
20+
"$<TARGET_FILE:GpufitJNI>"
21+
"${java_directory}/build/libs/Gpufit-1.1.0.jar"
22+
"${CMAKE_CURRENT_SOURCE_DIR}/README.txt"
23+
)
1824

19-
add_custom_target( JAVA_PACKAGE
25+
add_custom_target( JAVA_PACKAGE ALL
2026
COMMAND ${CMAKE_COMMAND} -E
2127
remove_directory ${build_directory}
2228
COMMAND ${CMAKE_COMMAND} -E
2329
make_directory ${build_directory}
2430
COMMAND ${CMAKE_COMMAND} -E
25-
copy_if_different ${binary} ${build_directory}
31+
chdir ${java_directory} gradlew.bat build
32+
COMMAND ${CMAKE_COMMAND} -E
33+
copy_if_different ${binary_files} ${build_directory}
34+
COMMAND ${CMAKE_COMMAND} -E
35+
copy_directory "${java_directory}/src/test/java/com/github/gpufit" ${build_directory}
2636
)
2737
set_property( TARGET JAVA_PACKAGE PROPERTY FOLDER CMakePredefinedTargets )
28-
add_dependencies( JAVA_PACKAGE Gpufit )
38+
add_dependencies( JAVA_PACKAGE Gpufit GpufitJNI )

package/README.md

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,66 @@
1-
# Creating a binary package
1+
# Creating a binary package/release
22

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

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

8-
create_package.bat %1 %2 %3
9-
10-
with
8+
## Set/Update the version number
119

12-
- %1 is the BUILD_BASE_PATH (the path containing the various (see below) CMake generated Visual Studio projects)
13-
14-
- %2 is the VERSION (e.g. 1.0.0)
15-
16-
- %3 is the SOURCE_BASE_PATH (the path containing the sources)
10+
Unfortunately the version has to be updated in various places.
1711

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

20-
## Requirements
22+
Push to Github afterwards (you can add a Git tag).
2123

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

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

26-
CMake
28+
## Use CMAKE to generate the project
2729

2830
- CUDA_ARCHITECTURE must be set to All (it is by default)
29-
3031
- CUDA toolkit 8.0/9.0 is used for all builds (must be installed before)
31-
3232
- Build directory for MSVC14 Win64 is BUILD_BASE_PATH/VC14x64-8.0
33-
3433
- Build directory for MSVC14 Win32 is BUILD_BASE_PATH/VC14x32-8.0
34+
- Matlab, Python, Java, Latex (e.g. Miktex) must be available
3535

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

38-
Build
38+
## Build for Win32 and Win64
3939

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

42+
- Configuration RelWithDebInfo is used for all builds!
4243
- With MSVC14 Win64 build target PYTHON_WHEEL, MATLAB_GPUFIT_PACKAGE and the Gpufit_Cpufit_Performance_Comparison example
43-
4444
- With MSVC14 Win32 build target PYTHON_WHEEL, MATLAB_GPUFIT_PACKAGE and the Gpufit_Cpufit_Performance_Comparison example
45+
- SOURCE_BASE_PATH\docs\_build\latex\Gpufit.pdf will be created from Gpufit.tex at the same location
4546

46-
Documentation
47+
## Run the examples for the Bindings
4748

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

50-
## Setting the version number
51+
## Call the assemble script
5152

52-
Unfortunately the version has to be updated in various places.
53+
create_package.bat %1 %2 %3
5354

54-
- CmakeLists.txt (project( Gpufit VERSION 1.0.0 ))
55-
- docs/conf.py (release = u'1.0.0')
56-
- docs/epilog.txt (.. |GF_version| replace:: 1.0.0)
57-
- Gpufit/matlab/gpufit_version.m
58-
- Gpufit/python/pygpufit/version.py
59-
- calling the packaging script (create_package.bat %1 1.0.0 %3)
60-
- package/sdk_readme.txt, also CUDA version inside
55+
with
56+
57+
- %1 is the BUILD_BASE_PATH (the path containing the various (see below) CMake generated Visual Studio projects)
58+
59+
- %2 is the VERSION (e.g. 1.0.0)
60+
61+
- %3 is the SOURCE_BASE_PATH (the path containing the sources)
62+
63+
The output is a folder (BUILD_BASE_PATH/Gpufit-VERSION) which is also zipped if 7-Zip is available.
6164

6265
## Retrieve the hash for the current commit in GIT
6366

package/create_package.bat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ set PERFORMANCE_TEST_INSTALL=%ROOT_INSTALL%\gpufit_performance_test
5454
set PYTHON_INSTALL=%ROOT_INSTALL%\python
5555
set x32_MATLAB_INSTALL=%ROOT_INSTALL%\matlab32
5656
set x64_MATLAB_INSTALL=%ROOT_INSTALL%\matlab64
57+
set x32_JAVA_INSTALL=%ROOT_INSTALL%\java32
58+
set x64_JAVA_INSTALL=%ROOT_INSTALL%\java64
5759
set SDK_INSTALL_ROOT=%ROOT_INSTALL%\gpufit_sdk
5860

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

72+
set x64_JAVA_BUILD=%x64_BUILD%\java
73+
set x32_JAVA_BUILD=%x32_BUILD%\java
74+
7075
set EXAMPLES_SOURCE=%SOURCE_BASE%\examples
7176
set PYTHON_SOURCE=%SOURCE_BASE%\Gpufit\python
7277
set MATLAB_SOURCE=%SOURCE_BASE%\Gpufit\matlab
@@ -137,6 +142,18 @@ mkdir "%x64_MATLAB_INSTALL%"
137142
xcopy "%x64_MATLAB_BUILD%" "%x64_MATLAB_INSTALL%" /q
138143
xcopy "%MATLAB_SOURCE%\examples" "%x64_MATLAB_INSTALL%\examples" /i /q
139144

145+
REM copy Java 32 bit
146+
147+
echo collect java32
148+
mkdir "%x32_JAVA_INSTALL%"
149+
xcopy "%x32_JAVA_BUILD%" "%x32_JAVA_INSTALL%" /q
150+
151+
REM copy Java 64 bit
152+
153+
echo collect java64
154+
mkdir "%x64_JAVA_INSTALL%"
155+
xcopy "%x64_JAVA_BUILD%" "%x64_JAVA_INSTALL%" /q
156+
140157
REM copy SDK_INSTALL_ROOT
141158

142159
echo collect SDK
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
REM adapt next line to include Scripts folder of your Python distribution
3+
SET PATH=%PATH%;C:\Miniconda3\Scripts
4+
cd "..\docs"
5+
rmdir /s /q "_build"
6+
call make.bat html
7+
call make.bat latex
8+
pause

0 commit comments

Comments
 (0)