Skip to content
Merged
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
43 changes: 18 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ BUILD_TYPE = Debug
INSTALL_PREFIX = fpsdk
BUILD_TESTING =
VERBOSE = 0
USE_PROJ =
USE_FFMPEG =

# User vars
-include config.mk
Expand All @@ -26,13 +28,13 @@ else ifeq ($(ROS_VERSION),2)
endif

# A unique ID for this exact config we're using
configuid=$(shell echo "$(BUILD_TYPE) $(INSTALL_PREFIX) $(BUILD_TESTING) $(FPSDK_VERSION_STRING) $(CC) $(CXX) $$(uname -a)" | md5sum | cut -d " " -f1)
configuid=$(shell echo "$(BUILD_TYPE) $(INSTALL_PREFIX) $(BUILD_TESTING) $(USE_PROJ) $(USE_FFMPEG) $(FPSDK_VERSION_STRING) $(CC) $(CXX) $$(uname -a)" | md5sum | cut -d " " -f1)

.PHONY: help
help:
@echo "Usage:"
@echo
@echo " make <target> [INSTALL_PREFIX=...] [BUILD_TYPE=Debug|Release] [BUILD_TESTING=|ON|OFF] [FPSDK_VERSION_STRING=x.x.x-gggggggg] [VERBOSE=1]"
@echo " make <target> [INSTALL_PREFIX=...] [BUILD_TYPE=Debug|Release] [BUILD_TESTING=|ON|OFF] [USE_PROJ=|ON|OFF] [USE_FFMPEG=|ON|OFF] [FPSDK_VERSION_STRING=x.x.x-gggggggg] [VERBOSE=1]"
@echo
@echo "Where possible <target>s are:"
@echo
Expand All @@ -57,6 +59,7 @@ help:
@echo "- All <target>s but 'clean' and 'pre-commit' require that the same command-line variables are passed"
@echo "- Command-line variables can be stored into a config.mk file, which is automatically loaded"
@echo "- 'make ci' runs the CI (more or less) like on Github. INSTALL_PREFIX and BUILD_TYPE have no effect here."
@echo "- For more control, such as disabling features, use cmake instead of this Makefile"
@echo

########################################################################################################################
Expand Down Expand Up @@ -125,7 +128,13 @@ ifneq ($(ROS_PACKAGE_PATH),)
CMAKE_ARGS += -DROS_PACKAGE_PATH=$(ROS_PACKAGE_PATH)
endif
ifneq ($(BUILD_TESTING),)
CMAKE_ARGS += -DBUILD_TESTING=$(BUILD_TESTING)
CMAKE_ARGS += -DFPSDK_BUILD_TESTING=$(BUILD_TESTING)
endif
ifneq ($(USE_PROJ),)
CMAKE_ARGS += -DFPSDK_USE_PROJ=$(USE_PROJ)
endif
ifneq ($(USE_FFMPEG),)
CMAKE_ARGS += -DFPSDK_USE_FFMPEG=$(USE_FFMPEG)
endif
ifneq ($(FPSDK_VERSION_STRING),)
CMAKE_ARGS += -DVERSION_STRING=$(FPSDK_VERSION_STRING)
Expand Down Expand Up @@ -166,26 +175,10 @@ distclean:
$(BUILD_DIR):
$(V)$(MKDIR) -p $@

# Detect changed build config
ifneq ($(MAKECMDGOALS),)
ifneq ($(MAKECMDGOALS),help)
ifneq ($(MAKECMDGOALS),pre-commit)
ifneq ($(MAKECMDGOALS),ci)
ifneq ($(MAKECMDGOALS),distclean)
ifneq ($(MAKECMDGOALS),doc)
builddiruid=$(shell $(CAT) $(BUILD_DIR)/.make-uid 2>/dev/null || echo "none")
ifneq ($(builddiruid),$(configuid))
dummy=$(shell $(RM) -f $(BUILD_DIR)/.make-uid)
endif
endif
endif
endif
endif
endif
endif

$(BUILD_DIR)/.make-uid: | $(BUILD_DIR)
$(V)$(ECHO) $(configuid) > $@
$(BUILD_DIR)/.make-configuid-$(configuid): | $(BUILD_DIR)
@echo "Build config changed"
$(V)$(RM) -vf $(BUILD_DIR)/.make-configuid-*
$(V)$(TOUCH) $@

# ----------------------------------------------------------------------------------------------------------------------

Expand All @@ -194,7 +187,7 @@ cmake: $(BUILD_DIR)/.make-cmake

