Revamp image to build dependencies as part of stages (#83)

Fixes #17.

Stage 2 is fairly minimal, stage 3 builds/installs OpenCV and WPILib et al, and stage 4
builds/installs the FRCVision webdash and adds the vision examples.

Other changes:
- OpenCV compiled with ffmpeg, OpenBLAS, and libgtk (fixes #79, fixes #80)
- OpenBLAS added to image (fixes #65)
- C++ Makefile is more easily extensible (fixes #71)
- Sources for everything are bundled into image into /usr/src
- README updated (fixes #16)
- pkg-config files for wpilibc et al are now installed and C++ Makefile uses them (if compiled local to Pi)
- Both dynamic and static libs are included in image

The only downside of all these changes (particularly the ffmpeg, OpenBLAS, and libgtk inclusion)
is the image size is now over 3GB (800MB compressed). The previous image didn't quite fit on a
2GB card however.
This commit is contained in:
Peter Johnson
2019-02-02 23:37:18 -08:00
committed by GitHub
parent 02d5c468a2
commit c85fd9f33c
75 changed files with 775 additions and 721 deletions
+9
View File
@@ -0,0 +1,9 @@
set(JNI_INCLUDE_DIRS "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include" "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include/linux")
set(JNI_LIBRARIES )
set(JNI_FOUND YES)
set(JAVA_AWT_LIBRARY )
set(JAVA_JVM_LIBRARY )
set(JAVA_INCLUDE_PATH "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include")
set(JAVA_INCLUDE_PATH2 "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include/linux")
set(JAVA_AWT_INCLUDE_PATH )
@@ -0,0 +1,80 @@
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)
set(CMAKE_SYSROOT "$ENV{ROOTFS_DIR}")
include("$ENV{ROOTFS_DIR}/usr/src/opencv-3.4.4/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()
set(ARM_LINKER_FLAGS "-Wl,-rpath -Wl,$ENV{ROOTFS_DIR}/opt/vc/lib")
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 "-isystem $ENV{ROOTFS_DIR}/usr/include/arm-linux-gnueabihf ${CMAKE_CXX_FLAGS} -Wno-psabi")
set(CMAKE_C_FLAGS "-isystem $ENV{ROOTFS_DIR}/usr/include/arm-linux-gnueabihf ${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()
@@ -0,0 +1,2 @@
/usr/local/frc/lib
/usr/local/frc/third-party/lib
@@ -0,0 +1,14 @@
# Package Information for pkg-config
prefix=/usr/local/frc
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: cameraserver
Description: WPILib Robotics Library CameraServer
Version: 2019.2.1
Requires: cscore wpiutil
Requires.private: ntcore
Libs: -L${libdir} -lcameraserver
Cflags: -I${includedir}
@@ -0,0 +1,14 @@
# Package Information for pkg-config
prefix=/usr/local/frc
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: cscore
Description: WPILib Robotics Library CameraServer Core
Version: 2019.2.1
Requires: wpiutil opencv
Libs: -L${libdir} -lcscore
Libs.private: -lpthread
Cflags: -I${includedir}
@@ -0,0 +1,14 @@
# Package Information for pkg-config
prefix=/usr/local/frc
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: ntcore
Description: WPILib Robotics Library NetworkTables
Version: 2019.2.1
Requires: wpiutil
Libs: -L${libdir} -lntcore
Libs.private: -lpthread
Cflags: -I${includedir}
@@ -0,0 +1,13 @@
# Package Information for pkg-config
prefix=/usr/local/frc
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: wpilibc
Description: WPILib Robotics Library
Version: 2019.2.1
Requires: cameraserver ntcore cscore wpiutil
Libs: -L${libdir} -lwpilibc -lwpiHal
Cflags: -I${includedir}
@@ -0,0 +1,13 @@
# Package Information for pkg-config
prefix=/usr/local/frc
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: wpiutil
Description: WPILib Robotics Library utilities
Version: 2019.2.1
Libs: -L${libdir} -lwpiutil
Libs.private: -lpthread
Cflags: -I${includedir}
@@ -0,0 +1 @@
export PKG_CONFIG_PATH=/usr/local/frc/lib/pkgconfig