-
Notifications
You must be signed in to change notification settings - Fork 55
/
build.sh
executable file
·77 lines (70 loc) · 2.27 KB
/
build.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
#!/bin/bash
G45() {
local FILE="${1}"
IN_NON_G45=0
IN_G45=0
while IFS= read -r LINE; do
if [[ "${LINE}" = *"/* END NON-G45 */"* ]]; then
IN_NON_G45=0
elif [[ "${LINE}" = *"/* END G45 */"* ]]; then
IN_G45=0
fi
if (( IN_G45 == 1 )); then
echo "${LINE}" | sed -E 's|^(\s+)?// |\1|'
elif (( IN_NON_G45 == 1 )) && ! [[ ${LINE} =~ ^[[:space:]]*// ]]; then
echo "${LINE}" | sed -E 's|^(\s+)?|\1// |'
else
echo "${LINE}"
fi
if [[ "${LINE}" = *"/* BEGIN NON-G45 */"* ]]; then
IN_NON_G45=1
elif [[ "${LINE}" = *"/* BEGIN G45 */"* ]]; then
IN_G45=1
fi
done < "${FILE}"
}
NON_G45() {
local FILE="${1}"
IN_NON_G45=0
IN_G45=0
while IFS= read -r LINE; do
if [[ "${LINE}" = *"/* END NON-G45 */"* ]]; then
IN_NON_G45=0
elif [[ "${LINE}" = *"/* END G45 */"* ]]; then
IN_G45=0
fi
if (( IN_G45 == 1 )) && ! [[ ${LINE} =~ ^[[:space:]]*// ]]; then
echo "${LINE}" | sed -E 's|^(\s+)?|\1// |'
elif (( IN_NON_G45 == 1 )); then
echo "${LINE}" | sed -E 's|^(\s+)?// |\1|'
else
echo "${LINE}"
fi
if [[ "${LINE}" = *"/* BEGIN NON-G45 */"* ]]; then
IN_NON_G45=1
elif [[ "${LINE}" = *"/* BEGIN G45 */"* ]]; then
IN_G45=1
fi
done < "${FILE}"
}
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "${SCRIPT_DIR}"
rm -rf dist
mkdir -p dist/G43/build
mkdir -p dist/G45/build
glib-compile-schemas schemas/
FILES="extension.js keybindings.js prefs.js"
for FILE in ${FILES}; do
NON_G45 ${FILE} > dist/G43/build/${FILE}
G45 ${FILE} > dist/G45/build/${FILE}
done
cp -a settings.ui schemas dist/G43/build/
cp -a settings.ui schemas dist/G45/build/
cp -a metadata.json dist/G43/build/metadata.json
cp -a metadata-45.json dist/G45/build/metadata.json
cd dist/G43/build
zip -r9 wintile@nowsci.com.zip extension.js keybindings.js metadata.json prefs.js settings.ui schemas
mv wintile@nowsci.com.zip ..
cd ../../G45/build
zip -r9 wintile@nowsci.com.zip extension.js keybindings.js metadata.json prefs.js settings.ui schemas
mv wintile@nowsci.com.zip ..