Version file building stuff.
authorDavid Robillard <d@drobilla.net>
Thu, 26 Feb 2009 02:24:16 +0000 (02:24 +0000)
committerDavid Robillard <d@drobilla.net>
Thu, 26 Feb 2009 02:24:16 +0000 (02:24 +0000)
Ardour should now compile from a fresh svn checkout using only waf.

git-svn-id: svn://localhost/ardour2/branches/3.0@4671 d708f5d6-7413-0410-9779-e7cbd77b26cf

autowaf.py
gtk2_ardour/wscript
libs/ardour/wscript
libs/gtkmm2ext/wscript
libs/midi++2/wscript
libs/pbd/wscript
libs/taglib/wscript
wscript

index b61a39f4bfac3a3cbd39c1c8e82d0b6b68a5ad1a..8dc9efffc3693c53a71c8023163160f6bf5998e1 100644 (file)
@@ -338,6 +338,38 @@ def build_dox(bld, name, version, srcdir, blddir):
        out1.argv = [os.path.abspath(doc_dir) + '/reference.doxygen']
        out1.command_is_external = True
 
+# Version code file generation
+def build_version_files(header_path, source_path, domain, major, minor, micro):
+       header_path = os.path.abspath(header_path)
+       source_path = os.path.abspath(source_path)
+       text  = "int " + domain + "_major_version = " + str(major) + ";\n"
+       text += "int " + domain + "_minor_version = " + str(minor) + ";\n"
+       text += "int " + domain + "_micro_version = " + str(micro) + ";\n"
+       try:
+               o = file(source_path, 'w')
+               o.write(text)
+               o.close()
+       except IOError:
+               print "Could not open", source_path, " for writing\n"
+               sys.exit(-1)
+
+       text  = "#ifndef __" + domain + "_version_h__\n"
+       text += "#define __" + domain + "_version_h__\n"
+       text += "extern const char* " + domain + "_revision;\n"
+       text += "extern int " + domain + "_major_version;\n"
+       text += "extern int " + domain + "_minor_version;\n"
+       text += "extern int " + domain + "_micro_version;\n"
+       text += "#endif /* __" + domain + "_version_h__ */\n"
+       try:
+               o = file(header_path, 'w')
+               o.write(text)
+               o.close()
+       except IOError:
+               print "Could not open", header_path, " for writing\n"
+               sys.exit(-1)
+               
+       return None
+
 def shutdown():
        # This isn't really correct (for packaging), but people asking is annoying
        if Options.commands['install']:
index f1a90deaf627f9c6fed28f9fa91c5286830a923c..438159876164301c2106e7d6e1ecffe500a5f97d 100644 (file)
@@ -3,7 +3,10 @@ import autowaf
 import os
 
 # Version of this package (even if built as a child)
-GTK2_ARDOUR_VERSION = '3.0.0'
+MAJOR = '1'
+MINOR = '0'
+MICRO = '2'
+GTK2_ARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
 
 # Variables for 'waf dist'
 APPNAME = 'gtk2_ardour'
@@ -13,10 +16,14 @@ VERSION = GTK2_ARDOUR_VERSION
 srcdir = '.'
 blddir = 'build'
 
+path_prefix = 'gtk2_ardour/'
+
 def set_options(opt):
        autowaf.set_options(opt)
 
 def configure(conf):
+       autowaf.build_version_files(path_prefix+'version.h', path_prefix+'version.cc',
+                       'gtk2_ardour', MAJOR, MINOR, MICRO)
        autowaf.configure(conf)
        autowaf.check_tool(conf, 'compiler_cxx')
        
index e48632c6a02681775f7acfb9a6c171748771a930..e2b3200fd551a6d1e75e6db7886ffeb67d958d83 100644 (file)
@@ -3,7 +3,10 @@ import autowaf
 import os
 
 # Version of this package (even if built as a child)
-LIBARDOUR_VERSION = '3.0.0'
+MAJOR = '3'
+MINOR = '0'
+MICRO = '0'
+LIBARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
 
 # Library version (UNIX style major, minor, micro)
 # major increment <=> incompatible changes
@@ -19,6 +22,8 @@ VERSION = LIBARDOUR_VERSION
 srcdir = '.'
 blddir = 'build'
 
+path_prefix = 'libs/ardour/'
+
 def set_options(opt):
        autowaf.set_options(opt)
 
