From 43c710ec398cf731f73c75dfe3bfd8501a8bf3ce Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 30 Dec 2018 02:07:22 -0800 Subject: [PATCH] Build wpilib with cmake instead of gradle (#15) * Move java lib install to /usr/local/frc/java * Build and install both debug and normal OpenCV libraries * Install OpenCV cmake files * Build OpenCV Java with version 8 target * Build static OpenCV for static allwpilib binaries * Move netconsoleTee install to /usr/local/frc/bin * Move multiCameraServer default app install to /usr/local/frc/bin * Install more FRC binaries * Fix /home/pi/zips/java-multiCameraServer.zip owner to pi:pi * Remove azure 60 minute timeout * Add openjdk-8-jdk to Azure docker image (this is needed for cmake to find javah as only cmake 3.9 is available) --- .gitmodules | 3 - azure-docker/Dockerfile | 2 +- azure-pipelines.yml | 2 + deps/02-extract.sh | 17 +- deps/03-build.sh | 160 +++++++++++++----- deps/04-copy.sh | 36 ++-- deps/allwpilib | 2 +- deps/arm-pi-gnueabihf.toolchain.cmake | 77 +++++++++ .../java-multiCameraServer/build.gradle | 2 +- deps/thirdparty-opencv | 1 - deps/tools/Makefile | 25 +-- .../tools/rpiConfigServer_src/Application.cpp | 2 +- stage2/01-sys-tweaks/01-run.sh | 30 ++-- stage2/01-sys-tweaks/files/camera_log_run | 2 +- stage2/01-sys-tweaks/files/runCamera | 2 +- 15 files changed, 266 insertions(+), 97 deletions(-) create mode 100644 deps/arm-pi-gnueabihf.toolchain.cmake delete mode 160000 deps/thirdparty-opencv diff --git a/.gitmodules b/.gitmodules index ce888eb..811e89b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,3 @@ [submodule "deps/allwpilib"] path = deps/allwpilib url = https://github.com/wpilibsuite/allwpilib.git -[submodule "deps/thirdparty-opencv"] - path = deps/thirdparty-opencv - url = https://github.com/wpilibsuite/thirdparty-opencv.git diff --git a/azure-docker/Dockerfile b/azure-docker/Dockerfile index 779e61b..6d4e315 100644 --- a/azure-docker/Dockerfile +++ b/azure-docker/Dockerfile @@ -7,6 +7,6 @@ RUN apt-get -y update \ git vim parted \ quilt realpath qemu-user-static debootstrap zerofree pxz zip dosfstools \ bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file \ - build-essential cmake python3 ant sudo \ + build-essential cmake python3 ant sudo openjdk-8-jdk \ && apt-get -y -t stretch-backports install openjdk-11-jdk \ && rm -rf /var/lib/apt/lists/* diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1b05e23..69a417f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,6 +9,8 @@ jobs: pool: vmImage: 'Ubuntu 16.04' + timeoutInMinutes: 0 + container: pi-gen steps: diff --git a/deps/02-extract.sh b/deps/02-extract.sh index 5f9d852..0446cdc 100755 --- a/deps/02-extract.sh +++ b/deps/02-extract.sh @@ -32,7 +32,22 @@ popd # opencv sources tar xzf ../01-download/3.4.4.tar.gz mv opencv-3.4.4 opencv -cp ../thirdparty-opencv/arm-pi-gnueabihf.toolchain.cmake . +sed -i -e 's/javac sourcepath/javac target="1.8" source="1.8" sourcepath/' opencv/modules/java/jar/build.xml.in + +# toolchain setup for opencv and wpilib +cp ../arm-pi-gnueabihf.toolchain.cmake . cp -R ../thirdparty-opencv/jni . +tar xzf ../01-download/jdk_11*.tar.gz jdk/include +mkdir -p cmake-modules +cat > cmake-modules/FindJNI.cmake << EOF +set(JNI_INCLUDE_DIRS "${PWD}/jdk/include" "${PWD}/jdk/include/linux") +set(JNI_LIBRARIES ) +set(JNI_FOUND YES) +set(JAVA_AWT_LIBRARY ) +set(JAVA_JVM_LIBRARY ) +set(JAVA_INCLUDE_PATH "${PWD}/jdk/include") +set(JAVA_INCLUDE_PATH2 "${PWD}/jdk/include/linux") +set(JAVA_AWT_INCLUDE_PATH ) +EOF popd diff --git a/deps/03-build.sh b/deps/03-build.sh index e42b584..0b42cd6 100755 --- a/deps/03-build.sh +++ b/deps/03-build.sh @@ -2,53 +2,133 @@ export PATH=${PWD}/02-extract/raspbian9/bin:${PATH} +split_debug () { + arm-raspbian9-linux-gnueabihf-objcopy --only-keep-debug $1 $1.debug + arm-raspbian9-linux-gnueabihf-strip -g $1 + arm-raspbian9-linux-gnueabihf-objcopy --add-gnu-debuglink=$1.debug $1 +} + +split_debug_so () { + pushd $1 + for lib in *.so + do + split_debug $lib + done + popd +} + +split_debug_exe () { + pushd $1 + for exe in * + do + split_debug $exe + done + popd +} + # opencv +build_opencv () { + cmake ../../02-extract/opencv \ + -DWITH_CUDA=OFF \ + -DWITH_IPP=OFF \ + -DWITH_ITT=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_FFMPEG=OFF \ + -DWITH_OPENEXR=OFF \ + -DWITH_GSTREAMER=OFF \ + -DWITH_LAPACK=OFF \ + -DWITH_GTK=ON \ + -DWITH_1394=OFF \ + -DWITH_JASPER=OFF \ + -DWITH_TIFF=OFF \ + -DBUILD_JPEG=ON \ + -DBUILD_PNG=ON \ + -DBUILD_ZLIB=ON \ + -DBUILD_TESTS=OFF \ + -DPython_ADDITIONAL_VERSIONS=3.5 \ + -DWITH_WEBP=OFF \ + -DBUILD_JAVA=$2 \ + -DBUILD_WITH_STATIC_CRT=OFF \ + -DWITH_PROTOBUF=OFF \ + -DWITH_DIRECTX=OFF \ + -DENABLE_CXX11=ON \ + -DBUILD_SHARED_LIBS=$2 \ + -DCMAKE_BUILD_TYPE=$1 \ + -DCMAKE_DEBUG_POSTFIX=d \ + -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ + -DCMAKE_MAKE_PROGRAM=make \ + -DENABLE_NEON=ON \ + -DENABLE_VFPV3=ON \ + -DBUILD_opencv_python3=$2 \ + -DPYTHON3_INCLUDE_PATH=${PWD}/../../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf/usr/include/python3.5m \ + -DPYTHON3_NUMPY_INCLUDE_DIRS=${PWD}/../../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf/usr/include/python3.5m/numpy \ + -DOPENCV_EXTRA_FLAGS_DEBUG=-Og \ + -DCMAKE_MODULE_PATH=${PWD}/../../02-extract/cmake-modules \ + || exit 1 + make -j3 || exit 1 + make install || exit 1 + if [ "$1" == "RelWithDebugInfo" ] + then + cp -p install/share/OpenCV/java/libopencv_java*.so install/lib/ + fi + split_debug_so install/lib +} + mkdir -p 03-build/opencv-build pushd 03-build/opencv-build -cmake ../../02-extract/opencv \ - -DWITH_CUDA=OFF \ - -DWITH_IPP=OFF \ - -DWITH_ITT=OFF \ - -DWITH_OPENCL=OFF \ - -DWITH_FFMPEG=OFF \ - -DWITH_OPENEXR=OFF \ - -DWITH_GSTREAMER=OFF \ - -DWITH_LAPACK=OFF \ - -DWITH_GTK=ON \ - -DWITH_1394=OFF \ - -DWITH_JASPER=OFF \ - -DWITH_TIFF=OFF \ - -DBUILD_JPEG=ON \ - -DBUILD_PNG=ON \ - -DBUILD_ZLIB=ON \ - -DBUILD_TESTS=OFF \ - -DPython_ADDITIONAL_VERSIONS=3.5 \ - -DWITH_WEBP=OFF \ - -DBUILD_JAVA=ON \ - -DBUILD_WITH_STATIC_CRT=OFF \ - -DWITH_PROTOBUF=OFF \ - -DWITH_DIRECTX=OFF \ - -DENABLE_CXX11=ON \ - -DBUILD_SHARED_LIBS=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ - -DCMAKE_MAKE_PROGRAM=make \ - -DENABLE_NEON=ON \ - -DENABLE_VFPV3=ON \ - -DBUILD_opencv_python3=ON \ - -DPYTHON3_INCLUDE_PATH=${PWD}/../../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf/usr/include/python3.5m \ - -DPYTHON3_NUMPY_INCLUDE_DIRS=${PWD}/../../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf/usr/include/python3.5m/numpy \ - -DOPENCV_EXTRA_FLAGS_DEBUG=-Og \ - -DCMAKE_MODULE_PATH=${PWD}/../../thirdparty-opencv/arm-frc-modules \ - || exit 1 -make -j3 || exit 1 -make install || exit 1 +build_opencv RelWithDebugInfo ON || exit 1 +popd +mkdir -p 03-build/opencv-build-debug +pushd 03-build/opencv-build-debug +build_opencv Debug ON || exit 1 +popd + +mkdir -p 03-build/opencv-static +pushd 03-build/opencv-static +build_opencv RelWithDebugInfo OFF || exit 1 popd # wpiutil, cscore, ntcore, cameraserver -pushd allwpilib -./gradlew -PonlyRaspbian :wpiutil:build :cscore:build :ntcore:build :cameraserver:build :cameraserver:multiCameraServer:build || exit 1 +# always use the release version of opencv jar/jni +build_wpilib () { + cmake ../../allwpilib \ + -DCMAKE_BUILD_TYPE=$1 \ + -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ + -DCMAKE_MODULE_PATH=${PWD}/../../02-extract/cmake-modules \ + -DOPENCV_JAR_FILE=`ls ${PWD}/../opencv-build/install/share/OpenCV/java/opencv-*.jar` \ + -DOPENCV_JNI_FILE=`ls ${PWD}/../opencv-build/install/share/OpenCV/java/libopencv_java*.so` \ + -DOpenCV_DIR=${PWD}/../$2/install/share/OpenCV \ + -DTHREADS_PTHREAD_ARG=-pthread \ + || exit 1 + make -j3 || exit 1 + split_debug_so lib +} + +mkdir -p 03-build/allwpilib-build +pushd 03-build/allwpilib-build +build_wpilib RelWithDebugInfo opencv-build || exit 1 +popd + +mkdir -p 03-build/allwpilib-build-debug +pushd 03-build/allwpilib-build-debug +build_wpilib Debug opencv-build-debug || exit 1 +popd + +# static (for tools) +mkdir -p 03-build/allwpilib-static +pushd 03-build/allwpilib-static +cmake ../../allwpilib \ + -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ + -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ + -DCMAKE_MODULE_PATH=${PWD}/../../02-extract/cmake-modules \ + -DOpenCV_DIR=${PWD}/../opencv-static/install/share/OpenCV \ + -DWITHOUT_JAVA=ON \ + -DBUILD_SHARED_LIBS=OFF \ + -DTHREADS_PTHREAD_ARG=-pthread \ + || exit 1 +make -j3 || exit 1 +split_debug_exe bin popd # tools diff --git a/deps/04-copy.sh b/deps/04-copy.sh index 6398294..6e76401 100755 --- a/deps/04-copy.sh +++ b/deps/04-copy.sh @@ -21,7 +21,9 @@ sh -c 'cd examples && zip -r - python-multiCameraServer' > ${DEST}/python-multiC cp tools/setuidgids ${DEST}/ cp tools/_cscore.so ${DEST}/_cscore.cpython-35m-arm-linux-gnueabihf.so +cp tools/_cscore.so.debug ${DEST}/ cp tools/rpiConfigServer ${DEST}/ +cp tools/rpiConfigServer.debug ${DEST}/ # # openjdk @@ -30,15 +32,19 @@ cp tools/rpiConfigServer ${DEST}/ cp 01-download/jdk_11.0.1-strip.tar.gz ${DEST}/ # -# thirdparty-opencv +# opencv # sh -c 'cd 03-build/opencv-build/install/lib && tar czf - libopencv*' > ${DEST}/libopencv.tar.gz +sh -c 'cd 03-build/opencv-build-debug/install/lib && tar czf - libopencv*' > ${DEST}/libopencv-debug.tar.gz sh -c 'cd 03-build/opencv-build/install/include && tar czf - .' > ${DEST}/opencv-include.tar.gz cp 03-build/opencv-build/install/share/OpenCV/java/opencv-*.jar ${DEST}/ +sh -c 'cd 03-build/opencv-build/install/share/OpenCV && tar czf - *.cmake' > ${DEST}/opencv-cmake.tar.gz +sh -c 'cd 03-build/opencv-build-debug/install/share/OpenCV && tar czf - *.cmake' > ${DEST}/opencv-cmake-debug.tar.gz + # the opencv build names the python .so with the build platform name instead # of the target platform, so rename it cp 03-build/opencv-build/install/python/cv2/python-*/cv2.*.so ${DEST}/cv2.cpython-35m-arm-linux-gnueabihf.so @@ -59,32 +65,14 @@ sh -c 'cd pynetworktables && tar czf - networktables ntcore' > ${DEST}/pynetwork # allwpilib # -cp \ - allwpilib/wpiutil/build/libs/wpiutil/shared/release/libwpiutil.so* \ - allwpilib/wpiutil/build/libs/wpiutil/shared/debug/libwpiutild.so* \ - allwpilib/wpiutil/build/libs/wpiutil.jar \ - allwpilib/cscore/build/libs/cscore/shared/release/libcscore.so* \ - allwpilib/cscore/build/libs/cscore/shared/debug/libcscored.so* \ - allwpilib/cscore/build/libs/cscoreJNIShared/shared/release/libcscorejni.so* \ - allwpilib/cscore/build/libs/cscore.jar \ - allwpilib/ntcore/build/libs/ntcore/shared/release/libntcore.so* \ - allwpilib/ntcore/build/libs/ntcore/shared/debug/libntcored.so* \ - allwpilib/ntcore/build/libs/ntcoreJNIShared/shared/release/libntcorejni.so* \ - allwpilib/ntcore/build/libs/ntcore.jar \ - allwpilib/cameraserver/build/libs/cameraserver/shared/release/libcameraserver.so* \ - allwpilib/cameraserver/build/libs/cameraserver/shared/debug/libcameraserverd.so* \ - allwpilib/cameraserver/build/libs/cameraserver.jar \ - ${DEST}/ +sh -c 'cd 03-build/allwpilib-build/lib && tar czf - lib*' > ${DEST}/wpilib.tar.gz +sh -c 'cd 03-build/allwpilib-build-debug/lib && tar czf - lib*' > ${DEST}/wpilib-debug.tar.gz + +cp 03-build/allwpilib-build/jar/*.jar ${DEST}/ sh -c 'cd allwpilib/wpiutil/src/main/native/include && tar czf - uv.h uv wpi' > ${DEST}/wpiutil-include.tar.gz sh -c 'cd allwpilib/cscore/src/main/native/include && tar czf - .' > ${DEST}/cscore-include.tar.gz sh -c 'cd allwpilib/ntcore/src/main/native/include && tar czf - .' > ${DEST}/ntcore-include.tar.gz sh -c 'cd allwpilib/cameraserver/src/main/native/include && tar czf - cameraserver vision' > ${DEST}/cameraserver-include.tar.gz -cp \ - allwpilib/cameraserver/multiCameraServer/build/exe/multiCameraServerCpp/multiCameraServerCpp \ - ${DEST}/multiCameraServer - -cp \ - allwpilib/wpiutil/build/exe/netconsoleTee/netconsoleTee \ - ${DEST}/ +sh -c 'cd 03-build/allwpilib-static/bin && tar czf - cscore_* multiCameraServer* netconsoleTee*' > ${DEST}/wpilib-bin.tar.gz diff --git a/deps/allwpilib b/deps/allwpilib index 7d7af28..300eeb3 160000 --- a/deps/allwpilib +++ b/deps/allwpilib @@ -1 +1 @@ -Subproject commit 7d7af287f6718c0fcb2123aca1b2cebc3177ade5 +Subproject commit 300eeb330d78e2ef605d30644efbc4dd8bcdad61 diff --git a/deps/arm-pi-gnueabihf.toolchain.cmake b/deps/arm-pi-gnueabihf.toolchain.cmake new file mode 100644 index 0000000..25cc691 --- /dev/null +++ b/deps/arm-pi-gnueabihf.toolchain.cmake @@ -0,0 +1,77 @@ +if(COMMAND toolchain_save_config) + return() # prevent recursive call +endif() + +set(GCC_COMPILER_VERSION "" CACHE STRING "GCC Compiler version") +set(GNU_MACHINE "arm-raspbian9-linux-gnueabi" CACHE STRING "GNU compiler triple") +set(SOFTFP no) +set(FLOAT_ABI_SUFFIX "hf") +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR arm) + +include("${CMAKE_CURRENT_LIST_DIR}/opencv/platforms/linux/gnu.toolchain.cmake") + +if(NOT DEFINED CMAKE_C_COMPILER) + find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_CXX_COMPILER) + find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_LINKER) + find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) +else() + #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") +endif() +if(NOT DEFINED CMAKE_AR) + find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) +else() + #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") +endif() + +if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) + set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) +endif() + +if(NOT DEFINED CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") + set(CMAKE_C_FLAGS "" CACHE INTERNAL "") + set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-psabi") + set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} -rdynamic ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} -rdynamic ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} -rdynamic ${CMAKE_EXE_LINKER_FLAGS}") +else() + #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") +endif() + +if(USE_NEON) + message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) + set(ENABLE_NEON TRUE) +elseif(USE_VFPV3) + message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) + set(ENABLE_VFPV3 TRUE) +endif() + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) + +if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + +set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} + ARM_LINUX_SYSROOT + ENABLE_NEON + ENABLE_VFPV3 + CUDA_TOOLKIT_ROOT_DIR +) +toolchain_save_config() + diff --git a/deps/examples/java-multiCameraServer/build.gradle b/deps/examples/java-multiCameraServer/build.gradle index bcc9b11..811e32e 100644 --- a/deps/examples/java-multiCameraServer/build.gradle +++ b/deps/examples/java-multiCameraServer/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'com.github.johnrengelman.shadow' repositories { mavenCentral() flatDir { - dirs '/home/pi/javalibs', '.' + dirs '/usr/local/frc/java', '.' } } diff --git a/deps/thirdparty-opencv b/deps/thirdparty-opencv deleted file mode 160000 index 579bc6b..0000000 --- a/deps/thirdparty-opencv +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 579bc6b26169c690bdadb52150d4396e696eed31 diff --git a/deps/tools/Makefile b/deps/tools/Makefile index 81b9a1c..b577e56 100644 --- a/deps/tools/Makefile +++ b/deps/tools/Makefile @@ -1,7 +1,8 @@ SYSROOT?=../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf COMPILER?=../02-extract/raspbian9/bin/arm-raspbian9-linux-gnueabihf- -WPILIB?=../allwpilib -WPILIB_PLATFORM?=. +WPILIB_SRC?=../allwpilib +WPILIB_BUILD?=../03-build/allwpilib-build +WPILIB_STATIC_BUILD?=../03-build/allwpilib-static OPENCV_INSTALL?=../03-build/opencv-build/install EXEC_HOME?=/home/pi FRC_JSON?=/boot/frc.json @@ -25,19 +26,21 @@ setuidgids: setuidgids.c ${COMPILER}gcc -O -Wall -D_GNU_SOURCE -o $@ $< _cscore.so: ../robotpy-cscore/src/_cscore.cpp ../robotpy-cscore/src/ndarray_converter.cpp - ${COMPILER}g++ -O -Wall -fvisibility=hidden -shared -fPIC -o $@ \ + ${COMPILER}g++ -g -O -Wall -fvisibility=hidden -shared -fPIC -o $@ \ -I${OPENCV_INSTALL}/include \ - -I${WPILIB}/wpiutil/src/main/native/include \ - -I${WPILIB}/cscore/src/main/native/include \ + -I${WPILIB_SRC}/wpiutil/src/main/native/include \ + -I${WPILIB_SRC}/cscore/src/main/native/include \ -I${SYSROOT}/usr/include/python3.5 \ - -L${WPILIB}/cscore/build/libs/cscore/shared/${WPILIB_PLATFORM}/release \ - -L${WPILIB}/wpiutil/build/libs/wpiutil/shared/${WPILIB_PLATFORM}/release \ + -L${WPILIB_BUILD}/lib \ -L${OPENCV_INSTALL}/lib \ ../robotpy-cscore/src/_cscore.cpp \ ../robotpy-cscore/src/ndarray_converter.cpp \ -lcscore \ -lwpiutil \ -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core + ${COMPILER}objcopy --only-keep-debug $@ $@.debug + ${COMPILER}strip -g $@ + ${COMPILER}objcopy --add-gnu-debuglink=$@.debug $@ RPICONFIGSERVER_OBJS= \ rpiConfigServer_src/main.o \ @@ -53,17 +56,17 @@ RPICONFIGSERVER_OBJS= \ rpiConfigServer_src/resources/frcvision.js.o rpiConfigServer: ${RPICONFIGSERVER_OBJS} - ${COMPILER}g++ -pthread -o $@ \ + ${COMPILER}g++ -pthread -g -o $@ \ ${RPICONFIGSERVER_OBJS} \ - -L${WPILIB}/wpiutil/build/libs/wpiutil/static/${WPILIB_PLATFORM}/release \ + -L${WPILIB_STATIC_BUILD}/lib \ -lwpiutil ${COMPILER}objcopy --only-keep-debug $@ $@.debug ${COMPILER}strip -g $@ ${COMPILER}objcopy --add-gnu-debuglink=$@.debug $@ %.o: %.cpp - ${COMPILER}g++ -O -Wall -c -o $@ \ - -I${WPILIB}/wpiutil/src/main/native/include \ + ${COMPILER}g++ -g -O -Wall -c -o $@ \ + -I${WPILIB_SRC}/wpiutil/src/main/native/include \ '-DEXEC_HOME="${EXEC_HOME}"' \ '-DFRC_JSON="${FRC_JSON}"' \ '-DDHCPCD_CONF="${DHCPCD_CONF}"' \ diff --git a/deps/tools/rpiConfigServer_src/Application.cpp b/deps/tools/rpiConfigServer_src/Application.cpp index e252fec..fd300d8 100644 --- a/deps/tools/rpiConfigServer_src/Application.cpp +++ b/deps/tools/rpiConfigServer_src/Application.cpp @@ -30,7 +30,7 @@ void Application::Set(wpi::StringRef appType, wpi::StringRef appCommand; if (appType == "builtin") { - appCommand = "./multiCameraServer"; + appCommand = "/usr/local/frc/bin/multiCameraServer"; } else if (appType == "example-java") { appDir = "java-multiCameraServer"; appCommand = diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index 309628d..ecca070 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -21,8 +21,6 @@ install -m 644 files/frc.json "${ROOTFS_DIR}/boot/" install -m 755 extfiles/setuidgids "${ROOTFS_DIR}/usr/local/bin/" -install -m 755 -o 1000 -g 1000 extfiles/multiCameraServer "${ROOTFS_DIR}/home/pi/" - cat extfiles/jdk_11.0.1-strip.tar.gz | sh -c "mkdir -p ${ROOTFS_DIR}/usr/lib/jvm && cd ${ROOTFS_DIR}/usr/lib/jvm/ && tar xzf - --exclude=\*.diz --exclude=src.zip --transform=s/^jdk/jdk-11.0.1/" cp files/jdk-11.0.1.jinfo "${ROOTFS_DIR}/usr/lib/jvm/.jdk-11.0.1.jinfo" @@ -83,8 +81,13 @@ EOF install -m 644 files/ld.so.conf.d/*.conf "${ROOTFS_DIR}/etc/ld.so.conf.d/" +install -v -d "${ROOTFS_DIR}/usr/local/frc/bin" + +cat extfiles/wpilib-bin.tar.gz | sh -c 'cd ${ROOTFS_DIR}/usr/local/frc/bin/ && tar xzf -' + install -v -d "${ROOTFS_DIR}/usr/local/frc/lib" +cat extfiles/libopencv-debug.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" cat extfiles/libopencv.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" install -m 755 extfiles/cv2.*.so "${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/" @@ -93,10 +96,8 @@ cat extfiles/pynetworktables.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/lib/pyth cat extfiles/robotpy-cscore.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/ && tar xzf -" install -m 755 extfiles/_cscore.*.so "${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/cscore/" -install -m 755 extfiles/libwpiutil*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" -install -m 755 extfiles/libcscore*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" -install -m 755 extfiles/libntcore*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" -install -m 755 extfiles/libcameraserver*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" +cat extfiles/wpilib-debug.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" +cat extfiles/wpilib.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" install -v -d "${ROOTFS_DIR}/usr/local/frc/include" @@ -105,6 +106,15 @@ cat extfiles/cscore-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/inclu cat extfiles/ntcore-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" cat extfiles/cameraserver-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" +install -v -d "${ROOTFS_DIR}/usr/local/frc/share/OpenCV" + +cat extfiles/opencv-cmake-debug.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/share/OpenCV/ && tar xzf -" +cat extfiles/opencv-cmake.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/share/OpenCV/ && tar xzf -" + +install -v -d "${ROOTFS_DIR}/usr/local/frc/java" + +install -m 644 -o 1000 -g 1000 extfiles/*.jar "${ROOTFS_DIR}/usr/local/frc/java/" + install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/examples/" install -v -o 1000 -g 1000 extfiles/*-multiCameraServer.zip "${ROOTFS_DIR}/home/pi/examples/" on_chroot << EOF @@ -117,11 +127,10 @@ mv *.zip ../zips/ chown -R 1000:1000 . EOF -install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/javalibs/" -install -m 644 -o 1000 -g 1000 extfiles/*.jar "${ROOTFS_DIR}/home/pi/javalibs/" -sh -c "cd ${ROOTFS_DIR}/home/pi/javalibs && zip ../zips/java-multiCameraServer.zip *.jar" +sh -c "cd ${ROOTFS_DIR}/usr/local/frc/java && zip ${ROOTFS_DIR}/home/pi/zips/java-multiCameraServer.zip *.jar" on_chroot << EOF +chown -R 1000:1000 /home/pi/zips ldconfig EOF @@ -130,8 +139,7 @@ install -v -d "${ROOTFS_DIR}/service/configServer" install -m 755 files/configServer_run "${ROOTFS_DIR}/service/configServer/run" install -m 755 extfiles/rpiConfigServer "${ROOTFS_DIR}/usr/local/sbin/configServer" - -install -m 755 extfiles/netconsoleTee "${ROOTFS_DIR}/usr/local/bin/" +install -m 644 extfiles/rpiConfigServer.debug "${ROOTFS_DIR}/usr/local/sbin/" install -v -d "${ROOTFS_DIR}/service/camera" install -v -d "${ROOTFS_DIR}/service/camera/log" diff --git a/stage2/01-sys-tweaks/files/camera_log_run b/stage2/01-sys-tweaks/files/camera_log_run index 1f3fa7d..4556e8e 100755 --- a/stage2/01-sys-tweaks/files/camera_log_run +++ b/stage2/01-sys-tweaks/files/camera_log_run @@ -1,2 +1,2 @@ #!/bin/sh -exec /usr/local/bin/netconsoleTee -u +exec /usr/local/frc/bin/netconsoleTee -u diff --git a/stage2/01-sys-tweaks/files/runCamera b/stage2/01-sys-tweaks/files/runCamera index 937499e..fe94ed0 100755 --- a/stage2/01-sys-tweaks/files/runCamera +++ b/stage2/01-sys-tweaks/files/runCamera @@ -2,4 +2,4 @@ ### TYPE: builtin echo "Waiting 5 seconds..." sleep 5 -exec ./multiCameraServer +exec /usr/local/frc/bin/multiCameraServer