summaryrefslogtreecommitdiff
path: root/60-simple-cam.sh
blob: 8ab89d5104b4a032195d78c9a11fcb14b25ed562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Compile test builder.
#
# Call a meson/ninja build with all combinations of gcc/clang identifyied in
# the path using compgen. Builds are left in tree, allowing incremental builds
# on each call.

source ./common.sh

# Simple Cam builds against a libcamera BUILD directory...
LIBCAMERA_BUILD=${1:-"$(builddir unit-tests)"}
LIBCAMERA=$LIBCAMERA_BUILD/source/

SIMPLECAM=$(srcdir simple-cam)
SIMPLECAM_REPO=https://git.libcamera.org/libcamera/simple-cam.git

check_version $LIBCAMERA $ID

echo "Build latest simple-cam for libcamera at version : " $(libcamera_version "$LIBCAMERA")

#### Building and compiling

function update_sources() {
	if [ ! -d $SIMPLECAM ]; then
		git clone https://git.libcamera.org/libcamera/simple-cam.git $SIMPLECAM
	fi

	echo Using: $LIBCAMERA_BUILD

	git -C $SIMPLECAM pull --ff-only
}

function build() {
	LIBCAMERA_UNINSTALLED=$(realpath -L $LIBCAMERA_BUILD/meson-uninstalled/)

	# Always build apps from clean
	BUILDDIR="$(builddir $ID)"
	rm -fr "$BUILDDIR"

	PKG_CONFIG_PATH=$LIBCAMERA_UNINSTALLED \
		meson "$BUILDDIR" "$SIMPLECAM" \
			-Db_sanitize=address,undefined

	ninja -C "$BUILDDIR"
	ret=$?

	return $ret
}

function run() {
	BUILDDIR="$(builddir $ID)"

	# libevent has a known memory leak. Its out of our control, Suppress it.
	echo "leak:event_new" > $BUILDDIR/leak-suppressions.txt

	LD_LIBRARY_PATH=$LIBCAMERA_BUILD/src/libcamera:$LIBCAMERA_BUILD/src/libcamera/base \
	LSAN_OPTIONS=suppressions=$BUILDDIR/leak-suppressions.txt \
		$BUILDDIR/simple-cam 2>&1
}

logfile=$(log_filename $ID)

update_sources > $logfile
build >> $logfile
pass_fail $? "build simple-cam:"

run >> $logfile
pass_fail $? "run simple-cam:"

completed $ID