Various bits related to subtitle font handling, particularly copying fonts to the...
[dcpomatic.git] / platform / windows / wscript
1 from __future__ import print_function
2 import os
3
4 def write_installer(bits, version, debug):
5     try:
6         os.makedirs('build/platform/windows')
7     except:
8         pass
9
10     f = open('build/platform/windows/installer.%d.nsi' % bits, 'w')
11     print('!include "MUI2.nsh"', file=f)
12     if bits == 64:
13         print('!include "x64.nsh"', file=f)
14
15     if debug:
16         print('Name "DCP-o-matic Debug"', file=f)
17     else:
18         print('Name "DCP-o-matic"', file=f)
19
20     print('RequestExecutionLevel admin', file=f)
21
22     if debug:
23         print('outFile "DCP-o-matic Debug %s %d-bit Installer.exe"' % (version, bits), file=f)
24     else:
25         print('outFile "DCP-o-matic %s %d-bit Installer.exe"' % (version, bits), file=f)
26
27     print("""
28 !define MUI_ICON "%resources%/dcpomatic.ico"
29 !define MUI_UNICON "%resources%/dcpomatic.ico"
30 !define MUI_SPECIALBITMAP "%resources%/dcpomatic.bmp"
31 !include "Sections.nsh"
32     """, file=f)
33
34     if debug:
35         print('InstallDir "$PROGRAMFILES\\DCP-o-matic 2 Debug"', file=f)
36     else:
37         print('InstallDir "$PROGRAMFILES\\DCP-o-matic 2"', file=f)
38
39     print("""
40 !insertmacro MUI_PAGE_WELCOME
41 !insertmacro MUI_PAGE_LICENSE "../../../COPYING"
42 !insertmacro MUI_PAGE_DIRECTORY
43 !insertmacro MUI_PAGE_COMPONENTS
44
45 Section "Common files (required)" SEC_COMMON
46 SectionIn RO
47     """, file=f)
48
49     if bits == 64:
50         print("""
51 ${If} ${RunningX64}
52    DetailPrint "Installer running on 64-bit host"
53    ; disable registry redirection (enable access to 64-bit portion of registry)
54    SetRegView 64
55    ; change install dir
56    StrCpy $INSTDIR "$PROGRAMFILES64\DCP-o-matic 2"
57 ${EndIf}
58         """, file=f)
59
60     print("""
61 SetOutPath "$INSTDIR\\bin"
62 WriteUninstaller "$INSTDIR\Uninstall.exe"
63
64 File "%static_deps%/bin/libintl-8.dll"
65 File "%static_deps%/bin/libboost_chrono-mt.dll"
66 File "%static_deps%/bin/libboost_filesystem-mt.dll"
67 File "%static_deps%/bin/libboost_system-mt.dll"
68 File "%static_deps%/bin/libboost_thread_win32-mt.dll"
69 File "%static_deps%/bin/libboost_date_time-mt.dll"
70 File "%static_deps%/bin/libboost_locale-mt.dll"
71 File "%static_deps%/bin/libeay32.dll"
72 File "%static_deps%/bin/libgcc_s_sjlj-1.dll"
73 File "%static_deps%/bin/libgio-2.0-0.dll"
74 File "%static_deps%/bin/libglib-2.0-0.dll"
75 File "%static_deps%/bin/libgobject-2.0-0.dll"
76 File "%static_deps%/bin/libiconv-2.dll"
77 File "%static_deps%/bin/libjpeg-8.dll"
78 File "%static_deps%/bin/libMagick++-6.Q16-3.dll"
79 File "%static_deps%/bin/libMagickCore-6.Q16-1.dll"
80 File "%static_deps%/bin/libMagickWand-6.Q16-1.dll"
81 File "%static_deps%/bin/libpng15-15.dll"
82 File "%static_deps%/bin/libsigc-2.0-0.dll"
83 File "%static_deps%/bin/libsndfile-1.dll"
84 File "%static_deps%/bin/libssh.dll"
85 File "%static_deps%/bin/libstdc++-6.dll"
86 File "%static_deps%/bin/zlib1.dll"
87 File "%static_deps%/bin/libjpeg-8.dll"
88 File "%static_deps%/bin/wxbase30u_gcc_custom.dll"
89 File "%static_deps%/bin/wxmsw30u_core_gcc_custom.dll"
90 File "%static_deps%/bin/wxmsw30u_adv_gcc_custom.dll"
91 File "%static_deps%/bin/wxmsw30u_richtext_gcc_custom.dll"
92 File "%static_deps%/bin/wxmsw30u_html_gcc_custom.dll"
93 File "%static_deps%/bin/wxbase30u_xml_gcc_custom.dll"
94 File "%static_deps%/bin/libcairo-2.dll"
95 File "%static_deps%/bin/libfreetype-6.dll"
96 File "%static_deps%/bin/libgthread-2.0-0.dll"
97 File "%static_deps%/bin/libpango-1.0-0.dll"
98 File "%static_deps%/bin/libgmodule-2.0-0.dll"
99 File "%static_deps%/bin/libpangocairo-1.0-0.dll"
100 File "%static_deps%/bin/libpangowin32-1.0-0.dll"
101 File "%static_deps%/bin/libtiff-5.dll"
102 File "%static_deps%/bin/libglibmm-2.4-1.dll"
103 File "%static_deps%/bin/libxml++-2.6-2.dll"
104 File "%static_deps%/bin/libxml2-2.dll"
105 File "%static_deps%/bin/libpixman-1-0.dll"
106 File "%static_deps%/bin/libfontconfig-1.dll"
107 File "%static_deps%/bin/libexpat-1.dll"
108 File "%static_deps%/bin/libbz2.dll"
109 File "%static_deps%/bin/libxmlsec1.dll"
110 File "%static_deps%/bin/libxmlsec1-openssl.dll"
111 File "%static_deps%/bin/libexslt-0.dll"
112 File "%static_deps%/bin/libxslt-1.dll"
113 File "%static_deps%/bin/libffi-6.dll"
114 File "%static_deps%/bin/openssl.exe"
115 File "%static_deps%/bin/libcurl-4.dll"
116 File "%static_deps%/bin/ssleay32.dll"
117 File "%static_deps%/bin/libzip-2.dll"
118 File "%static_deps%/bin/libcairomm-1.0-1.dll"
119 File "%static_deps%/bin/libpangomm-1.4-1.dll"
120 File "%static_deps%/bin/pango-querymodules.exe"
121
122 File "%cdist_deps%/bin/asdcp-libdcp-1.0.dll"
123 File "%cdist_deps%/bin/kumu-libdcp-1.0.dll"
124 File "%cdist_deps%/bin/avcodec-56.dll"
125 File "%cdist_deps%/bin/avfilter-5.dll"
126 File "%cdist_deps%/bin/avformat-56.dll"
127 File "%cdist_deps%/bin/avutil-54.dll"
128 File "%cdist_deps%/bin/avdevice-56.dll"
129 File "%cdist_deps%/bin/postproc-53.dll"
130 File "%cdist_deps%/bin/dcp-1.0.dll"
131 File "%cdist_deps%/bin/libopenjpeg-1.dll"
132 File "%cdist_deps%/bin/swresample-1.dll"
133 File "%cdist_deps%/bin/swscale-3.dll"
134 File "%cdist_deps%/bin/cxml-0.dll"
135 File "%cdist_deps%/bin/sub-1.0.dll"
136 File "%cdist_deps%/bin/asdcp-libsub-1.0.dll"
137 File "%cdist_deps%/bin/kumu-libsub-1.0.dll"
138 File "%cdist_deps%/bin/ffprobe.exe"
139     """, file=f)
140
141     if debug:
142         print('File "%resources%/gdb_script"', file=f)
143         print('File "%resources%/debug.bat"', file=f)
144         print('File "%mingw%/gdb.exe"', file=f)
145         print('File "%mingw%/addr2line.exe"', file=f)
146     else:
147         print('File "%binaries%/src/wx/dcpomatic2-wx.dll"', file=f)
148         print('File "%binaries%/src/lib/dcpomatic2.dll"', file=f)
149
150     print("""
151 SetOutPath "$INSTDIR\\lib\\pango\\1.8.0\\modules"
152 File "%static_deps%/lib/pango/1.8.0/modules/pango-arabic-lang.dll"
153 File "%static_deps%/lib/pango/1.8.0/modules/pango-basic-win32.dll"
154 File "%static_deps%/lib/pango/1.8.0/modules/pango-indic-lang.dll"
155
156 SetOutPath "$INSTDIR\\bin"
157 # I don't know why, but sometimes it seems that 
158 # delegates.xml must be in with the binaries, and
159 # sometimes in the $PROFILE.  Meh.
160 File "%static_deps%/etc/ImageMagick-6/delegates.xml"
161 SetOutPath "$PROFILE\\.magick"
162 File "%static_deps%/etc/ImageMagick-6/delegates.xml"
163
164 SetOutPath "$INSTDIR\\locale\\fr\\LC_MESSAGES"
165 File "%binaries%/src/lib/mo/fr_FR/libdcpomatic2.mo"
166 File "%binaries%/src/wx/mo/fr_FR/libdcpomatic2-wx.mo"
167 File "%binaries%/src/tools/mo/fr_FR/dcpomatic2.mo"
168 File "%static_deps%/share/locale/fr/LC_MESSAGES/wxstd.mo"
169 SetOutPath "$INSTDIR\\locale\\it\\LC_MESSAGES"
170 File "%binaries%/src/lib/mo/it_IT/libdcpomatic2.mo"
171 File "%binaries%/src/wx/mo/it_IT/libdcpomatic2-wx.mo"
172 File "%binaries%/src/tools/mo/it_IT/dcpomatic2.mo"
173 File "%static_deps%/share/locale/it/LC_MESSAGES/wxstd.mo"
174 SetOutPath "$INSTDIR\\locale\\es\\LC_MESSAGES"
175 File "%binaries%/src/lib/mo/es_ES/libdcpomatic2.mo"
176 File "%binaries%/src/wx/mo/es_ES/libdcpomatic2-wx.mo"
177 File "%binaries%/src/tools/mo/es_ES/dcpomatic2.mo"
178 File "%static_deps%/share/locale/es/LC_MESSAGES/wxstd.mo"
179 SetOutPath "$INSTDIR\\locale\\sv\\LC_MESSAGES"
180 File "%binaries%/src/lib/mo/sv_SE/libdcpomatic2.mo"
181 File "%binaries%/src/wx/mo/sv_SE/libdcpomatic2-wx.mo"
182 File "%binaries%/src/tools/mo/sv_SE/dcpomatic2.mo"
183 File "%static_deps%/share/locale/sv/LC_MESSAGES/wxstd.mo"
184 SetOutPath "$INSTDIR\\locale\\de\\LC_MESSAGES"
185 File "%binaries%/src/lib/mo/de_DE/libdcpomatic2.mo"
186 File "%binaries%/src/wx/mo/de_DE/libdcpomatic2-wx.mo"
187 File "%binaries%/src/tools/mo/de_DE/dcpomatic2.mo"
188 File "%static_deps%/share/locale/de/LC_MESSAGES/wxstd.mo"
189 SetOutPath "$INSTDIR\\locale\\nl\\LC_MESSAGES"
190 File "%binaries%/src/lib/mo/nl_NL/libdcpomatic2.mo"
191 File "%binaries%/src/wx/mo/nl_NL/libdcpomatic2-wx.mo"
192 File "%binaries%/src/tools/mo/nl_NL/dcpomatic2.mo"
193 File "%static_deps%/share/locale/nl/LC_MESSAGES/wxstd.mo"
194
195 SetOutPath "$INSTDIR"
196 File "%resources%/../../LiberationSans-Regular.ttf"
197     """, file=f)
198
199     if debug:
200         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "DisplayName" "DCP-o-matic 2 Debug (remove only)"', file=f)
201         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
202     else:
203         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" "DisplayName" "DCP-o-matic 2 (remove only)"', file=f)
204         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
205
206     print("""
207 WriteUninstaller "$INSTDIR\\Uninstall.exe"
208
209 CreateDirectory "$INSTDIR\etc\pango"
210 ReadEnvStr $0 COMSPEC
211 SetOutPath "$INSTDIR"
212 nsExec::ExecToLog '$0 /C bin\pango-querymodules.exe > etc\pango\pango.modules'
213
214 SectionEnd
215     """, file=f)
216
217     if debug:
218         print('Section "DCP-o-matic 2 Debug" SEC_MASTER', file=f)
219     else:
220         print('Section "DCP-o-matic 2" SEC_MASTER', file=f)
221     
222     print('SetOutPath "$INSTDIR\\bin"', file=f)
223
224     if debug:
225         print('CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2 Debug"', file=f)
226     else:
227         print('CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2"', file=f)
228
229     print("""
230 File "%binaries%/src/tools/dcpomatic2.exe"
231 File "%binaries%/src/tools/dcpomatic2_batch.exe"
232 File "%binaries%/src/tools/dcpomatic2_cli.exe"
233     """, file=f)
234
235     if debug:
236         print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Debug.lnk" "$INSTDIR\\bin\\debug.bat" ""', file=f)
237         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 Debug\\DCP-o-matic 2 Debug.lnk" "$INSTDIR\\bin\\debug.bat"', file=f)
238         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2 Debug.lnk" "$INSTDIR\\Uninstall.exe"', file=f)
239         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "DisplayName" "DCP-o-matic 2 Debug (remove only)"', file=f)
240         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
241     else:
242         print('CreateShortCut "$DESKTOP\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe" ""', file=f)
243         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f)
244         print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 batch converter.lnk" "$INSTDIR\\bin\\dcpomatic2_batch.exe"', file=f)
245         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 batch converter.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f)
246         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe"', file=f)
247         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic2" "DisplayName" "DCP-o-matic 2 (remove only)"', file=f)
248         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic2" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
249
250     print("""
251 WriteUninstaller "$INSTDIR\\Uninstall.exe"
252 SectionEnd
253     """, file=f)
254
255     if not debug:
256         print("""
257 Section "Encode server" SEC_SERVER
258 SetOutPath "$INSTDIR\\bin"
259 CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2"
260 File "%binaries%/src/tools/dcpomatic2_server_cli.exe"
261 File "%binaries%/src/tools/dcpomatic2_server.exe"
262 CreateShortCut "$DESKTOP\\DCP-o-matic 2 encode server.lnk" "$INSTDIR\\bin\\dcpomatic2_server.exe" ""
263 CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 encode server.lnk" "$INSTDIR\\bin\\dcpomatic_server.exe" "" "$INSTDIR\\bin\\dcpomatic2_server.exe" 0
264 CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe" "" "$INSTDIR\\Uninstall.exe" 0
265 SectionEnd
266     """, file=f)
267
268     if debug:
269         print('LangString DESC_SEC_MASTER ${LANG_ENGLISH} "DCP-o-matic 2 Debug"', file=f)
270     else:
271         print('LangString DESC_SEC_MASTER ${LANG_ENGLISH} "DCP-o-matic 2"', file=f)
272         print('LangString DESC_SEC_SERVER ${LANG_ENGLISH} "DCP-o-matic 2 encode server"', file=f)
273
274     print("""
275 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
276   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_MASTER} $(DESC_SEC_MASTER)
277   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_SERVER} $(DESC_SEC_SERVER)
278 !insertmacro MUI_FUNCTION_DESCRIPTION_END
279
280 !insertmacro MUI_PAGE_INSTFILES
281 !insertmacro MUI_PAGE_FINISH
282
283 !insertmacro MUI_UNPAGE_WELCOME
284 !insertmacro MUI_UNPAGE_CONFIRM
285 !insertmacro MUI_UNPAGE_INSTFILES
286 !insertmacro MUI_UNPAGE_FINISH
287 !insertmacro MUI_LANGUAGE "English"
288     """, file=f)
289
290     if debug:
291         print("""
292 Section "Uninstall"
293 RMDir /r "$INSTDIR\\*.*"    
294 RMDir "$INSTDIR"
295 Delete "$DESKTOP\\DCP-o-matic 2 Debug.lnk"
296 Delete "$SMPROGRAMS\\DCP-o-matic 2 Debug\\*.*"
297 RmDir  "$SMPROGRAMS\\DCP-o-matic 2 Debug"
298 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\DCP-o-matic 2 Debug"
299 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug"
300  SectionEnd
301         """, file=f)
302     else:
303         print("""
304 Section "Uninstall"
305 RMDir /r "$INSTDIR\\*.*"    
306 RMDir "$INSTDIR"
307 Delete "$DESKTOP\\DCP-o-matic 2.lnk"
308 Delete "$DESKTOP\\DCP-o-matic 2 batch converter.lnk"
309 Delete "$DESKTOP\\DCP-o-matic 2 encode server.lnk"
310 Delete "$SMPROGRAMS\\DCP-o-matic 2\\*.*"
311 RmDir  "$SMPROGRAMS\\DCP-o-matic 2"
312 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\DCP-o-matic 2"
313 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2"
314  SectionEnd
315     """, file=f)
316     
317
318 def build(bld):
319     write_installer(32, bld.env.VERSION, bld.env.DEBUG)
320     write_installer(64, bld.env.VERSION, bld.env.DEBUG)