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

add cuda build for librealsense2 #1032

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions librealsense2/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ LIBUSB_VERSION=1.0.22
download https://github.com/IntelRealSense/librealsense/archive/v$LIBREALSENSE2_VERSION.tar.gz librealsense-$LIBREALSENSE2_VERSION.tar.gz
download http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-$LIBUSB_VERSION/libusb-$LIBUSB_VERSION.tar.bz2/download libusb-$LIBUSB_VERSION.tar.bz2

mkdir -p $PLATFORM
cd $PLATFORM
mkdir -p "$PLATFORM$EXTENSION"
cd "$PLATFORM$EXTENSION"
mkdir -p include lib bin
INSTALL_PATH=`pwd`
echo "Decompressing archives..."
Expand All @@ -24,6 +24,11 @@ cd librealsense-$LIBREALSENSE2_VERSION
patch -Np1 < ../../../librealsense2.patch || true
sedinplace 's/float_t/float/g' `find src/tm2/ -type f`

GPU_FLAGS="-DBUILD_WITH_CUDA=OFF"
if [[ "$EXTENSION" == *gpu ]]; then
GPU_FLAGS="-DBUILD_WITH_CUDA=ON"
fi

case $PLATFORM in
linux-armhf)
cd ../libusb-$LIBUSB_VERSION
Expand All @@ -41,7 +46,7 @@ case $PLATFORM in
make -j $MAKEJ
make install
cd ../librealsense-$LIBREALSENSE2_VERSION
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLIBUSB_INC=$INSTALL_PATH/include/libusb-1.0/ -DLIBUSB_LIB=$INSTALL_PATH/lib/libusb-1.0.a -DBUILD_UNIT_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF .
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLIBUSB_INC=$INSTALL_PATH/include/libusb-1.0/ -DLIBUSB_LIB=$INSTALL_PATH/lib/libusb-1.0.a -DBUILD_UNIT_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF $GPU_FLAGS .
make -j $MAKEJ
make install/strip
;;
Expand All @@ -61,7 +66,7 @@ case $PLATFORM in
make -j $MAKEJ
make install
cd ../librealsense-$LIBREALSENSE2_VERSION
CC="gcc -m64" CXX="g++ -m64" "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLIBUSB_INC=$INSTALL_PATH/include/libusb-1.0/ -DLIBUSB_LIB=$INSTALL_PATH/lib/libusb-1.0.a -DBUILD_UNIT_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF .
CC="gcc -m64" CXX="g++ -m64" "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DLIBUSB_INC=$INSTALL_PATH/include/libusb-1.0/ -DLIBUSB_LIB=$INSTALL_PATH/lib/libusb-1.0.a -DBUILD_UNIT_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF $GPU_FLAGS .
make -j $MAKEJ
make install/strip
;;
Expand All @@ -87,7 +92,7 @@ case $PLATFORM in
cd build
export CC="cl.exe"
export CXX="cl.exe"
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DBUILD_UNIT_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF ..
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DBUILD_UNIT_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GRAPHICAL_EXAMPLES=OFF $GPU_FLAGS ..
ninja -j $MAKEJ
cd ..
cp -a include/* ../include/
Expand Down
128 changes: 128 additions & 0 deletions librealsense2/platform/gpu/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-presets</artifactId>
<version>1.5.9-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<groupId>org.bytedeco</groupId>
<artifactId>librealsense2-platform-gpu</artifactId>
<version>2.50.0-${project.parent.version}</version>
<name>JavaCPP Presets Platform GPU for librealsense2</name>

<properties>
<javacpp.moduleId>librealsense2</javacpp.moduleId>
<javacpp.platform.extension>-gpu</javacpp.platform.extension>
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-platform</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-arm64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${javacpp.moduleId}</artifactId>
<version>${project.version}</version>
<classifier>${javacpp.platform.windows-x86_64}</classifier>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<configuration>
<archive>
<manifestEntries>
<Class-Path>
${javacpp.moduleId}.jar
${javacpp.moduleId}-linux-arm64-gpu.jar
${javacpp.moduleId}-linux-x86_64-gpu.jar
${javacpp.moduleId}-windows-x86_64-gpu.jar
</Class-Path>
</manifestEntries>
</archive>
</configuration>
</execution>
<execution>
<id>empty-javadoc-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>javadoc</classifier>
</configuration>
</execution>
<execution>
<id>empty-sources-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>sources</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
<execution>
<id>add-module-infos</id>
<phase>none</phase>
</execution>
<execution>
<id>add-platform-module-info</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<modules>
<module>
<file>${project.build.directory}/${project.artifactId}.jar</file>
<moduleInfoSource>
module org.bytedeco.${javacpp.moduleId}.platform.gpu {
requires static org.bytedeco.${javacpp.moduleId}.linux.arm64.gpu;
requires static org.bytedeco.${javacpp.moduleId}.linux.x86_64.gpu;
requires static org.bytedeco.${javacpp.moduleId}.windows.x86_64.gpu;
}
</moduleInfoSource>
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
4 changes: 2 additions & 2 deletions librealsense2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<configuration>
<encoding>ISO-8859-1</encoding>
<linkPaths>
<linkPath>${basedir}/cppbuild/${javacpp.platform}/lib/</linkPath>
<linkPath>${basedir}/cppbuild/${javacpp.platform}/lib64/</linkPath>
<linkPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/lib/</linkPath>
<linkPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/lib64/</linkPath>
</linkPaths>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@
},
link = "[email protected]"
),
@Platform(value = "macosx", preload = "[email protected]", preloadpath = "/usr/local/lib/")
@Platform(value = "macosx", preload = "[email protected]", preloadpath = "/usr/local/lib/"),
@Platform(value = {"linux-arm64", "linux-x86_64", "windows-x86_64"},
extension = "-gpu"
)
},
target = "org.bytedeco.librealsense2",
global = "org.bytedeco.librealsense2.global.realsense2"
Expand Down