Bump version.
[libdcp.git] / wscript
1 import subprocess
2 import os
3
4 APPNAME = 'libdcp'
5 VERSION = '0.05pre'
6
7 def options(opt):
8     opt.load('compiler_cxx')
9
10 def configure(conf):
11     conf.load('compiler_cxx')
12     conf.env.append_value('CXXFLAGS', ['-Wall', '-Werror', '-Wextra', '-Wno-unused-result', '-O2', '-D_FILE_OFFSET_BITS=64'])
13     conf.env.append_value('CXXFLAGS', ['-DLIBDCP_VERSION="%s"' % VERSION])
14
15     conf.check_cfg(package = 'openssl', args = '--cflags --libs', uselib_store = 'OPENSSL', mandatory = True)
16     conf.check_cfg(package = 'sigc++-2.0', args = '--cflags --libs', uselib_store = 'SIGC++', mandatory = True)
17     
18     conf.check_cxx(fragment = """
19                               #include <boost/filesystem.hpp>\n
20                               int main() { boost::filesystem::copy_file ("a", "b"); }\n
21                               """,
22                    msg = 'Checking for boost filesystem library',
23                    libpath = '/usr/local/lib',
24                    lib = ['boost_filesystem', 'boost_system'],
25                    uselib_store = 'BOOST_FILESYSTEM')
26
27     conf.recurse('test')
28     conf.recurse('asdcplib')
29
30 def build(bld):
31     create_version_cc(VERSION)
32
33     bld(source = 'libdcp.pc.in',
34         version = VERSION,
35         includedir = '%s/include' % bld.env.PREFIX,
36         libs = "-L${libdir} -ldcp -lkumu-libdcp -lasdcp-libdcp",
37         install_path = '${LIBDIR}/pkgconfig')
38
39     bld.recurse('src')
40     bld.recurse('test')
41     bld.recurse('asdcplib')
42
43 def dist(ctx):
44     ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~'
45
46 def create_version_cc(version):
47     if os.path.exists('.git'):
48         cmd = "LANG= git log --abbrev HEAD^..HEAD ."
49         output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
50         o = output[0].decode('utf-8')
51         commit = o.replace ("commit ", "")[0:10]
52     else:
53         commit = "release"
54
55     try:
56         text =  '#include "version.h"\n'
57         text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
58         text += 'char const * libdcp::version = \"%s\";\n' % version
59         print('Writing version information to src/version.cc')
60         o = open('src/version.cc', 'w')
61         o.write(text)
62         o.close()
63     except IOError:
64         print('Could not open src/version.cc for writing\n')
65         sys.exit(-1)