2016-07-16 23:12:02 +02:00
|
|
|
#!/bin/bash
|
2017-03-29 00:17:58 +02:00
|
|
|
if [[ ! $@ ]]; then
|
|
|
|
echo 'Prints the list of icons required by the projects in the specified directories.'
|
|
|
|
echo 'However, no project directories have been specified.'
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2016-07-16 23:12:02 +02:00
|
|
|
declare -A icon_names
|
|
|
|
|
|
|
|
# iterate over specified source directories
|
|
|
|
for srcdir in "$@"; do
|
|
|
|
# find icons in *.ui files
|
|
|
|
for iconset in $(find "$srcdir" -iname '*.ui' -print0 | xargs -0 cat | grep -Po '<iconset\stheme=\".*?\"'); do
|
|
|
|
if [ "${iconset:0:7}" == 'theme="' ]; then
|
|
|
|
icon_names["${iconset: 7 : -1}"]=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# find icons in *.cpp files
|
|
|
|
for from_theme_call in $(find "$srcdir" -iname '*.cpp' -print0 | xargs -0 cat | grep -Po 'QIcon::fromTheme\(QStringLiteral\(\".*?\"\)'); do
|
|
|
|
icon_names["${from_theme_call: 33 : -2}"]=1
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2018-08-31 22:44:12 +02:00
|
|
|
# sort results
|
|
|
|
sorted_icon_names=("${!icon_names[@]}")
|
|
|
|
IFS=$'\n' sorted_icon_names=($(sort <<<"${sorted_icon_names[*]}"))
|
|
|
|
unset IFS
|
|
|
|
|
2016-07-16 23:12:02 +02:00
|
|
|
# print results
|
|
|
|
echo 'set(REQUIRED_ICONS'
|
2018-08-31 22:44:12 +02:00
|
|
|
for icon_name in "${sorted_icon_names[@]}"; do
|
2016-07-16 23:12:02 +02:00
|
|
|
echo " ${icon_name}"
|
|
|
|
done
|
|
|
|
echo ')'
|