summaryrefslogtreecommitdiff
path: root/src/libtracker-common/generate-tracker-parser-sha1-header.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtracker-common/generate-tracker-parser-sha1-header.sh')
-rwxr-xr-xsrc/libtracker-common/generate-tracker-parser-sha1-header.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libtracker-common/generate-tracker-parser-sha1-header.sh b/src/libtracker-common/generate-tracker-parser-sha1-header.sh
new file mode 100755
index 000000000..9ff478547
--- /dev/null
+++ b/src/libtracker-common/generate-tracker-parser-sha1-header.sh
@@ -0,0 +1,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