Make build scripts python2/3 agnostic.
authorCarl Hetherington <carl@carlh.net>
Wed, 27 Oct 2010 23:10:27 +0000 (23:10 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 27 Oct 2010 23:10:27 +0000 (23:10 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7931 d708f5d6-7413-0410-9779-e7cbd77b26cf

autowaf.py
gtk2_ardour/wscript
libs/ardour/wscript
libs/gtkmm2ext/wscript
libs/surfaces/wscript
wscript

index 7e8790a2ed6903fb3d1ef604ec2176bb59ae8c79..413a5fa24f529acf3466e66c625076baee3551aa 100644 (file)
@@ -212,7 +212,7 @@ def configure(conf):
        display_msg(conf, "Debuggable build", str(conf.env['DEBUG']))
        display_msg(conf, "Strict compiler flags", str(conf.env['STRICT']))
        display_msg(conf, "Build documentation", str(conf.env['DOCS']))
-       print
+       print()
 
        g_step = 2
        
@@ -340,11 +340,11 @@ def build_version_files(header_path, source_path, domain, major, minor, micro):
        text += "int " + domain + "_minor_version = " + str(minor) + ";\n"
        text += "int " + domain + "_micro_version = " + str(micro) + ";\n"
        try:
-               o = file(source_path, 'w')
+               o = open(source_path, 'w')
                o.write(text)
                o.close()
        except IOError:
-               print "Could not open", source_path, " for writing\n"
+               print("Could not open %s for writing\n", source_path)
                sys.exit(-1)
 
        text  = "#ifndef __" + domain + "_version_h__\n"
@@ -355,11 +355,11 @@ def build_version_files(header_path, source_path, domain, major, minor, micro):
        text += "extern int " + domain + "_micro_version;\n"
        text += "#endif /* __" + domain + "_version_h__ */\n"
        try:
-               o = file(header_path, 'w')
+               o = open(header_path, 'w')
                o.write(text)
                o.close()
        except IOError:
-               print "Could not open", header_path, " for writing\n"
+               print("Could not open %s for writing\n", header_path)
                sys.exit(-1)
                
        return None
@@ -384,12 +384,12 @@ def run_tests(ctx, appname, tests):
                                stdout=lcov_log, stderr=lcov_log)
        except:
                lcov = False
-               print "Failed to run lcov, no coverage report will be generated"
+               print("Failed to run lcov, no coverage report will be generated")
 
 
        # Run all tests
        for i in tests:
-               print
+               print()
                Utils.pprint('BOLD', 'Running %s test %s' % (appname, i))
                if subprocess.call(i) == 0:
                        Utils.pprint('GREEN', 'Passed %s %s' % (appname, i))
@@ -418,7 +418,7 @@ def run_tests(ctx, appname, tests):
        
        lcov_log.close()
 
-       print
+       print()
        Utils.pprint('BOLD', 'Summary:', sep=''),
        if failures == 0:
                Utils.pprint('GREEN', 'All ' + appname + ' tests passed')
@@ -426,7 +426,7 @@ def run_tests(ctx, appname, tests):
                Utils.pprint('RED', str(failures) + ' ' + appname + ' test(s) failed')
 
        Utils.pprint('BOLD', 'Coverage:', sep='')
-       print os.path.abspath('coverage/index.html')
+       print(os.path.abspath('coverage/index.html'))
 
        os.chdir(orig_dir)
 
index c15f5609e25f36e2f4da23e836782d5e593db2a4..e72d02282949141b625dd25efe4d8973a758c734 100644 (file)
@@ -286,7 +286,7 @@ def build(bld):
        obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
        obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
                        os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
-        obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
+       obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
 
        if bld.env['HAVE_SLV2']:
                obj.source += [ 'lv2_plugin_ui.cc' ]
@@ -299,8 +299,8 @@ def build(bld):
                obj.source += [ 'vst_pluginui.cc' ]
                obj.cxxflags += [ '-DVST_SUPPORT' ]
 
-        if bld.env['PHONE_HOME']:
-                obj.cxxflags += [ '-DPHONE_HOME' ]
+       if bld.env['PHONE_HOME']:
+               obj.cxxflags += [ '-DPHONE_HOME' ]
 
        if bld.env['GTKOSX']:
                TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
@@ -344,13 +344,13 @@ def build(bld):
        obj              = bld.new_task_gen('subst')
        obj.source       = 'ardev_common.sh.in'
        obj.target       = 'ardev_common_waf.sh'
-       obj.chmod        = 0755
+       obj.chmod        = 0o755
        obj.dict         = wrapper_subst_dict
 
        obj              = bld.new_task_gen('subst')
        obj.source       = 'ardour.sh.in'
        obj.target       = 'ardour3'
-       obj.chmod        = 0755
+       obj.chmod        = 0o755
        obj.dict         = wrapper_subst_dict
        obj.install_path = bld.env['BINDIR']
 
@@ -392,7 +392,7 @@ def build(bld):
 
        # Set up font substitution dictionary
        for style in ['', 'BOLD', 'ITALIC']:
-               for sizename,points in font_sizes.iteritems():
+               for sizename,points in iter(font_sizes.items()):
                        if (len (style)):
                                key = "_".join (['FONT',style,sizename])
                                fontstyle = " ".join ([basefont,style.lower(),points])
index a2c4898053cb996d5a121ca5c8ea597dab114e8a..14811eed50795f526175bc6449c4cd0b3093aba4 100644 (file)
@@ -208,14 +208,14 @@ def flac_supported():
        cmd = subprocess.Popen ("sndfile-info testfile.flac", 
                                stdout = subprocess.PIPE,
                                stderr = subprocess.STDOUT, shell = True)
-       out = cmd.communicate()[0];
+       out = cmd.communicate()[0].decode('utf-8');
        return re.search ('unknown format', out) == None
 
 def ogg_supported():
        cmd = subprocess.Popen ("sndfile-info testfile.ogg", 
                                stdout = subprocess.PIPE,
                                stderr = subprocess.STDOUT, shell = True)
-       out = cmd.communicate()[0];
+       out = cmd.communicate()[0].decode('utf-8');
        return re.search ('unknown format', out) == None
 
 def set_options(opt):
@@ -293,7 +293,7 @@ def build(bld):
                        os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
        obj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
                        os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
-        obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
+       obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
 
        #obj.source += ' st_stretch.cc st_pitch.cc '
        #obj.uselib += ' SOUNDTOUCH '
index 10d02489064be36bf638c83f502831d500417ce9..0425b6614971790205689a2bc007e76114912299 100644 (file)
@@ -91,7 +91,7 @@ def build(bld):
                                os.path.normpath(bld.env['DATADIRNAME']), 'locale') + '"']
        if bld.env['GTKOSX']:
                obj.source += ['gtkapplication_quartz.mm']