@@ -29,6 +34,8 @@ def check_header_and_define(conf, header, define):
                conf.env.append_value('CXXFLAGS', '-D' + define)
        
 def configure(conf):
+       autowaf.build_version_files(path_prefix+'ardour/version.h', path_prefix+'version.cc',
+                       'libardour3', MAJOR, MINOR, MICRO)
        autowaf.configure(conf)
        autowaf.check_tool(conf, 'compiler_cxx')
        autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', atleast_version='0.3.2')
index 78bdd69dabeb9ec568a258a0090b5bbbc02b1f20..2a5532b9ac1aaeb9a64cb35835ca7065f68fc69a 100644 (file)
@@ -3,7 +3,10 @@ import autowaf
 import os
 
 # Version of this package (even if built as a child)
-GTKMM2EXT_VERSION = '0.0.0'
+MAJOR = '0'
+MINOR = '8'
+MICRO = '3'
+GTKMM2EXT_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
 
 # Library version (UNIX style major, minor, micro)
 # major increment <=> incompatible changes
@@ -19,10 +22,14 @@ VERSION = GTKMM2EXT_VERSION
 srcdir = '.'
 blddir = 'build'
 
+path_prefix = 'libs/gtkmm2ext/'
+
 def set_options(opt):
        autowaf.set_options(opt)
 
 def configure(conf):
+       autowaf.build_version_files(path_prefix+'gtkmm2ext/version.h', path_prefix+'version.cc',
+                       'libgtkmm2ext', MAJOR, MINOR, MICRO)
        autowaf.configure(conf)
        autowaf.check_tool(conf, 'compiler_cxx')
        autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM', atleast_version='2.8')
index 43ec395b4b92c4aee01db69aa1c0f176eab3ac9d..8629d2c4c32a3c2e84720cfce1b951433b049b85 100644 (file)
@@ -2,7 +2,10 @@
 import autowaf
 
 # Version of this package (even if built as a child)
-LIBMIDIPP_VERSION = '0.0.0'
+MAJOR = '2'
+MINOR = '1'
+MICRO = '1'
+LIBMIDIPP_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
 
 # Library version (UNIX style major, minor, micro)
 # major increment <=> incompatible changes
@@ -18,10 +21,14 @@ VERSION = LIBMIDIPP_VERSION
 srcdir = '.'
 blddir = 'build'
 
+path_prefix = 'libs/midi++2/'
+
 def set_options(opt):
        autowaf.set_options(opt)
 
 def configure(conf):
+       autowaf.build_version_files(path_prefix+'midi++/version.h', path_prefix+'version.cc',
+                       'midipp', MAJOR, MINOR, MICRO)
        autowaf.configure(conf)
        autowaf.check_tool(conf, 'compiler_cxx')
        autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.109.0')
index a5239566173ec01744cd524cb8df9157b4f84348..cf708c12b619af5878bba663355fd6f850dfde9b 100644 (file)
@@ -2,7 +2,10 @@
 import autowaf
 
 # Version of this package (even if built as a child)
-LIBPBD_VERSION = '0.0.0'
+MAJOR = '4'
+MINOR = '1'
+MICRO = '0'
+LIBPBD_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
 
 # Library version (UNIX style major, minor, micro)
 # major increment <=> incompatible changes
@@ -18,10 +21,14 @@ VERSION = LIBPBD_VERSION
 srcdir = '.'
 blddir = 'build'
 
+path_prefix = 'libs/pbd/'
+
 def set_options(opt):
        autowaf.set_options(opt)
 
 def configure(conf):
+       autowaf.build_version_files(path_prefix+'pbd/version.h', path_prefix+'version.cc',
+                       'libpbd', MAJOR, MINOR, MICRO)
        autowaf.configure(conf)
        autowaf.check_tool(conf, 'compiler_cxx')
        autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
index 12a707ab32fb8d506d522e7b5b1df7402784f9bd..e8fd74a7d5b41657ecfd61e6a88907b4ee6ab946 100644 (file)
@@ -19,6 +19,8 @@ VERSION = LIBTAGLIB_VERSION
 srcdir = '.'
 blddir = 'build'
 
+path_prefix = 'libs/taglib/'
+
 def set_options(opt):
        autowaf.set_options(opt)
 
@@ -29,25 +31,24 @@ def configure(conf):
 def build(bld):
        # Library
        obj = bld.new_task_gen('cxx', 'shlib')
