Make version acceptable to dpkg-buildpackage even if the git commit hash starts with...
[dcpomatic.git] / cscript
1 # -*- mode: python -*-
2 #
3 #    Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
4 #
5 #    This file is part of DCP-o-matic.
6 #
7 #    DCP-o-matic is free software; you can redistribute it and/or modify
8 #    it under the terms of the GNU General Public License as published by
9 #    the Free Software Foundation; either version 2 of the License, or
10 #    (at your option) any later version.
11 #
12 #    DCP-o-matic is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU General Public License for more details.
16 #
17 #    You should have received a copy of the GNU General Public License
18 #    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 from __future__ import print_function
22 import datetime
23 import glob
24 import shutil
25 import os
26 import copy
27 import json
28
29 def dmg_prefix(variant):
30     return 'DCP-o-matic'
31
32 def debian_name(variant):
33     return 'dcpomatic'
34
35 deb_build_depends = dict()
36
37 deb_build_depends_base = ['debhelper', 'g++', 'pkg-config', 'libsndfile1-dev', 'libgtk2.0-dev', 'libx264-dev']
38
39 for v in ['16.04', '18.04', '20.04']:
40     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
41     deb_build_depends[v].extend(['libssh-dev', 'python'])
42 for v in ['22.04']:
43     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
44     deb_build_depends[v].extend(['libssh-dev', 'python3.10'])
45 for v in ['23.04', '23.10']:
46     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
47     deb_build_depends[v].extend(['libssh-dev', 'python3.11'])
48 for v in ['24.04']:
49     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
50     deb_build_depends[v].extend(['libssh-dev', 'python3.12'])
51 for v in ['9', '10']:
52     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
53     deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python'])
54 for v in ['11']:
55     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
56     deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python3.9'])
57 for v in ['12']:
58     deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
59     deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python3.11'])
60 deb_build_depends['unstable'] = copy.deepcopy(deb_build_depends_base)
61 deb_build_depends['unstable'].extend(['python3'])
62
63 deb_depends = dict()
64 deb_depends_gui = dict()
65
66 deb_depends_base = ['libc6', 'libsndfile1', 'libsamplerate0', 'libxmlsec1', 'libxmlsec1-openssl', 'libgtk2.0-0']
67
68 deb_depends['16.04'] = copy.deepcopy(deb_depends_base)
69 deb_depends['16.04'].extend(['libboost-filesystem1.58.0',
70                              'libboost-thread1.58.0',
71                              'libboost-regex1.58.0',
72                              'libxml++2.6-2v5',
73                              'libboost-date-time1.58.0',
74                              'libzip4',
75                              'libcairomm-1.0-1v5',
76                              'libpangomm-1.4-1v5',
77                              'libicu55',
78                              'libnettle6',
79                              'libssh-4',
80                              'libx264-148',
81                              'libcurl3',
82                              'libxerces-c3.1'])
83
84 deb_depends['18.04'] = copy.deepcopy(deb_depends_base)
85 deb_depends['18.04'].extend(['libboost-filesystem1.65.1',
86                              'libboost-thread1.65.1',
87                              'libboost-regex1.65.1',
88                              'libboost-date-time1.65.1',
89                              'libcairomm-1.0-1v5',
90                              'libpangomm-1.4-1v5',
91                              'libxml++2.6-2v5',
92                              'libzip4',
93                              'libicu60',
94                              'libnettle6',
95                              'libssh-4',
96                              'libx264-152',
97                              'libcurl4',
98                              'libpulse0',
99                              'libxerces-c3.2',
100                              'libnanomsg4'])
101
102 deb_depends['20.04'] = copy.deepcopy(deb_depends_base)
103 deb_depends['20.04'].extend(['libboost-filesystem1.71.0',
104                              'libboost-thread1.71.0',
105                              'libboost-regex1.71.0',
106                              'libboost-date-time1.71.0',
107                              'libcairomm-1.0-1v5',
108                              'libpangomm-1.4-1v5',
109                              'libxml++2.6-2v5',
110                              'libzip5',
111                              'libicu66',
112                              'libnettle7',
113                              'libssh-4',
114                              'libx264-155',
115                              'libcurl4',
116                              'libpulse0',
117                              'libxerces-c3.2',
118                              'libnanomsg5'])
119
120 deb_depends['21.10'] = copy.deepcopy(deb_depends_base)
121 deb_depends['21.10'].extend(['libboost-filesystem1.74.0',
122                              'libboost-thread1.74.0',
123                              'libboost-regex1.74.0',
124                              'libboost-date-time1.74.0',
125                              'libcairomm-1.0-1v5',
126                              'libpangomm-1.4-1v5',
127                              'libxml++2.6-2v5',
128                              'libzip4',
129                              'libicu67',
130                              'libnettle8',
131                              'libssh-4',
132                              'libx264-160',
133                              'libcurl4',
134                              'libpulse0',
135                              'libxerces-c3.2',
136                              'libnanomsg5',
137                              'libdav1d4'])
138
139 deb_depends['22.04'] = copy.deepcopy(deb_depends_base)
140 deb_depends['22.04'].extend(['libboost-filesystem1.74.0',
141                              'libboost-thread1.74.0',
142                              'libboost-regex1.74.0',
143                              'libboost-date-time1.74.0',
144                              'libcairomm-1.0-1v5',
145                              'libpangomm-1.4-1v5',
146                              'libxml++2.6-2v5',
147                              'libzip4',
148                              'libicu70',
149                              'libnettle8',
150                              'libssh-4',
151                              'libx264-163',
152                              'libcurl4',
153                              'libpulse0',
154                              'libxerces-c3.2',
155                              'libnanomsg5',
156                              'libdav1d5'])
157
158 deb_depends['23.04'] = copy.deepcopy(deb_depends_base)
159 deb_depends['23.04'].extend(['libboost-filesystem1.74.0',
160                              'libboost-thread1.74.0',
161                              'libboost-regex1.74.0',
162                              'libboost-date-time1.74.0',
163                              'libcairomm-1.0-1v5',
164                              'libpangomm-1.4-1v5',
165                              'libxml++2.6-2v5',
166                              'libzip4',
167                              'libicu72',
168                              'libnettle8',
169                              'libssh-4',
170                              'libx264-164',
171                              'libcurl4',
172                              'libpulse0',
173                              'libxerces-c3.2',
174                              'libnanomsg5',
175                              'libwxgtk3.2-1',
176                              'libwxgtk-gl3.2-1'])
177
178 deb_depends['23.10'] = copy.deepcopy(deb_depends_base)
179 deb_depends['23.10'].extend(['libboost-filesystem1.74.0',
180                              'libboost-thread1.74.0',
181                              'libboost-regex1.74.0',
182                              'libboost-date-time1.74.0',
183                              'libcairomm-1.0-1v5',
184                              'libpangomm-1.4-1v5',
185                              'libxml++2.6-2v5',
186                              'libzip4',
187                              'libicu72',
188                              'libnettle8',
189                              'libssh-4',
190                              'libx264-164',
191                              'libcurl4',
192                              'libpulse0',
193                              'libxerces-c3.2',
194                              'libnanomsg5',
195                              'libwxgtk3.2-1',
196                              'libwxgtk-gl3.2-1'])
197
198 def debs(boost, icu, x264):
199     output = copy.deepcopy(deb_depends_base)
200     output.extend(['libboost-filesystem' + boost,
201                    'libboost-thread' + boost,
202                    'libboost-regex' + boost,
203                    'libboost-date-time' + boost,
204                    'libcairomm-1.0-1v5',
205                    'libpangomm-1.4-1v5',
206                    'libxml++2.6-2v5',
207                    'libzip4',
208                    'libicu' + icu,
209                    'libnettle8',
210                    'libssh-4',
211                    'libx264-' + x264,
212                    'libcurl4',
213                    'libpulse0',
214                    'libxerces-c3.2',
215                    'libnanomsg5',
216                    'libwxgtk3.2-1',
217                    'libwxgtk-gl3.2-1'])
218     return output
219
220 deb_depends['24.04'] = debs(boost='1.83.0', icu='74', x264='164')
221
222 deb_depends['9'] = copy.deepcopy(deb_depends_base)
223 deb_depends['9'].extend(['libboost-filesystem1.62.0',
224                          'libboost-thread1.62.0',
225                          'libboost-regex1.62.0',
226                          'libboost-date-time1.62.0',
227                          'libxml++2.6-2v5',
228                          'libgtk2.0-0',
229                          'libzip4',
230                          'libcairomm-1.0-1v5',
231                          'libpangomm-1.4-1v5',
232                          'libicu57',
233                          'libssh-4',
234                          'libssh-gcrypt-4',
235                          'libnettle6',
236                          'libx264-148',
237                          'libcurl3',
238                          'libxerces-c3.1'])
239
240 deb_depends_gui['9'] = [ 'libxcb-xfixes0',
241                          'libxcb-shape0',
242                          'libasound2',
243                          'libpulse0' ]
244
245 deb_depends['10'] = copy.deepcopy(deb_depends_base)
246 deb_depends['10'].extend(['libboost-filesystem1.67.0',
247                           'libboost-thread1.67.0',
248                           'libboost-regex1.67.0',
249                           'libboost-date-time1.67.0',
250                           'libxml++2.6-2v5',
251                           'libgtk2.0-0',
252                           'libzip4',
253                           'libcairomm-1.0-1v5',
254                           'libpangomm-1.4-1v5',
255                           'libicu63',
256                           'libssh-4',
257                           'libssh-gcrypt-4',
258                           'libnettle6',
259                           'libx264-155',
260                           'libcurl4',
261                           'libxerces-c3.2',
262                           'libnanomsg5'])
263
264 deb_depends_gui['10'] = [ 'libxcb-xfixes0',
265                           'libxcb-shape0',
266                           'libasound2',
267                           'libpulse0' ]
268
269 deb_depends['11'] = copy.deepcopy(deb_depends_base)
270 deb_depends['11'].extend(['libboost-filesystem1.74.0',
271                           'libboost-thread1.74.0',
272                           'libboost-regex1.74.0',
273                           'libboost-date-time1.74.0',
274                           'libxml++2.6-2v5',
275                           'libzip4',
276                           'libcairomm-1.0-1v5',
277                           'libpangomm-1.4-1v5',
278                           'libicu67',
279                           'libssh-4',
280                           'libssh-gcrypt-4',
281                           'libnettle8',
282                           'libx264-160',
283                           'libcurl4',
284                           'libxerces-c3.2',
285                           'libnanomsg5',
286                           'libdav1d4'])
287
288 deb_depends_gui['11'] = [ 'libxcb-xfixes0',
289                           'libxcb-shape0',
290                           'libasound2',
291                           'libpulse0' ]
292
293 deb_depends['12'] = copy.deepcopy(deb_depends_base)
294 deb_depends['12'].extend(['libboost-filesystem1.74.0',
295                           'libboost-thread1.74.0',
296                           'libboost-regex1.74.0',
297                           'libboost-date-time1.74.0',
298                           'libxml++2.6-2v5',
299                           'libzip4',
300                           'libcairomm-1.0-1v5',
301                           'libpangomm-1.4-1v5',
302                           'libicu72',
303                           'libssh-4',
304                           'libssh-gcrypt-4',
305                           'libnettle8',
306                           'libx264-164',
307                           'libcurl4',
308                           'libxerces-c3.2',
309                           'libnanomsg5'])
310
311 deb_depends_gui['12'] = [ 'libxcb-xfixes0',
312                           'libxcb-shape0',
313                           'libasound2',
314                           'libpulse0' ]
315
316 deb_depends['unstable'] = copy.deepcopy(deb_depends_base)
317 deb_depends['unstable'].extend(['libboost-filesystem1.67.0',
318                                 'libboost-thread1.67.0',
319                                 'libboost-regex1.67.0',
320                                 'libboost-date-time1.67.0',
321                                 'libxml++2.6-2v5',
322                                 'libgtk2.0-0',
323                                 'libzip4',
324                                 'libicu63',
325                                 'libnettle6',
326                                 'libx264-155',
327                                 'libcurl4',
328                                 'libxerces-c3.2',
329                                 'libdav1d4'])
330
331 def can_build_disk(target):
332     # We can build dcpomatic2_disk on platforms that have Boost process and can build the lwext4
333     # library.  For now, just whitelist good ones here.
334     #
335     # - Lots of Linux distros (including Ubuntu 16.04) don't have a new enough boost (1.64 or above)
336     # - On Centos 6 we can't build lwext4 because it needs a new CMake which Centos 6's g++ is not new enough to build.
337     # - On Centos 7 there is a build error in lwext4 related to __unused
338     if target.platform == 'windows':
339         return True
340     if target.platform == 'osx':
341         return True
342     if target.platform == 'linux':
343         if target.distro == 'ubuntu' and target.version != '16.04':
344             return True
345         if target.distro == 'debian' and target.version != '9':
346             return True
347         if target.detail == 'appimage':
348             return True 
349         if target.distro == 'fedora' and int(target.version) >= 31:
350             return True
351         if target.distro == 'centos' and target.version != '7':
352             return True
353         if target.distro == 'mageia':
354             return True
355     return False
356
357 def packages(name, packages, f):
358     s = '%s: ' % name
359     for p in packages:
360         s += str(p) + ', '
361     print(s[:-2], file=f)
362
363 def make_control(debian_version, bits, filename, debug, gui, name):
364     f = open(filename, 'w')
365     print(f'Source: {name}', file=f)
366     print('Section: video', file=f)
367     print('Priority: extra', file=f)
368     print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
369     packages('Build-Depends', deb_build_depends[debian_version], f)
370     print('Standards-Version: 3.9.3', file=f)
371     print('Homepage: https://dcpomatic.com/', file=f)
372     print('', file=f)
373     suffix = '' if gui else '-cli'
374     print(f'Package: {name}{suffix}', file=f)
375     if gui:
376         print(f'Replaces: {name}-cli', file=f)
377     if bits == 32:
378         print('Architecture: i386', file=f)
379     else:
380         print('Architecture: amd64', file=f)
381
382     pkg = deb_depends[debian_version]
383     if gui and debian_version in deb_depends_gui:
384         pkg.extend(deb_depends_gui[debian_version])
385
386     packages('Depends', pkg, f)
387
388     print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
389     print('  DCP-o-matic generates Digital Cinema Packages (DCPs) from videos, images,', file=f)
390     print('  sound and subtitle files.  You can use it to make content for playback on DCI-compliant', file=f)
391     print('  cinema projectors.', file=f)
392     if not gui:
393         print('  This package contains the command-line tools only.', file=f)
394
395     if debug:
396         print('', file=f)
397         print(f'Package: {name}{suffix}-dbg', file=f)
398         if bits == 32:
399             print('Architecture: i386', file=f)
400         else:
401             print('Architecture: amd64', file=f)
402         print('Section: debug', file=f)
403         print('Priority: extra', file=f)
404         packages('Depends', pkg, f)
405         print(f'Description: debugging symbols for {name}', file=f)
406         print(f'  This package contains the debugging symbols for {name}.', file=f)
407         print('', file=f)
408
409 def make_spec(filename, version, target, options, requires=None):
410     """Make a .spec file for a RPM build"""
411     f = open(filename, 'w')
412     print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
413     print('Name:dcpomatic2', file=f)
414     print('Version:%s' % version, file=f)
415     print('Release:1%{?dist}', file=f)
416     print('License:GPL', file=f)
417     print('Group:Applications/Multimedia', file=f)
418     print('URL:https://dcpomatic.com/', file=f)
419     if requires is not None:
420         print('Requires:%s' % requires, file=f)
421     print('', file=f)
422     print('%description', file=f)
423     print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
424     print('files for presentation on DCI-compliant digital projectors.', file=f)
425     print('', file=f)
426     print('%files', file=f)
427     print('%{_bindir}/dcpomatic2', file=f)
428     print('%{_bindir}/dcpomatic2_batch', file=f)
429     print('%{_bindir}/dcpomatic2_cli', file=f)
430     print('%{_bindir}/dcpomatic2_create', file=f)
431     print('%{_bindir}/dcpomatic2_editor', file=f)
432     print('%{_bindir}/dcpomatic2_kdm', file=f)
433     print('%{_bindir}/dcpomatic2_server', file=f)
434     print('%{_bindir}/dcpomatic2_server_cli', file=f)
435     print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
436     print('%{_bindir}/dcpomatic2_player', file=f)
437     print('%{_bindir}/dcpomatic2_playlist', file=f)
438     print('%{_bindir}/dcpomatic2_openssl', file=f)
439     print('%{_bindir}/dcpomatic2_combiner', file=f)
440     print('%{_bindir}/dcpomatic2_verify_cli', file=f)
441     print('%{_bindir}/dcpomatic2_verifier', file=f)
442     print('%{_bindir}/dcpomatic2_kdm_inspect', file=f)
443     print('%{_bindir}/dcpomatic2_map', file=f)
444     if can_build_disk(target):
445         print('%{_bindir}/dcpomatic2_disk', file=f)
446         print('%caps(cap_dac_override=ep) %{_bindir}/dcpomatic2_disk_writer', file=f)
447     print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
448     print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
449     print('%{_datadir}/applications/dcpomatic2_editor.desktop', file=f)
450     print('%{_datadir}/applications/dcpomatic2_verifier.desktop', file=f)
451     print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
452     print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
453     print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
454     print('%{_datadir}/applications/dcpomatic2_playlist.desktop', file=f)
455     print('%{_datadir}/applications/dcpomatic2_combiner.desktop', file=f)
456     if can_build_disk(target):
457         print('%{_datadir}/applications/dcpomatic2_disk.desktop', file=f)
458     print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
459     print('%{_datadir}/dcpomatic2/select_white.png', file=f)
460     print('%{_datadir}/dcpomatic2/select_black.png', file=f)
461     print('%{_datadir}/dcpomatic2/sequence_white.png', file=f)
462     print('%{_datadir}/dcpomatic2/sequence_black.png', file=f)
463     print('%{_datadir}/dcpomatic2/snap_white.png', file=f)
464     print('%{_datadir}/dcpomatic2/snap_black.png', file=f)
465     print('%{_datadir}/dcpomatic2/zoom_white.png', file=f)
466     print('%{_datadir}/dcpomatic2/zoom_black.png', file=f)
467     print('%{_datadir}/dcpomatic2/zoom_all_white.png', file=f)
468     print('%{_datadir}/dcpomatic2/zoom_all_black.png', file=f)
469     print('%{_datadir}/dcpomatic2/link_black.png', file=f)
470     print('%{_datadir}/dcpomatic2/link_white.png', file=f)
471     print('%{_datadir}/dcpomatic2/me.jpg', file=f)
472     print('%{_datadir}/dcpomatic2/add_black.png', file=f)
473     print('%{_datadir}/dcpomatic2/add_white.png', file=f)
474     print('%{_datadir}/dcpomatic2/pause_black.png', file=f)
475     print('%{_datadir}/dcpomatic2/pause_white.png', file=f)
476     print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
477     print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
478     print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
479     print('%{_datadir}/dcpomatic2/splash.png', file=f)
480     for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
481         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
482         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
483         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_editor.png' % r, file=f)
484         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_verifier.png' % r, file=f)
485         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
486         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
487         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
488         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_playlist.png' % r, file=f)
489         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_disk.png' % r, file=f)
490         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_combiner.png' % r, file=f)
491     for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK',
492               'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN', 'tr_TR', 'sl_SI', 'hu_HU',
493               'ka_KA', 'fa_IR']:
494         print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
495         print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
496         print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
497     print('%{_datadir}/libdcp/tags/*', file=f)
498     print('%{_datadir}/libdcp/xsd/*', file=f)
499     print('%{_datadir}/libdcp/ratings', file=f)
500     print('%{_datadir}/polkit-1/actions/com.dcpomatic.write-drive.policy', file=f)
501     print('', file=f)
502     print('%prep', file=f)
503     print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
504     print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
505     print('%build', file=f)
506     print('cd dcpomatic-%s' % version, file=f)
507     print('export PKG_CONFIG_PATH=%s/lib/pkgconfig:%s/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig' % (target.directory, target.directory), file=f)
508     print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --destdir=/usr %s' %
509           (target.directory, target.directory, configure_options(target, options, for_package=True)), file=f)
510     print('./waf', file=f)
511     print('%install', file=f)
512     print('cd dcpomatic-%s' % version, file=f)
513     print('./waf install', file=f)
514     print('/bin/cp %s/src/openssl/apps/openssl %%{buildroot}/usr/bin/dcpomatic2_openssl' % target.directory, file=f)
515     print('/bin/mkdir -p %{buildroot}/usr/share/libdcp', file=f)
516     print('/bin/cp -r %s/src/libdcp/tags %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
517     print('/bin/cp -r %s/src/libdcp/xsd %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
518     print('/bin/cp %s/src/libdcp/ratings %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
519     print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify_cli' % target.directory, file=f)
520     print('/bin/mv %s/bin/dcpkdm %%{buildroot}/usr/bin/dcpomatic2_kdm_inspect' % target.directory, file=f)
521     print('', file=f)
522     print('%post', file=f)
523     print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
524     print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
525     print('', file=f)
526     print('%postun', file=f)
527     print('if [ $1 -eq 0 ] ; then', file=f)
528     print('    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
529     print('    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
530     print('fi', file=f)
531     print('', file=f)
532     print('%posttrans', file=f)
533     print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
534
535 def dependencies(target, options):
536     deps = [('libdcp', '9b9af8a80860210c6a29446f7a24795eeda9e7bc', {'c++17': target.platform == 'osx'})]
537     deps.append(('libsub', 'v1.6.47'))
538     deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
539     deps.append(('rtaudio', 'f619b76'))
540     # We get our OpenSSL libraries from the environment, but we
541     # also need a patched openssl binary to make certificates.
542     # This dependency is to get that binary, which is added into
543     # the appropriate place later
544     deps.append(('openssl', '54298369cacfe0ae01c5aa42ace8a463fd2e7a2e'))
545     if can_build_disk(target):
546         deps.append(('lwext4', 'ab082923a791b58478d1d9939d65a0583566ac1f'))
547     deps.append(('ffcmp', '5ab6ed3b75d8ca7cf1f66bb9fb08792b92f4b419'))
548
549     return deps
550
551 option_defaults = { "gui": True, "variant": None }
552
553 def configure_options(target, options, for_package=False):
554     opt = ' --warnings-are-errors'
555
556     if for_package or not (
557             (target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['18.04', '22.04']) or
558             (target.platform == 'osx') or
559             (target.platform == 'windows')
560         ):
561         # Currently we only build tests on macOS, Windows, and some Ubuntu versions
562         opt += ' --disable-tests'
563
564     if target.debug:
565         opt += ' --enable-debug'
566     if target.platform == 'windows':
567         opt += f' --target-windows-{target.bits}'
568     elif target.platform == 'linux':
569         opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
570         if target.distro == 'centos':
571             if target.version == '6.5':
572                 opt += ' --static-boost --static-xmlpp'
573             elif target.version == '7':
574                 opt += ' --workaround-gssapi'
575
576     if not options['gui']:
577         opt += ' --disable-gui'
578
579     if options['variant']:
580         opt += ' --variant=%s' % options['variant']
581
582     # Build Windows debug versions with static linking as I think gdb works better then
583     if target.debug and target.platform == 'windows':
584         opt += ' --static-dcpomatic'
585
586     if can_build_disk(target):
587         opt += ' --enable-disk'
588
589     if target.platform == 'osx':
590         opt += ' --c++17'
591         if target.arch == 'arm64':
592             opt += ' --wx-config=%s/wx-config' % target.bin
593
594     if target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['22.04']:
595         opt += ' --enable-grok'
596
597     return opt
598
599 def build(target, options, for_package):
600     if target.platform == 'flatpak':
601         target.checkout_dependencies()
602         prefix = 'https://dcpomatic.com/deps'
603         modules = []
604         modules.append({'name': 'libzip',
605                         'buildsystem': 'cmake',
606                         'sources': [{'type': 'archive',
607                                      'url': '%s/libzip-1.4.0.tar.xz' % prefix,
608                                      'sha256': 'e508aba025f5f94b267d5120fc33761bcd98440ebe49dbfe2ed3df3afeacc7b1'}]})
609         modules.append({'name': 'libsigc++',
610                         'sources': [{'type': 'archive',
611                                      'url': '%s/libsigc++-2.10.0.tar.xz' % prefix,
612                                      'sha256': 'f843d6346260bfcb4426259e314512b99e296e8ca241d771d21ac64f28298d81'}]})
613         modules.append({'name': 'glibmm',
614                         'sources': [{'type': 'archive',
615                                      'url': '%s/glibmm-2.48.1.tar.xz' % prefix,
616                                      'sha256': 'dc225f7d2f466479766332483ea78f82dc349d59399d30c00de50e5073157cdf'}]})
617         modules.append({'name': 'cairomm',
618                         'sources': [{'type': 'archive',
619                                      'url': '%s/cairomm-1.12.2.tar.gz' % prefix,
620                                      'sha256': '45c47fd4d0aa77464a75cdca011143fea3ef795c4753f6e860057da5fb8bd599'}]})
621         modules.append({'name': 'pangomm',
622                         'sources': [{'type': 'archive',
623                                      'url': '%s/pangomm-2.40.1.tar.xz' % prefix,
624                                      'sha256': '9762ee2a2d5781be6797448d4dd2383ce14907159b30bc12bf6b08e7227be3af'}]})
625         modules.append({'name': 'libxml++',
626                         'sources': [{'type': 'archive',
627                                      'url': '%s/libxml++-2.40.1.tar.xz' % prefix,
628                                      'sha256': '4ad4abdd3258874f61c2e2a41d08e9930677976d303653cd1670d3e9f35463e9'}]})
629         modules.append({'name': 'xmlsec1',
630                         'sources': [{'type': 'archive',
631                                      'url': '%s/xmlsec1-1.2.25.tar.gz' % prefix,
632                                      'sha256': '967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2'}]})
633         modules.append({'name': 'openjpeg2',
634                         'buildsystem': 'cmake',
635                         'sources': [{'type': 'dir', 'path': os.path.abspath('../openjpeg2-cdist')}]})
636         modules.append({'name': 'boost',
637                         'buildsystem': 'simple',
638                         'build-commands': [
639                             './bootstrap.sh --prefix=/app',
640                             './b2 install'
641                         ],
642                         'sources': [{'type': 'archive',
643                                      'url': '%s/boost_1_66_0.tar.bz2' % prefix,
644                                      'sha256': '5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'}]})
645         modules.append({'name': 'asdcplib',
646                         'buildsystem': 'simple',
647                         'build-commands': [
648                             './waf configure --prefix=/app  --libdir=/app/lib build install'
649                         ],
650                         'sources': [{'type': 'dir', 'path': os.path.abspath('../asdcplib-carl')}]})
651         modules.append({'name': 'locked_sstream',
652                         'buildsystem': 'simple',
653                         'build-commands': [
654                             './waf configure --prefix=/app build install'
655                         ],
656                         'sources': [{'type': 'dir', 'path': os.path.abspath('../locked_sstream')}]})
657         modules.append({'name': 'libcxml',
658                         'buildsystem': 'simple',
659                         'build-commands': [
660                             './waf configure --prefix=/app  --libdir=/app/lib build install'
661                         ],
662                         'sources': [{'type': 'dir', 'path': os.path.abspath('../libcxml')}]})
663         modules.append({'name': 'libdcp',
664                         'buildsystem': 'simple',
665                         'build-commands': [
666                             './waf configure --prefix=/app --libdir=/app/lib build install'
667                         ],
668                         'sources': [{'type': 'dir', 'path': os.path.abspath('../libdcp')}]})
669         modules.append({'name': 'libsub',
670                         'buildsystem': 'simple',
671                         'build-commands': [
672                             './waf configure --prefix=/app --libdir=/app/lib build install'
673                         ],
674                         'sources': [{'type': 'dir', 'path': os.path.abspath('../libsub')}]})
675         modules.append({'name': 'rtaudio',
676                         'build-options': {
677                         'config-opts': [
678                             '--prefix=/app',
679                             '--with-pulse',
680                             '--with-alsa'
681                         ]
682                         },
683                         'sources': [{'type': 'dir', 'path': os.path.abspath('../rtaudio-cdist')}]})
684         modules.append({'name': 'wxwidgets',
685                         'sources': [{'type': 'archive',
686                                      'url': '%s/wxWidgets-3.0.3.tar.bz2' % prefix,
687                                      'sha256': '08c8033f48ec1b23520f036cde37b5ae925a6a65f137ded665633ca159b9307b'}]})
688         modules.append({'name': 'libssh',
689                         'buildsystem': 'cmake',
690                         'builddir': True,
691                         'sources': [{'type': 'archive',
692                                      'url': '%s/libssh-0.7.5.tar.xz' % prefix,
693                                      'sha256': '54e86dd5dc20e5367e58f3caab337ce37675f863f80df85b6b1614966a337095'}]})
694         modules.append({'name': 'dcpomatic',
695                         'buildsystem': 'simple',
696                         'build-commands': [
697                             './waf configure --prefix=/app build install'
698                          ],
699                         'build-options': {
700                            'build-args': ['--share=network']
701                         },
702                         'sources': [{'type': 'dir', 'path': os.path.abspath('.')}]})
703         desc = {'app-id': 'com.dcpomatic.DCP-o-matic',
704                 'runtime': 'org.gnome.Sdk',
705                 'runtime-version': '3.26',
706                 'sdk': 'org.gnome.Sdk',
707                 'command': 'dcpomatic2',
708                 'finish-args': ['--socket=x11', '--share=ipc', '--share=network', '--socket=pulseaudio', '--filesystem=host'],
709                 'modules': modules}
710         os.makedirs('build/platform')
711         with open('build/com.dcpomatic.DCP-o-matic.json', 'w') as outfile:
712             json.dump(desc, outfile)
713         target.command('%s --repo=build/platform/repo build/platform/flatpak build/com.dcpomatic.DCP-o-matic.json' % target.flatpak_builder())
714     elif target.platform != 'linux' or target.detail == 'appimage' or not for_package:
715         target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target, options, for_package)))
716         target.command('./waf')
717         target.command('./waf install')
718
719 def package_windows(target):
720     identifier = '%d' % target.bits
721     shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
722     target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
723     target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
724     target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
725     target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
726     target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.environment_prefix, identifier))
727     target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
728     target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier)
729     target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier)
730     return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
731
732 def package_debian(target, cpu, version, options):
733     name = debian_name(options['variant'])
734     make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'], name)
735     if target.version != '9' and target.version != '16.04' and options['gui']:
736         with open('debian/postinst', 'w') as f:
737             print('#!/bin/sh', file=f)
738             # Get the required capability to write to disks
739             print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
740     target.command('./waf dist')
741     f = open('debian/files', 'w')
742     suffix = '' if options['gui'] else '-cli'
743     print(f'{name}{suffix}_{version}-1_{cpu}.deb video extra', file=f)
744     shutil.rmtree('build/deb', ignore_errors=True)
745
746     os.makedirs('build/deb')
747     os.chdir('build/deb')
748     shutil.move(f'../../dcpomatic-{version}.tar.bz2', f'{name}_{version}.orig.tar.bz2')
749     target.command(f'tar xjf {name}_{version}.orig.tar.bz2')
750     os.chdir(f'dcpomatic-{version}')
751
752     with open('debian/changelog', 'w') as f:
753         print(f'{name} ({version}-1) unstable; urgency=medium', file=f)
754         print('', file=f)
755         print('  * New upstream release.', file=f)
756         print('', file=f)
757         print(f" -- Carl Hetherington <carl@dcpomatic.com>  {datetime.datetime.now().astimezone().strftime('%a, %d %b %Y %H:%M:%S %z')}", file=f)
758
759     target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
760     target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
761     target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
762     target.set('CDIST_DIRECTORY', target.directory)
763
764     target.set('CDIST_CONFIGURE', '"' + configure_options(target, options, for_package=True) + '"')
765     target.set('CDIST_PACKAGE', f'{name}{suffix}')
766     target.set('CDIST_WX_VERSION', "3.2" if target.version in ("23.04", "23.10", "24.04") else "3.1")
767     if not target.debug:
768         target.set('CDIST_DEBUG_PACKAGE_FLAG', '--no-ddebs')
769
770     target.command('dpkg-buildpackage -uc -us')
771
772     debs = []
773     for p in glob.glob('../*.deb'):
774         debs.append(os.path.abspath(p))
775
776     return debs
777
778 def package_rpm(target, cpu, version, options):
779     topdir = os.path.realpath('build/rpmbuild')
780     os.makedirs('%s/BUILD' % topdir)
781     os.makedirs('%s/RPMS' % topdir)
782     os.makedirs('%s/SOURCES' % topdir)
783     os.makedirs('%s/SPECS' % topdir)
784     os.makedirs('%s/SRPMS' % topdir)
785
786     target.command('./waf dist')
787     shutil.copyfile(
788         "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
789         "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
790         )
791
792     requires = None
793     if target.distro == 'mageia':
794         requires = "lib64xmlsec1-devel lib64canberra-gtk0 libcap-utils"
795
796     make_spec('dcpomatic2.spec', version, target, options, requires)
797     cmd = 'rpmbuild --define "_topdir %s" -bb dcpomatic2.spec' % topdir
798     target.command(cmd)
799     rpms = []
800
801     if cpu == "amd64":
802         cpu = "x86_64"
803     else:
804         cpu = "i686"
805
806     for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
807         rpms.append(os.path.abspath(p))
808
809     return rpms
810
811 def make_appimage(target, nice_name, internal_name, version, extra_binaries=None):
812     nice_filename = nice_name.replace(' ', '_')
813     appdir = f'build/{nice_filename}.AppDir'
814     os.makedirs(f'{appdir}/usr/bin')
815     target.command(f'cp {target.directory}/bin/{internal_name} {appdir}/usr/bin')
816     target.command(f'cp {target.directory}/src/openssl/apps/openssl {appdir}/usr/bin/dcpomatic2_openssl')
817     target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify_cli')
818     target.command(f'cp {target.directory}/bin/dcpkdm {appdir}/usr/bin/dcpomatic2_kdm_inspect')
819     if extra_binaries:
820         for bin in extra_binaries:
821             target.command(f'cp {target.directory}/bin/{bin} {appdir}/usr/bin')
822     target.command(f'mkdir -p {appdir}/usr/share/libdcp')
823     target.command(f'cp -r {target.directory}/share/dcpomatic2 {appdir}/usr/share/')
824     target.command(f'cp -r {target.directory}/share/libdcp/xsd {appdir}/usr/share/libdcp/')
825     target.command(f'cp -r {target.directory}/share/libdcp/tags {appdir}/usr/share/libdcp/')
826     target.command(f'cp {target.directory}/share/libdcp/ratings {appdir}/usr/share/libdcp/')
827     lib = 'usr/lib/x86_64-linux-gnu'
828     target.command(f'mkdir -p build/{nice_filename}.AppDir/{lib}/gdk-pixbuf-2.0/2.10.0')
829     target.command(f'cp -a /{lib}/gdk-pixbuf-2.0 build/{nice_filename}.AppDir/usr/lib/x86_64-linux-gnu/')
830     target.command('sudo apt update')
831     for package in ['libc6', 'libglib2.0-0', 'gnome-settings-daemon-schemas', 'librsvg2-common', 'libgdk-pixbuf2.0-0', 'libpango-1.0-0', 'libpangoft2-1.0-0', 'libpangocairo-1.0-0', 'libthai0']:
832         target.command(f'apt download {package}')
833         target.command(f'dpkg-deb -x {package}*.deb {appdir}')
834     target.command(f'glib-compile-schemas {appdir}/usr/share/glib-2.0/schemas')
835     target.command(f'sed -i -e "s|/usr/lib/x86_64-linux-gnu/gdk-pixbuf-.*/.*/loaders/||g" {appdir}/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache')
836     # Stop anything loading from outside the AppImage
837     target.command(f'sed -i -e "s|/usr|/xxx|g" {appdir}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2')
838
839     if internal_name == 'dcpomatic2_disk':
840         target.command(f'mkdir -p {appdir}/usr/share/polkit-1/actions')
841         target.command(f'cp {target.directory}/share/polkit-1/actions/com.dcpomatic.write-drive.policy {appdir}/usr/share/polkit-1/actions')
842
843     with open(f'{appdir}/AppRun', 'w') as f:
844         print('#!/bin/bash', file=f)
845         print('export PATH=$APPDIR/usr/bin:$PATH', file=f)
846         print('export XDG_DATA_DIRS="$APPDIR/usr/share/:/usr/share/:$XDG_DATA_DIRS"', file=f)
847         print('export GDK_PIXBUF_MODULEDIR=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders/ )', file=f)
848         print('export GDK_PIXBUF_MODULE_FILE=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache )', file=f)
849         print('export LD_LIBRARY_PATH=$GDK_PIXBUF_MODULEDIR:$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu', file=f)
850         print(f'"$APPDIR"/usr/bin/{internal_name} $@', file=f)
851     target.command(f'chmod a+rx {appdir}/AppRun')
852     with open(f'{appdir}/{internal_name}.desktop', 'w') as f:
853         print('[Desktop Entry]', file=f)
854         print('Type=Application', file=f)
855         print('Categories=AudioVideo;', file=f)
856         print(f'Name={nice_name}', file=f)
857         print(f'Icon={internal_name}', file=f)
858     target.command(f'cp graphics/linux/256/{internal_name}.png {appdir}')
859     target.command(f'linuxdeploy-x86_64.AppImage --appdir {appdir}')
860     target.command(f'appimagetool-x86_64.AppImage {appdir}')
861     target.command(f'mv {nice_filename}-x86_64.AppImage build/{nice_filename}-{version}-x86_64.AppImage')
862     return os.path.abspath(f'build/{nice_filename}-{version}-x86_64.AppImage')
863
864 def package(target, version, options):
865     """version: DCP-o-matic version string"""
866     if target.platform == 'windows':
867         return package_windows(target)
868     elif target.platform == 'linux':
869         if target.detail == 'appimage':
870             out = []
871             out.append(make_appimage(target, 'DCP-o-matic', 'dcpomatic2', version, ('dcpomatic2_map', 'dcpomatic2_cli')))
872             out.append(make_appimage(target, 'DCP-o-matic Player', 'dcpomatic2_player', version))
873             out.append(make_appimage(target, 'DCP-o-matic Playlist Editor', 'dcpomatic2_playlist', version))
874             out.append(make_appimage(target, 'DCP-o-matic KDM Creator', 'dcpomatic2_kdm', version))
875             out.append(make_appimage(target, 'DCP-o-matic Batch Converter', 'dcpomatic2_batch', version))
876             out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
877             out.append(make_appimage(target, 'DCP-o-matic Combiner', 'dcpomatic2_combiner', version))
878             out.append(make_appimage(target, 'DCP-o-matic Editor', 'dcpomatic2_editor', version))
879             out.append(make_appimage(target, 'DCP-o-matic Verifier', 'dcpomatic2_verifier', version))
880             return out
881         else:
882             if target.bits == 32:
883                 cpu = 'i386'
884             else:
885                 cpu = 'amd64'
886
887             if target.distro == 'debian' or target.distro == 'ubuntu':
888                 return package_debian(target, cpu, version, options)
889             elif target.distro == 'centos' or target.distro == 'fedora' or target.distro == 'mageia':
890                 return package_rpm(target, cpu, version, options)
891     elif target.platform == 'osx':
892         archs = '-a ' + ' -a '.join(f'{t.arch}/{t.deployment}' for t in target.sub_targets)
893         cmd = 'bash platform/osx/make_dmg.sh -e %s -r %s -i %s -p %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password, archs)
894         if 'part' in options:
895             cmd += ' -b ' + options['part']
896         if options['variant']:
897             cmd += ' -v ' + options['variant']
898         target.command(cmd)
899         return glob.glob('build/platform/osx/' + dmg_prefix(options['variant']) + '*.dmg')
900     elif target.platform == 'docker':
901         shutil.copyfile(target.deb, 'build/platform/docker')
902         f = open('build/platform/docker/Dockerfile', 'w')
903         print('FROM debian:jessie', file=f)
904         print('MAINTAINER carl@dcpomatic.com', file=f)
905         print('ADD build/platform/docker/dcpomatic_%s-1_amd64.deb /tmp' % (version, version), file=f)
906         print('RUN apt-get -o Acquire:http::Timeout="5" update; exit 0', file=f)
907         print('RUN dpkg -i /tmp/dcpomatic_*.deb; exit 0', file=f)
908         print('RUN apt-get -y -f install', file=f)
909         print('RUN apt-get clean', file=f)
910         print('EXPOSE 6192', file=f)
911         print('CMD ["/usr/bin/dcpomatic2_server_cli", "--verbose"]', file=f)
912         f.close()
913         target.command('docker build build/platform/docker -t dcpomatic-server:%s' % version)
914         target.command('docker save dcpomatic-server:%s -o dcpomatic-server-%s-docker.tar' % (version, version))
915     elif target.platform == 'flatpak':
916         target.command('%s build-bundle build/platform/repo build/dcpomatic_%s.flatpak com.dcpomatic.DCP-o-matic' % (target.flatpak(), version))
917         return os.path.abspath('build/dcpomatic_%s.flatpak' % version)
918
919 def make_pot(target):
920     target.command('./waf pot')
921     return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
922             os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
923             os.path.abspath('build/src/tools/dcpomatic.pot')]
924
925 def make_manual(target):
926     target.command('make -C doc/manual LIBDCP=../../../libdcp')
927     os.chdir('doc/manual')
928     target.command('pdflatex colour.tex')
929     return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
930
931 def test(target, options, test):
932     target.set('LC_ALL', 'C')
933     if target.platform == 'windows':
934         cmd = 'run\\tests '
935     else:
936         cmd = 'run/tests --check --log_level=test_suite '
937     if target.debug:
938         cmd += '--backtrace '
939     if test is not None:
940         cmd += '-t %s' % test
941     target.command(cmd)