summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorThomas Nagy <tnagy@waf.io>2015-06-26 20:13:09 +0200
committerAndrew Bartlett <abartlet@samba.org>2015-09-02 00:47:18 +0200
commitbcf5f45d8731b713be7c34b50ff3f93974eac7f3 (patch)
treead9a98eadbbe8bbc44cf5ac00b06a4bfaf22c70e /third_party
parent841845dea35089a187fd1626c9752d708989ac7b (diff)
downloadsamba-bcf5f45d8731b713be7c34b50ff3f93974eac7f3.tar.gz
third_party:waf: Backport parts of the waf 1.8 API
This modifies our waf 1.5 wafadmin copy to resemble the waf 1.8 waflib API. It is a preparation to change to waf 1.8, decoupling this change from changes in wafsamba. Signed-off-by: Thomas Nagy <tnagy@waf.io> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'third_party')
-rw-r--r--third_party/waf/wafadmin/Build.py4
-rw-r--r--third_party/waf/wafadmin/Node.py7
-rw-r--r--third_party/waf/wafadmin/TaskGen.py3
-rw-r--r--third_party/waf/wafadmin/Tools/cc.py6
-rw-r--r--third_party/waf/wafadmin/Tools/ccroot.py10
-rw-r--r--third_party/waf/wafadmin/Tools/msvc.py2
-rw-r--r--third_party/waf/wafadmin/Tools/osx.py6
-rw-r--r--third_party/waf/wafadmin/Utils.py41
8 files changed, 58 insertions, 21 deletions
diff --git a/third_party/waf/wafadmin/Build.py b/third_party/waf/wafadmin/Build.py
index 50f4d7f6c69..d36d3df8eca 100644
--- a/third_party/waf/wafadmin/Build.py
+++ b/third_party/waf/wafadmin/Build.py
@@ -645,6 +645,10 @@ class BuildContext(Utils.Context):
cache[v] = x
return cache.get(env.variant() + '_' + name, None)
+ def get_tgen_by_name(self, name):
+ """waf 1.8 api"""
+ return self.name_to_obj(name, self.env)
+
def flush(self, all=1):
"""tell the task generators to create the tasks"""
diff --git a/third_party/waf/wafadmin/Node.py b/third_party/waf/wafadmin/Node.py
index 158a4a4d470..6b037263678 100644
--- a/third_party/waf/wafadmin/Node.py
+++ b/third_party/waf/wafadmin/Node.py
@@ -689,6 +689,13 @@ class Node(object):
child = self.ensure_dir_node_from_path(k)
child.update_build_dir(env)
+ def read(self, flags='r', encoding='ISO8859-1'):
+ """backported from waf 1.8"""
+ return Utils.readf(self.abspath(), flags, encoding)
+
+ def write(self, data, flags='w', encoding='ISO8859-1'):
+ """backported from waf 1.8"""
+ Utils.writef(self.abspath(self.bld.env), data, flags, encoding)
class Nodu(Node):
pass
diff --git a/third_party/waf/wafadmin/TaskGen.py b/third_party/waf/wafadmin/TaskGen.py
index 5900809ddfe..386798f424c 100644
--- a/third_party/waf/wafadmin/TaskGen.py
+++ b/third_party/waf/wafadmin/TaskGen.py
@@ -242,6 +242,9 @@ class task_gen(object):
def name_to_obj(self, name):
return self.bld.name_to_obj(name, self.env)
+ def get_tgen_by_name(self, name):
+ return self.bld.get_tgen_by_name(name)
+
def find_sources_in_dirs(self, dirnames, excludes=[], exts=[]):
"""
The attributes "excludes" and "exts" must be lists to avoid the confusion
diff --git a/third_party/waf/wafadmin/Tools/cc.py b/third_party/waf/wafadmin/Tools/cc.py
index e54df4715e5..7eb5272d69a 100644
--- a/third_party/waf/wafadmin/Tools/cc.py
+++ b/third_party/waf/wafadmin/Tools/cc.py
@@ -23,7 +23,7 @@ g_cc_type_vars = ['CCFLAGS', 'LINKFLAGS']
class cc_taskgen(ccroot.ccroot_abstract):
pass
-@feature('cc')
+@feature('c', 'cc')
@before('apply_type_vars')
@after('default_cc')
def init_cc(self):
@@ -33,7 +33,7 @@ def init_cc(self):
if not self.env['CC_NAME']:
raise Utils.WafError("At least one compiler (gcc, ..) must be selected")
-@feature('cc')
+@feature('c', 'cc')
@after('apply_incpaths')
def apply_obj_vars_cc(self):
"""after apply_incpaths for INC_PATHS"""
@@ -51,7 +51,7 @@ def apply_obj_vars_cc(self):
for i in env['CPPPATH']:
app('_CCINCFLAGS', cpppath_st % i)
-@feature('cc')
+@feature('c', 'cc')
@after('apply_lib_vars')
def apply_defines_cc(self):
"""after uselib is set for CCDEFINES"""
diff --git a/third_party/waf/wafadmin/Tools/ccroot.py b/third_party/waf/wafadmin/Tools/ccroot.py
index c130b40a21d..2240b2f3ae2 100644
--- a/third_party/waf/wafadmin/Tools/ccroot.py
+++ b/third_party/waf/wafadmin/Tools/ccroot.py
@@ -190,7 +190,7 @@ def get_target_name(self):
return os.path.join(dir, pattern % name)
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@before('apply_core')
def default_cc(self):
"""compiled_tasks attribute must be set before the '.c->.o' tasks can be created"""
@@ -253,7 +253,7 @@ def default_link_install(self):
if self.install_path:
self.bld.install_files(self.install_path, self.link_task.outputs[0], env=self.env, chmod=self.chmod)
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@after('apply_type_vars', 'apply_lib_vars', 'apply_core')
def apply_incpaths(self):
"""used by the scanner
@@ -297,7 +297,7 @@ def apply_incpaths(self):
if USE_TOP_LEVEL:
self.env.append_value('INC_PATHS', self.bld.srcnode)
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@after('init_cc', 'init_cxx')
@before('apply_lib_vars')
def apply_type_vars(self):
@@ -339,7 +339,7 @@ def apply_link(self):
self.link_task = tsk
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@after('apply_link', 'init_cc', 'init_cxx', 'apply_core')
def apply_lib_vars(self):
"""after apply_link because of 'link_task'
@@ -523,7 +523,7 @@ c_attrs = {
'frameworkpath' : 'FRAMEWORKPATH'
}
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@before('init_cxx', 'init_cc')
@before('apply_lib_vars', 'apply_obj_vars', 'apply_incpaths', 'init_cc')
def add_extra_flags(self):
diff --git a/third_party/waf/wafadmin/Tools/msvc.py b/third_party/waf/wafadmin/Tools/msvc.py
index 2a97d19a7eb..72e7376c129 100644
--- a/third_party/waf/wafadmin/Tools/msvc.py
+++ b/third_party/waf/wafadmin/Tools/msvc.py
@@ -638,7 +638,7 @@ def msvc_common_flags(conf):
##### conf above, build below
@after('apply_link')
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
def apply_flags_msvc(self):
if self.env.CC_NAME != 'msvc' or not self.link_task:
return
diff --git a/third_party/waf/wafadmin/Tools/osx.py b/third_party/waf/wafadmin/Tools/osx.py
index 88ca0d950aa..95184eec015 100644
--- a/third_party/waf/wafadmin/Tools/osx.py
+++ b/third_party/waf/wafadmin/Tools/osx.py
@@ -38,7 +38,7 @@ app_info = '''
# see WAF issue 285
# and also http://trac.macports.org/ticket/17059
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@before('apply_lib_vars')
def set_macosx_deployment_target(self):
if self.env['MACOSX_DEPLOYMENT_TARGET']:
@@ -47,7 +47,7 @@ def set_macosx_deployment_target(self):
if sys.platform == 'darwin':
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '.'.join(platform.mac_ver()[0].split('.')[:2])
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
@after('apply_lib_vars')
def apply_framework(self):
for x in self.to_list(self.env['FRAMEWORKPATH']):
@@ -145,7 +145,7 @@ def apply_link_osx(self):
self.env.append_value('LINKFLAGS', path)
@before('apply_link', 'apply_lib_vars')
-@feature('cc', 'cxx')
+@feature('c', 'cc', 'cxx')
def apply_bundle(self):
"""use env['MACBUNDLE'] to force all shlibs into mac bundles
or use obj.mac_bundle = True for specific targets only"""
diff --git a/third_party/waf/wafadmin/Utils.py b/third_party/waf/wafadmin/Utils.py
index 5a59a4c30a3..03b4229f02c 100644
--- a/third_party/waf/wafadmin/Utils.py
+++ b/third_party/waf/wafadmin/Utils.py
@@ -147,6 +147,38 @@ except ImportError:
# portability fixes may be added elsewhere (although, md5 should be everywhere by now)
md5 = None
+def readf(fname, m='r', encoding='ISO8859-1'):
+ """backported from waf 1.8"""
+ if sys.hexversion > 0x3000000 and not 'b' in m:
+ m += 'b'
+ f = open(fname, m)
+ try:
+ txt = f.read()
+ finally:
+ f.close()
+ if encoding:
+ txt = txt.decode(encoding)
+ else:
+ txt = txt.decode()
+ else:
+ f = open(fname, m)
+ try:
+ txt = f.read()
+ finally:
+ f.close()
+ return txt
+
+def writef(fname, data, m='w', encoding='ISO8859-1'):
+ """backported from waf 1.8"""
+ if sys.hexversion > 0x3000000 and not 'b' in m:
+ data = data.encode(encoding)
+ m += 'b'
+ f = open(fname, m)
+ try:
+ f.write(data)
+ finally:
+ f.close()
+
class ordered_dict(UserDict):
def __init__(self, dict = None):
self.allkeys = []
@@ -557,15 +589,6 @@ def load_tool(tool, tooldir=None):
for dt in tooldir:
sys.path.remove(dt)
-def readf(fname, m='r'):
- "get the contents of a file, it is not used anywhere for the moment"
- f = open(fname, m)
- try:
- txt = f.read()
- finally:
- f.close()
- return txt
-
def nada(*k, **kw):
"""A function that does nothing"""
pass