Fix cscript libdcp dep to match wscript.
[dcpomatic.git] / cscript
1 import glob
2 import shutil
3 import os
4
5 deb_build_depends = {'debhelper': '8.0.0',
6                      'python': '2.7.3',
7                      'g++': '4:4.6.3',
8                      'pkg-config': '0.26',
9                      'libssh-dev': '0.5.2',
10                      'libboost-filesystem-dev': '1.46.0',
11                      'libboost-thread-dev': '1.46.0',
12                      'libsndfile1-dev': '1.0.25',
13                      'libmagick++-dev': '8:6.6.9.7',
14                      'libgtk2.0-dev': '2.24.10'}
15
16 deb_depends = dict()
17
18 deb_depends['12.04'] = {'libc6': '2.15',
19                         'libssh-4': '0.5.2',
20                         'libboost-filesystem1.46.1': '1.46.1',
21                         'libboost-thread1.46.1': '1.46.1',
22                         'libsndfile1': '1.0.25',
23                         'libmagick++4': '8:6.6.9.7',
24                         'libxml++2.6-2': '2.34.1',
25                         'libgtk2.0-0': '2.24.10',
26                         'libxmlsec1': '1.2.14-1.2build1',
27                         'libxmlsec1-openssl': '1.2.14-1.2build1',
28                         'libboost-date-time1.46.1': '1.46.1',
29                         'libcurl3': '7.22.0-3ubuntu4',
30                         'libzip2': '0.10-1ubuntu1'}
31
32 deb_depends['12.10'] = {'libc6': '2.15',
33                         'libssh-4': '0.5.2',
34                         'libboost-filesystem1.49.0': '1.49.0',
35                         'libboost-thread1.49.0': '1.49.0',
36                         'libsndfile1': '1.0.25',
37                         'libmagick++5': '8:6.7.7.10',
38                         'libxml++2.6-2': '2.34.2',
39                         'libgtk2.0-0': '2.24.13',
40                         'libxmlsec1': '1.2.18-2',
41                         'libxmlsec1-openssl': '1.2.18-2',
42                         'libboost-date-time1.49.0': '1.49.0',
43                         'libcurl3': '7.27.0-1ubuntu1',
44                         'libzip2': '0.10.1-1.1'}
45
46 deb_depends['13.04'] = {'libc6': '2.15',
47                         'libssh-4': '0.5.2',
48                         'libboost-filesystem1.49.0': '1.49.0',
49                         'libboost-thread1.49.0': '1.49.0',
50                         'libsndfile1': '1.0.25',
51                         'libmagick++5': '8:6.7.7.10',
52                         'libxml++2.6-2': '2.34.2',
53                         'libgtk2.0-0': '2.24.13',
54                         'libxmlsec1': '1.2.18-2',
55                         'libxmlsec1-openssl': '1.2.18-2',
56                         'libboost-date-time1.49.0': '1.49.0',
57                         'libcurl3': '7.29.0-1ubuntu3',
58                         'libzip2': '0.10.1-1.1'}
59
60 deb_depends['13.10'] = {'libc6': '2.17-93',
61                         'libssh-4': '0.5.4',
62                         'libboost-filesystem1.53.0': '1.53.0',
63                         'libboost-thread1.53.0': '1.53.0',
64                         'libsndfile1': '1.0.25',
65                         'libmagick++5': '8:6.7.7.10',
66                         'libxml++2.6-2': '2.36.0',
67                         'libgtk2.0-0': '2.24.20',
68                         'libxmlsec1': '1.2.18-2',
69                         'libxmlsec1-openssl': '1.2.18-2',
70                         'libboost-date-time1.49.0': '1.49.0',
71                         'libcurl3': '7.29.0-1ubuntu3',
72                         'libzip2': '0.10.1-1.1'}
73
74 deb_depends['14.04'] = {'libc6': '2.19-0ubuntu6',
75                         'libssh-4': '0.6.1-0ubuntu3',
76                         'libboost-filesystem1.54.0': '1.54.0-4ubuntu3',
77                         'libboost-thread1.54.0': '1.54.0-4ubuntu3',
78                         'libsndfile1': '1.0.25-7ubuntu2',
79                         'libmagick++5': '8:6.7.7.10-6ubuntu3',
80                         'libxml++2.6-2': '2.36.0-2ubuntu1',
81                         'libgtk2.0-0': '2.24.23-0ubuntu1',
82                         'libxmlsec1': '1.2.18-2ubuntu1',
83                         'libxmlsec1-openssl': '1.2.18-2ubuntu1',
84                         'libboost-date-time1.54.0': '1.54.0-4ubuntu3',
85                         'libcurl3': '7.35.0-1ubuntu2',
86                         'libzip2': '0.10.1-1.2'}
87
88 deb_depends['7'] = {'libc6': '2.13',
89                     'libssh-4': '0.5.4',
90                     'libboost-filesystem1.49.0': '1.49.0',
91                     'libboost-thread1.49.0': '1.49.0',
92                     'libsndfile1': '1.0.25',
93                     'libmagick++5': '8:6.7.7.10',
94                     'libxml++2.6-2': '2.34.2',
95                     'libgtk2.0-0': '2.24.10',
96                     'libxmlsec1': '1.2.18',
97                     'libboost-date-time1.49.0': '1.49.0',
98                     'libxmlsec1-openssl': '1.2.18',
99                     'libcurl3': '7.26.0',
100                     'libzip2': '0.10.1'}
101
102 def packages(name, packages, f):
103     s = '%s: ' % name
104     for p in packages:
105         s += str(p) + ', '
106     print >>f,s[:-2]
107
108 def make_control(debian_version, bits, filename, debug):
109     f = open(filename, 'w')
110     print >>f,'Source: dcpomatic'
111     print >>f,'Section: video'
112     print >>f,'Priority: extra'
113     print >>f,'Maintainer: Carl Hetherington <carl@dcpomatic.com>'
114     packages('Build-Depends', deb_build_depends, f)
115     print >>f,'Standards-Version: 3.9.3'
116     print >>f,'Homepage: http://dcpomatic.com/'
117     print >>f,''
118     print >>f,'Package: dcpomatic'
119     if bits == 32:
120         print >>f,'Architecture: i386'
121     else:
122         print >>f,'Architecture: amd64'
123
124     packages('Depends', deb_depends[debian_version], f)
125
126     print >>f,'Description: Generator of Digital Cinema Packages (DCPs)'
127     print >>f,'  DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio'
128     print >>f,'  files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant'
129     print >>f,'  digital projectors.'
130
131     if debug:
132         print >>f,''
133         print >>f,'Package: dcpomatic-dbg'
134         if bits == 32:
135             print >>f,'Architecture: i386'
136         else:
137             print >>f,'Architecture: amd64'
138         print >>f,'Section: debug'
139         print >>f,'Priority: extra'
140         packages('Depends', deb_depends[debian_version], f)
141         print >>f,'Description: debugging symbols for dcpomatic'
142         print >>f,'  This package contains the debugging symbols for dcpomatic.'
143         print >>f,''
144
145 def dependencies(target):
146     return (('ffmpeg-cdist', 'bba68a5'),
147             ('libdcp', 'v0.94.0'))
148
149 def build(target, options):
150     cmd = './waf configure --prefix=%s' % target.work_dir_cscript()
151     if target.platform == 'windows':
152         cmd += ' --target-windows'
153     elif target.platform == 'linux':
154         if target.distro == 'debian' or target.distro == 'ubuntu':
155             cmd += ' --target-debian'
156         elif target.distro == 'centos':
157             cmd += ' --target-centos'
158
159     target.command(cmd)
160     target.command('./waf')
161
162     if target.platform == 'linux' or target.platform == 'osx':
163         target.command('./waf install')
164
165 def package_windows(target):
166     shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
167     target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
168     target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
169     target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.work_dir_cscript(), target.bits))
170     target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
171     target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
172     target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
173     return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
174
175 def package_debian(target, cpu, version):
176     make_control(target.version, target.bits, 'debian/control', target.debug)
177     target.command('./waf dist')
178     f = open('debian/files', 'w')
179     print >>f,'dcpomatic_%s-1_%s.deb video extra' % (version, cpu)
180     shutil.rmtree('build/deb', ignore_errors=True)
181     
182     os.makedirs('build/deb')
183     os.chdir('build/deb')
184     shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
185     target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
186     os.chdir('dcpomatic-%s' % version)
187     target.command('dch -b -v %s-1 "New upstream release."' % version)
188     target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
189     target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
190     target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
191     target.command('dpkg-buildpackage')
192     
193     debs = []
194     for p in glob.glob('../*.deb'):
195         debs.append(os.path.abspath(p))
196     
197     return debs
198
199 def package_centos(target, cpu, version):
200     os.makedirs('%s/rpmbuild/BUILD' % target.work_dir_cdist())
201     os.makedirs('%s/rpmbuild/RPMS' % target.work_dir_cdist())
202     os.makedirs('%s/rpmbuild/SOURCES' % target.work_dir_cdist())
203     os.makedirs('%s/rpmbuild/SPECS' % target.work_dir_cdist())
204     os.makedirs('%s/rpmbuild/SRPMS' % target.work_dir_cdist())
205
206     f = open('%s/.rpmmacros' % target.dir_in_chroot, 'w')
207     print >>f,"%%_topdir %srpmbuild" % target.dir_in_chroot
208     f.close()
209
210     target.command('./waf dist')
211     shutil.copyfile(
212         "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.work_dir_cdist(), version),
213         "%s/rpmbuild/SOURCES/dcpomatic-%s.tar.bz2" % (target.work_dir_cdist(), version)
214         )
215
216     target.command('rpmbuild -bb build/platform/linux/dcpomatic.spec')
217     rpms = []
218
219     if cpu == "amd64":
220         cpu = "x86_64"
221
222     for p in glob.glob('%s/rpmbuild/RPMS/%s/*.rpm' % (target.work_dir_cdist(), cpu)):
223         rpms.append(os.path.abspath(p))
224
225     return rpms
226
227 def package(target, version):
228     if target.platform == 'windows':
229         return package_windows(target)
230     elif target.platform == 'linux':
231         if target.bits == 32:
232             cpu = 'i386'
233         else:   
234             cpu = 'amd64'
235
236         if target.distro == 'debian' or target.distro == 'ubuntu':
237             return package_debian(target, cpu, version)
238         elif target.distro == 'centos':
239             return package_centos(target, cpu, version)
240     elif target.platform == 'osx':
241         target.command('bash platform/osx/make_dmg.sh %s' % target.work_dir_cscript())
242         return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
243
244 def make_pot(target):
245     target.command('./waf pot')
246     return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
247             os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
248             os.path.abspath('build/src/tools/dcpomatic.pot')]
249
250 def make_manual(target):
251     os.chdir('doc/manual')
252     target.command('make')
253     target.command('pdflatex colour.tex')
254     return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
255
256 def test(target):
257     if target.platform != 'windows':
258         target.set('LC_ALL', 'C')
259         target.command('run/tests')