Make a more generic generate_qrc script
This commit is contained in:
parent
becb9e629d
commit
a49140512f
|
@ -1,23 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
QRC="images.qrc"
|
|
||||||
IMG_DIR="img"
|
|
||||||
|
|
||||||
cat <<EOF >"$QRC"
|
|
||||||
<!DOCTYPE RCC>
|
|
||||||
<RCC version="1.0">
|
|
||||||
<qresource>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
find "$IMG_DIR" -type f | while IFS= read -r file; do
|
|
||||||
printf " <file>%s</file>\n" "$file" >>"$QRC"
|
|
||||||
done
|
|
||||||
|
|
||||||
cat <<EOF >>"$QRC"
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
|
|
||||||
<!-- vi: ft=xml
|
|
||||||
-->
|
|
||||||
EOF
|
|
38
generate_qrc.sh
Executable file
38
generate_qrc.sh
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CUR_DIR="$(dirname "$0")"
|
||||||
|
|
||||||
|
# Function to generate a .qrc file for a given directory and file extension
|
||||||
|
generate_qrc() {
|
||||||
|
local dir=$1
|
||||||
|
local qrc_file=$2
|
||||||
|
local pattern=$3
|
||||||
|
|
||||||
|
# Start the QRC file
|
||||||
|
cat <<EOF >"$qrc_file"
|
||||||
|
<!DOCTYPE RCC>
|
||||||
|
<RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Find all files with the given extension in the directory and add them to the QRC file
|
||||||
|
find "$dir" -type f -name "$pattern" | while IFS= read -r file; do
|
||||||
|
printf " <file>%s</file>\n" "$file" >>"$qrc_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
# End the QRC file
|
||||||
|
cat <<EOF >>"$qrc_file"
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Split this to avoid vim interpreting this file as xml
|
||||||
|
echo -n "<!-- vi" >>"$qrc_file"
|
||||||
|
echo ": ft=xml" >>"$qrc_file"
|
||||||
|
echo "-->" >>"$qrc_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
pushd "$CUR_DIR" >/dev/null
|
||||||
|
generate_qrc "img" "images.qrc" "*.svg"
|
||||||
|
popd >/dev/null
|
|
@ -69,6 +69,5 @@
|
||||||
<file>img/playing_cards/fronts/spades_queen.svg</file>
|
<file>img/playing_cards/fronts/spades_queen.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
||||||
<!-- vi: ft=xml
|
<!-- vi: ft=xml
|
||||||
-->
|
-->
|
||||||
|
|
Loading…
Reference in a new issue