Make variable to say whether we were built with debug or not.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 12:41:59 +0000 (12:41 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 12:41:59 +0000 (12:41 +0000)
src/version.h
wscript

index 7fd9dc25d1a3a885261fadf77d940ac675516a2e..52abd13a746e3864daa886ba1d1101ac6c3d4092 100644 (file)
@@ -3,5 +3,6 @@ namespace libdcp {
 
 extern char const * version;
 extern char const * git_commit;
+extern bool built_with_debug;
        
 }
diff --git a/wscript b/wscript
index 06facf2697b404c2d5ced1d87904ac45e4c8273c..7412271e3755a3c59d55f951c1f79fe08769787b 100644 (file)
--- a/wscript
+++ b/wscript
@@ -20,6 +20,7 @@ def configure(conf):
     conf.env.TARGET_WINDOWS = conf.options.target_windows
     conf.env.STATIC_OPENJPEG = conf.options.static_openjpeg
     conf.env.STATIC_LIBDCP = conf.options.static_libdcp
+    conf.env.ENABLE_DEBUG = conf.options.enable_debug
 
     if conf.options.target_windows:
         conf.env.append_value('CXXFLAGS', '-DLIBDCP_WINDOWS')
@@ -76,7 +77,7 @@ def configure(conf):
     conf.recurse('asdcplib')
 
 def build(bld):
-    create_version_cc(VERSION)
+    create_version_cc(bld, VERSION)
 
     if bld.env.TARGET_WINDOWS:
         boost_lib_suffix = '-mt'
@@ -100,7 +101,7 @@ def build(bld):
 def dist(ctx):
     ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__'
 
-def create_version_cc(version):
+def create_version_cc(bld, version):
     if os.path.exists('.git'):
         cmd = "LANG= git log --abbrev HEAD^..HEAD ."
         output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
@@ -113,6 +114,11 @@ def create_version_cc(version):
         text =  '#include "version.h"\n'
         text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
         text += 'char const * libdcp::version = \"%s\";\n' % version
+        if bld.env.ENABLE_DEBUG:
+            debug_string = 'true'
+        else:
+            debug_string = 'false'
+        text += 'bool const built_with_debug = %s;\n' % debug_string
         print('Writing version information to src/version.cc')
         o = open('src/version.cc', 'w')
         o.write(text)