This repository has been archived by the owner on Feb 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_backgroundMusic_rcc.sh
executable file
·89 lines (71 loc) · 1.82 KB
/
generate_backgroundMusic_rcc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# generate_backgroundMusic_rcc.sh
# Copyright (C) 2014 Holger Kaelberer
# Copyright (C) 2016 Divyam Madaan
#
# Generates Qt binary resource files (.rcc) for background music.
#
# Results will be written to $PWD/.rcc/ which is supposed be synced to the
# upstream location.
#
export RCC=/usr/bin/rcc
[ $# -ne 1 ] && {
echo "Usage: generate_backgroundMusic_rcc.sh ogg|aac|ac3|mp3"
exit 1
}
# Compressed Audio Format
CA=$1
QRC_DIR="."
RCC_DIR=".rcc"
#RCC_DEFAULT=`which rcc 2>/dev/null` # default, better take /usr/bin/rcc?
RCC_DEFAULT=$Qt5_DIR/bin/rcc
CONTENTS_FILE=Contents
MD5SUM=/usr/bin/md5sum
[ -z "${RCC}" ] && RCC=${RCC_DEFAULT}
[ -z "${RCC}" ] && {
echo "No rcc command in PATH, can't continue. Try to set specify RCC in environment:"
echo "RCC=/path/to/qt/bin/rcc $0"
exit 1
}
function generate_rcc {
# Generate RCC
echo -n "$2 ... "
mkdir -p ${2%/*}
${RCC} -binary $1 -o $2
echo "md5sum ... "
cd ${2%/*}
${MD5SUM} ${2##*/}>> ${CONTENTS_FILE}
cd - &>/dev/null
}
function header_rcc {
(cat <<EOHEADER
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/gcompris/data">
EOHEADER
) > $1
}
function footer_rcc {
(cat <<EOFOOTER
</qresource>
</RCC>
EOFOOTER
) >> $1
}
echo "Generating binary resource files in ${RCC_DIR}/ folder:"
[ -d ${RCC_DIR} ] && rm -rf ${RCC_DIR}
mkdir ${RCC_DIR}
#header of the global qrc (all the langs)
QRC_FULL_FILE="${QRC_DIR}/backgroundMusic-${CA}.qrc"
RCC_FULL_FILE="${RCC_DIR}/backgroundMusic-${CA}.rcc"
header_rcc $QRC_FULL_FILE
for i in `find backgroundMusic -type f -name "*.$CA" | sort | cut -c 1-`
do
echo " <file>${i#${MUSIC_DIR}}</file>" >> "${QRC_DIR}/backgroundMusic-${CA}.qrc"
done
footer_rcc $QRC_FULL_FILE
echo -n " full: ${QRC_FULL_FILE} ... "
generate_rcc ${QRC_FULL_FILE} ${RCC_FULL_FILE}
echo "Finished!"
echo ""
#EOF