[kupfer] Update wscripts for Waf 1.6



commit ef0d0638d76e5d967982bfd1cde0731dd2355fb9
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Nov 5 13:02:04 2010 +0100

    Update wscripts for Waf 1.6
    
    We update the waf setup so that we can use the newest release. The
    newer releases are simultaneously usable with either Python 2 or
    Python 3.
    
    NOTE: All users of the Git repository must download new Waf (See README).

 README             |    2 +-
 auxdata/wscript    |   25 +++++++-------
 data/wscript_build |    7 ++--
 extras/wscript     |    2 +-
 help/wscript       |   34 +++++++++-----------
 wscript            |   90 ++++++++++++++++++++++++---------------------------
 6 files changed, 75 insertions(+), 85 deletions(-)
---
diff --git a/README b/README
index ecc3230..ae117fb 100644
--- a/README
+++ b/README
@@ -11,7 +11,7 @@ Installing
 This project is configured for waf; waf is shipped in the distributable
 tarball but not in the repository.  If you need to get waf, run::
 
-    wget -O waf http://waf.googlecode.com/files/waf-1.5.8
+    wget -O waf http://waf.googlecode.com/files/waf-1.6.3
     chmod +x waf
 
 Installation follows the steps::
diff --git a/auxdata/wscript b/auxdata/wscript
index 0824a5f..c151632 100644
--- a/auxdata/wscript
+++ b/auxdata/wscript
@@ -1,9 +1,8 @@
 #! /usr/bin/env python
 
-import Options
-import Utils
+from waflib import Options, Utils, Logs
 
