1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

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>
This commit is contained in:
Thomas Nagy 2015-06-26 20:13:09 +02:00 committed by Andrew Bartlett
parent 841845dea3
commit bcf5f45d87
8 changed files with 58 additions and 21 deletions

View File

@ -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"""

View File

@ -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

View File

@ -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

View File

@ -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"""

View File

@ -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):

View File

@ -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

View File

@ -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"""

View File

@ -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