summaryrefslogtreecommitdiff
path: root/src/libtracker-common/generate-tracker-parser-sha1-header.sh
blob: 9ff4785473a9b7a92910022877358995b898f3c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

# Write the Git SHA1 of the libtracker-common subdir to a header file.
#
# This is used in tracker-db-manager.c to regenerate FTS tables if the parser
# code used by the FTS tokenizer code could have changed.
#
# It's important that this script doesn't touch the output file unless it needs
# to. If it updates the file unconditionally, everything will rebuild from
# scratch every time Meson reexecutes.

set -eu

SRCDIR=${MESON_SOURCE_ROOT}/src/libtracker-common
BUILDDIR=${MESON_BUILD_ROOT}/src/libtracker-common

cached_sha1=$(cat ${BUILDDIR}/tracker-parser-sha1.cached || echo "")
new_sha1=$(git -C ${SRCDIR} log -n1 --format=format:%H -- . )

if [ "$cached_sha1" != "$new_sha1" ]; then
	echo "#define TRACKER_PARSER_SHA1 \"${new_sha1}\"" > ${BUILDDIR}/tracker-parser-sha1.h
	echo ${new_sha1} > ${BUILDDIR}/tracker-parser-sha1.cached
fi