From 7f3116a63d7d91f4c0d26adf8fcdef0a5a957971 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Thu, 8 Apr 2010 07:45:46 +1000 Subject: build: allow the waf build to work with python 3.0 and 3.1 Python 3.x is a bit fussier about print statements and indentation. Signed-off-by: Andrew Tridgell --- buildtools/wafsamba/samba_autoconf.py | 2 +- buildtools/wafsamba/samba_deps.py | 21 ++++++++++----------- buildtools/wafsamba/samba_install.py | 4 +++- buildtools/wafsamba/samba_utils.py | 6 +++--- buildtools/wafsamba/wafsamba.py | 10 ++++++---- 5 files changed, 23 insertions(+), 20 deletions(-) (limited to 'buildtools') diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index d1b43d4e8a..32c7463981 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -545,7 +545,7 @@ def SAMBA_CONFIG_H(conf, path=None): testflags=True) if Options.options.pedantic: - conf.ADD_CFLAGS('-W', testflags=True) + conf.ADD_CFLAGS('-W', testflags=True) if path is None: conf.write_config_header('config.h', top=True) diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py index 08a24db5bb..be77d2c611 100644 --- a/buildtools/wafsamba/samba_deps.py +++ b/buildtools/wafsamba/samba_deps.py @@ -96,10 +96,9 @@ def build_dependencies(self): if getattr(self, 'uselib', None): up_list = [] - for l in self.uselib: - up_list.append(l.upper()) - self.uselib = up_list - + for l in self.uselib: + up_list.append(l.upper()) + self.uselib = up_list def build_includes(self): '''This builds the right set of includes for a target. @@ -280,7 +279,7 @@ def check_orpaned_targets(bld, tgt_list): type = target_dict[t.sname] if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']: if re.search('^PIDL_', t.sname) is None: - print "Target %s of type %s is unused by any other target" % (t.sname, type) + print("Target %s of type %s is unused by any other target" % (t.sname, type)) def show_final_deps(bld, tgt_list): @@ -329,7 +328,7 @@ def build_direct_deps(bld, tgt_list): d = EXPAND_ALIAS(bld, d) if d == t.sname: continue if not d in targets: - print "Unknown dependency %s in %s" % (d, t.sname) + print("Unknown dependency %s in %s" % (d, t.sname)) raise if targets[d] in [ 'EMPTY', 'DISABLED' ]: continue @@ -344,7 +343,7 @@ def build_direct_deps(bld, tgt_list): continue t2 = bld.name_to_obj(d, bld.env) if t2 is None: - print "no task %s type %s" % (d, targets[d]) + print("no task %s type %s" % (d, targets[d])) if t2.samba_type in [ 'LIBRARY', 'MODULE' ]: t.direct_libs.add(d) elif t2.samba_type in [ 'SUBSYSTEM', 'ASN1', 'PYTHON' ]: @@ -823,7 +822,7 @@ def check_project_rules(bld): continue t = bld.name_to_obj(tgt, bld.env) if t is None: - print "Target %s of type %s has no task generator" % (tgt, type) + print("Target %s of type %s has no task generator" % (tgt, type)) raise tgt_list.append(t) @@ -832,7 +831,7 @@ def check_project_rules(bld): if load_samba_deps(bld, tgt_list): return - print "Checking project rules ..." + print("Checking project rules ...") debug('deps: project rules checking started') @@ -851,7 +850,7 @@ def check_project_rules(bld): #check_orpaned_targets(bld, tgt_list) if not check_duplicate_sources(bld, tgt_list): - print "Duplicate sources present - aborting" + print("Duplicate sources present - aborting") sys.exit(1) show_final_deps(bld, tgt_list) @@ -861,7 +860,7 @@ def check_project_rules(bld): save_samba_deps(bld, tgt_list) - print "Project rules pass" + print("Project rules pass") def CHECK_PROJECT_RULES(bld): diff --git a/buildtools/wafsamba/samba_install.py b/buildtools/wafsamba/samba_install.py index 2f861616c1..30b607bf4c 100644 --- a/buildtools/wafsamba/samba_install.py +++ b/buildtools/wafsamba/samba_install.py @@ -7,6 +7,8 @@ import Options from TaskGen import feature, before, after from samba_utils import * +O755 = 493 + @feature('install_bin') @after('apply_core') @before('apply_link') @@ -41,7 +43,7 @@ def install_binary(self): # tell waf to install the right binary bld.install_as(os.path.join(install_path, orig_target), os.path.join(self.path.abspath(bld.env), self.target), - chmod=0755) + chmod=O755) diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 8a8a7e3975..a527e811fa 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -220,7 +220,7 @@ def subst_vars_error(string, env): if re.match('\$\{\w+\}', v): vname = v[2:-1] if not vname in env: - print "Failed to find variable %s in %s" % (vname, string) + print("Failed to find variable %s in %s" % (vname, string)) sys.exit(1) v = env[vname] out.append(v) @@ -356,7 +356,7 @@ def RUN_COMMAND(cmd, return os.WEXITSTATUS(status) if os.WIFSIGNALED(status): return - os.WTERMSIG(status) - print "Unknown exit reason %d for command: %s" (status, cmd) + print("Unknown exit reason %d for command: %s" (status, cmd)) return -1 @@ -434,7 +434,7 @@ def RECURSE(ctx, directory): return ctx.sub_config(relpath) if ctxclass == 'BuildContext': return ctx.add_subdirs(relpath) - print 'Unknown RECURSE context class', ctxclass + print('Unknown RECURSE context class', ctxclass) raise Options.Handler.RECURSE = RECURSE Build.BuildContext.RECURSE = RECURSE diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index a28f1ebb79..75639d47ab 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -25,6 +25,8 @@ import irixcc import generic_cc import samba_dist +O644 = 420 + # some systems have broken threading in python if os.environ.get('WAF_NOTHREADS') == '1': import nothreads @@ -523,7 +525,7 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None): Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT -def install_file(bld, destdir, file, chmod=0644, flat=False, +def install_file(bld, destdir, file, chmod=O644, flat=False, python_fixup=False, destname=None, base_name=None): '''install a file''' destdir = bld.EXPAND_VARIABLES(destdir) @@ -545,7 +547,7 @@ def install_file(bld, destdir, file, chmod=0644, flat=False, bld.install_as(dest, file, chmod=chmod) -def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False, +def INSTALL_FILES(bld, destdir, files, chmod=O644, flat=False, python_fixup=False, destname=None, base_name=None): '''install a set of files''' for f in TO_LIST(files): @@ -555,7 +557,7 @@ def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False, Build.BuildContext.INSTALL_FILES = INSTALL_FILES -def INSTALL_WILDCARD(bld, destdir, pattern, chmod=0644, flat=False, +def INSTALL_WILDCARD(bld, destdir, pattern, chmod=O644, flat=False, python_fixup=False, exclude=None, trim_path=None): '''install a set of files matching a wildcard pattern''' files=TO_LIST(bld.path.ant_glob(pattern)) @@ -623,7 +625,7 @@ def subst_at_vars(task): if not vname in task.env and vname.upper() in task.env: vname = vname.upper() if not vname in task.env: - print "Unknown substitution %s in %s" % (v, task.name) + print("Unknown substitution %s in %s" % (v, task.name)) raise v = SUBST_VARS_RECURSIVE(task.env[vname], task.env) # now we back substitute the allowed pc vars -- cgit