#!/bin/bash
#
# rebuild-qrc-nosvn
#
# Copyright 2009-2020 the Rosegarden development team.
# Released under the GPL v2.
#
# Generates a .qrc file without consulting svn.

ofile=data.qrc

echo "QRC Builder: Assembling a new data/data.qrc based on the current contents of data/"

cd data || exit 1

writeEntries() {
    echo "  assembling files of type $1..."
    # for each file with the extension of interest
    for f in $(find . -name \*.$1 | sort --ignore-case --dictionary-order); do
        # Generate the <file> tag.
        cat >> $ofile << EOF
<file>$f</file>
EOF
    done
}

cat > $ofile << EOF
<!DOCTYPE RCC>
<RCC version="1.0">
<!--

WARNING! This file was created automatically by $0

DO NOT EDIT THIS FILE BY HAND!  All changes will be LOST!

-->
<qresource>
EOF

# for each file extension, generate the <file> entries
for ext in pfa png jpg qss rc rg rgd rgp rgt xml xpm; do
    writeEntries $ext
done

cat >> $ofile << EOF
</qresource>
</RCC>
EOF

echo All resources successfully added!

exit 0

