[Xfce4-commits] <gigolo:master> Update Waf to 1.6.1 and adjust wscript
Enrico Tröger
noreply at xfce.org
Mon Jan 3 00:10:08 CET 2011
Updating branch refs/heads/master
to b994dbee7bb659a5f9022893a36f544f52396521 (commit)
from bc8f76ec117699a57f51df8aac3b6c36559b9ad3 (commit)
commit b994dbee7bb659a5f9022893a36f544f52396521
Author: Enrico Tröger <enrico at xfce.org>
Date: Sun Jan 2 14:42:46 2011 +0100
Update Waf to 1.6.1 and adjust wscript
waf | Bin 59403 -> 76329 bytes
wscript | 396 ++++++++++++++++++++++++++++++---------------------------------
2 files changed, 188 insertions(+), 208 deletions(-)
diff --git a/waf b/waf
index 29af63d..95ffdf3 100755
Binary files a/waf and b/waf differ
diff --git a/wscript b/wscript
index 3c721ec..b7fa147 100644
--- a/wscript
+++ b/wscript
@@ -20,238 +20,218 @@
-from TaskGen import taskgen, feature
-import Build, Configure, Options, Utils, UnitTest
-import sys, os, shutil
+import os
+from waflib import Logs, Options, Scripting
+from waflib.TaskGen import feature
APPNAME = 'gigolo'
VERSION = '0.4.1'
+LINGUAS_FILE = 'po/LINGUAS'
-srcdir = '.'
-blddir = '_build_'
+top = '.'
+out = '_build_'
-sources = [ 'src/compat.c', 'src/window.c', 'src/bookmark.c', 'src/settings.c',
- 'src/menubuttonaction.c', 'src/mountoperation.c', 'src/bookmarkdialog.c',
- 'src/bookmarkeditdialog.c', 'src/preferencesdialog.c', 'src/backendgvfs.c',
- 'src/common.c', 'src/mountdialog.c', 'src/browsenetworkpanel.c',
- 'src/singleinstance.c', 'src/bookmarkpanel.c' ]
+sources = ['src/compat.c', 'src/window.c', 'src/bookmark.c', 'src/settings.c',
+ 'src/menubuttonaction.c', 'src/mountoperation.c', 'src/bookmarkdialog.c',
+ 'src/bookmarkeditdialog.c', 'src/preferencesdialog.c', 'src/backendgvfs.c',
+ 'src/common.c', 'src/mountdialog.c', 'src/browsenetworkpanel.c',
+ 'src/singleinstance.c', 'src/bookmarkpanel.c']
def configure(conf):
- conf.check_tool('compiler_cc intltool misc gnu_dirs')
+ conf.load('compiler_c intltool gnu_dirs waf_unit_test')
- conf.check_cfg(package='gtk+-2.0', atleast_version='2.12.0', uselib_store='GTK',
- mandatory=True, args='--cflags --libs')
- conf.check_cfg(package='gio-2.0', atleast_version='2.16.0', uselib_store='GIO',
- mandatory=True, args='--cflags --libs')
- conf.check_cfg(package='x11', uselib_store='X11', mandatory=True, args='--libs')
+ conf.check_cfg(package='gtk+-2.0', atleast_version='2.12.0', uselib_store='GTK',
+ mandatory=True, args='--cflags --libs')
+ conf.check_cfg(package='gio-2.0', atleast_version='2.16.0', uselib_store='GIO',
+ mandatory=True, args='--cflags --libs')
+ conf.check_cfg(package='x11', uselib_store='X11', mandatory=True, args='--libs')
- gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK')
- gio_version = conf.check_cfg(modversion='gio-2.0', uselib_store='GIO')
+ gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK')
+ gio_version = conf.check_cfg(modversion='gio-2.0', uselib_store='GIO')
- conf.define('GETTEXT_PACKAGE', APPNAME, 1)
- conf.define('PACKAGE', APPNAME, 1)
- conf.define('VERSION', VERSION, 1)
+ conf.define('GETTEXT_PACKAGE', APPNAME, 1)
+ conf.define('PACKAGE', APPNAME, 1)
+ conf.define('VERSION', VERSION, 1)
- conf.write_config_header('config.h')
+ conf.write_config_header('config.h', remove=False)
- if 'LINGUAS' in os.environ:
- conf.env['LINGUAS'] = os.environ['LINGUAS']
+ if 'LINGUAS' in os.environ:
+ conf.env['LINGUAS'] = os.environ['LINGUAS']
- # debug flags
- if Options.options.debug:
- conf.env.append_value('CCFLAGS', '-g -O0 -DDEBUG '.split())
+ # debug flags
+ if conf.options.debug:
+ conf.env.append_value('CCFLAGS', '-g -O0 -DDEBUG '.split())
- Utils.pprint('BLUE', 'Summary:')
- print_message(conf, 'Install Gigolo ' + VERSION + ' in', conf.env['PREFIX'])
- print_message(conf, 'Using GTK version', gtk_version or 'Unknown')
- print_message(conf, 'Using GIO version', gio_version or 'Unknown')
- print_message(conf, 'Compiling with debugging support', Options.options.debug and 'yes' or 'no')
+ Logs.pprint('BLUE', 'Summary:')
+ conf.msg('Install Gigolo ' + VERSION + ' in', conf.env['PREFIX'])
+ conf.msg('Using GTK version', gtk_version or 'Unknown')
+ conf.msg('Using GIO version', gio_version or 'Unknown')
+ conf.msg('Compiling with debugging support', conf.options.debug and 'yes' or 'no')
-def set_options(opt):
- opt.tool_options('compiler_cc')
- opt.tool_options('intltool')
- opt.tool_options('gnu_dirs')
+def options(opt):
+ opt.load('compiler_cc intltool gnu_dirs waf_unit_test')
- # Features
- opt.add_option('--enable-debug', action='store_true', default=False,
- help='enable debug mode [default: No]', dest='debug')
- opt.add_option('--update-po', action='store_true', default=False,
- help='update the message catalogs for translation', dest='update_po')
+ opt.add_option('--enable-debug', action='store_true', default=False,
+ help='enable debug mode [default: No]', dest='debug')
- at taskgen
- at feature('intltool_po')
+def _remove_linguas_file():
+ try:
+ os.unlink(LINGUAS_FILE)
+ except OSError:
+ pass
+
+
+ at feature('linguas')
def write_linguas_file(self):
- linguas = ''
- if 'LINGUAS' in Build.bld.env:
- files = Build.bld.env['LINGUAS']
- for po_filename in files.split(' '):
- if os.path.exists('po/%s.po' % po_filename):
- linguas += '%s ' % po_filename
- else:
- files = os.listdir('%s/po' % self.path.abspath())
- files.sort()
- for f in files:
- if f.endswith('.po'):
- linguas += '%s ' % f[:-3]
- f = open("po/LINGUAS", "w")
- f.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
- f.close()
+ if os.path.exists(LINGUAS_FILE):
+ return
+ linguas = ''
+ if 'LINGUAS' in self.env:
+ files = self.env['LINGUAS']
+ for po_filename in files.split(' '):
+ if os.path.exists ('po/%s.po' % po_filename):
+ linguas += '%s ' % po_filename
+ else:
+ files = os.listdir('%s/po' % self.path.abspath())
+ files.sort()
+ for filename in files:
+ if filename.endswith('.po'):
+ linguas += '%s ' % filename[:-3]
+ file_h = open(LINGUAS_FILE, 'w')
+ file_h.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
+ file_h.close()
+
+
+def distclean(ctx):
+ Scripting.distclean(ctx)
+ _remove_linguas_file()
def build(bld):
- def add_tests(bld):
- tests = os.listdir('tests')
- for test in tests:
- if test[-2:] != '.c':
- continue
- target = test[:-2]
- source = os.path.join("tests", test)
-
- bld.new_task_gen(
- features = 'cc cprogram',
- target = 'test-' + target,
- source = source,
- includes = '. src',
- uselib = 'GTK GIO',
- uselib_local = 'gigolo_lib',
- unit_test = 1,
- install_path = None
- )
-
-
- bld.new_task_gen(
- features = 'cc cstaticlib',
- name = 'gigolo_lib',
- target = 'gigolo_lib',
- source = sources,
- includes = '.',
- uselib = 'GTK GIO',
- install_path = None
- )
-
- bld.new_task_gen(
- features = 'cc cprogram',
- name = 'gigolo',
- target = 'gigolo',
- source = 'src/main.c',
- includes = '.',
- uselib = 'GTK GIO X11',
- uselib_local = 'gigolo_lib',
- )
-
- if Options.commands['check']:
- add_tests(bld)
-
- # Translations
- bld.new_task_gen(
- features = 'intltool_po',
- podir = 'po',
- appname = 'gigolo'
- )
-
- # gigolo.desktop
- bld.new_task_gen(
- features = 'intltool_in',
- source = 'gigolo.desktop.in',
- flags = [ '-d', '-q', '-u', '-c' ],
- install_path = '${DATADIR}/applications'
- )
-
- # gigolo.1
- bld.new_task_gen(
- features = 'subst',
- source = 'gigolo.1.in',
- target = 'gigolo.1',
- dict = { 'VERSION' : VERSION },
- install_path = '${MANDIR}/man1'
- )
-
- # Docs
- bld.install_files('${DOCDIR}', 'AUTHORS ChangeLog COPYING README NEWS TODO')
-
-
-def dist():
- import md5
- from Scripting import dist, excludes
- excludes.append('gigolo-%s.tar.bz2.sig' % VERSION)
- filename = dist(APPNAME, VERSION)
- f = file(filename,'rb')
- m = md5.md5()
- readBytes = 100000
- while (readBytes):
- readString = f.read(readBytes)
- m.update(readString)
- readBytes = len(readString)
- f.close()
- launch('gpg --detach-sign --digest-algo SHA512 %s' % filename, 'Signing %s' % filename)
- print 'MD5 sum:', filename, m.hexdigest()
- sys.exit(0)
-
-
-def shutdown():
- # the following code was taken from midori's WAF script, thanks
- # (disabled because we don't need it at all as long as we don't have an own icon :( )
- #~ if Options.commands['install'] or Options.commands['uninstall']:
- #~ dir = Build.bld.get_install_path('${DATADIR}/icons/hicolor')
- #~ icon_cache_updated = False
- #~ if not Options.options.destdir:
- #~ try:
- #~ if not Utils.exec_command('gtk-update-icon-cache -q -f -t %s' % dir):
- #~ Utils.pprint('YELLOW', "Updated Gtk icon cache.")
- #~ icon_cache_updated = True
- #~ except:
- #~ Utils.pprint('RED', "Failed to update icon cache.")
- #~ if not icon_cache_updated:
- #~ Utils.pprint('YELLOW', "Icon cache not updated. After install, run this:")
- #~ Utils.pprint('YELLOW', "gtk-update-icon-cache -q -f -t %s" % dir)
- if Options.options.update_po:
- os.chdir(os.path.join(srcdir, 'po'))
- try:
- try:
- size_old = os.stat('gigolo.pot').st_size
- except:
- size_old = 0
- Utils.exec_command(['intltool-update', '--pot', '-g', APPNAME])
- size_new = os.stat('gigolo.pot').st_size
- if size_new != size_old:
- Utils.pprint('CYAN', 'Updated POT file.')
- launch('intltool-update -r %s' % APPNAME, 'Updating translations', 'CYAN')
- else:
- Utils.pprint('CYAN', 'POT file is up to date.')
- except:
- Utils.pprint('RED', 'Failed to generate pot file.')
- os.chdir('..')
-
-
-def check(ch):
- test = UnitTest.unit_test()
- test.change_to_testfile_dir = False
- test.want_to_see_test_output = True
- test.want_to_see_test_error = True
- test.run()
- test.print_results()
-
-
-# Simple function to execute a command and print its exit status
-def launch(command, status, success_color='GREEN'):
- ret = 0
- Utils.pprint(success_color, status)
- try:
- ret = Utils.exec_command(command.split())
- except:
- ret = 1
-
- if ret != 0:
- Utils.pprint('RED', status + ' failed')
-
- return ret
-
-def print_message(conf, msg, result, color = 'GREEN'):
- conf.check_message_1(msg)
- conf.check_message_2(result, color)
+ if bld.cmd == 'clean':
+ _remove_linguas_file()
+
+ bld.new_task_gen(
+ features = 'c cstlib',
+ name = 'gigolo_lib',
+ target = 'gigolo_lib',
+ source = sources,
+ includes = '.',
+ uselib = ['GTK', 'GIO'],
+ install_path = None)
+
+ bld.new_task_gen(
+ features = 'c cprogram',
+ name = 'gigolo',
+ target = 'gigolo',
+ source = 'src/main.c',
+ includes = '.',
+ use = ['GTK', 'GIO', 'X11', 'gigolo_lib'])
+
+ # tests
+ bld(
+ features = 'c cprogram test',
+ source = 'tests/uri_parsing.c',
+ target = 'test-uri-parsing',
+ includes = ['.', 'src'],
+ use = ['GTK', 'GIO', 'X11', 'gigolo_lib'],
+ install_path = None)
+ bld.add_post_fun(_unit_test_summary)
+
+ # Translations
+ bld.new_task_gen(
+ features = ['linguas', 'intltool_po'],
+ podir = 'po',
+ install_path = '${LOCALEDIR}',
+ appname = 'gigolo')
+
+ # gigolo.desktop
+ bld.new_task_gen(
+ features = 'intltool_in',
+ source = 'gigolo.desktop.in',
+ flags = ['-d', '-q', '-u', '-c'],
+ install_path = '${DATADIR}/applications',
+ after = 'intltool_po')
+
+ # gigolo.1
+ bld.new_task_gen(
+ features = 'subst',
+ source = 'gigolo.1.in',
+ target = 'gigolo.1',
+ dct = {'VERSION' : VERSION},
+ install_path = '${MANDIR}/man1')
+
+ # Docs
+ bld.install_files('${DOCDIR}', 'AUTHORS ChangeLog COPYING README NEWS TODO')
+
+
+def _unit_test_summary(ctx):
+ lst = getattr(ctx, 'utest_results', [])
+ if lst:
+ Logs.pprint('CYAN', 'Execution summary:')
+
+ total = len(lst)
+ tfail = len([x for x in lst if x[1]])
+
+ Logs.pprint('CYAN', ' Passed tests: %d/%d' % (total-tfail, total))
+ for (filename, code, stdout, stderr) in lst:
+ if not code:
+ Logs.pprint('CYAN', ' %s' % filename)
+
+ Logs.pprint('CYAN', ' Failed tests: %d/%d' % (tfail, total))
+ for (filename, code, stdout, stderr) in lst:
+ if code:
+ Logs.pprint('CYAN', '%s:' % filename)
+ Logs.pprint('RED', '%s' % stdout)
+
+
+def updatepo(ctx):
+ """update the message catalogs for internationalization"""
+ potfile = '%s.pot' % APPNAME
+ os.chdir('%s/po' % top)
+ try:
+ try:
+ old_size = os.stat(potfile).st_size
+ except OSError:
+ old_size = 0
+ ctx.exec_command('intltool-update --pot -g %s' % APPNAME)
+ size_new = os.stat(potfile).st_size
+ if size_new != old_size:
+ Logs.pprint('CYAN', 'Updated POT file.')
+ Logs.pprint('CYAN', 'Updating translations')
+ ret = ctx.exec_command('intltool-update -r -g %s' % APPNAME)
+ if ret != 0:
+ Logs.pprint('RED', 'Updating translations failed')
+ else:
+ Logs.pprint('CYAN', 'POT file is up to date.')
+ except OSError:
+ Logs.pprint('RED', 'Failed to generate pot file.')
+
+
+def dist(ctx):
+ ctx.base_path = ctx.path
+ ctx.excl = ctx.get_excl() + 'gigolo-%s.tar.bz2.sig module.xml RUN .gitignore .intlcache' % VERSION
+
+
+def sign(ctx):
+ """sign the source tarball for distribution"""
+ from hashlib import md5
+ filename = '%s-%s.tar.bz2' % (APPNAME, VERSION)
+ md5_hash = md5()
+ read_bytes = 100000
+ archive_file = file(filename,'rb')
+ while read_bytes:
+ read_string = archive_file.read(read_bytes)
+ md5_hash.update(read_string)
+ read_bytes = len(read_string)
+ archive_file.close()
+
+ ctx.cmd_and_log('gpg --detach-sign --digest-algo SHA512 %s' % filename)
+ Logs.pprint('GREEN', 'MD5 sum: %s %s' % (filename, md5_hash.hexdigest()))
+
More information about the Xfce4-commits
mailing list