Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify DIPjavaio build by including a Bio-Formats "stub" jar file in the repo. #157

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# brew update
run: |
brew install libomp glfw wget
brew install libomp glfw

- name: Deploy
run: bash tools/build/deploy_macos.sh
Expand All @@ -54,7 +54,7 @@ jobs:
# export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# brew update
run: |
brew install libomp glfw wget
brew install libomp glfw

- name: Deploy
run: bash tools/build/deploy_macos.sh
Expand Down
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,14 @@ if(JAVA_FOUND)
if(JNI_FOUND)
set(DIP_BUILD_JAVAIO ON CACHE BOOL "Build the javaio module")
include(UseJava)
find_jar(BIOFORMATS_JAR bioformats_package DOC "Location of the Bio-Formats package JAR-file")
if(BIOFORMATS_JAR)
list(APPEND DIP_JAVAIO_INTERFACES "Bio-Formats")
endif()
list(APPEND DIP_JAVAIO_INTERFACES "Bio-Formats")
endif()
set(DIP_JAVA_VERSION "1.8" CACHE BOOL "Java version to target when building DIPviewer Java bindings and DIPjavaio.")
set(DIP_JAVA_VERSION "1.8" CACHE STRING "Java version to target when building DIPviewer Java bindings and DIPjavaio.")
# MATLAB R2013b--R2017a use Java SDK 1.7, R2017b-- use SDK 1.8.
set(CMAKE_JAVA_COMPILE_FLAGS -target ${DIP_JAVA_VERSION} -source ${DIP_JAVA_VERSION})
endif()

if(DIP_BUILD_JAVAIO)
if(NOT DEFINED DIP_JAVAIO_INTERFACES)
message(WARNING "No interfaces for DIPjavaio were found -- disabling DIPjavaio")
set(DIP_BUILD_JAVAIO OFF CACHE BOOL "Build the javaio module" FORCE)
endif()
add_subdirectory(javaio)
endif()

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ limitations under the License.
see [`dipimage/private/bf*.m`](dipimage/private/bfGetReader.m)
(the full *Bio-Formats* library needs to be installed for these to be useful)

- A few Java files from *OME Bio-Formats* (used only to resolve references during the build
process of *DIPjavaio*, not used otherwise)
Copyright (C) 2005 - 2017 Open Microscopy Environment
2-Clause BSD License
see [`javaio/java/bioformats/readme.md`](javaio/java/bioformats/readme.md)
(the full *Bio-Formats* library needs to be installed to use *DIPjavaio*)

- Modified CSS files from *dox++*, which originally came from *m.css* (for documentation)
Copyright 2017, 2018, 2019 Vladimír Vondruš
MIT License
Expand Down
8 changes: 3 additions & 5 deletions doc/release_procedure/DIPimage_on_Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Few things to keep in mind:

