Fix builtin variable names

pull/5311/head
Daniel Mensinger 5 years ago
parent bf98ffca9e
commit e75211d321
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 6
      mesonbuild/ast/introspection.py
  2. 4
      mesonbuild/backend/ninjabackend.py
  3. 4
      mesonbuild/compilers/cs.py
  4. 8
      mesonbuild/dependencies/ui.py
  5. 16
      mesonbuild/mesonlib.py
  6. 30
      mesonbuild/mesonmain.py
  7. 2
      mesonbuild/minstall.py
  8. 10
      mesonbuild/mlog.py
  9. 6
      mesonbuild/modules/python.py
  10. 4
      mesonbuild/modules/windows.py
  11. 10
      mesonbuild/munstable_coredata.py
  12. 4
      run_unittests.py
  13. 2
      setup.cfg
  14. 1
      sideci.yml

@ -173,9 +173,9 @@ class IntrospectionInterpreter(AstInterpreter):
arg_node = curr.args
elif isinstance(curr, IdNode):
# Try to resolve the ID and append the node to the queue
id = curr.value
if id in self.assignments and self.assignments[id]:
tmp_node = self.assignments[id][0]
var_name = curr.value
if var_name in self.assignments and self.assignments[var_name]:
tmp_node = self.assignments[var_name][0]
if isinstance(tmp_node, (ArrayNode, IdNode, FunctionNode)):
srcqueue += [tmp_node]
elif isinstance(curr, ArithmeticNode):