-        else:
+       else:
                 obj.source += ['gtkapplication_x11.c']
 
 def shutdown():
index 2ff22bbfb6b06950235237eb046e7fb4121f6ec6..f9e68f48f9d2732cd8c9d6a0d94193c27627e434 100644 (file)
@@ -51,11 +51,11 @@ def configure(conf):
        if Options.options.wiimote:
                conf.check_cc (header_name='cwiid.h',define_name='HAVE_CWIID_H')
                if not conf.env['HAVE_CWIID_H']:
-                       print 'WIIMOTE configured but you are missing libcwiid!'
+                       print('WIIMOTE configured but you are missing libcwiid!')
                        sys.exit(1)
                conf.check_cc (header_name='bluetooth/bluetooth.h',define_name='HAVE_BLUETOOTH_H')
                if not conf.env['HAVE_BLUETOOTH_H']:
-                       print 'WIIMOTE configured but you are missing the libbluetooth headers needed to compile wiimote support!'
+                       print('WIIMOTE configured but you are missing the libbluetooth headers needed to compile wiimote support!')
                        sys.exit(1)
                conf.define ('BUILD_WIIMOTE', 1)
 
diff --git a/wscript b/wscript
index 2f5d7eeaf05a4aa42b99c07e055bcd93136f022e..19fb5fb6697f0334c91727e86c9f71517cdabbdf 100644 (file)
--- a/wscript
+++ b/wscript
@@ -2,7 +2,6 @@
 import autowaf
 import Options
 import os
-import commands
 import re
 import string
 import subprocess
@@ -42,18 +41,20 @@ i18n_children = [
 
 def fetch_svn_revision (path):
        cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
-       return commands.getoutput(cmd)
+       return subprocess.Popen(cmd, shell=True, stderr=sub.STDOUT, stdout=sub.PIPE).communicate()[0]
 
 def fetch_gcc_version ():
        cmd = "LANG= gcc --version"
-       output = commands.getoutput(cmd).splitlines()
-        version = output[0].split(' ')[2].split('.')
+       output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
+       o = output[0].decode('utf-8')
+       version = o.split(' ')[2].split('.')
        return version
 
 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]