* No documentation
* No Python interface
* Build with BioFormats
* No DIPjavaio
* Build with Matlab R2018b
* Matlab R2021b install has problems with root rights in display, use `xhost` line
* Matlab R2018b requires g++-8
Expand Down Expand Up @@ -37,7 +37,6 @@ export CC=gcc-8
export CXX=g++-8
mkdir ~/diplib
cd ~/diplib
wget https://downloads.openmicroscopy.org/bio-formats/7.0.0/artifacts/bioformats_package.jar
mkdir download source repository
cd download
wget http://www.fftw.org/fftw-3.3.10.tar.gz
Expand Down Expand Up @@ -69,17 +68,16 @@ git clone https://github.com/DIPlib/diplib.git
cd diplib
cmake .. -DCMAKE_INSTALL_PREFIX=~/diplib/diplib \
-DDIP_BUILD_PYDIP=Off \
-DDIP_BUILD_JAVAIO=Off \
-DDIP_ENABLE_FFTW=On \
-DDIP_ENABLE_FREETYPE=On \
-DFFTW3_LIBRARY_FFTW3=~/diplib/fftw/lib/libfftw3.so \
-DFFTW3_LIBRARY_FFTW3F=~/diplib/fftw/lib/libfftw3f.so \
-DFFTW3_LIBRARY_FFTW3_THREADS=~/diplib/fftw/lib/libfftw3_threads.so \
-DFFTW3_LIBRARY_FFTW3F_THREADS=~/diplib/fftw/lib/libfftw3f_threads.so \
-DFFTW3_INCLUDE_DIR=~/diplib/fftw/include \
-DBIOFORMATS_JAR=~/diplib/bioformats_package.jar
-DFFTW3_INCLUDE_DIR=~/diplib/fftw/include
make -j
make -j check
make install
cp ~/diplib/bioformats_package.jar ~/diplib/diplib/share/DIPimage/private
matlab
```
3 changes: 1 addition & 2 deletions doc/release_procedure/DIPimage_on_Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ Also the following dependencies have been downloaded:
- FFTW, version 3.3.10 <https://fftw.org/download.html>. Download the source as we will build our own static library (see [FFTW static library](#fftw-static-library))
- GLFW, version 3.3.6 <https://www.glfw.org/download.html>. Download the 64-bit Windows binaries as they contain a prebuild static library
- Freetype, version 2.11.1 <https://github.com/ubawurinna/freetype-windows-binaries/releases>. Download the `Source code (zip)` as is it contains a prebuild static library
- Bio-Formats package, version 7.0.0 <https://www.openmicroscopy.org/bio-formats/downloads/>. Download `bioformats_package.jar`

For testing the *DIPlib* images are used:

Expand Down Expand Up @@ -147,9 +146,9 @@ FFTW comes with the GNU General Public License, Version 2 which is not compatibl
- `Matlab_ROOT_DIR` `C:/Program Files/MATLAB/R2021b`
1. press the <kbd>Generate</kbd> button
1. continue setting the variables:
- `BIOFORMATS_JAR` `C:/diplib/bioformats_package.jar`
- `DIP_ENABLE_FFTW` set
- `DIP_ENABLE_FREETYPE` set
- `DIP_BUILD_JAVAIO` unset
1. press the <kbd>Generate</kbd> button
1. press the <kbd>Open Project</kbd> button
1. in Visual Studio check if Solution Configuration is set to `Release`
Expand Down
15 changes: 6 additions & 9 deletions doc/src/Build/Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,20 @@ correctly.
If building only *DIPimage* (the *MATLAB* toolbox), skip this section and instead follow the directions
you can read when you do `help readim` in *MATLAB* after installation.

First, make sure you have the *Java 8 SDK* (*JDK 8*) installed, you can obtain it from the
[Oracle website](http://www.oracle.com/technetwork/java/javase/downloads/index.html) for commercial
purposes, or from [jdk.java.net](https://jdk.java.net) for an open-source build. Next, download
`bioformats_package.jar` from the [*Bio-Formats* website](https://www.openmicroscopy.org/bio-formats/).
You need to add the location of this file to the `cmake` command line using the `-DBIOFORMATS_JAR=<path>`
flag.
First, make sure you have the *Java 8 SDK* (*JDK 8*) or later installed,
you can obtain it from the [Oracle website](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
for commercial purposes, or from [jdk.java.net](https://jdk.java.net) for an open-source build.

When running *CMake* with the proper *JDK* installed, the *DIPjavaio* module becomes available.

Check the *CMake* output to see which *JNI* was found. It should match the version of Java found.
These two should be listed together, but the *JNI* output is only produced on first run. Delete the
`CMakeCache.txt` file to run `cmake` fresh and see all its output.
These two should be listed together, but the *JNI* output is only produced on first run.
Delete the `CMakeCache.txt` file to run `cmake` fresh and see all its output.

If the version of *JNI* found is not the one in the *JDK*, or if it is not found at all, add `-DJAVA_HOME=<path>`
to the `cmake` command line:
```bash
cmake .. -DBIOFORMATS_JAR=$HOME/java/bioformats_package.jar -DJAVA_HOME=/opt/jvm/java-8-oracle
cmake .. -DJAVA_HOME=/opt/jvm/java-8-oracle
```
Note that these arguments to `cmake` must be combined with the arguments mentioned earlier, into a single,
long command line argument.
Expand Down
5 changes: 2 additions & 3 deletions doc/src/Build/Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ directory for the first parameter, and "lib-vc2015\glfw3.lib" for the second.
don't have *MATLAB* installed, you are building 32-bit binaries, or the *Java SDK* could not
be found. This is only necessary if you want to use the `viewslice` command from *DIPimage*.

- If `BIOFORMATS_JAR` is not on the list, the *Java SDK* could not be found. If it is,
point it to the "bioformats_package.jar" you downloaded earlier. This is only necessary if
you want to import image formats that are not directly supported by *DIPlib*, and only
- If `DIP_BUILD_JAVAIO` is not on the list, the *Java SDK* could not be found. This is only
necessary if you want to import image formats that are not directly supported by *DIPlib*, and only
for *Python* and C++ (*MATLAB* uses the *Bio-Formats* package differently, see `help readim`
after installation).

Expand Down
7 changes: 3 additions & 4 deletions doc/src/Build/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ Controlling the build of *DIPjavaio*:
if its dependencies are available.
- `JAVA_HOME`: Set the path to the JDK to use.
- `DIP_JAVA_VERSION`: Set the version of Java to target. Defaults to "1.8".
- `BIOFORMATS_JAR`: Set the path to the Bio-Formats JAR file (`bioformats_package.jar`).
- Note that for the *MATLAB* toolbox, *DIPjavaio* is not used; build this only if you work in C++ or Python.

Controlling the build of *DIPimage*:
Expand All @@ -170,9 +169,9 @@ Controlling the build of *DIPimage*:
- `Matlab_ROOT_DIR`: Set the path of the *MATLAB* installation to compile *DIPimage* against.
- `JAVA_HOME`: Set the path to the JDK to use. Java is used by *DIPimage* to interface with *DIPviewer*.
- `DIP_JAVA_VERSION`: Set the version of Java to target. Defaults to "1.8". For MATLAB versions prior to R2017b
use "1.7" (and set `JAVA_HOME` to a release of the JDK that supports 1.7). You should not target a Java version
later than the one used by your MATLAB. Check the version of Java used by MATLAB by running `version -java`
on the MATLAB command prompt.
use "1.7" (and set `JAVA_HOME` to a release of the JDK that supports 1.7). You should not target a Java version
later than the one used by your MATLAB. Check the version of Java used by MATLAB by running `version -java`
on the MATLAB command prompt.

Controlling the build of *PyDIP*:

Expand Down
7 changes: 2 additions & 5 deletions doc/src/Build/macOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ This will change over time, as new versions of *GCC* are adopted by *HomeBrew*.
If building only *DIPimage* (the *MATLAB* toolbox), skip this section and instead follow the directions
you can read when you do `help readim` in *MATLAB* after installation.

First, make sure you have the *Java 8 SDK* (*JDK 8*) installed,
First, make sure you have the *Java 8 SDK* (*JDK 8*) or later installed,
you can obtain it from the [Oracle website](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
for commercial purposes, or from [jdk.java.net](https://jdk.java.net) for an open-source build.
Next, download `bioformats_package.jar` from the [*Bio-Formats* website](https://www.openmicroscopy.org/bio-formats/).
You need to add the location of this file to the `cmake` command line using the `-DBIOFORMATS_JAR=<path>` flag.

When running *CMake* with the proper *JDK* installed, the *DIPjavaio* module becomes available.

Expand All @@ -229,8 +227,7 @@ For example, on my Mac it might find the *JNI* that belongs to *Java 6*.
In this case, add `-DJAVA_HOME=<path>` to the `cmake` command line:

```bash
cmake .. -DBIOFORMATS_JAR=$HOME/java/bioformats_package.jar \
-DJAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/
cmake .. -DJAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/
```

Note that these arguments to `cmake` must be combined with the arguments mentioned earlier,
Expand Down
7 changes: 3 additions & 4 deletions javaio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/diplib/javaio" DESTINATION incl

### Java part

if (BIOFORMATS_JAR)
set(DIP_JAVAIO_JAVA ${DIP_JAVAIO_JAVA} ${DIP_JAVAIO_BIOFORMATS_JAVA})
set(DIP_JAVAIO_CLASSPATH ${DIP_JAVAIO_CLASSPATH} ${BIOFORMATS_JAR})
endif()
# Bio-Formats interface
set(DIP_JAVAIO_JAVA ${DIP_JAVAIO_JAVA} ${DIP_JAVAIO_BIOFORMATS_JAVA})
set(DIP_JAVAIO_CLASSPATH ${DIP_JAVAIO_CLASSPATH} "${CMAKE_CURRENT_LIST_DIR}/java/bioformats/bio-formats-stripped.jar")

configure_file("${CMAKE_CURRENT_LIST_DIR}/Manifest.txt.in" "${CMAKE_CURRENT_BINARY_DIR}/Manifest.txt" @ONLY)

Expand Down
2 changes: 1 addition & 1 deletion javaio/Manifest.txt.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Class-Path: bioformats_package.jar file:///@BIOFORMATS_JAR@ file:///@CMAKE_INSTALL_PREFIX@/@LIBRARY_DESTINATION@/bioformats_package.jar
Class-Path: bioformats_package.jar file:///@CMAKE_INSTALL_PREFIX@/@LIBRARY_DESTINATION@/bioformats_package.jar
Binary file added javaio/java/bioformats/bio-formats-stripped.jar
Binary file not shown.
52 changes: 52 additions & 0 deletions javaio/java/bioformats/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
`bio-formats-stripped.jar` is a stripped-down version of `bioformats_package.jar`
We simply removed all the files that weren't necessary to build our `BioFormatsInterface.java`
source file into `DIPjavaio.jar`. This left a small amount of compiled Java that we
could include into our repository, to simplify the build process. Note that this
Java package is only used to resolve references when building `DIPjavaio.jar`, none
of the code actually ands up in there. When using *DIPjavaio*, one must fetch the
original `bioformats_package.jar`.

The files in `bio-formats-stripped.jar` come from these repositories:

- https://github.com/ome/bioformats
- https://github.com/ome/ome-common-java
- https://github.com/ome/ome-model

The original sources for these files are distributed under a 2-clause BSD licence.
Below we reproduce the copyright statement for these files and the associated license
text.

```none
Copyright (C) 2005 - 2017 Open Microscopy Environment:
- Board of Regents of the University of Wisconsin-Madison
- Glencoe Software, Inc.
- University of Dundee

