From 5f8d458fff45bae9d7705ccf3d504490a8e2f004 Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao Date: Fri, 14 May 2021 00:15:29 +0200 Subject: [PATCH] standalone --- .gitignore | 3 ++- build.sh | 20 ++++++++++++++++++-- toolchain.cmake.template | 9 +++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index cf533a2..9aeb239 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ sysroot/ tools/ librealsense/ sysroot-relativelinks.py -toolchain.cmake \ No newline at end of file +toolchain.cmake +output diff --git a/build.sh b/build.sh index 24307f8..dca0363 100755 --- a/build.sh +++ b/build.sh @@ -29,6 +29,7 @@ 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 ] @@ -59,6 +60,21 @@ cmake ../ -DBUILD_EXAMPLES=false \ -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 + -DCMAKE_TOOLCHAIN_FILE=${CURDIR}/toolchain.cmake make -j14 -tar cvzf $CURDIR/librealsensecompiled.tar.gz $(find . -name "*.so*") + +# Collect built binaries and tar up +mkdir -p $CURDIR/output +make DESTDIR=$CURDIR/output install + +cd $CURDIR/output +tar cvzf ./librealsense2_pyrealsense2_aarch64.tar.gz ./* + +cd $CURDIR +read -p "Remove generated build files (incl. toolchain, librealsense source and Raspi libraries)? " -n 1 -r +echo # (optional) move to a new line +if [[ $REPLY =~ ^[Yy]$ ]] +then + rm -rf ./sysroot ./tools ./librealsense ./output +fi + diff --git a/toolchain.cmake.template b/toolchain.cmake.template index c64ca47..8188be8 100644 --- a/toolchain.cmake.template +++ b/toolchain.cmake.template @@ -1,13 +1,15 @@ set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR arm) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(CMAKE_CROSSCOMPILING TRUE) -set(CMAKE_SYSROOT TEMPLATESYSROOT) +set(CMAKE_FIND_ROOT_PATH 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++) +set(CMAKE_LIBRARY_ARCHITECTURE aarch64-linux-gnu) -include_directories(SYSTEM TEMPLATESYSROOT/usr/include/aarch64-linux-gnu) +include_directories(SYSTEM TEMPLATESYSROOT/usr/include) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) @@ -15,4 +17,3 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_THREAD_LIBS_INIT "-lpthread") -