b82e0ad7751a4a59248a25a724cf21534bf66150
[dcpomatic.git] / cscript
1 import glob
2 import shutil
3 import os
4
5 def dependencies(target):
6     return (('ffmpeg-cdist', 'b1219246a0cce9a4b916669d506bb33c925225c3'),
7             ('libdcp', '658695856029c7ae80e3556d07a1a5cb1b51cf1d'))
8
9 def build(target):
10     cmd = './waf configure --prefix=%s' % target.work_dir_cscript()
11     if target.platform == 'windows':
12         cmd += ' --target-windows'
13     elif target.platform == 'linux':
14         cmd += ' --static'
15     target.command(cmd)
16
17     target.command('./waf')
18
19     if target.platform == 'linux' or target.platform == 'osx':
20         target.command('./waf install')
21
22
23 def package(target, version):
24     if target.platform == 'windows':
25         shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
26         target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
27         target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
28         target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.work_dir_cscript(), target.bits))
29         target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
30         target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
31         target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
32         return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
33     elif target.platform == 'linux':
34         if target.bits == 32:
35             cpu = 'i386'
36         else:
37             cpu = 'amd64'
38
39         shutil.copyfile('platform/linux/control-%s-%d' % (target.version, target.bits), 'debian/control')
40         target.command('./waf dist')
41         f = open('debian/files', 'w')
42         print >>f,'dcpomatic_%s-1_%s.deb video extra' % (version, cpu)
43         shutil.rmtree('build/deb', ignore_errors=True)
44
45         os.makedirs('build/deb')
46         os.chdir('build/deb')
47         shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
48         target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
49         os.chdir('dcpomatic-%s' % version)
50         target.command('dch -b -v %s-1 "New upstream release."' % version)
51         target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
52         target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
53         target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
54         target.command('dpkg-buildpackage')
55         
56         debs = []
57         for p in glob.glob('../*.deb'):
58             debs.append(os.path.abspath(p))
59
60         return debs
61     elif target.platform == 'osx':
62         target.command('bash platform/osx/make_dmg.sh %s' % target.work_dir_cscript())
63         return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
64
65 def make_pot(target):
66     target.command('./waf pot')
67     return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
68             os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
69             os.path.abspath('build/src/tools/dcpomatic.pot')]
70
71 def make_manual(target):
72     os.chdir('doc/manual')
73     target.command('make')
74     target.command('pdflatex colour.tex')
75     return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]