Add versioning; tweak libdcp version reporting; make makedcp more useful for testing.
[dcpomatic.git] / wscript
diff --git a/wscript b/wscript
index 9e550eb2ec37dd486d61b90c15b2bd03a749dbbd..ec6f76824cdcf924810f5cadf86ba306a771f98e 100644 (file)
--- a/wscript
+++ b/wscript
@@ -1,11 +1,14 @@
+import subprocess
+
 APPNAME = 'dvdomatic'
-VERSION = '0.26'
+VERSION = '0.27pre'
 
 def options(opt):
     opt.load('compiler_cxx')
     opt.add_option('--debug-hash', action='store_true', default = False, help = 'print hashes of data at various points')
     opt.add_option('--enable-debug', action='store_true', default = False, help = 'build with debugging information and without optimisation')
     opt.add_option('--disable-gui', action='store_true', default = False, help = 'disable building of GUI tools')
+    opt.add_option('--ffmpeg-083', action='store_true', default = False, help = 'Use FFmpeg version in Ubuntu 12.04')
 
 def configure(conf):
     conf.load('compiler_cxx')
@@ -20,6 +23,9 @@ def configure(conf):
     else:
         conf.env.append_value('CXXFLAGS', '-O3')
 
+    if conf.options.ffmpeg_083:
+        conf.env.append_value('CXXFLAGS', '-DDVDOMATIC_FFMPEG_0_8_3')
+
     conf.env.DISABLE_GUI = conf.options.disable_gui
 
     conf.check_cfg(package = 'sigc++-2.0', args = '--cflags --libs', uselib_store = 'SIGC++', mandatory = True)
@@ -28,7 +34,6 @@ def configure(conf):
     conf.check_cfg(package = 'libavcodec', args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = True)
     conf.check_cfg(package = 'libavutil', args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = True)
     conf.check_cfg(package = 'libswscale', args = '--cflags --libs', uselib_store = 'SWSCALE', mandatory = True)
-    conf.check_cfg(package = 'libswresample', args = '--cflags --libs', uselib_store = 'SWRESAMPLE', mandatory = True)
     conf.check_cfg(package = 'libpostproc', args = '--cflags --libs', uselib_store = 'POSTPROC', mandatory = True)
     conf.check_cfg(package = 'sndfile', args = '--cflags --libs', uselib_store = 'SNDFILE', mandatory = True)
     conf.check_cfg(package = 'libdcp', args = '--cflags --libs', uselib_store = 'DCP', mandatory = True)
@@ -64,6 +69,8 @@ def configure(conf):
     conf.recurse('test')
 
 def build(bld):
+    create_version_cc(VERSION)
+
     bld.recurse('src')
     bld.recurse('test')
 
@@ -78,6 +85,23 @@ def build(bld):
     for r in ['22x22', '32x32', '48x48', '64x64', '128x128']:
         bld.install_files('${PREFIX}/share/icons/hicolor/%s/apps' % r, 'icons/%s/dvdomatic.png' % r)
 
-
 def dist(ctx):
     ctx.excl = 'TODO core *~ src/gtk/*~ src/lib/*~ .waf* build .git'
+
+def create_version_cc(version):
+    cmd = "LANG= git log --abbrev HEAD^..HEAD ."
+    output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
+    o = output[0].decode('utf-8')
+    commit = o.replace ("commit ", "")[0:10]
+
+    try:
+        text =  '#include "version.h"\n'
+        text += 'char const * dvdomatic_git_commit = \"%s\";\n' % commit
+        text += 'char const * dvdomatic_version = \"%s\";\n' % version
+        print('Writing version information to src/lib/version.cc')
+        o = open('src/lib/version.cc', 'w')
+        o.write(text)
+        o.close()
+    except IOError:
+        print('Could not open src/lib/version.cc for writing\n')
+        sys.exit(-1)