Make graphics/update fail on error.
[dcpomatic.git] / graphics / update
1 #!/bin/bash -e
2 #
3 # Update generated stuff in graphics/ from the source files.
4 #
5 # It would be nice to do this with waf but:
6 # a) getting the wscript right is a complete pain in the arse
7 # b) running Inkscape from the command line on OS X is a complete pain in the arse
8
9 set -e
10
11 pwd=`pwd`
12 if [ `basename $pwd` != "graphics" ]; then
13     echo "$0: run within graphics/"
14     exit 1
15 fi
16
17 function required_font()
18 {
19     check=$(fc-list | grep "$1")
20     if [ "$check" == "" ]; then
21         echo "Missing font $1"
22         exit 1
23     fi
24 }
25
26 svg_apps="dcpomatic2_kdm dcpomatic2_server dcpomatic2_batch dcpomatic2_player dcpomatic2_playlist dcpomatic2_disk"
27 required_font "Libre Baskerville"
28
29
30 if [ `uname -s` == "Darwin" ]; then
31     # Convert OS X icons using OS X-only iconutil
32     for p in dcpomatic2 $svg_apps; do
33         iconutil --convert icns --output osx/$p.icns osx/$p.iconset
34     done
35 else
36
37     for c in icotool convert inkscape inkbatch; do
38         if [ ! -x "$(command -v $c)" ]; then
39             echo "$c is required"
40             exit 1
41         fi
42     done
43
44     INKSCAPE="inkscape -C --export-type=png"
45
46     # OS X application icons
47     mkdir -p osx
48     for r in 16 32 128 256 512; do
49         for p in dcpomatic2; do
50             mkdir -p osx/$p.iconset
51             convert src/dcpomatic.png -resize $rx$r osx/$p.iconset/icon_${r}x${r}.png
52             convert src/dcpomatic.png -resize $rx$r osx/$p.iconset/icon_${r}x${r}@2x.png
53         done
54         for p in $svg_apps; do
55             mkdir -p osx/$p.iconset
56             $INKSCAPE --export-filename=osx/$p.iconset/icon_${r}x${r}.png -w $r -h $r src/$p.svg
57             $INKSCAPE --export-filename=osx/$p.iconset/icon_${r}x${r}@2x.png -w $r -h $r src/$p.svg
58         done
59     done
60
61     # Linux application icons
62     mkdir -p linux
63     for r in 16 22 32 48 64 128 256 512; do
64         mkdir -p linux/$r
65         convert src/dcpomatic.png -resize $rx$r linux/$r/dcpomatic2.png
66         for p in $svg_apps; do
67             $INKSCAPE --export-filename=linux/$r/$p.png src/$p.svg -w $r -h $r
68         done
69     done
70
71     # Windows application icons
72     mkdir -p windows
73     for p in dcpomatic2 $svg_apps; do
74         icotool -c -o windows/$p.ico linux/16/$p.png linux/32/$p.png linux/48/$p.png linux/64/$p.png linux/128/$p.png
75     done
76     convert src/dcpomatic.png -resize 400x400 windows/dcpomatic.bmp
77
78     # OS X preferences icons
79     mkdir -p osx/preferences
80     for i in defaults email kdm_email cover_sheet keys tms notifications locations sound identifiers servers general advanced; do
81         inkbatch -i bounds-$i -o osx/preferences/$i.png --width 32 --height 32 src/preferences.svg
82         inkbatch -i bounds-$i -o osx/preferences/$i@2x.png --width 64 --height 64 src/preferences.svg
83     done
84
85     # OS X menu bar icon for the server
86     $INKSCAPE --export-filename=osx/dcpomatic_small.png -w 64 -h 64 src/dcpomatic_small.svg
87
88     # Splash screen (all platforms)
89     $INKSCAPE --export-filename=splash.png src/splash.svg -w 400 -h 300
90
91     # Timeline toolbar icons (all platforms)
92     for i in select zoom zoom_all snap sequence; do
93         $INKSCAPE --export-filename=$i.png src/$i.svg -w 32 -h 32
94     done
95
96     # Playlist editor tick/no-tick
97     $INKSCAPE --export-filename=tick.png src/tick.svg -w 16 -h 16
98     $INKSCAPE --export-filename=no_tick.png src/no_tick.svg -w 16 -h 16
99
100     # Link icon
101     $INKSCAPE --export-filename=link.png src/link.svg -w 9 -h 16
102
103     # favicon
104     mkdir -p web
105     convert src/web.png -resize 256x256 -transparent white web/favicon-256x256.png
106     for r in 16 32 64 128; do
107         convert web/favicon-256x256.png -resize $rx$r web/favicon-${r}x${r}.png
108     done
109     convert web/favicon-16x16.png web/favicon-32x32.png web/favicon-64x64.png web/favicon-128x128.png web/favicon-256x256.png web/favicon.ico
110     convert src/web.png -resize 123x123 -transparent white web/logo.png
111 fi