@ -406,9 +406,9 @@ int dummy;
}
}
'''
id = target.get_id()
tid = target.get_id()
lang = comp.get_language()
tgt = self.introspection_data[id]
tgt = self.introspection_data[tid]
# Find an existing entry or create a new one
id_hash = (lang, tuple(parameters))
src_block = tgt.get(id_hash, None)

@ -28,10 +28,10 @@ cs_optimization_args = {'0': [],
}
class CsCompiler(Compiler):
def __init__(self, exelist, version, id, runner=None):
def __init__(self, exelist, version, comp_id, runner=None):
self.language = 'cs'
super().__init__(exelist, version)
self.id = id
self.id = comp_id
self.is_cross = False
self.runner = runner

@ -298,8 +298,8 @@ class QtBaseDependency(ExternalDependency):
# the Qt + m_name there is not a symlink, it's a file
mod_private_dir = qt_inc_dir
mod_private_inc = _qt_get_private_includes(mod_private_dir, m_name, m.version)
for dir in mod_private_inc:
self.compile_args.append('-I' + dir)
for directory in mod_private_inc:
self.compile_args.append('-I' + directory)
self.link_args += m.get_link_args()
if 'Core' in modules:
@ -402,8 +402,8 @@ class QtBaseDependency(ExternalDependency):
if self.private_headers:
priv_inc = self.get_private_includes(mincdir, module)
for dir in priv_inc:
self.compile_args.append('-I' + dir)
for directory in priv_inc:
self.compile_args.append('-I' + directory)
libfile = self.clib_compiler.find_library(self.qtpkgname + module + modules_lib_suffix,
self.env,
libdir)

@ -722,11 +722,11 @@ def has_path_sep(name, sep='/\\'):
return True
return False
def do_replacement(regex, line, format, confdata):
def do_replacement(regex, line, variable_format, confdata):
missing_variables = set()
start_tag = '@'
backslash_tag = '\\@'
if format == 'cmake':
if variable_format == 'cmake':
start_tag = '${'
backslash_tag = '\\${'
@ -779,7 +779,7 @@ def do_mesondefine(line, confdata):
raise MesonException('#mesondefine argument "%s" is of unknown type.' % varname)
def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
def do_conf_file(src, dst, confdata, variable_format, encoding='utf-8'):
try:
with open(src, encoding=encoding, newline='') as f:
data = f.readlines()
@ -787,15 +787,15 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
raise MesonException('Could not read input file %s: %s' % (src, str(e)))
# Only allow (a-z, A-Z, 0-9, _, -) as valid characters for a define
# Also allow escaping '@' with '\@'
if format in ['meson', 'cmake@']:
if variable_format in ['meson', 'cmake@']:
regex = re.compile(r'(?:\\\\)+(?=\\?@)|\\@|@([-a-zA-Z0-9_]+)@')
elif format == 'cmake':
elif variable_format == 'cmake':
regex = re.compile(r'(?:\\\\)+(?=\\?\$)|\\\${|\${([-a-zA-Z0-9_]+)}')
else:
raise MesonException('Format "{}" not handled'.format(format))
raise MesonException('Format "{}" not handled'.format(variable_format))
search_token = '#mesondefine'
if format != 'meson':
if variable_format != 'meson':
search_token = '#cmakedefine'
result = []
@ -808,7 +808,7 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
confdata_useless = False
line = do_mesondefine(line, confdata)
else:
line, missing = do_replacement(regex, line, format, confdata)
line, missing = do_replacement(regex, line, variable_format, confdata)
missing_variables.update(missing)
if missing:
confdata_useless = False

@ -41,41 +41,41 @@ class CommandLineParser:
self.subparsers = self.parser.add_subparsers(title='Commands',
description='If no command is specified it defaults to setup command.')
self.add_command('setup', msetup.add_arguments, msetup.run,
help='Configure the project')
help_msg='Configure the project')
self.add_command('configure', mconf.add_arguments, mconf.run,
help='Change project options',)
help_msg='Change project options',)
self.add_command('install', minstall.add_arguments, minstall.run,
help='Install the project')
help_msg='Install the project')
self.add_command('introspect', mintro.add_arguments, mintro.run,
help='Introspect project')
help_msg='Introspect project')
self.add_command('init', minit.add_arguments, minit.run,
help='Create a new project')
help_msg='Create a new project')
self.add_command('test', mtest.add_arguments, mtest.run,
help='Run tests')
help_msg='Run tests')
self.add_command('wrap', wraptool.add_arguments, wraptool.run,
help='Wrap tools')
help_msg='Wrap tools')
self.add_command('subprojects', msubprojects.add_arguments, msubprojects.run,
help='Manage subprojects')
help_msg='Manage subprojects')
self.add_command('help', self.add_help_arguments, self.run_help_command,
help='Print help of a subcommand')
help_msg='Print help of a subcommand')
self.add_command('rewrite', lambda parser: rewriter.add_arguments(parser, self.formater), rewriter.run,
help='Modify the project definition')
help_msg='Modify the project definition')
# Hidden commands
self.add_command('runpython', self.add_runpython_arguments, self.run_runpython_command,
help=argparse.SUPPRESS)
help_msg=argparse.SUPPRESS)
self.add_command('unstable-coredata', munstable_coredata.add_arguments, munstable_coredata.run,
help=argparse.SUPPRESS)
help_msg=argparse.SUPPRESS)
def add_command(self, name, add_arguments_func, run_func, help, aliases=None):
def add_command(self, name, add_arguments_func, run_func, help_msg, aliases=None):
aliases = aliases or []
# FIXME: Cannot have hidden subparser:
# https://bugs.python.org/issue22848
if help == argparse.SUPPRESS:
if help_msg == argparse.SUPPRESS:
p = argparse.ArgumentParser(prog='meson ' + name, formatter_class=self.formater)
self.hidden_commands.append(name)
else:
p = self.subparsers.add_parser(name, help=help, aliases=aliases, formatter_class=self.formater)
p = self.subparsers.add_parser(name, help=help_msg, aliases=aliases, formatter_class=self.formater)
add_arguments_func(p)
p.set_defaults(run_func=run_func)
for i in [name] + aliases:

@ -65,7 +65,7 @@ class DirMaker:
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
def __exit__(self, exception_type, value, traceback):
self.dirs.reverse()
for d in self.dirs:
append_to_log(self.lf, d)

@ -234,14 +234,14 @@ def exception(e: Exception, prefix: AnsiDecorator = red('ERROR:')) -> None:
# Format a list for logging purposes as a string. It separates
# all but the last item with commas, and the last with 'and'.
def format_list(list_: typing.List[str]) -> str:
l = len(list_)
def format_list(input_list: typing.List[str]) -> str:
l = len(input_list)
if l > 2:
return ' and '.join([', '.join(list_[:-1]), list_[-1]])
return ' and '.join([', '.join(input_list[:-1]), input_list[-1]])
elif l == 2:
return ' and '.join(list_)
return ' and '.join(input_list)
elif l == 1:
return list_[0]
return input_list[0]
else:
return ''

@ -477,9 +477,9 @@ class PythonModule(ExtensionModule):
ver = {'python2': '-2', 'python3': '-3'}[name_or_path]
cmd = ['py', ver, '-c', "import sysconfig; print(sysconfig.get_config_var('BINDIR'))"]
_, stdout, _ = mesonlib.Popen_safe(cmd)
dir = stdout.strip()
if os.path.exists(dir):
return os.path.join(dir, 'python')
directory = stdout.strip()
if os.path.exists(directory):
return os.path.join(directory, 'python')
else:
return None

@ -59,7 +59,7 @@ class WindowsModule(ExtensionModule):
if not rescomp.found():
raise MesonException('Could not find Windows resource compiler')
for (arg, match, type) in [
for (arg, match, rc_type) in [
('/?', '^.*Microsoft.*Resource Compiler.*$', ResourceCompilerType.rc),
('--version', '^.*GNU windres.*$', ResourceCompilerType.windres),
]:
@ -67,7 +67,7 @@ class WindowsModule(ExtensionModule):
m = re.search(match, o, re.MULTILINE)
if m:
mlog.log('Windows resource compiler: %s' % m.group())
self._rescomp = (rescomp, type)
self._rescomp = (rescomp, rc_type)
break
else:
raise MesonException('Could not determine type of Windows resource compiler')

@ -51,7 +51,7 @@ def run(options):
'change the working directory to it.')
return 1
all = options.all
all_backends = options.all
print('This is a dump of the internal unstable cache of meson. This is for debugging only.')
print('Do NOT parse, this will change from version to version in incompatible ways')
@ -64,18 +64,18 @@ def run(options):
# use `meson configure` to view these
pass
elif k in ['install_guid', 'test_guid', 'regen_guid']:
if all or backend.startswith('vs'):
if all_backends or backend.startswith('vs'):
print(k + ': ' + v)
elif k == 'target_guids':
if all or backend.startswith('vs'):
if all_backends or backend.startswith('vs'):
print(k + ':')
dump_guids(v)
elif k in ['lang_guids']:
if all or backend.startswith('vs') or backend == 'xcode':
if all_backends or backend.startswith('vs') or backend == 'xcode':
print(k + ':')
dump_guids(v)
elif k == 'meson_command':
if all or backend.startswith('vs'):
if all_backends or backend.startswith('vs'):
print('Meson command used in build file regeneration: ' + ' '.join(v))
elif k == 'pkgconf_envvar':
print('Last seen PKGCONFIG enviroment variable value: ' + v)

@ -2681,9 +2681,9 @@ int main(int argc, char **argv) {
if ninja is None:
raise unittest.SkipTest('This test currently requires ninja. Fix this once "meson build" works.')
for lang in ('c', 'cpp'):
for type in ('executable', 'library'):
for target_type in ('executable', 'library'):
with tempfile.TemporaryDirectory() as tmpdir:
self._run(self.meson_command + ['init', '--language', lang, '--type', type],
self._run(self.meson_command + ['init', '--language', lang, '--type', target_type],
workdir=tmpdir)
self._run(self.setup_command + ['--backend=ninja', 'builddir'],
workdir=tmpdir)

@ -28,4 +28,6 @@ ignore =
E722
# W504: line break after binary operator
W504
# A003: builtin class attribute
A003
max-line-length = 120

@ -3,3 +3,4 @@ linter:
version: 3
plugins:
- flake8-blind-except
- flake8-builtins

Loading…
Cancel
Save