Skip to content

Commit

Permalink
* Add support for Mac OS X and Windows to presets for libfreenect2 (…
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Dec 5, 2017
1 parent afc6150 commit 468be6b
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add support for Mac OS X and Windows to presets for libfreenect2 ([issue bytedeco/javacv#837](https://github.com/bytedeco/javacv/issues/837))
* Enable VisualOn AMR-WB encoder library support for FFmpeg ([pull #487](https://github.com/bytedeco/javacpp-presets/pull/487))
* Use native threads for FFmpeg on Windows to prevent deadlocks with pthreads ([pull #481](https://github.com/bytedeco/javacpp-presets/pull/481))
* Add cross-compilation support for `linux-ppc64le` ([pull #471](https://github.com/bytedeco/javacpp-presets/pull/471))
Expand Down
16 changes: 8 additions & 8 deletions libdc1394/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ cd libdc1394-$LIBDC1394_VERSION

case $PLATFORM in
linux-x86)
CC="$OLDCC -m32" ./configure --prefix=$INSTALL_PATH
CC="$OLDCC -m32" ./configure --prefix=$INSTALL_PATH --disable-sdltest
make -j4
make install-strip
;;
linux-x86_64)
CC="$OLDCC -m64" ./configure --prefix=$INSTALL_PATH
CC="$OLDCC -m64" ./configure --prefix=$INSTALL_PATH --disable-sdltest
make -j4
make install-strip
;;
linux-armhf)
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ./configure --prefix=$INSTALL_PATH --host=arm-linux-gnueabihf
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ./configure --prefix=$INSTALL_PATH --host=arm-linux-gnueabihf --disable-sdltest
make -j4
make install-strip
;;
linux-ppc64le)
MACHINE_TYPE=$( uname -m )
sed -i s/elf64ppc/elf64lppc/ configure
if [[ "$MACHINE_TYPE" =~ ppc64 ]]; then
CC="$OLDCC -m64" ./configure --prefix=$INSTALL_PATH
CC="$OLDCC -m64" ./configure --prefix=$INSTALL_PATH --disable-sdltest
else
CC="powerpc64le-linux-gnu-gcc -m64" ./configure --host=powerpc64le-linux-gnu --build=ppc64le-linux --prefix=$INSTALL_PATH
CC="powerpc64le-linux-gnu-gcc -m64" ./configure --host=powerpc64le-linux-gnu --build=ppc64le-linux --prefix=$INSTALL_PATH --disable-sdltest
fi
make -j4
make install-strip
;;
macosx-*)
patch -Np1 < ../../../libdc1394-$LIBDC1394_VERSION-macosx.patch
LIBUSB_CFLAGS=-I/usr/local/include/libusb-1.0/ LIBUSB_LIBS="-L/usr/local/lib/ -lusb-1.0" ./configure --prefix=$INSTALL_PATH
LIBUSB_CFLAGS=-I/usr/local/include/libusb-1.0/ LIBUSB_LIBS="-L/usr/local/lib/ -lusb-1.0" ./configure --prefix=$INSTALL_PATH --disable-sdltest
make -j4
make install-strip
;;
Expand All @@ -55,7 +55,7 @@ case $PLATFORM in
mkdir -p "$INSTALL_PATH/bin"
cp "/c/Program Files (x86)/CMU/1394Camera/lib/1394camera.dll" "$INSTALL_PATH/bin/lib1394camera.dll"
export LIBRARY_PATH="$INSTALL_PATH/bin/"
CC="gcc -m32 -Duint=int -static-libgcc" ./configure --prefix=$INSTALL_PATH --enable-shared --disable-static
CC="gcc -m32 -Duint=int -static-libgcc" ./configure --prefix=$INSTALL_PATH --enable-shared --disable-static --disable-sdltest
make -j4
make install-strip
;;
Expand All @@ -64,7 +64,7 @@ case $PLATFORM in
mkdir -p "$INSTALL_PATH/bin"
cp "/c/Program Files (x86)/CMU/1394Camera/lib64/x64/1394camera.dll" "$INSTALL_PATH/bin/lib1394camera.dll"
export LIBRARY_PATH="$INSTALL_PATH/bin/"
CC="gcc -m64 -Duint=int -static-libgcc" ./configure --prefix=$INSTALL_PATH --enable-shared --disable-static
CC="gcc -m64 -Duint=int -static-libgcc" ./configure --prefix=$INSTALL_PATH --enable-shared --disable-static --disable-sdltest
make -j4
make install-strip
;;
Expand Down
16 changes: 8 additions & 8 deletions libdc1394/src/main/java/org/bytedeco/javacpp/presets/dc1394.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
*
* @author Samuel Audet
*/
@Properties(target="org.bytedeco.javacpp.dc1394", value={
@Platform(not="android", include={"<poll.h>", "<dc1394/dc1394.h>", "<dc1394/types.h>", "<dc1394/log.h>",
@Properties(target = "org.bytedeco.javacpp.dc1394", value = {
@Platform(not = "android", include = {"<poll.h>", "<dc1394/dc1394.h>", "<dc1394/types.h>", "<dc1394/log.h>",
"<dc1394/camera.h>", "<dc1394/control.h>", "<dc1394/capture.h>", "<dc1394/conversions.h>", "<dc1394/format7.h>",
"<dc1394/iso.h>", "<dc1394/register.h>", "<dc1394/video.h>", "<dc1394/utils.h>"}, link="dc1394@.22",
preload="usb-1.0@.0", preloadpath="/usr/local/lib/"),
@Platform(value="windows", include={"<dc1394/dc1394.h>", "<dc1394/types.h>", "<dc1394/log.h>",
"<dc1394/iso.h>", "<dc1394/register.h>", "<dc1394/video.h>", "<dc1394/utils.h>"}, link = "dc1394@.22"),
@Platform(value = "macosx", preload = "usb-1.0@.0", preloadpath = "/usr/local/lib/"),
@Platform(value = "windows", include = {"<dc1394/dc1394.h>", "<dc1394/types.h>", "<dc1394/log.h>",
"<dc1394/camera.h>", "<dc1394/control.h>", "<dc1394/capture.h>", "<dc1394/conversions.h>", "<dc1394/format7.h>",
"<dc1394/iso.h>", "<dc1394/register.h>", "<dc1394/video.h>", "<dc1394/utils.h>"}, preload={"libdc1394-22", "libusb-1.0"}) })
"<dc1394/iso.h>", "<dc1394/register.h>", "<dc1394/video.h>", "<dc1394/utils.h>"}, preload = {"libdc1394-22", "libusb-1.0"}) })
public class dc1394 implements InfoMapper {
public void map(InfoMap infoMap) {
infoMap.put(new Info("poll.h").skip())
Expand All @@ -64,7 +64,7 @@ public void map(InfoMap infoMap) {
POLLHUP = 0x010,
POLLNVAL = 0x020;

@Platform(not="windows") public static class pollfd extends Pointer {
@Platform(not = "windows") public static class pollfd extends Pointer {
static { Loader.load(); }
public pollfd() { allocate(); }
public pollfd(long size) { allocateArray(size); }
Expand All @@ -81,7 +81,7 @@ public void map(InfoMap infoMap) {
public native short revents(); public native pollfd revents(short fd);
}

@Platform(not="windows") public native static int poll(pollfd fds, @Cast("nfds_t") long nfds, int timeout);
@Platform(not = "windows") public native static int poll(pollfd fds, @Cast("nfds_t") long nfds, int timeout);

public static abstract class dc1394video_frame_t_abstract extends Pointer {
public dc1394video_frame_t_abstract() { }
Expand Down
52 changes: 38 additions & 14 deletions libfreenect2/cppbuild.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@ if [[ -z "$PLATFORM" ]]; then
exit
fi

LIBJPEG=libjpeg-turbo-1.5.2
GLFW_VERSION=3.2.1
LIBJPEG=libjpeg-turbo-1.5.2
LIBFREENECT2_VERSION=0.2.0
download https://github.com/glfw/glfw/archive/$GLFW_VERSION.tar.gz glfw-$GLFW_VERSION.tar.gz
download http://downloads.sourceforge.net/project/libjpeg-turbo/1.5.2/$LIBJPEG.tar.gz $LIBJPEG.tar.gz
download https://github.com/OpenKinect/libfreenect2/archive/v$LIBFREENECT2_VERSION.zip libfreenect2-$LIBFREENECT2_VERSION.zip
download https://github.com/glfw/glfw/releases/download/$GLFW_VERSION/glfw-$GLFW_VERSION.zip glfw-$GLFW_VERSION.zip
download https://github.com/OpenKinect/libfreenect2/archive/v$LIBFREENECT2_VERSION.tar.gz libfreenect2-$LIBFREENECT2_VERSION.tar.gz

mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`
echo "Decompressing archives..."
tar --totals -xzf ../$LIBJPEG.tar.gz
unzip -o ../glfw-$GLFW_VERSION.zip
mkdir -p include lib bin
unzip -o ../libfreenect2-$LIBFREENECT2_VERSION.zip
tar --totals -xzf ../glfw-$GLFW_VERSION.tar.gz
tar --totals -xzf ../$LIBJPEG.tar.gz
tar --totals -xzf ../libfreenect2-$LIBFREENECT2_VERSION.tar.gz

if [[ $PLATFORM == windows* ]]; then
download https://github.com/OpenKinect/libfreenect2/releases/download/v$LIBFREENECT2_VERSION/libfreenect2-$LIBFREENECT2_VERSION-usbdk-vs2015-x64.zip libfreenect2-$LIBFREENECT2_VERSION-usbdk-vs2015-x64.zip

unzip -o libfreenect2-$LIBFREENECT2_VERSION-usbdk-vs2015-x64.zip
fi

case $PLATFORM in
linux-x86)
Expand All @@ -35,11 +41,10 @@ case $PLATFORM in
make -j $MAKEJ
make install
cd ../libfreenect2-$LIBFREENECT2_VERSION
# patch -Np1 < ../../../libfreenect2-$LIBFREENECT2_VERSION.patch
CC="$OLDCC -m32" CXX="$OLDCXX -m32" $CMAKE -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_OPENNI_DRIVER=OFF -DENABLE_CUDA=OFF -DENABLE_CXX11=OFF -DENABLE_OPENCL=OFF -DENABLE_VAAPI=OFF -DENABLE_TEGRAJPEG=OFF -DCMAKE_INSTALL_PREFIX=.. -DGLFW3_LIBRARY=../lib/libglfw3.a -DTurboJPEG_INCLUDE_DIRS=../include -DTurboJPEG_LIBRARIES=../lib/libturbojpeg.a
make -j4
patch -Np1 < ../../../libfreenect2.patch
CC="$OLDCC -m32" CXX="$OLDCXX -m32" $CMAKE -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_OPENNI_DRIVER=OFF -DENABLE_CUDA=OFF -DENABLE_CXX11=OFF -DENABLE_OPENCL=OFF -DENABLE_VAAPI=OFF -DENABLE_TEGRAJPEG=OFF -DCMAKE_INSTALL_PREFIX=.. -DGLFW3_INCLUDE_DIRS=../include -DGLFW3_LIBRARY=../lib/libglfw3.a -DTurboJPEG_INCLUDE_DIRS=../include -DTurboJPEG_LIBRARIES=../lib/libturbojpeg.a
make -j $MAKEJ
make install
patch -Np1 < ../../../libfreenect2-$LIBFREENECT2_VERSION.patch
;;
linux-x86_64)
export CC="$OLDCC -m64 -fPIC"
Expand All @@ -52,11 +57,30 @@ case $PLATFORM in
make -j $MAKEJ
make install
cd ../libfreenect2-$LIBFREENECT2_VERSION
# patch -Np1 < ../../../libfreenect2-$LIBFREENECT2_VERSION.patch
CC="$OLDCC -m64" CXX="$OLDCXX -m64" $CMAKE -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_OPENNI_DRIVER=OFF -DENABLE_CUDA=OFF -DENABLE_CXX11=OFF -DENABLE_OPENCL=OFF -DENABLE_VAAPI=OFF -DENABLE_TEGRAJPEG=OFF -DCMAKE_INSTALL_PREFIX=.. -DTurboJPEG_INCLUDE_DIRS=../include -DTurboJPEG_LIBRARIES=../lib/libturbojpeg.a
make -j4
patch -Np1 < ../../../libfreenect2.patch
CC="$OLDCC -m64" CXX="$OLDCXX -m64" $CMAKE -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_OPENNI_DRIVER=OFF -DENABLE_CUDA=OFF -DENABLE_CXX11=OFF -DENABLE_OPENCL=OFF -DENABLE_VAAPI=OFF -DENABLE_TEGRAJPEG=OFF -DCMAKE_INSTALL_PREFIX=.. -DGLFW3_INCLUDE_DIRS=../include -DGLFW3_LIBRARY=../lib/libglfw3.a -DTurboJPEG_INCLUDE_DIRS=../include -DTurboJPEG_LIBRARIES=../lib/libturbojpeg.a
make -j $MAKEJ
make install
;;
macosx-x86_64)
cd glfw-$GLFW_VERSION
$CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..
make -j $MAKEJ
make install
cd ../$LIBJPEG
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic
make -j $MAKEJ
make install
cd ../libfreenect2-$LIBFREENECT2_VERSION
patch -Np1 < ../../../libfreenect2.patch
LDFLAGS="-framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo" $CMAKE -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_OPENNI_DRIVER=OFF -DENABLE_CUDA=OFF -DENABLE_CXX11=OFF -DENABLE_OPENCL=OFF -DENABLE_VAAPI=OFF -DENABLE_TEGRAJPEG=OFF -DCMAKE_INSTALL_PREFIX=.. -DGLFW3_INCLUDE_DIRS=../include -DGLFW3_LIBRARY=../lib/libglfw3.a -DTurboJPEG_INCLUDE_DIRS=../include -DTurboJPEG_LIBRARIES=../lib/libturbojpeg.a -DCMAKE_MACOSX_RPATH=ON
make -j $MAKEJ
make install
patch -Np1 < ../../../libfreenect2-$LIBFREENECT2_VERSION.patch
;;
windows-x86_64)
cp -a libfreenect2-$LIBFREENECT2_VERSION-usbdk-vs2015-x64/include/* include
cp -a libfreenect2-$LIBFREENECT2_VERSION-usbdk-vs2015-x64/lib/* lib
cp -a libfreenect2-$LIBFREENECT2_VERSION-usbdk-vs2015-x64/bin/* bin
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
Expand Down
31 changes: 0 additions & 31 deletions libfreenect2/libfreenect2-0.2.0.patch

This file was deleted.

27 changes: 27 additions & 0 deletions libfreenect2/libfreenect2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff -ruN libfreenect2-0.2.0/cmake_modules/FindGLFW3.cmake libfreenect2-0.2.0-patch/cmake_modules/FindGLFW3.cmake
--- libfreenect2-0.2.0/cmake_modules/FindGLFW3.cmake 2016-04-28 05:34:51.000000000 +0900
+++ libfreenect2-0.2.0-patch/cmake_modules/FindGLFW3.cmake 2017-12-05 13:07:59.751981013 +0900
@@ -6,23 +6,6 @@
# GLFW3_INCLUDE_DIRS
# GLFW3_LIBRARIES

-IF(PKG_CONFIG_FOUND)
- IF(APPLE)
- # homebrew or macports pkgconfig locations
- SET(ENV{PKG_CONFIG_PATH} "/usr/local/opt/glfw3/lib/pkgconfig:/opt/local/lib/pkgconfig")
- ENDIF()
- SET(ENV{PKG_CONFIG_PATH} "${DEPENDS_DIR}/glfw/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
- PKG_CHECK_MODULES(GLFW3 glfw3)
-
- FIND_LIBRARY(GLFW3_LIBRARY
- NAMES ${GLFW3_LIBRARIES}
- HINTS ${GLFW3_LIBRARY_DIRS}
- )
- SET(GLFW3_LIBRARIES ${GLFW3_LIBRARY})
-
- RETURN()
-ENDIF()
-
FIND_PATH(GLFW3_INCLUDE_DIRS
GLFW/glfw3.h
DOC "GLFW include directory "
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@
* @author Jeremy Laviole
*/
@Properties(target = "org.bytedeco.javacpp.freenect2", value = {
@Platform(value = "linux-x86", include = {"<libfreenect2/libfreenect2.hpp>", "<libfreenect2/frame_listener.hpp>",
"<libfreenect2/frame_listener_impl.h>", "<libfreenect2/logger.h>", "<libfreenect2/packet_pipeline.h>",
"<libfreenect2/registration.h>", "<libfreenect2/config.h>"},
link = "freenect2@0.2", preload = "usb-1.0@.0") })
@Platform(value = {"linux-x86", "macosx-x86_64", "windows-x86_64"}, include = {"<libfreenect2/libfreenect2.hpp>",
"<libfreenect2/frame_listener.hpp>", "<libfreenect2/frame_listener_impl.h>", "<libfreenect2/logger.h>",
"<libfreenect2/packet_pipeline.h>", "<libfreenect2/registration.h>", "<libfreenect2/config.h>"},
link = "freenect2@.0.2"),
@Platform(value = "macosx-x86_64", preload = "usb-1.0@.0", preloadpath = "/usr/local/lib/"),
@Platform(value = "windows-x86_64", preload = {"freenect2-openni2", "glfw3", "libusb-1.0", "turbojpeg", "concrt140", "msvcp140", "vcruntime140",
"api-ms-win-crt-locale-l1-1-0", "api-ms-win-crt-string-l1-1-0", "api-ms-win-crt-stdio-l1-1-0", "api-ms-win-crt-math-l1-1-0",
"api-ms-win-crt-heap-l1-1-0", "api-ms-win-crt-runtime-l1-1-0", "api-ms-win-crt-convert-l1-1-0", "api-ms-win-crt-environment-l1-1-0",
"api-ms-win-crt-time-l1-1-0", "api-ms-win-crt-filesystem-l1-1-0", "api-ms-win-crt-utility-l1-1-0", "api-ms-win-crt-multibyte-l1-1-0"},
preloadpath = {"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist/x64/Microsoft.VC140.CRT/",
"C:/Program Files (x86)/Windows Kits/10/Redist/ucrt/DLLs/x64/"}) })
public class freenect2 implements InfoMapper {
public void map(InfoMap infoMap) {
infoMap.put(new Info("LIBFREENECT2_WITH_CUDA_SUPPORT", "LIBFREENECT2_WITH_OPENCL_SUPPORT").define(false))
Expand Down

0 comments on commit 468be6b

Please sign in to comment.