deps_cmake := Makefile $(wildcard config.mk) $(wildcard $(sort $(wildcard CMakeLists.txt */CMakeLists.txt */cmake/*)))

$(BUILD_DIR)/.make-cmake: $(deps_cmake) $(BUILD_DIR)/.make-uid
$(BUILD_DIR)/.make-cmake: $(deps_cmake) $(BUILD_DIR)/.make-configuid-$(configuid)
@echo "$(HLW)***** Configure ($(BUILD_TYPE)) *****$(HLO)"
$(V)$(CMAKE) -B $(BUILD_DIR) $(CMAKE_ARGS)
$(V)$(TOUCH) $@
Expand All @@ -210,7 +203,7 @@ deps_build = $(sort $(wildcard fpsdk.sh fpsdk_doc/* \
.PHONY: build
build: $(BUILD_DIR)/.make-build

$(BUILD_DIR)/.make-build: $(deps_build) $(BUILD_DIR)/.make-cmake $(BUILD_DIR)/.make-uid
$(BUILD_DIR)/.make-build: $(deps_build) $(BUILD_DIR)/.make-cmake
@echo "$(HLW)***** Build ($(BUILD_TYPE)) *****$(HLO)"
$(V)$(NICE_BUILD) $(CMAKE) --build $(BUILD_DIR) $(CMAKE_ARGS_BUILD) -- -k
$(V)$(TOUCH) $@
Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile.humble-base
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ RUN /tmp/install_proj.sh && rm -f /tmp/install_proj.sh
COPY docker/scripts/install_doxygen.sh /tmp
RUN /tmp/install_doxygen.sh && rm -f /tmp/install_doxygen.sh

# Download, build and install FFmpeg libraries (LGPL)
COPY docker/scripts/install_ffmpeg.sh /tmp
RUN /tmp/install_ffmpeg.sh && rm -f /tmp/install_ffmpeg.sh

# Update ld cache for the installed libraries
RUN /usr/sbin/ldconfig

Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile.jazzy-base
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ RUN /tmp/install_clangformat.sh && rm -f /tmp/install_clangformat.sh
COPY docker/scripts/install_doxygen.sh /tmp
RUN /tmp/install_doxygen.sh && rm -f /tmp/install_doxygen.sh

# Download, build and install FFmpeg libraries (LGPL)
COPY docker/scripts/install_ffmpeg.sh /tmp
RUN /tmp/install_ffmpeg.sh && rm -f /tmp/install_ffmpeg.sh

# Update ld cache for the installed libraries
RUN /usr/sbin/ldconfig

Expand Down
8 changes: 8 additions & 0 deletions docker/Dockerfile.noetic-base
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ RUN /tmp/install_proj.sh && rm -f /tmp/install_proj.sh
COPY docker/scripts/install_doxygen.sh /tmp
RUN /tmp/install_doxygen.sh && rm -f /tmp/install_doxygen.sh

# Download, build and install NASM (for FFmpeg)
COPY docker/scripts/install_nasm.sh /tmp
RUN /tmp/install_nasm.sh && rm -f /tmp/install_nasm.sh

# Download, build and install FFmpeg libraries (LGPL)
COPY docker/scripts/install_ffmpeg.sh /tmp
RUN /tmp/install_ffmpeg.sh && rm -f /tmp/install_ffmpeg.sh

# Download, build and install pre-commit
COPY docker/scripts/install_precommit.sh /tmp
RUN /tmp/install_precommit.sh && rm -f /tmp/install_precommit.sh
Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile.trixie-base
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ RUN /tmp/install_apt_base.sh && rm -f /tmp/install_apt_base.sh
COPY docker/scripts/install_doxygen.sh /tmp
RUN /tmp/install_doxygen.sh && rm -f /tmp/install_doxygen.sh

# Download, build and install FFmpeg libraries (LGPL)
COPY docker/scripts/install_ffmpeg.sh /tmp
RUN /tmp/install_ffmpeg.sh && rm -f /tmp/install_ffmpeg.sh

# Update ld cache for the installed libraries
RUN /usr/sbin/ldconfig

Expand Down
4 changes: 2 additions & 2 deletions docker/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function build_toplevel_release_noros_mindeps
cmake -B build/${buildname} -S . \
-DCMAKE_INSTALL_PREFIX=install/${buildname} \
-DCMAKE_BUILD_TYPE=Release \
-DFPSDK_USE_PROJ=OFF || return 1
-DFPSDK_USE_PROJ=OFF -DFPSDK_USE_FFMPEG=OFF || return 1
cmake --build build/${buildname} ${CMAKE_BUILD_ARGS} || return 1
cmake --install build/${buildname} || return 1

Expand All @@ -253,7 +253,7 @@ function build_projs_release_noros_mindeps
cmake -B build/${buildname}/fpsdk_common -S fpsdk_common \
-DCMAKE_INSTALL_PREFIX=install/${buildname} \
-DCMAKE_BUILD_TYPE=Release \
-DFPSDK_USE_PROJ=OFF || return 1
-DFPSDK_USE_PROJ=OFF -DFPSDK_USE_FFMPEG=OFF || return 1
cmake --build build/${buildname}/fpsdk_common ${CMAKE_BUILD_ARGS} || return 1
cmake --install build/${buildname}/fpsdk_common || return 1

Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ services:
# Apparently required... (so that the container doesn't kill itself?)
command: tail -f


# ----- ROS1 -------------------------------------------------------------------------------------------------------

build-noetic-base:
Expand Down Expand Up @@ -100,6 +101,7 @@ services:
hostname: fpsdk-noetic-dev-${USER}
command: tail -f


# ----- ROS2 -------------------------------------------------------------------------------------------------------

build-humble-base:
Expand Down
2 changes: 2 additions & 0 deletions docker/scripts/install_apt_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ packages=$(awk -v filt=${FPSDK_IMAGE%-*} '$1 ~ filt { print $2 }' <<EOF
noetic.humble.jazzy.trixie libssl-dev
noetic.humble.jazzy.trixie libsqlite3-dev
noetic.humble.jazzy.trixie libtiff-dev
noetic.humble.jazzy.trixie libva-dev # automatically installs va-driver-all?
noetic.humble.jazzy.trixie libyaml-cpp-dev
noetic.humble.jazzy.trixie nasm
noetic.humble.jazzy.trixie netbase
noetic.humble.jazzy.trixie nlohmann-json3-dev
.......humble.jazzy.trixie pre-commit
Expand Down
2 changes: 2 additions & 0 deletions docker/scripts/install_apt_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ packages=$(awk -v filt=${FPSDK_IMAGE%-*} '$1 ~ filt { print $2 }' <<EOF
noetic.humble.jazzy.trixie gdb
noetic.humble.jazzy.trixie git-lfs
noetic.humble.jazzy.trixie htop
noetic.humble.jazzy.trixie imagemagick
noetic.humble.jazzy.trixie iproute2
noetic.humble.jazzy.trixie iputils-ping
noetic.humble.jazzy.trixie less
Expand Down Expand Up @@ -77,6 +78,7 @@ packages=$(awk -v filt=${FPSDK_IMAGE%-*} '$1 ~ filt { print $2 }' <<EOF
noetic.humble.jazzy.trixie systemd-journal-remote
noetic.humble.jazzy.trixie tcpdump
noetic.humble.jazzy.trixie tig
noetic.humble.jazzy.trixie va-driver-all
noetic.humble.jazzy.trixie valgrind
noetic.humble.jazzy.trixie vim
noetic.humble.jazzy.trixie wget
Expand Down
2 changes: 2 additions & 0 deletions docker/scripts/install_apt_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ set -eEu
# List of packages, with filter for the different images we make
packages=$(awk -v filt=${FPSDK_IMAGE%-*} '$1 ~ filt { print $2 }' <<EOF
noetic.humble.jazzy.trixie rsync
noetic.humble.jazzy.trixie va-driver-all
noetic.humble.jazzy.trixie vainfo
EOF
)

Expand Down
79 changes: 79 additions & 0 deletions docker/scripts/install_ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
########################################################################################################################
# ___ ___
# \ \ / /
# \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
# / /\ \ License: see the LICENSE file
# /__/ \__\
#
########################################################################################################################
#
# Download, build and install FFmpeg's libavcodec, libavutil and libswscale
# Note the use of --disable-gpl and --disable-nonfree to make this LGPL and
# compatible with the Fixposition SDK license.
#
########################################################################################################################
set -eEu

# curl -L https://ffmpeg.org/releases/ffmpeg-8.1.1.tar.xz -o /tmp/ffmpeg.tar.gz
# echo "0b8318579556aaa736096ceb1e8333d2260b63bf /tmp/ffmpeg.tar.gz" | sha1sum --check

# LTS
curl -L https://ffmpeg.org/releases/ffmpeg-7.1.5.tar.xz -o /tmp/ffmpeg.tar.gz
echo "280615051f0546371d20d8b119f3ff357e0fb948 /tmp/ffmpeg.tar.gz" | sha1sum --check


mkdir /tmp/ffmpeg
cd /tmp/ffmpeg
tar --strip-components=1 -xvf ../ffmpeg.tar.gz


./configure \
--disable-everything \
--disable-programs \
--disable-doc \
--disable-swresample \
--disable-network \
--disable-podpages \
--disable-iconv \
--disable-lzma \
--disable-bzlib \
--disable-zlib \
--disable-libxcb \
\
--enable-avcodec \
--enable-avformat \
--enable-avfilter \
--enable-filters \
--enable-decoder=h264 \
--enable-decoder=hevc \
--enable-decoder=mjpeg \
--enable-parser=h264 \
--enable-parser=hevc \
--enable-parser=mjpeg \
--enable-vaapi \
\
--disable-static \
--enable-shared \
\
--disable-gpl \
--disable-nonfree \
\
--prefix=/usr/local

# --disable-avformat
# --disable-avdevice

# --enable-vulkan
# --enable-nvdec

#./configure --disable-gpl --disable-nonfree --enable-shared --disable-static --prefix=/usr/local

make -j4
make install

cd /
rm -rf /tmp/ffmpeg.tar.gz /tmp/ffmpeg


########################################################################################################################
32 changes: 32 additions & 0 deletions docker/scripts/install_nasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
########################################################################################################################
# ___ ___
# \ \ / /
# \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
# / /\ \ License: see the LICENSE file
# /__/ \__\
#
########################################################################################################################
#
# Download, build nasm
#
########################################################################################################################
set -eEu


curl -L https://www.nasm.us/pub/nasm/releasebuilds/3.01/nasm-3.01.tar.xz -o /tmp/nasm.tar.gz
echo "f0531dfe9728192fe190cc4932df44a26f1bde7c /tmp/nasm.tar.gz" | sha1sum --check

mkdir /tmp/nasm
cd /tmp/nasm
tar --strip-components=1 -xvf ../nasm.tar.gz

./configure --prefix=/usr/local
make -j4
make install

cd /
rm -rf /tmp/nasm.tar.gz /tmp/nasm


########################################################################################################################
17 changes: 17 additions & 0 deletions fpsdk.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"peacock.remoteColor": "#f9e64f",
"workbench.colorCustomizations": {
"commandCenter.border": "#15202b99",
"commandCenter.foreground": "#15202b",
"titleBar.activeBackground": "#f9e64f",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#f9e64f99",
Expand Down Expand Up @@ -342,6 +343,22 @@
{ "text": "handle SIGPIPE nostop noprint pass", "description": "ignore SIGPIPE", "ignoreFailures": true },
{ "text": "source ${workspaceFolder}/.devcontainer/.gdb/gdbinit", "description": "load local gdbinit", "ignoreFailures": false }
]
},
{
"name": "Fixposition SDK: debug fpltool extract",
"type": "cppdbg", "request": "launch", "MIMode": "gdb", "miDebuggerPath" : "gdb",
"stopAtEntry": false,
"preLaunchTask" : "Fixposition SDK: build",
"program": "${workspaceFolder}/build/Debug/fpsdk_apps/fpltool",
"args": [
"extract", "-f", "test.fpl", "-v", "-v", "-v", "-v" ],
"cwd": "${workspaceFolder}",
"setupCommands": [
{ "text": "set auto-load safe-path ${workspaceFolder}", "description": "", "ignoreFailures": true },
{ "text": "-enable-pretty-printing", "description": "enable pretty printing", "ignoreFailures": true },
{ "text": "handle SIGPIPE nostop noprint pass", "description": "ignore SIGPIPE", "ignoreFailures": true },
{ "text": "source ${workspaceFolder}/.devcontainer/.gdb/gdbinit", "description": "load local gdbinit", "ignoreFailures": false }
]
}
],
"compounds": []
Expand Down
12 changes: 9 additions & 3 deletions fpsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,21 @@ function main
local args="${docker_args}"
# - single-use container, no funny network
args="${args} --rm --network host"
# - connect stdin
args="${args} --interactive"
# - connect stdin, create tty
args="${args} --interactive --tty"
# - Mount current directory as /data and run command inside docker from there
args="${args} --volume ${PWD}:/data --workdir /data"
# - Additional mounts
args="${args} ${volume_args}"
# - Set user, mount passwd and group file
args="${args} --user $(id -u):$(id -g) --volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro"

# - Allow FFmpeg vaapi access on some systems. Note: this doesn't work with "-i noetic" (Ubuntu 20).
# Related: https://github.com/joedefen/ffmpeg-vaapi-docker
if [ -r /dev/dri ]; then
args="${args} --device=/dev/dri"
rendergid=$(awk -F: '/^render:/ { print $3 }' /etc/group)
args="${args} --group-add ${rendergid}"
fi

[ ${DEBUG} -gt 0 ] && set -x
if ! docker run ${args} ${image} "$@"; then
Expand Down
Loading
Loading