update drobilla's fascistic dir-locals.el to force emacs users into whitespace submis...
[ardour.git] / autowaf.py
index 7e8790a2ed6903fb3d1ef604ec2176bb59ae8c79..f98cad1adaaf0165861410052bbfca4b16901549 100644 (file)
@@ -11,6 +11,8 @@ import misc
 import os
 import subprocess
 import sys
+import glob
+
 from TaskGen import feature, before, after
 
 global g_is_child
@@ -37,8 +39,10 @@ def set_options(opt):
                return
        opt.tool_options('compiler_cc')
        opt.tool_options('compiler_cxx')
-       opt.add_option('--debug', action='store_true', default=False, dest='debug',
-                       help="Build debuggable binaries [Default: False]")
+       opt.add_option('--debug', action='store_true', default=True, dest='debug',
+                       help="Build debuggable binaries [Default: True]")
+       opt.add_option('--optimize', action='store_false', default=True, dest='debug',
+                       help="Build optimized binaries [Default: False]")
        opt.add_option('--strict', action='store_true', default=False, dest='strict',
                        help="Use strict compiler flags and show all warnings [Default: False]")
        opt.add_option('--docs', action='store_true', default=False, dest='docs',
@@ -212,7 +216,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 +344,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 +359,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 +388,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 +422,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 +430,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)
 
@@ -436,3 +440,41 @@ def shutdown():
                try: os.popen("/sbin/ldconfig")
                except: pass
 
+def build_i18n(bld,srcdir,dir,name,sources):
+       pwd = bld.get_curdir()
+       os.chdir(os.path.join (srcdir, dir))
+
+       pot_file = '%s.pot' % name
+
+       args = [ 'xgettext',
+                '--keyword=_',
+                '--keyword=N_',
+                '--from-code=UTF-8',
+                '-o', pot_file,
+                '--copyright-holder="Paul Davis"' ]
+       args += sources
+       print 'Updating ', pot_file
+       os.spawnvp (os.P_WAIT, 'xgettext', args)
+       
+       po_files = glob.glob ('po/*.po')
+       languages = [ po.replace ('.po', '') for po in po_files ]
+       
+       for po_file in po_files:
+               args = [ 'msgmerge',
+                        '--update',
+                        po_file,
+                        pot_file ]
+               print 'Updating ', po_file
+               os.spawnvp (os.P_WAIT, 'msgmerge', args)
+               
+       for po_file in po_files:
+               mo_file = po_file.replace ('.po', '.mo')
+               args = [ 'msgfmt',
+                        '-c',
+                        '-f',
+                        '-o',
+                        mo_file,
+                        po_file ]
+               print 'Generating ', po_file
+               os.spawnvp (os.P_WAIT, 'msgfmt', args)
+       os.chdir (pwd)