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