+       output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
+       o = output[0].decode('utf-8')
+       rev = o.replace ("commit", "git")[0:10]
        for line in output:
                try:
                        if "git-svn-id" in line:
@@ -79,23 +80,23 @@ def create_stored_revision():
                rev = fetch_git_revision('.');
        elif os.path.exists('.bzr'):
                rev = fetch_bzr_revision('.');
-               print "Revision: " + rev;
+               print("Revision: %s", rev)
        elif os.path.exists('libs/ardour/svn_revision.cc'):
-               print "Using packaged svn revision"
+               print("Using packaged svn revision")
                return
        else:
-               print "Missing libs/ardour/svn_revision.cc.  Blame the packager."
+               print("Missing libs/ardour/svn_revision.cc.  Blame the packager.")
                sys.exit(-1)
 
        try:
                text =  '#include "ardour/svn_revision.h"\n'
                text += 'namespace ARDOUR { const char* svn_revision = \"' + rev + '\"; }\n'
-               print 'Writing svn revision info to libs/ardour/svn_revision.cc'
-               o = file('libs/ardour/svn_revision.cc', 'w')
+               print('Writing svn revision info to libs/ardour/svn_revision.cc')
+               o = open('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'
+               print('Could not open libs/ardour/svn_revision.cc for writing\n')
                sys.exit(-1)
 
 def set_compiler_flags (conf,opt):
@@ -216,7 +217,7 @@ def set_compiler_flags (conf,opt):
                        optimization_flags.append ("-DUSE_X86_64_ASM")
                        debug_flags.append ("-DUSE_X86_64_ASM")
                if not build_host_supports_sse:
-                       print "\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be an error, especially if you are a package maintainer)"
+                       print("\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be an error, especially if you are a package maintainer)")
        
        # check this even if we aren't using FPU optimization
        if not conf.env['HAVE_POSIX_MEMALIGN']:
@@ -229,10 +230,10 @@ def set_compiler_flags (conf,opt):
        #
            
        if conf.env['build_target'] == 'x86_64' and opt.vst:
-               print "\n\n=================================================="
-               print "You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0"
-               print "\nIt is theoretically possible to build a 32 bit host on a 64 bit system."
-               print "However, this is tricky and not recommended for beginners."
+               print("\n\n==================================================")
+               print("You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0")
+               print("\nIt is theoretically possible to build a 32 bit host on a 64 bit system.")
+               print("However, this is tricky and not recommended for beginners.")
                sys.exit (-1)
 
        #
@@ -383,16 +384,16 @@ def sub_config_and_use(conf, name, has_objects = True):
 
 def configure(conf):
        create_stored_revision()
-        conf.env['VERSION'] = VERSION
+       conf.env['VERSION'] = VERSION
        conf.line_just = 52
        autowaf.set_recursive()
        autowaf.configure(conf)
        autowaf.display_header('Ardour Configuration')
 
        gcc_versions = fetch_gcc_version()
-        if not Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4':
-                print 'Version 4.5 of gcc is not ready for use when compiling Ardour with optimization.'
-                print 'Please use a different version or re-configure with --debug'
+       if not Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4':
+                print('Version 4.5 of gcc is not ready for use when compiling Ardour with optimization.')
+                print('Please use a different version or re-configure with --debug')
                 exit (1)
 
        if sys.platform == 'darwin':
@@ -519,7 +520,7 @@ def configure(conf):
         # debug builds should not call home
 
        opts = Options.options
-        if opts.debug:
+       if opts.debug:
                 opts.phone_home = False;
 
        autowaf.display_msg(conf, 'Build Target', conf.env['build_target'])
@@ -570,14 +571,14 @@ def configure(conf):
                conf.define('WIIMOTE',1)
        conf.define('WINDOWS_KEY', opts.windows_key)
        autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
-        conf.env['PROGRAM_NAME'] = opts.program_name
-        autowaf.display_msg(conf, 'Program Name', opts.program_name)
+       conf.env['PROGRAM_NAME'] = opts.program_name
+       autowaf.display_msg(conf, 'Program Name', opts.program_name)
 
        set_compiler_flags (conf, Options.options)
 
        autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS'])
        autowaf.display_msg(conf, 'C++ Compiler flags', conf.env['CXXFLAGS'])
-       print
+       print()
 
        # and dump the same stuff to a file for use in the build