d6111b0bb6698e14b9918968403877ea74745076
[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/libboost_regex-mt.dll"
72 File "%static_deps%/bin/libeay32.dll"
73 File "%static_deps%/bin/libgcc_s_sjlj-1.dll"
74 File "%static_deps%/bin/libgio-2.0-0.dll"
75 File "%static_deps%/bin/libglib-2.0-0.dll"
76 File "%static_deps%/bin/libgobject-2.0-0.dll"
77 File "%static_deps%/bin/libiconv-2.dll"
78 File "%static_deps%/bin/libjpeg-8.dll"
79 File "%static_deps%/bin/libMagick++-6.Q16-3.dll"
80 File "%static_deps%/bin/libMagickCore-6.Q16-1.dll"
81 File "%static_deps%/bin/libMagickWand-6.Q16-1.dll"
82 File "%static_deps%/bin/libpng15-15.dll"
83 File "%static_deps%/bin/libsigc-2.0-0.dll"
84 File "%static_deps%/bin/libsndfile-1.dll"
85 File "%static_deps%/bin/libssh.dll"
86 File "%static_deps%/bin/libstdc++-6.dll"
87 File "%static_deps%/bin/zlib1.dll"
88 File "%static_deps%/bin/libjpeg-8.dll"
89 File "%static_deps%/bin/wxbase30u_gcc_custom.dll"
90 File "%static_deps%/bin/wxmsw30u_core_gcc_custom.dll"
91 File "%static_deps%/bin/wxmsw30u_adv_gcc_custom.dll"
92 File "%static_deps%/bin/wxmsw30u_richtext_gcc_custom.dll"
93 File "%static_deps%/bin/wxmsw30u_html_gcc_custom.dll"
94 File "%static_deps%/bin/wxbase30u_xml_gcc_custom.dll"
95 File "%static_deps%/bin/libcairo-2.dll"
96 File "%static_deps%/bin/libfreetype-6.dll"
97 File "%static_deps%/bin/libgthread-2.0-0.dll"
98 File "%static_deps%/bin/libpango-1.0-0.dll"
99 File "%static_deps%/bin/libgmodule-2.0-0.dll"
100 File "%static_deps%/bin/libpangocairo-1.0-0.dll"
101 File "%static_deps%/bin/libpangowin32-1.0-0.dll"
102 File "%static_deps%/bin/libtiff-5.dll"
103 File "%static_deps%/bin/libglibmm-2.4-1.dll"
104 File "%static_deps%/bin/libxml++-2.6-2.dll"
105 File "%static_deps%/bin/libxml2-2.dll"
106 File "%static_deps%/bin/libpixman-1-0.dll"
107 File "%static_deps%/bin/libfontconfig-1.dll"
108 File "%static_deps%/bin/libexpat-1.dll"
109 File "%static_deps%/bin/libbz2.dll"
110 File "%static_deps%/bin/libxmlsec1.dll"
111 File "%static_deps%/bin/libxmlsec1-openssl.dll"
112 File "%static_deps%/bin/libexslt-0.dll"
113 File "%static_deps%/bin/libxslt-1.dll"
114 File "%static_deps%/bin/libffi-6.dll"
115 File "%static_deps%/bin/openssl.exe"
116 File "%static_deps%/bin/libcurl-4.dll"
117 File "%static_deps%/bin/ssleay32.dll"
118 File "%static_deps%/bin/libzip-2.dll"
119 File "%static_deps%/bin/libcairomm-1.0-1.dll"
120 File "%static_deps%/bin/libpangomm-1.4-1.dll"
121 File "%static_deps%/bin/pango-querymodules.exe"
122
123 File "%cdist_deps%/bin/asdcp-libdcp-1.0.dll"
124 File "%cdist_deps%/bin/kumu-libdcp-1.0.dll"
125 File "%cdist_deps%/bin/avcodec-56.dll"
126 File "%cdist_deps%/bin/avfilter-5.dll"
127 File "%cdist_deps%/bin/avformat-56.dll"
128 File "%cdist_deps%/bin/avutil-54.dll"
129 File "%cdist_deps%/bin/avdevice-56.dll"
130 File "%cdist_deps%/bin/postproc-53.dll"
131 File "%cdist_deps%/bin/dcp-1.0.dll"
132 File "%cdist_deps%/bin/libopenjpeg-1.dll"
133 File "%cdist_deps%/bin/swresample-1.dll"
134 File "%cdist_deps%/bin/swscale-3.dll"
135 File "%cdist_deps%/bin/cxml-0.dll"
136 File "%cdist_deps%/bin/sub-1.0.dll"
137 File "%cdist_deps%/bin/asdcp-libsub-1.0.dll"
138 File "%cdist_deps%/bin/kumu-libsub-1.0.dll"
139 File "%cdist_deps%/bin/ffprobe.exe"
140     """, file=f)
141
142     if debug:
143         print('File "%resources%/gdb_script"', file=f)
144         print('File "%resources%/debug.bat"', file=f)
145         print('File "%mingw%/gdb.exe"', file=f)
146         print('File "%mingw%/addr2line.exe"', file=f)
147     else:
148         print('File "%binaries%/src/wx/dcpomatic2-wx.dll"', file=f)
149         print('File "%binaries%/src/lib/dcpomatic2.dll"', file=f)
150
151     print("""
152 SetOutPath "$INSTDIR\\lib\\pango\\1.8.0\\modules"
153 File "%static_deps%/lib/pango/1.8.0/modules/pango-arabic-lang.dll"
154 File "%static_deps%/lib/pango/1.8.0/modules/pango-basic-win32.dll"
155 File "%static_deps%/lib/pango/1.8.0/modules/pango-indic-lang.dll"
156
157 SetOutPath "$INSTDIR\\bin"
158 # I don't know why, but sometimes it seems that
159 # delegates.xml must be in with the binaries, and
160 # sometimes in the $PROFILE.  Meh.
161 File "%static_deps%/etc/ImageMagick-6/delegates.xml"
162 SetOutPath "$PROFILE\\.magick"
163 File "%static_deps%/etc/ImageMagick-6/delegates.xml"
164
165 SetOutPath "$INSTDIR\\locale\\fr\\LC_MESSAGES"
166 File "%binaries%/src/lib/mo/fr_FR/libdcpomatic2.mo"
167 File "%binaries%/src/wx/mo/fr_FR/libdcpomatic2-wx.mo"
168 File "%binaries%/src/tools/mo/fr_FR/dcpomatic2.mo"
169 File "%static_deps%/share/locale/fr/LC_MESSAGES/wxstd.mo"
170 SetOutPath "$INSTDIR\\locale\\it\\LC_MESSAGES"
171 File "%binaries%/src/lib/mo/it_IT/libdcpomatic2.mo"
172 File "%binaries%/src/wx/mo/it_IT/libdcpomatic2-wx.mo"
173 File "%binaries%/src/tools/mo/it_IT/dcpomatic2.mo"
174 File "%static_deps%/share/locale/it/LC_MESSAGES/wxstd.mo"
175 SetOutPath "$INSTDIR\\locale\\es\\LC_MESSAGES"
176 File "%binaries%/src/lib/mo/es_ES/libdcpomatic2.mo"
177 File "%binaries%/src/wx/mo/es_ES/libdcpomatic2-wx.mo"
178 File "%binaries%/src/tools/mo/es_ES/dcpomatic2.mo"
179 File "%static_deps%/share/locale/es/LC_MESSAGES/wxstd.mo"
180 SetOutPath "$INSTDIR\\locale\\sv\\LC_MESSAGES"
181 File "%binaries%/src/lib/mo/sv_SE/libdcpomatic2.mo"
182 File "%binaries%/src/wx/mo/sv_SE/libdcpomatic2-wx.mo"
183 File "%binaries%/src/tools/mo/sv_SE/dcpomatic2.mo"
184 File "%static_deps%/share/locale/sv/LC_MESSAGES/wxstd.mo"
185 SetOutPath "$INSTDIR\\locale\\de\\LC_MESSAGES"
186 File "%binaries%/src/lib/mo/de_DE/libdcpomatic2.mo"
187 File "%binaries%/src/wx/mo/de_DE/libdcpomatic2-wx.mo"
188 File "%binaries%/src/tools/mo/de_DE/dcpomatic2.mo"
189 File "%static_deps%/share/locale/de/LC_MESSAGES/wxstd.mo"
190 SetOutPath "$INSTDIR\\locale\\nl\\LC_MESSAGES"
191 File "%binaries%/src/lib/mo/nl_NL/libdcpomatic2.mo"
192 File "%binaries%/src/wx/mo/nl_NL/libdcpomatic2-wx.mo"
193 File "%binaries%/src/tools/mo/nl_NL/dcpomatic2.mo"
194 File "%static_deps%/share/locale/nl/LC_MESSAGES/wxstd.mo"
195 SetOutPath "$INSTDIR\\locale\\ru\\LC_MESSAGES"
196 File "%binaries%/src/lib/mo/ru_RU/libdcpomatic2.mo"
197 File "%binaries%/src/wx/mo/ru_RU/libdcpomatic2-wx.mo"
198 File "%binaries%/src/tools/mo/ru_RU/dcpomatic2.mo"
199 File "%static_deps%/share/locale/ru/LC_MESSAGES/wxstd.mo"
200 SetOutPath "$INSTDIR\\locale\\pl\\LC_MESSAGES"
201 File "%binaries%/src/lib/mo/pl_PL/libdcpomatic2.mo"
202 File "%binaries%/src/wx/mo/pl_PL/libdcpomatic2-wx.mo"
203 File "%binaries%/src/tools/mo/pl_PL/dcpomatic2.mo"
204 File "%static_deps%/share/locale/pl/LC_MESSAGES/wxstd.mo"
205
206 SetOutPath "$INSTDIR"
207 File "%resources%/../../LiberationSans-Regular.ttf"
208     """, file=f)
209
210     if debug:
211         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "DisplayName" "DCP-o-matic 2 Debug (remove only)"', file=f)
212         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
213     else:
214         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" "DisplayName" "DCP-o-matic 2 (remove only)"', file=f)
215         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
216
217     print("""
218 WriteUninstaller "$INSTDIR\\Uninstall.exe"
219
220 CreateDirectory "$INSTDIR\etc\pango"
221 ReadEnvStr $0 COMSPEC
222 SetOutPath "$INSTDIR"
223 nsExec::ExecToLog '$0 /C bin\pango-querymodules.exe > etc\pango\pango.modules'
224
225 SectionEnd
226     """, file=f)
227
228     if debug:
229         print('Section "DCP-o-matic 2 Debug" SEC_MASTER', file=f)
230     else:
231         print('Section "DCP-o-matic 2" SEC_MASTER', file=f)
232
233     print('SetOutPath "$INSTDIR\\bin"', file=f)
234
235     if debug:
236         print('CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2 Debug"', file=f)
237     else:
238         print('CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2"', file=f)
239
240     print("""
241 File "%binaries%/src/tools/dcpomatic2.exe"
242 File "%binaries%/src/tools/dcpomatic2_batch.exe"
243 File "%binaries%/src/tools/dcpomatic2_cli.exe"
244     """, file=f)
245
246     if debug:
247         print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Debug.lnk" "$INSTDIR\\bin\\debug.bat" ""', file=f)
248         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 Debug\\DCP-o-matic 2 Debug.lnk" "$INSTDIR\\bin\\debug.bat"', file=f)
249         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2 Debug.lnk" "$INSTDIR\\Uninstall.exe"', file=f)
250         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "DisplayName" "DCP-o-matic 2 Debug (remove only)"', file=f)
251         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
252     else:
253         print('CreateShortCut "$DESKTOP\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe" ""', file=f)
254         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f)
255         print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 batch converter.lnk" "$INSTDIR\\bin\\dcpomatic2_batch.exe"', file=f)
256         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 batch converter.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f)
257         print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe"', file=f)
258         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic2" "DisplayName" "DCP-o-matic 2 (remove only)"', file=f)
259         print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic2" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
260
261     print("""
262 WriteUninstaller "$INSTDIR\\Uninstall.exe"
263 SectionEnd
264     """, file=f)
265
266     if not debug:
267         print("""
268 Section "Encode server" SEC_SERVER
269 SetOutPath "$INSTDIR\\bin"
270 CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2"
271 File "%binaries%/src/tools/dcpomatic2_server_cli.exe"
272 File "%binaries%/src/tools/dcpomatic2_server.exe"
273 CreateShortCut "$DESKTOP\\DCP-o-matic 2 encode server.lnk" "$INSTDIR\\bin\\dcpomatic2_server.exe" ""
274 CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 encode server.lnk" "$INSTDIR\\bin\\dcpomatic_server.exe" "" "$INSTDIR\\bin\\dcpomatic2_server.exe" 0
275 CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe" "" "$INSTDIR\\Uninstall.exe" 0
276 SectionEnd
277     """, file=f)
278
279     if debug:
280         print('LangString DESC_SEC_MASTER ${LANG_ENGLISH} "DCP-o-matic 2 Debug"', file=f)
281     else:
282         print('LangString DESC_SEC_MASTER ${LANG_ENGLISH} "DCP-o-matic 2"', file=f)
283         print('LangString DESC_SEC_SERVER ${LANG_ENGLISH} "DCP-o-matic 2 encode server"', file=f)
284
285     print("""
286 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
287   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_MASTER} $(DESC_SEC_MASTER)
288   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_SERVER} $(DESC_SEC_SERVER)
289 !insertmacro MUI_FUNCTION_DESCRIPTION_END
290
291 !insertmacro MUI_PAGE_INSTFILES
292 !insertmacro MUI_PAGE_FINISH
293
294 !insertmacro MUI_UNPAGE_WELCOME
295 !insertmacro MUI_UNPAGE_CONFIRM
296 !insertmacro MUI_UNPAGE_INSTFILES
297 !insertmacro MUI_UNPAGE_FINISH
298 !insertmacro MUI_LANGUAGE "English"
299     """, file=f)
300
301     if debug:
302         print("""
303 Section "Uninstall"
304 RMDir /r "$INSTDIR\\*.*"
305 RMDir "$INSTDIR"
306 Delete "$DESKTOP\\DCP-o-matic 2 Debug.lnk"
307 Delete "$SMPROGRAMS\\DCP-o-matic 2 Debug\\*.*"
308 RmDir  "$SMPROGRAMS\\DCP-o-matic 2 Debug"
309 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\DCP-o-matic 2 Debug"
310 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug"
311  SectionEnd
312         """, file=f)
313     else:
314         print("""
315 Section "Uninstall"
316 RMDir /r "$INSTDIR\\*.*"
317 RMDir "$INSTDIR"
318 Delete "$DESKTOP\\DCP-o-matic 2.lnk"
319 Delete "$DESKTOP\\DCP-o-matic 2 batch converter.lnk"
320 Delete "$DESKTOP\\DCP-o-matic 2 encode server.lnk"
321 Delete "$SMPROGRAMS\\DCP-o-matic 2\\*.*"
322 RmDir  "$SMPROGRAMS\\DCP-o-matic 2"
323 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\DCP-o-matic 2"
324 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2"
325  SectionEnd
326     """, file=f)
327
328
329 def build(bld):
330     write_installer(32, bld.env.VERSION, bld.env.DEBUG)
331     write_installer(64, bld.env.VERSION, bld.env.DEBUG)