File: export-dirs.sh

package info (click to toggle)
notmuch 0.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,104 kB
  • sloc: sh: 21,888; ansic: 14,897; lisp: 9,061; cpp: 7,990; python: 6,221; perl: 391; makefile: 231; javascript: 34; ruby: 13
file content (31 lines) | stat: -rw-r--r-- 845 bytes parent folder | download | duplicates (2)
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
# Source this script to set and export NOTMUCH_SRCDIR and
# NOTMUCH_BUILDDIR.
#
# For this to work, always have current directory somewhere within the
# build directory hierarchy, and run the script sourcing this script
# using a path (relative or absolute) to the source directory.

if [[ -z "${NOTMUCH_SRCDIR}" ]]; then
	export NOTMUCH_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)"
fi

find_builddir () {
	local dir="$1"

	while [[ -n "$dir" ]] && [[ "$dir" != "/" ]]; do
		if [[ -x "$dir/notmuch" ]] && [[ ! -d "$dir/notmuch" ]]; then
			echo "$dir"
			break
		fi
		dir="$(dirname "$dir")"
	done
}

if [[ -z "${NOTMUCH_BUILDDIR}" ]]; then
	export NOTMUCH_BUILDDIR="$(find_builddir "$(pwd)")"

	if [ -z "${NOTMUCH_BUILDDIR}" -a "${NOTMUCH_TEST_INSTALLED-0}" = "0" ]; then
		echo "Run tests in a subdir of built notmuch tree." >&2
		exit 1
	fi
fi