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