13
0

Make build scripts python2/3 agnostic.

git-svn-id: svn://localhost/ardour2/branches/3.0@7931 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-10-27 23:10:27 +00:00
parent 04585abae3
commit 9f7f0f79a3
6 changed files with 47 additions and 46 deletions

View File

@ -212,7 +212,7 @@ def configure(conf):
display_msg(conf, "Debuggable build", str(conf.env['DEBUG'])) display_msg(conf, "Debuggable build", str(conf.env['DEBUG']))
display_msg(conf, "Strict compiler flags", str(conf.env['STRICT'])) display_msg(conf, "Strict compiler flags", str(conf.env['STRICT']))
display_msg(conf, "Build documentation", str(conf.env['DOCS'])) display_msg(conf, "Build documentation", str(conf.env['DOCS']))
print print()
g_step = 2 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 + "_minor_version = " + str(minor) + ";\n"
text += "int " + domain + "_micro_version = " + str(micro) + ";\n" text += "int " + domain + "_micro_version = " + str(micro) + ";\n"
try: try:
o = file(source_path, 'w') o = open(source_path, 'w')
o.write(text) o.write(text)
o.close() o.close()
except IOError: except IOError:
print "Could not open", source_path, " for writing\n" print("Could not open %s for writing\n", source_path)
sys.exit(-1) sys.exit(-1)
text = "#ifndef __" + domain + "_version_h__\n" 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 += "extern int " + domain + "_micro_version;\n"
text += "#endif /* __" + domain + "_version_h__ */\n" text += "#endif /* __" + domain + "_version_h__ */\n"
try: try:
o = file(header_path, 'w') o = open(header_path, 'w')
o.write(text) o.write(text)
o.close() o.close()
except IOError: except IOError:
print "Could not open", header_path, " for writing\n" print("Could not open %s for writing\n", header_path)
sys.exit(-1) sys.exit(-1)
return None return None
@ -384,12 +384,12 @@ def run_tests(ctx, appname, tests):
stdout=lcov_log, stderr=lcov_log) stdout=lcov_log, stderr=lcov_log)
except: except:
lcov = False 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 # Run all tests
for i in tests: for i in tests:
print print()
Utils.pprint('BOLD', 'Running %s test %s' % (appname, i)) Utils.pprint('BOLD', 'Running %s test %s' % (appname, i))
if subprocess.call(i) == 0: if subprocess.call(i) == 0:
Utils.pprint('GREEN', 'Passed %s %s' % (appname, i)) Utils.pprint('GREEN', 'Passed %s %s' % (appname, i))
@ -418,7 +418,7 @@ def run_tests(ctx, appname, tests):
lcov_log.close() lcov_log.close()
print print()
Utils.pprint('BOLD', 'Summary:', sep=''), Utils.pprint('BOLD', 'Summary:', sep=''),
if failures == 0: if failures == 0:
Utils.pprint('GREEN', 'All ' + appname + ' tests passed') 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('RED', str(failures) + ' ' + appname + ' test(s) failed')
Utils.pprint('BOLD', 'Coverage:', sep='') Utils.pprint('BOLD', 'Coverage:', sep='')
print os.path.abspath('coverage/index.html') print(os.path.abspath('coverage/index.html'))
os.chdir(orig_dir) os.chdir(orig_dir)

View File

@ -344,13 +344,13 @@ def build(bld):
obj = bld.new_task_gen('subst') obj = bld.new_task_gen('subst')
obj.source = 'ardev_common.sh.in' obj.source = 'ardev_common.sh.in'
obj.target = 'ardev_common_waf.sh' obj.target = 'ardev_common_waf.sh'
obj.chmod = 0755 obj.chmod = 0o755
obj.dict = wrapper_subst_dict obj.dict = wrapper_subst_dict
obj = bld.new_task_gen('subst') obj = bld.new_task_gen('subst')
obj.source = 'ardour.sh.in' obj.source = 'ardour.sh.in'
obj.target = 'ardour3' obj.target = 'ardour3'
obj.chmod = 0755 obj.chmod = 0o755
obj.dict = wrapper_subst_dict obj.dict = wrapper_subst_dict
obj.install_path = bld.env['BINDIR'] obj.install_path = bld.env['BINDIR']
@ -392,7 +392,7 @@ def build(bld):
# Set up font substitution dictionary # Set up font substitution dictionary
for style in ['', 'BOLD', 'ITALIC']: for style in ['', 'BOLD', 'ITALIC']:
for sizename,points in font_sizes.iteritems(): for sizename,points in iter(font_sizes.items()):
if (len (style)): if (len (style)):
key = "_".join (['FONT',style,sizename]) key = "_".join (['FONT',style,sizename])
fontstyle = " ".join ([basefont,style.lower(),points]) fontstyle = " ".join ([basefont,style.lower(),points])

View File

