Browse Source

initial commit

master
Nareshkumar Rao 4 years ago
commit
078fa5465d
  1. 5
      .gitignore
  2. 64
      build.sh
  3. 18
      toolchain.cmake.template

5
.gitignore

@ -0,0 +1,5 @@
sysroot/
tools/
librealsense/
sysroot-relativelinks.py
toolchain.cmake

64
build.sh

@ -0,0 +1,64 @@
#!/bin/bash
TOOLCHAIN_URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz?revision=972019b5-912f-4ae6-864a-f61f570e2e7e&la=en&hash=B8618949E6095C87E4C9FFA1648CAA67D4997D88"
LIBREALSENSE_GIT="https://github.com/IntelRealSense/librealsense.git"
SYSROOT_TOOL_URL="https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py"
CURDIR=$(pwd)
PI_USER_HOST="naresh@192.168.0.110"
# Download the toolchain
mkdir -p ./tools
cd ./tools
if [ ! -f ./toolchain.tar.xz ]
then
wget -O toolchain.tar.xz $TOOLCHAIN_URL
tar xf ./toolchain.tar.xz
fi
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "gcc*")
if [ $(echo $TOOLCHAIN_DIR | wc -l) != 1 ] && [ -d $TOOLCHAIN_DIR ]
then
echo "An error has occured."
exit
fi
TOOLCHAIN_DIR=$(readlink -f $TOOLCHAIN_DIR)
# Retrieve libraries from live PI
cd $CURDIR
rsync -avz --rsync-path="sudo rsync" $PI_USER_HOST:/lib sysroot/
rsync -avz --rsync-path="sudo rsync" $PI_USER_HOST:/usr/include sysroot/usr/
rsync -avz --rsync-path="sudo rsync" $PI_USER_HOST:/usr/lib sysroot/usr/
#rsync -avz --rsync-path="sudo rsync" $PI_USER_HOST:/opt/vc sysroot/opt/
SYSROOT=$(readlink -f ./sysroot)
if [ ! -f ./sysroot-relativelinks.py ]
then
wget $SYSROOT_TOOL_URL
chmod +x ./sysroot-relativelinks.py
fi
./sysroot-relativelinks.py ./sysroot
# Press toolchain template
sed "s/TEMPLATESYSROOT/$(echo $SYSROOT | sed 's_/_\\/_g')/" ./toolchain.cmake.template > ./toolchain.cmake
sed -i "s/TEMPLATETOOLCHAIN/$(echo $TOOLCHAIN_DIR | sed 's_/_\\/_g')/" ./toolchain.cmake
# Clone librealsense
cd $CURDIR
if [ ! -d ./librealsense ]
then
git clone $LIBREALSENSE_GIT ./librealsense
fi
cd ./librealsense
rm -rf ./build
mkdir -p ./build
cd ./build
cmake ../ -DBUILD_EXAMPLES=false \
-DBUILD_GRAPHICAL_EXAMPLES=false \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_PYTHON_BINDINGS:bool=true \
-DPython_INCLUDE_DIR="${SYSROOT}/usr/include/python3.8" \
-DPython_LIBRARY="${SYSROOT}/usr/lib/aarch64-linux-gnu/libpython3.8.so" \
-DLIBUSB_LIB="${SYSROOT}/usr/lib/aarch64-linux-gnu/libusb-1.0.so.0.2.0" \
-DCMAKE_TOOLCHAIN_FILE=${CURDIR}/toolchain.cmake
make -j14
tar cvzf $CURDIR/librealsensecompiled.tar.gz $(find . -name "*.so*")

18
toolchain.cmake.template

@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSROOT TEMPLATESYSROOT)
set(tools TEMPLATETOOLCHAIN)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-none-linux-gnu-g++)
include_directories(SYSTEM TEMPLATESYSROOT/usr/include/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
Loading…
Cancel
Save