Commit d7cdc758 authored by Sam Thursfield's avatar Sam Thursfield

build: Remove old extract rules from build tree when configuration changes

For the functional-tests we run Tracker entirely from the source tree.
We need to maintain a directory of .rule files for tracker-extract to
use, and we must only have the .rule files that are enabled in the
current build configuration. This wasn't working properly because we
didn't remove old .rule files when reconfiguring, so disabling an
extractor at configure-time would sometimes not work as expected.

This is fixed by preparing the uninstalled rule files in a shell
script rather than from Meson, allowing us to delete the rule files
each time that we reconfigure.
parent 10cf95ec
......@@ -390,7 +390,7 @@ tracker_extract_rules_dir = join_paths(get_option('prefix'), get_option('datadir
tracker_miner_services_dir = join_paths(get_option('prefix'), get_option('datadir'), 'tracker/miners')
tracker_writeback_modules_dir = join_paths(get_option('prefix'), get_option('libdir'), 'tracker-miners-@0@/writeback-modules'.format(tracker_api_version))
tracker_uninstalled_extract_rules_dir = join_paths(meson.current_build_dir(), 'src', 'tracker-extract')
tracker_uninstalled_extract_rules_dir = join_paths(meson.current_build_dir(), 'src', 'tracker-extract', 'uninstalled-rules')
tracker_uninstalled_writeback_modules_dir = join_paths(meson.current_build_dir(), 'src', 'tracker-writeback')
gsettings_schema_dir = join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')
......
......@@ -114,6 +114,7 @@ if libgxps.found()
modules += [['extract-xps', 'tracker-extract-xps.c', ['10-xps.rule'], [libgxps, tracker_miners_common_dep]]]
endif
enabled_rule_files = []
foreach module : modules
name = module[0]
......@@ -130,13 +131,7 @@ foreach module : modules
install_data(rules, install_dir: tracker_extract_rules_dir)
# Populate tracker_uninstalled_extract_rules_dir with the enabled .rule files.
foreach rule: rules
configure_file(
input: rule,
output: rule,
copy: true)
endforeach
enabled_rule_files += rules
endforeach
tracker_extract_priority_dbus = gnome.gdbus_codegen(
......@@ -206,3 +201,13 @@ if install_systemd_user_services
install: true,
install_dir: systemd_user_services_dir)
endif
# Populate a directory inside the build tree with the extract rules that are
# enabled in this build configuration.
setup_extract_rules = join_paths(meson.current_source_dir(), 'setup-extract-rules.sh')
result = run_command(setup_extract_rules, meson.current_source_dir(), tracker_uninstalled_extract_rules_dir, enabled_rule_files)
if result.returncode() != 0
output = result.stdout().strip()
errortxt = result.stderr().strip()
error('Failed to run @0@.\n@1@\n@2@'.format(setup_extract_rules, errortxt, output))
endif
#!/bin/sh
# Create a directory of enabled extract rules inside the build tree, for
# use when running tracker-extract from the build tree.
set -ex
if [ "$#" -lt 2 ]; then
echo >&2 "Usage: $0 SOURCE_DIR TARGET_DIR [RULE1 RULE2...]"
exit 1;
fi
source_dir=$1
target_dir=$2
shift
shift
if [ ! -d ${target_dir} ]; then
mkdir -p ${target_dir}
fi
# Start from a clean directory, this is very important when we
# reconfigure an existing build tree.
rm -f ${target_dir}/*.rule
while [ -n "$1" ]; do
rule="$1"
cp ${source_dir}/${rule} ${target_dir}
shift
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment