[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Tue May 4 03:47:10 MDT 2010


The branch, master has been updated
       via  6eb839c... s4-script: added a --waf option to minimal_includes.pl
       via  7281b02... build: allow use of target names as commands in waf
      from  727a1ac... s4-smbtorture: add extraformat to smbcli_rap_netprintqgetinfo() as well.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6eb839cd1695ce8da991c19611210eefda902c0f
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 4 10:30:39 2010 +0200

    s4-script: added a --waf option to minimal_includes.pl
    
    This takes advantage of the new waf target syntax

commit 7281b021814379b9c477b42bcf1f2215014d88ae
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 4 10:08:43 2010 +0200

    build: allow use of target names as commands in waf
    
    This allows for the following types of commands:
    
     waf smbd/samba
     waf smbd/server.c
     waf ../lib/util/util_file.c
     waf ../lib/util/util_file_*.o
    
    this will be used as part of an updated minimal_includes.pl script

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_wildcard.py |  114 +++++++++++++++++++++++++++++++++
 buildtools/wafsamba/wafsamba.py       |    1 +
 source4/script/minimal_includes.pl    |    7 ++
 source4/wscript                       |   11 +++-
 4 files changed, 132 insertions(+), 1 deletions(-)
 create mode 100644 buildtools/wafsamba/samba_wildcard.py


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_wildcard.py b/buildtools/wafsamba/samba_wildcard.py
new file mode 100644
index 0000000..bcacb4f
--- /dev/null
+++ b/buildtools/wafsamba/samba_wildcard.py
@@ -0,0 +1,114 @@
+#! /usr/bin/env python
+
+# based on playground/evil in the waf svn tree
+
+import os, datetime
+import Scripting, Utils, Options, Logs, Environment, fnmatch
+from Constants import *
+
+def run_task(t, k):
+	'''run a single build task'''
+	ret = t.run()
+	if ret:
+		raise Utils.WafError("Failed to build %s: %u" % (k, ret))
+
+
+def run_named_build_task(cmd):
+	'''run a named build task, matching the cmd name using fnmatch
+	wildcards against inputs and outputs of all build tasks'''
+	bld = fake_build_environment()
+	found = False
+	cwd_node = bld.root.find_dir(os.getcwd())
+	cmd = os.path.normpath(cmd)
+	for g in bld.task_manager.groups:
+		for attr in ['outputs', 'inputs']:
+			for t in g.tasks:
+				s = getattr(t, attr, [])
+				for k in s:
+					relpath = k.relpath_gen(cwd_node)
+					if fnmatch.fnmatch(relpath, cmd):
+						t.position= [0,0]
+						print t.display()
+						run_task(t, k)
+						return
+
+	if not found:
+		raise Utils.WafError("Unable to find build target matching %s" % cmd)
+
+
+
+def wildcard_main(missing_cmd_fn):
+	'''this replaces main from Scripting, allowing us to override the
+	   behaviour for unknown commands
+
+	   If a unknown command is found, then missing_cmd_fn() is called with
+	   the name of the requested command
+	   '''
+	Scripting.commands = Options.arg_line[:]
+
+	while Scripting.commands:
+		x = Scripting.commands.pop(0)
+
+		ini = datetime.datetime.now()
+		if x == 'configure':
+			fun = Scripting.configure
+		elif x == 'build':
+			fun = Scripting.build
+		else:
+			fun = getattr(Utils.g_module, x, None)
+
+		# this is the new addition on top of main from Scripting.py
+		if not fun:
+			missing_cmd_fn(x)
+			break
+
+		ctx = getattr(Utils.g_module, x + '_context', Utils.Context)()
+
+		if x in ['init', 'shutdown', 'dist', 'distclean', 'distcheck']:
+			try:
+				fun(ctx)
+			except TypeError:
+				fun()
+		else:
+			fun(ctx)
+
+		ela = ''
+		if not Options.options.progress_bar:
+			ela = ' (%s)' % Utils.get_elapsed_time(ini)
+
+		if x != 'init' and x != 'shutdown':
+			Logs.info('%r finished successfully%s' % (x, ela))
+
+		if not Scripting.commands and x != 'shutdown':
+			Scripting.commands.append('shutdown')
+
+
+
+
+def fake_build_environment():
+	"""create all the tasks for the project, but do not run the build
+	return the build context in use"""
+	bld = getattr(Utils.g_module, 'build_context', Utils.Context)()
+	bld = Scripting.check_configured(bld)
+
+	Options.commands['install'] = False
+	Options.commands['uninstall'] = False
+	Options.is_install = False
+
+	bld.is_install = 0 # False
+
+	try:
+		proj = Environment.Environment(Options.lockfile)
+	except IOError:
+		raise Utils.WafError("Project not configured (run 'waf configure' first)")
+
+	bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
+	bld.load_envs()
+
+	Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath())
+	bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]])
+
+	bld.pre_build()
+	bld.flush()
+	return bld
+
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index d4766b0..2b53a9c 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -25,6 +25,7 @@ import tru64cc
 import irixcc
 import generic_cc
 import samba_dist
+import samba_wildcard
 
 O644 = 420
 
diff --git a/source4/script/minimal_includes.pl b/source4/script/minimal_includes.pl
index 990ff00..4203d00 100755
--- a/source4/script/minimal_includes.pl
+++ b/source4/script/minimal_includes.pl
@@ -11,6 +11,7 @@ use Getopt::Long;
 my $opt_help = 0;
 my $opt_remove = 0;
 my $opt_skip_system = 0;
+my $opt_waf = 0;
 
 #####################################################################
 # write a string into a file
@@ -43,6 +44,10 @@ sub test_compile($)
 {
 	my $fname = shift;
 	my $obj;
+	if ($opt_waf) {
+		my $ret = `../buildtools/bin/waf $fname 2>&1`;
+		return $ret
+	}
 	if ($fname =~ s/(.*)\..*$/$1.o/) {
 		$obj = "$1.o";
 	} else {
@@ -142,6 +147,7 @@ sub ShowHelp()
                  --help         show help
                  --remove       remove includes, don't just list them
                  --skip-system  don't remove system/ includes
+                 --waf          use waf target conventions
 ";
 }
 
@@ -151,6 +157,7 @@ GetOptions (
 	    'h|help|?' => \$opt_help,
 	    'remove' => \$opt_remove,
 	    'skip-system' => \$opt_skip_system,
+	    'waf' => \$opt_waf,
 	    );
 
 if ($opt_help) {
diff --git a/source4/wscript b/source4/wscript
index e5c8d23..880069e 100644
--- a/source4/wscript
+++ b/source4/wscript
@@ -8,7 +8,7 @@ VERSION='4.0.0-alpha13'
 
 import sys, os
 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
-import wafsamba, Options, samba_dist
+import wafsamba, Options, samba_dist, Scripting
 
 samba_dist.DIST_DIRS('.')
 
@@ -147,4 +147,13 @@ def distcheck():
     d = Scripting.distcheck
     d(subdir='source4')
 
+def wildcard_cmd(cmd):
+    '''called on a unknown command'''
+    from samba_wildcard import run_named_build_task
+    run_named_build_task(cmd)
+
+def main():
+    from samba_wildcard import wildcard_main
+    wildcard_main(wildcard_cmd)
+Scripting.main = main
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list