mirror of https://gitlab.com/ita1024/waf.git
Some more compatibility in compat15.py
This commit is contained in:
parent
9a0a7ca562
commit
f748a01907
|
@ -39,8 +39,43 @@ Build.BuildContext.new_task_gen = Build.BuildContext.__call__
|
|||
Build.BuildContext.is_install = 0
|
||||
Node.Node.relpath_gen = Node.Node.path_from
|
||||
|
||||
Utils.pproc = Utils.subprocess
|
||||
Utils.get_term_cols = Logs.get_term_cols
|
||||
|
||||
def cmd_output(cmd, **kw):
|
||||
|
||||
silent = False
|
||||
if 'silent' in kw:
|
||||
silent = kw['silent']
|
||||
del(kw['silent'])
|
||||
|
||||
if 'e' in kw:
|
||||
tmp = kw['e']
|
||||
del(kw['e'])
|
||||
kw['env'] = tmp
|
||||
|
||||
kw['shell'] = isinstance(cmd, str)
|
||||
kw['stdout'] = Utils.subprocess.PIPE
|
||||
if silent:
|
||||
kw['stderr'] = Utils.subprocess.PIPE
|
||||
|
||||
try:
|
||||
p = Utils.subprocess.Popen(cmd, **kw)
|
||||
output = p.communicate()[0]
|
||||
except OSError, e:
|
||||
raise ValueError(str(e))
|
||||
|
||||
if p.returncode:
|
||||
if not silent:
|
||||
msg = "command execution failed: %s -> %r" % (cmd, str(output))
|
||||
raise ValueError(msg)
|
||||
output = ''
|
||||
return output
|
||||
Utils.cmd_output = cmd_output
|
||||
|
||||
def name_to_obj(self, s, env=None):
|
||||
Logs.warn('compat: change "name_to_obj(name, env)" by "get_tgen_by_name(name)"')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: change "name_to_obj(name, env)" by "get_tgen_by_name(name)"')
|
||||
return self.get_tgen_by_name(s)
|
||||
Build.BuildContext.name_to_obj = name_to_obj
|
||||
|
||||
|
@ -66,7 +101,8 @@ def retrieve(self, name, fromenv=None):
|
|||
self.prepare_env(env)
|
||||
self.all_envs[name] = env
|
||||
else:
|
||||
if fromenv: Logs.warn("The environment %s may have been configured already" % name)
|
||||
if fromenv:
|
||||
Logs.warn("The environment %s may have been configured already" % name)
|
||||
return env
|
||||
Configure.ConfigurationContext.retrieve = retrieve
|
||||
|
||||
|
@ -99,25 +135,35 @@ eld = Context.load_tool
|
|||
def load_tool(*k, **kw):
|
||||
ret = eld(*k, **kw)
|
||||
if 'set_options' in ret.__dict__:
|
||||
Logs.warn('compat: rename "set_options" to options')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: rename "set_options" to options')
|
||||
ret.options = ret.set_options
|
||||
if 'detect' in ret.__dict__:
|
||||
Logs.warn('compat: rename "detect" to "configure"')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: rename "detect" to "configure"')
|
||||
ret.configure = ret.detect
|
||||
return ret
|
||||
Context.load_tool = load_tool
|
||||
|
||||
def get_curdir(self):
|
||||
return self.path.abspath()
|
||||
Context.Context.curdir = property(get_curdir, Utils.nada)
|
||||
|
||||
|
||||
rev = Context.load_module
|
||||
def load_module(path, encoding=None):
|
||||
ret = rev(path, encoding)
|
||||
if 'set_options' in ret.__dict__:
|
||||
Logs.warn('compat: rename "set_options" to "options" (%r)' % path)
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: rename "set_options" to "options" (%r)' % path)
|
||||
ret.options = ret.set_options
|
||||
if 'srcdir' in ret.__dict__:
|
||||
Logs.warn('compat: rename "srcdir" to "top" (%r)' % path)
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: rename "srcdir" to "top" (%r)' % path)
|
||||
ret.top = ret.srcdir
|
||||
if 'blddir' in ret.__dict__:
|
||||
Logs.warn('compat: rename "blddir" to "out" (%r)' % path)
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: rename "blddir" to "out" (%r)' % path)
|
||||
ret.out = ret.blddir
|
||||
return ret
|
||||
Context.load_module = load_module
|
||||
|
@ -126,15 +172,18 @@ old_post = TaskGen.task_gen.post
|
|||
def post(self):
|
||||
self.features = self.to_list(self.features)
|
||||
if 'cc' in self.features:
|
||||
Logs.warn('compat: the feature cc does not exist anymore (use "c")')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: the feature cc does not exist anymore (use "c")')
|
||||
self.features.remove('cc')
|
||||
self.features.append('c')
|
||||
if 'cstaticlib' in self.features:
|
||||
Logs.warn('compat: the feature cstaticlib does not exist anymore (use "cstlib" or "cxxstlib")')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: the feature cstaticlib does not exist anymore (use "cstlib" or "cxxstlib")')
|
||||
self.features.remove('cstaticlib')
|
||||
self.features.append(('cxx' in self.features) and 'cxxstlib' or 'cstlib')
|
||||
if getattr(self, 'ccflags', None):
|
||||
Logs.warn('compat: "ccflags" was renamed to "cflags"')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: "ccflags" was renamed to "cflags"')
|
||||
self.cflags = self.ccflags
|
||||
return old_post(self)
|
||||
TaskGen.task_gen.post = post
|
||||
|
@ -165,7 +214,8 @@ def apply_uselib_local(self):
|
|||
seen = set([])
|
||||
tmp = Utils.deque(names) # consume a copy of the list of names
|
||||
if tmp:
|
||||
Logs.warn('compat: "uselib_local" is deprecated, replace by "use"')
|
||||
if Logs.verbose:
|
||||
Logs.warn('compat: "uselib_local" is deprecated, replace by "use"')
|
||||
while tmp:
|
||||
lib_name = tmp.popleft()
|
||||
# visit dependencies only once
|
||||
|
|
Loading…
Reference in New Issue