-       prefix = 'libs/taglib/'
-       sources = glob.glob(prefix + 'taglib/*.cpp')
-       sources += glob.glob(prefix + 'taglib/flac/*.cpp')
-       sources += glob.glob(prefix + 'taglib/mpc/*.cpp')
-       sources += glob.glob(prefix + 'taglib/mpeg/*.cpp')
-       sources += glob.glob(prefix + 'taglib/mpeg/id3v1/*.cpp')
-       sources += glob.glob(prefix + 'taglib/mpeg/id3v2/*.cpp')
-       sources += glob.glob(prefix + 'taglib/mpeg/id3v2/frames/*.cpp')
-       sources += glob.glob(prefix + 'taglib/ogg/*.cpp')
-       sources += glob.glob(prefix + 'taglib/ogg/vorbis/*.cpp')
-       sources += glob.glob(prefix + 'taglib/ogg/speex/*.cpp')
-       sources += glob.glob(prefix + 'taglib/ogg/flac/*.cpp')
-       sources += glob.glob(prefix + 'taglib/trueaudio/*.cpp')
-       sources += glob.glob(prefix + 'taglib/wavpack/*.cpp')
-       sources += glob.glob(prefix + 'taglib/ape/*.cpp')
-       sources += glob.glob(prefix + 'taglib/toolkit/*.cpp')
+       sources = glob.glob(path_prefix + 'taglib/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/flac/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/mpc/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/mpeg/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/mpeg/id3v1/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/mpeg/id3v2/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/mpeg/id3v2/frames/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/ogg/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/ogg/vorbis/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/ogg/speex/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/ogg/flac/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/trueaudio/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/wavpack/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/ape/*.cpp')
+       sources += glob.glob(path_prefix + 'taglib/toolkit/*.cpp')
        obj.source = []
        for i in sources:
-               obj.source += [ i.replace(prefix, '') ]
+               obj.source += [ i.replace(path_prefix, '') ]
        
        include_dirs = '''
                taglib
diff --git a/wscript b/wscript
index d54966fe49ac36ed618c65484b898a6f22df3ec2..0ac7049d415ad781cdebb5cb32cace698e969aaa 100644 (file)
--- a/wscript
+++ b/wscript
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 import autowaf
+import os
+import commands
 
 # Variables for 'waf dist'
 VERSION = '3.0pre0'
@@ -23,6 +25,53 @@ children = [
        'gtk2_ardour'
 ]
 
+
+# Version stuff
+
+def fetch_svn_revision (path):
+       cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
+       return commands.getoutput(cmd)
+
+def fetch_git_revision (path):
+       cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
+       output = commands.getoutput(cmd).splitlines()
+       rev = output[0].replace ("commit", "git")[0:10]
+       for line in output:
+               try:
+                       if "git-svn-id" in line:
+                               line = line.split('@')[1].split(' ')
+                               rev = line[0]
+               except:
+                       pass
+       return rev
+
+def create_stored_revision():
+       rev = ""
+       if os.path.exists('.svn'):
+               rev = fetch_svn_revision('.');
+       elif os.path.exists('.git'):
+               rev = fetch_git_revision('.');
+       elif os.path.exists('libs/ardour/svn_revision.cc'):
+               print "Using packaged svn revision"
+               return
+       else:
+               print "Missing libs/ardour/svn_revision.cc.  Blame the packager."
+               sys.exit(-1)
+
+       try:
+               text =  '#include <ardour/svn_revision.h>\n'
+               text += 'namespace ARDOUR { extern const char* svn_revision = \"' + rev + '\"; }\n'
+               print 'Writing svn revision info to libs/ardour/svn_revision.cc\n'
+               o = file('libs/ardour/svn_revision.cc', 'w')
+               o.write(text)
+               o.close()
+       except IOError:
+               print 'Could not open libs/ardour/svn_revision.cc for writing\n'
+               sys.exit(-1)
+
+
+# Waf stages
+
 def set_options(opt):
        autowaf.set_options(opt)
        for i in children:
@@ -33,6 +82,7 @@ def sub_config_and_use(conf, name, has_objects = True):
        autowaf.set_local_lib(conf, name, has_objects)
 
 def configure(conf):
+       create_stored_revision()
        autowaf.set_recursive()
        autowaf.configure(conf)
        autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')