Copyright (C) 2006 - 2016 Open Microscopy Environment:
- Massachusetts Institute of Technology
- National Institutes of Health
- University of Dundee
- Board of Regents of the University of Wisconsin-Madison
- Glencoe Software, Inc.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
```
1 change: 0 additions & 1 deletion tools/build/cmake_windows_2017a.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ cmake ^
-DJava_JAVAC_EXECUTABLE:FILEPATH=D:/local/jdk-12.0.2/bin/javac.exe ^
-DJava_JAVADOC_EXECUTABLE:FILEPATH=D:/local/jdk-12.0.2/bin/javadoc.exe ^
-DJava_JAVA_EXECUTABLE:FILEPATH=D:/local/jdk-12.0.2/bin/java.exe ^
-DBIOFORMATS_JAR:FILEPATH=D:/local/bioformats_package.jar ^
-DMatlab_ROOT_DIR:PATH="C:/Program Files/MATLAB/R2017a" ^
-DDIP_PYDIP_RELATIVE_LOCATION:BOOL=ON ^
-DPYDIP_INSTALL_PATH:PATH=D:/local/DIPlib_2017a/lib ^
Expand Down
1 change: 0 additions & 1 deletion tools/build/cmake_windows_2018b.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ cmake ^
-DJava_JAVAC_EXECUTABLE:FILEPATH=D:/local/jdk-12.0.2/bin/javac.exe ^
-DJava_JAVADOC_EXECUTABLE:FILEPATH=D:/local/jdk-12.0.2/bin/javadoc.exe ^
-DJava_JAVA_EXECUTABLE:FILEPATH=D:/local/jdk-12.0.2/bin/java.exe ^
-DBIOFORMATS_JAR:FILEPATH=D:/local/bioformats_package.jar ^
-DMatlab_ROOT_DIR:PATH="D:\MATLAB\R2018b" ^
-DDIP_PYDIP_RELATIVE_LOCATION:BOOL=ON ^
-DPYDIP_INSTALL_PATH:PATH=D:/local/DIPlib_2018b/lib ^
Expand Down
3 changes: 1 addition & 2 deletions tools/build/deploy_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ python3 -m pip install -U twine delocate

mkdir build
cd build
wget -nv https://downloads.openmicroscopy.org/bio-formats/7.0.0/artifacts/bioformats_package.jar

# Basic configuration
cmake .. -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On -DBIOFORMATS_JAR=`pwd`/bioformats_package.jar -DDIP_BUILD_DIPIMAGE=Off -DCMAKE_CXX_FLAGS="-I$HOMEBREW_DIR/opt/libomp/include -L$HOMEBREW_DIR/opt/libomp/lib"
cmake .. -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On -DDIP_BUILD_DIPIMAGE=Off -DCMAKE_CXX_FLAGS="-I$HOMEBREW_DIR/opt/libomp/include -L$HOMEBREW_DIR/opt/libomp/lib"

# Build all wheels
for v in ${PYTHON_VERSIONS[@]}; do
Expand Down
3 changes: 1 addition & 2 deletions tools/build/deploy_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mkdir build
cd build
mkdir wheelhouse

python -m wget https://downloads.openmicroscopy.org/bio-formats/7.0.0/artifacts/bioformats_package.jar
python -m wget https://sourceforge.net/projects/freeglut/files/freeglut/3.0.0/freeglut-3.0.0.tar.gz/download
python -c "import tarfile; tar = tarfile.open('download'); tar.extractall()"
cd freeglut-3.0.0
Expand All @@ -25,7 +24,7 @@ cd ..
cd ..

REM Basic configuration
cmake .. -A x64 -DBIOFORMATS_JAR=%CD%\bioformats_package.jar -DFREEGLUT_INCLUDE_DIR=%CD%\freeglut-3.0.0\include -DFREEGLUT_LIBRARY=%CD%\freeglut-3.0.0\build\lib\Release\freeglut_static.lib -DFREEGLUT_STATIC=On -DDIP_BUILD_DIPIMAGE=Off -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On -DDIP_ENABLE_UNICODE=Off
cmake .. -A x64 -DFREEGLUT_INCLUDE_DIR=%CD%\freeglut-3.0.0\include -DFREEGLUT_LIBRARY=%CD%\freeglut-3.0.0\build\lib\Release\freeglut_static.lib -DFREEGLUT_STATIC=On -DDIP_BUILD_DIPIMAGE=Off -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On -DDIP_ENABLE_UNICODE=Off

REM Python 3.8
C:\hostedtoolcache\windows\Python\%PYTHON38%\x64\python.exe -m pip install setuptools wheel build
Expand Down
5 changes: 2 additions & 3 deletions tools/build/manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Run this in a manylinux2014 docker container with /io mounted to some local directory

# Setup
yum -y install wget freeglut-devel java-1.8.0-openjdk-devel.x86_64
yum -y install freeglut-devel java-1.8.0-openjdk-devel.x86_64
/opt/python/cp39-cp39/bin/python -m pip install cmake auditwheel
CMAKE=/opt/python/cp39-cp39/lib/python3.9/site-packages/cmake/data/bin/cmake
BUILD_THREADS=4
Expand All @@ -14,10 +14,9 @@ git clone https://github.com/diplib/diplib
cd diplib
mkdir build
cd build
wget -nv https://downloads.openmicroscopy.org/bio-formats/7.0.0/artifacts/bioformats_package.jar

# Basic configuration
$CMAKE .. -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On -DBIOFORMATS_JAR=`pwd`/bioformats_package.jar
$CMAKE .. -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On

# Build wheels
for v in ${PYTHON_VERSIONS[@]}; do
Expand Down
Loading