-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_bundle.win
76 lines (66 loc) · 1.94 KB
/
create_bundle.win
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
#!/usr/bin/env bash
(($# < 1)) && echo "Missing parameters" && exit 1
PREPARE=0
[[ "$1" == prepare ]] && PREPARE=1 && shift
(($# < 1)) && echo "Missing parameters" && exit 1
WINDRES=/opt/mingw/usr/bin/i686-pc-mingw32-windres
TARGET=$1
APP_NAME=${2:-$TARGET}
TARGET_APP="$APP_NAME"
CONFIG=${3:-Release}
VERSION=${4:-0.1}
DEST="build/${APP_NAME}/${CONFIG}/Win32"
mkdir -p "${DEST}"
if ((PREPARE))
then
ICON="$DEST"/icon.ico
if [[ -f "sources/win/icon.ico" ]]
then
cp "sources/win/icon.ico" "$ICON"
elif [[ -f "sources/win/icon.png" ]]
then
## could remove -bordercolor white white -border 0 by replacing -alpha off with -alpha remove
## but has to be avoided with svg source as it gives "awful results"
## UNTESTED !!!
convert sources/win/icon.png -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
-delete 0 -alpha off -colors 256 "$DEST"
else
cp "templates/win/icon.ico" "$ICON"
fi
RC="$DEST"/info.rc
if [[ -f sources/win/res.rc ]]
then
cp sources/win/res.rc "$RC"
else
cp templates/win/res.rc.tmpl "$RC"
sed -i "s,%ICON%,${ICON},g" "$RC"
sed -i "s,%TARGET%,${TARGET},g" "$RC"
sed -i "s,%APP_NAME%,${APP_NAME},g" "$RC"
sed -i "s,%VERSION%,${VERSION},g" "$RC"
sed -i "/^\ *\/\/.*$/d" "$RC"
fi
"$WINDRES" "$RC" -O coff -o app_res.o
res=$?
\rm -f "$RC"
\rm -f "$ICON"
exit $res
## copy to build/
else
ext=.${TARGET##*.}
name="${APP_NAME//_sf}"
name="${name//_s}"
cp "$TARGET" "$DEST"/"$name${ext}"
if [[ -f "sources/win/README" ]]
then
cp "sources/win/README" "$DEST"
else
cp "templates/README.tmpl" "$DEST"/README
sed -i "s,%APP_NAME%,${APP_NAME},g" "$DEST"/README
fi
exit 0
fi
exit 1