-def set_options(opt):
+def options(opt):
 	opt.add_option('--no-update-mime',
 			action='store_true',
 			default=False,
@@ -18,14 +17,14 @@ def build(bld):
 	# merge translations into the .desktop file
 	# and set it up to be installed
 	def install_desktop_file(desktop_subst_file):
-		bld.new_task_gen(
-			"intltool_in",
+		bld(
+			features="intltool_in",
 			podir="../po",
 			flags = ("-d", "-q", "-u", "-c"),
 			source = desktop_subst_file  + ".in",
 			target = desktop_subst_file,
 			install_path = "${DATADIR}/applications",
-			chmod = 0755,
+			chmod = 0o755,
 		)
 
 	install_desktop_file("kupfer.desktop")
@@ -34,8 +33,8 @@ def build(bld):
 	# install mimetype descriptions
 
 	mimetypes_file = "kupfer-mimetypes.xml"
-	bld.new_task_gen(
-		"intltool_in",
+	bld(
+		features="intltool_in",
 		podir="../po",
 		flags = ("-x", "-q", "-u", "-c"),
 		source = mimetypes_file  + ".in",
@@ -54,11 +53,11 @@ def build(bld):
 
 	# Waf's "gnome" tool  -- def postinstall_icons():
 	if icons_inst and bld.is_install:
-		icon_dir = bld.get_install_path('${DATADIR}/icons/hicolor')
+		icon_dir = Utils.subst_vars('${DATADIR}/icons/hicolor', bld.env)
 		if not Options.options.destdir:
-			Utils.pprint('YELLOW',"Updating Gtk icon cache.")
+			Logs.pprint('GREEN',"Updating Gtk icon cache.")
 			command='gtk-update-icon-cache -q -f -t %s' % icon_dir
-			ret=Utils.exec_command(command)
+			bld.exec_command(command)
 		else:
-			Utils.pprint('YELLOW','Icon cache not updated. After install, run this:')
-			Utils.pprint('YELLOW','gtk-update-icon-cache -q -f -t %s'%icon_dir)
+			Logs.pprint('YELLOW','Icon cache not updated. After install, run this:')
+			Logs.pprint('YELLOW','gtk-update-icon-cache -q -f -t %s'%icon_dir)
diff --git a/data/wscript_build b/data/wscript_build
index 78bc971..0939f90 100644
--- a/data/wscript_build
+++ b/data/wscript_build
@@ -1,7 +1,8 @@
 # configuration defaults and ui files
 bld.install_files("${DATADIR}/kupfer", "defaults.cfg")
-bld.install_files("${DATADIR}/kupfer", "*.ui")
+bld.install_files("${DATADIR}/kupfer", bld.path.ant_glob("*.ui"))
 
 # install all pure data files
-bld.install_files("${DATADIR}/kupfer/art", "art/*")
-bld.install_files("${DATADIR}/kupfer/searchplugins", "searchplugins/*")
+bld.install_files("${DATADIR}/kupfer/art", bld.path.ant_glob("art/*"))
+bld.install_files("${DATADIR}/kupfer/searchplugins",
+                  bld.path.ant_glob("searchplugins/*"))
diff --git a/extras/wscript b/extras/wscript
index 558e2ca..b615aad 100644
--- a/extras/wscript
+++ b/extras/wscript
@@ -1,7 +1,7 @@
 import Options, Utils
 import os
 
-def set_options(opt):
+def options(opt):
 	opt.add_option('--no-install-nautilus-extension',
 			action='store_true',
 			default=False,
diff --git a/help/wscript b/help/wscript
index 33a7bd3..3acf41c 100644
--- a/help/wscript
+++ b/help/wscript
@@ -5,8 +5,7 @@
 
 ## Mallard functionality definitions ##
 import os
-import Task
-import TaskGen
+from waflib import Task, TaskGen, Utils
 
 # FIXME: Support for figures
 
@@ -25,8 +24,8 @@ def init_mallard(self):
 	have_vars = set(var for var in DOC_VAR if DOC_VAR[var])
 	missing_vars = set(require_vars).difference(have_vars)
 	if missing_vars:
-		print "Missing DOC variable declarations in %s:" % (mf_am.abspath())
-		print "\n".join(missing_vars)
+		print("Missing DOC variable declarations in %s:" % (mf_am.abspath()))
+		print("\n".join(missing_vars))
 
 	self.bld.env.update(DOC_VAR)
 	self.default_install_path='${PREFIX}/share/gnome/help/${DOC_ID}'
@@ -35,17 +34,16 @@ def apply_mallard(self):
 	bld = self.bld
 	lst = self.to_list(bld.env["DOC_LINGUAS"])
 	cnode = self.path.find_dir("C")
-	self.bld.rescan(cnode)
 
-	pages = [p for p in self.bld.cache_dir_contents[cnode.id]
-			if (os.path.splitext(p)[-1].lower()) == ".page"]
+	pages = cnode.ant_glob("*.page")
+	self.install_path = Utils.subst_vars(self.default_install_path, self.env)
 
 	# Check if the declared page list is consistent
 	declared_pages = self.to_list(bld.env["DOC_PAGES"])
-	missing_pages = set(pages).difference(declared_pages)
+	missing_pages = set([str(p) for p in pages]).difference(declared_pages)
 	if missing_pages:
-		print "Warning: Some pages not declared:"
-		print "\n".join(missing_pages)
+		print("Warning: Some pages not declared:")
+		print("\n".join([str(p) for p in missing_pages]))
 
 	for lang in lst:
 		node = self.path.find_resource("%s/%s.po" % (lang, lang))
@@ -55,12 +53,11 @@ def apply_mallard(self):
 			src = self.path.find_resource('C/%s' % page)
 			tsk.set_inputs([node,src])
 			tsk.set_outputs(out)
-			tsk.install_path = os.path.join(self.install_path, lang)
-	if bld.is_install:
-		for page in pages:
-			out = "%s/%s" % (cnode.abspath(), page)
-			instdir = os.path.join(self.install_path, "C")
-			bld.install_files(instdir, out)
+			bld.install_files(os.path.join(self.install_path, lang),
+			                  tsk.outputs)
+	for page in pages:
+		instdir = os.path.join(self.install_path, "C")
+		bld.install_files(instdir, page)
 
 Task.simple_task_type('xml2po', '${XML2PO} ${XML2POFLAGS} ${SRC} > ${TGT}',
 		color='BLUE')
@@ -74,7 +71,7 @@ TaskGen.after('init_mallard')(apply_mallard)
 
 # Build Configuration
 
-def set_options(opt):
+def options(opt):
 	pass
 
 def configure(conf):
@@ -83,7 +80,6 @@ def configure(conf):
 
 def build(bld):
 	if bld.env["XML2PO"]:
-		task = bld.new_task_gen(
-			features="mallard",
+		task = bld(features="mallard",
 			variable_definitions="Makefile.am",
 		)
diff --git a/wscript b/wscript
index 8f10839..7e8ed6b 100644
--- a/wscript
+++ b/wscript
@@ -6,9 +6,11 @@
 
 import os
 import sys
-import Configure
-import Options
-import Utils
+try:
+	from waflib import Configure, Options, Utils, Logs
+except ImportError:
+	print("You need to upgrade to Waf 1.6! See README.")
+	sys.exit(1)
 
 # the following two variables are used by the target "waf dist"
 APPNAME="kupfer"
@@ -20,8 +22,8 @@ def _get_git_version():
 	if os.path.exists(".git"):
 		try:
 			version = os.popen("git describe").read().strip()
-		except Exception, e:
-			print e
+		except Exception as e:
+			print(e)
 	return version
 
 def _read_git_version():
@@ -51,8 +53,8 @@ def _write_git_version():
 _read_git_version()
 
 # these variables are mandatory ('/' are converted automatically)
-srcdir = '.'
-blddir = 'build'
+top = '.'
+out = 'build'
 
 config_subdirs = "auxdata extras help"
 build_subdirs = "auxdata data po extras help"
@@ -80,7 +82,7 @@ def gitdist(ctx):
 	proc = subprocess.Popen(
 		["git", "archive", "--format=tar", "--prefix=%s/" % basename, "HEAD"],
 		stdout=subprocess.PIPE)
-	fd = os.open(outname, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0666)
+	fd = os.open(outname, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o666)
 	os.write(fd, proc.communicate()[0])
 	os.close(fd)
 	for distfile in EXTRA_DIST:
@@ -88,18 +90,17 @@ def gitdist(ctx):
 	subprocess.call(["gzip", outname])
 	subprocess.call(["sha1sum", outname + ".gz"])
 
-def dist():
+def dist(ctx):
 	"The standard waf dist process"
 	import Scripting
 	_write_git_version()
 	Scripting.g_gz = "gz"
-	Scripting.dist(APPNAME, VERSION)
+	Scripting.dist(ctx)
 
 
-def set_options(opt):
+def options(opt):
 	# options for disabling pyc or pyo compilation
 	opt.tool_options("python")
-	opt.tool_options("misc")
 	opt.tool_options("gnu_dirs")
 	opt.add_option('--nopyo',action='store_false',default=False,help='Do not install optimised compiled .pyo files [This is the default for Kupfer]',dest='pyo')
 	opt.add_option('--pyo',action='store_true',default=False,help='Install optimised compiled .pyo files [Default:not install]',dest='pyo')
@@ -118,10 +119,9 @@ def configure(conf):
 			raise
 		conf.env["PYTHON"] = "python2.6"
 		conf.check_python_version((2,6,0))
-	conf.check_tool("misc gnu_dirs")
+	conf.check_tool("gnu_dirs")
 
-	# BUG: intltool requires gcc
-	conf.check_tool("gcc intltool")
+	conf.check_tool("intltool")
 
 	conf.env["KUPFER"] = Utils.subst_vars("${BINDIR}/kupfer", conf.env)
 	conf.env["VERSION"] = VERSION
@@ -129,7 +129,7 @@ def configure(conf):
 
 	# Setup PYTHONDIR so we install into $DATADIR
 	conf.env["PYTHONDIR"] = Utils.subst_vars("${DATADIR}/kupfer", conf.env)
-	Utils.pprint("NORMAL",
+	Logs.pprint("NORMAL",
 			"Installing python modules into: %(PYTHONDIR)s" % conf.env)
 
 	opt_build_programs = {
@@ -138,7 +138,7 @@ def configure(conf):
 	for prog in opt_build_programs:
 		prog_path = conf.find_program(prog, var=prog.replace("-", "_").upper())
 		if not prog_path:
-			Utils.pprint("YELLOW",
+			Logs.pprint("YELLOW",
 			             "Optional, allows: %s" % opt_build_programs[prog])
 
 	if not Options.options.check_deps:
@@ -153,7 +153,7 @@ def configure(conf):
 	for module in python_modules.split():
 		conf.check_python_module(module)
 
-	Utils.pprint("NORMAL", "Checking optional dependencies:")
+	Logs.pprint("NORMAL", "Checking optional dependencies:")
 
 	opt_programs = {
 			"dbus-send": "Focus kupfer from the command line",
@@ -168,19 +168,19 @@ def configure(conf):
 	for prog in opt_programs:
 		prog_path = conf.find_program(prog, var=prog.replace("-", "_").upper())
 		if not prog_path:
-			Utils.pprint("YELLOW", "Optional, allows: %s" % opt_programs[prog])
+			Logs.pprint("YELLOW", "Optional, allows: %s" % opt_programs[prog])
 
 	try:
 		conf.check_python_module("keybinder")
-	except Configure.ConfigurationError, e:
-		Utils.pprint("RED", "Python module keybinder is recommended")
-		Utils.pprint("RED", "Please see README")
+	except Configure.ConfigurationError:
+		Logs.pprint("RED", "Python module keybinder is recommended")
+		Logs.pprint("RED", "Please see README")
 		
 	for mod in opt_pymodules:
 		try:
 			conf.check_python_module(mod)
-		except Configure.ConfigurationError, e:
-			Utils.pprint("YELLOW", "module %s is recommended, allows %s" % (
+		except Configure.ConfigurationError:
+			Logs.pprint("YELLOW", "module %s is recommended, allows %s" % (
 				mod, opt_pymodules[mod]))
 
 
@@ -189,21 +189,16 @@ def _new_package(bld, name):
 	where the name is the full (relative) path to the package
 	"""
 	obj = bld.new_task_gen("py")
-	obj.find_sources_in_dirs(name)
+	node = bld.path.find_dir(name)
+	obj.source = node.ant_glob("*.py")
 	obj.install_path = "${PYTHONDIR}/%s" % name
 
 	# Find embedded package datafiles
 	pkgnode = bld.path.find_dir(name)
-	bld.rescan(pkgnode)
-
-	def is_datafile(fname):
-		if fname in ["icon-list"]:
-			return True
-		return os.path.splitext(fname)[-1] in set([".png", ".svg"])
 
-	for dfile in filter(is_datafile, bld.cache_dir_contents[pkgnode.id]):
-		bld.install_files(obj.install_path,
-				"%s/%s" % (pkgnode.abspath(), dfile))
+	bld.install_files(obj.install_path, pkgnode.ant_glob("icon-list"))
+	bld.install_files(obj.install_path, pkgnode.ant_glob("*.png"))
+	bld.install_files(obj.install_path, pkgnode.ant_glob("*.svg"))
 
 def _find_packages_in_directory(bld, name):
 	"""Go through directory @name and recursively add all
@@ -223,14 +218,14 @@ def build(bld):
 	# kupfer/
 	# kupfer module version info file
 	version_subst_file = "kupfer/version_subst.py"
-	obj = bld.new_task_gen("subst",
+	bld(features="subst",
 		source=version_subst_file + ".in",
 		target=version_subst_file,
-		install_path="${PYTHONDIR}/kupfer",
 		dict = _dict_slice(bld.env,"VERSION DATADIR PACKAGE LOCALEDIR".split())
 		)
+	bld.install_files("${PYTHONDIR}/kupfer", "kupfer/version_subst.py")
 
-	obj = bld.new_task_gen(
+	bld.new_task_gen(
 		source="kupfer.py",
 		install_path="${PYTHONDIR}"
 		)
@@ -240,20 +235,19 @@ def build(bld):
 
 	# bin/
 	# Write in some variables in the shell script binaries
-	bld.new_task_gen("subst",
+	bld(features="subst",
 		source = "bin/kupfer.in",
 		target = "bin/kupfer",
-		install_path = "${BINDIR}",
-		chmod = 0755,
 		dict = _dict_slice(bld.env, "PYTHON PYTHONDIR".split())
 		)
-	bld.new_task_gen("subst",
+	bld.install_files("${BINDIR}", "bin/kupfer", chmod=0o755)
+
+	bld(features="subst",
 		source = "bin/kupfer-exec.in",
 		target = "bin/kupfer-exec",
-		install_path = "${BINDIR}",
-		chmod = 0755,
 		dict = _dict_slice(bld.env, "PACKAGE LOCALEDIR".split())
 		)
+	bld.install_files("${BINDIR}", "bin/kupfer-exec", chmod=0o755)
 
 	# Documentation/
 	if bld.env["RST2MAN"]:
@@ -280,9 +274,9 @@ def build(bld):
 	bld.add_subdirs(build_subdirs)
 
 def intlupdate(util):
-	print "You should use intltool-update directly."
-	print "You can read about this in Documentation/Manual.rst"
-	print "in the localization chapter!"
+	print("You should use intltool-update directly.")
+	print("You can read about this in Documentation/Manual.rst")
+	print("in the localization chapter!")
 
 def test(bld):
 	# find all files with doctests
@@ -292,7 +286,7 @@ def test(bld):
 	all_success = True
 	verbose = ("-v" in sys.argv)
 	for p in paths:
-		print p
+		print(p)
 		cmd = [python, p]
 		if verbose:
 			cmd.append("-v")
@@ -304,7 +298,7 @@ def test(bld):
 		all_success = all_success and bool(res)
 	return all_success
 
-def shutdown():
+def shutdown(bld):
 	pass
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]