@ -208,14 +208,14 @@ def flac_supported():
cmd = subprocess.Popen ("sndfile-info testfile.flac", cmd = subprocess.Popen ("sndfile-info testfile.flac",
stdout = subprocess.PIPE, stdout = subprocess.PIPE,
stderr = subprocess.STDOUT, shell = True) stderr = subprocess.STDOUT, shell = True)
out = cmd.communicate()[0]; out = cmd.communicate()[0].decode('utf-8');
return re.search ('unknown format', out) == None return re.search ('unknown format', out) == None
def ogg_supported(): def ogg_supported():
cmd = subprocess.Popen ("sndfile-info testfile.ogg", cmd = subprocess.Popen ("sndfile-info testfile.ogg",
stdout = subprocess.PIPE, stdout = subprocess.PIPE,
stderr = subprocess.STDOUT, shell = True) stderr = subprocess.STDOUT, shell = True)
out = cmd.communicate()[0]; out = cmd.communicate()[0].decode('utf-8');
return re.search ('unknown format', out) == None return re.search ('unknown format', out) == None
def set_options(opt): def set_options(opt):

View File

@ -51,11 +51,11 @@ def configure(conf):
if Options.options.wiimote: if Options.options.wiimote:
conf.check_cc (header_name='cwiid.h',define_name='HAVE_CWIID_H') conf.check_cc (header_name='cwiid.h',define_name='HAVE_CWIID_H')
if not conf.env['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) sys.exit(1)
conf.check_cc (header_name='bluetooth/bluetooth.h',define_name='HAVE_BLUETOOTH_H') conf.check_cc (header_name='bluetooth/bluetooth.h',define_name='HAVE_BLUETOOTH_H')
if not conf.env['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) sys.exit(1)
conf.define ('BUILD_WIIMOTE', 1) conf.define ('BUILD_WIIMOTE', 1)

41
wscript
View File

@ -2,7 +2,6 @@
import autowaf import autowaf
import Options import Options
import os import os
import commands
import re import re
import string import string
import subprocess import subprocess
@ -42,18 +41,20 @@ i18n_children = [
def fetch_svn_revision (path): def fetch_svn_revision (path):
cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'" 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 (): def fetch_gcc_version ():
cmd = "LANG= gcc --version" cmd = "LANG= gcc --version"
output = commands.getoutput(cmd).splitlines() output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
version = output[0].split(' ')[2].split('.') o = output[0].decode('utf-8')
version = o.split(' ')[2].split('.')
return version return version
def fetch_git_revision (path): def fetch_git_revision (path):
cmd = "LANG= git log --abbrev HEAD^..HEAD " + path cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
output = commands.getoutput(cmd).splitlines() output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
rev = output[0].replace ("commit", "git")[0:10] o = output[0].decode('utf-8')
rev = o.replace ("commit", "git")[0:10]
for line in output: for line in output:
try: try:
if "git-svn-id" in line: if "git-svn-id" in line:
@ -79,23 +80,23 @@ def create_stored_revision():
rev = fetch_git_revision('.'); rev = fetch_git_revision('.');
elif os.path.exists('.bzr'): elif os.path.exists('.bzr'):
rev = fetch_bzr_revision('.'); rev = fetch_bzr_revision('.');
print "Revision: " + rev; print("Revision: %s", rev)
elif os.path.exists('libs/ardour/svn_revision.cc'): elif os.path.exists('libs/ardour/svn_revision.cc'):
print "Using packaged svn revision" print("Using packaged svn revision")
return return
else: else:
print "Missing libs/ardour/svn_revision.cc. Blame the packager." print("Missing libs/ardour/svn_revision.cc. Blame the packager.")
sys.exit(-1) sys.exit(-1)
try: try:
text = '#include "ardour/svn_revision.h"\n' text = '#include "ardour/svn_revision.h"\n'
text += 'namespace ARDOUR { const char* svn_revision = \"' + rev + '\"; }\n' text += 'namespace ARDOUR { const char* svn_revision = \"' + rev + '\"; }\n'
print 'Writing svn revision info to libs/ardour/svn_revision.cc' print('Writing svn revision info to libs/ardour/svn_revision.cc')
o = file('libs/ardour/svn_revision.cc', 'w') o = open('libs/ardour/svn_revision.cc', 'w')
o.write(text) o.write(text)
o.close() o.close()
except IOError: 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) sys.exit(-1)
def set_compiler_flags (conf,opt): def set_compiler_flags (conf,opt):
@ -216,7 +217,7 @@ def set_compiler_flags (conf,opt):
optimization_flags.append ("-DUSE_X86_64_ASM") optimization_flags.append ("-DUSE_X86_64_ASM")
debug_flags.append ("-DUSE_X86_64_ASM") debug_flags.append ("-DUSE_X86_64_ASM")
if not build_host_supports_sse: 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 # check this even if we aren't using FPU optimization
if not conf.env['HAVE_POSIX_MEMALIGN']: 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: if conf.env['build_target'] == 'x86_64' and opt.vst:
print "\n\n==================================================" print("\n\n==================================================")
print "You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0" 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("\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("However, this is tricky and not recommended for beginners.")
sys.exit (-1) sys.exit (-1)
# #
@ -391,8 +392,8 @@ def configure(conf):
gcc_versions = fetch_gcc_version() gcc_versions = fetch_gcc_version()
if not Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4': 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('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' print('Please use a different version or re-configure with --debug')
exit (1) exit (1)
if sys.platform == 'darwin': if sys.platform == 'darwin':
@ -577,7 +578,7 @@ def configure(conf):
autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS']) autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS'])
autowaf.display_msg(conf, 'C++ Compiler flags', conf.env['CXXFLAGS']) 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 # and dump the same stuff to a file for use in the build