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