diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 91 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 2 | ||||
-rw-r--r-- | mesonbuild/build.py | 16 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 16 | ||||
-rw-r--r-- | mesonbuild/dependencies.py | 18 | ||||
-rw-r--r-- | mesonbuild/environment.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 6 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 14 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 12 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 8 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 2 | ||||
-rw-r--r-- | mesonbuild/scripts/depfixer.py | 2 | ||||
-rw-r--r-- | mesonbuild/scripts/uninstall.py | 2 | ||||
-rw-r--r-- | mesonbuild/wrap/wraptool.py | 4 |
15 files changed, 99 insertions, 100 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 389e759..65e1162 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -313,7 +313,9 @@ class Backend: # anyone both enables unity builds and has a file called foo-unity.cpp. osrc = self.get_unity_source_filename(extobj.target, comp.get_default_suffix()) + osrc = os.path.join(self.get_target_private_dir(extobj.target), osrc) objname = self.object_filename_from_source(extobj.target, osrc, True) + objname = objname.replace('/', '_').replace('\\', '_') objpath = os.path.join(proj_dir_to_build_root, targetdir, objname) return [objpath] for osrc in extobj.srclist: @@ -328,7 +330,7 @@ class Backend: includeargs = compiler.get_include_args(pchpath, False) for lang in ['c', 'cpp']: p = target.get_pch(lang) - if len(p) == 0: + if not p: continue if compiler.can_compile(p[-1]): header = p[0] diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d8be828..4066ebf 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -40,25 +40,6 @@ else: def ninja_quote(text): return text.replace(' ', '$ ').replace(':', '$:') -class RawFilename: - """ - Used when a filename is already relative to the root build directory, so - that we know not to add the target's private build directory to it. - """ - def __init__(self, fname): - self.fname = fname - - def __str__(self): - return self.fname - - def __repr__(self): - return '<RawFilename: {0}>'.format(self.fname) - - def split(self, c): - return self.fname.split(c) - - def startswith(self, s): - return self.fname.startswith(s) class NinjaBuildElement: def __init__(self, all_outputs, outfilenames, rule, infilenames): @@ -175,11 +156,16 @@ int dummy; stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdo, _) = pc.communicate() + # We want to match 'Note: including file: ' in the line + # 'Note: including file: d:\MyDir\include\stdio.h', however + # different locales have different messages with a different + # number of colons. Match up to the the drive name 'd:\'. + matchre = re.compile(rb"^(.*\s)[a-zA-Z]:\\.*stdio.h$") for line in stdo.split(b'\r\n'): - if line.endswith(b'stdio.h'): - matchstr = b':'.join(line.split(b':')[0:2]) + b':' + match = matchre.match(line) + if match: with open(tempfilename, 'ab') as binfile: - binfile.write(b'msvc_deps_prefix = ' + matchstr + b'\n') + binfile.write(b'msvc_deps_prefix = ' + match.group(1) + b'\n') return open(tempfilename, 'a') raise MesonException('Could not determine vs dep dependency prefix string.') @@ -371,7 +357,8 @@ int dummy; # same time, also deal with generated sources that need to be compiled. generated_source_files = [] for rel_src, gensrc in generated_sources.items(): - raw_src = RawFilename(rel_src) + dirpart, fnamepart = os.path.split(rel_src) + raw_src = File(True, dirpart, fnamepart) if self.environment.is_source(rel_src) and not self.environment.is_header(rel_src): if is_unity and self.get_target_source_can_unity(target, rel_src): unity_deps.append(raw_src) @@ -404,7 +391,8 @@ int dummy; # necessary. This needs to be separate for at least Vala vala_generated_source_files = [] for src in vala_generated_sources: - raw_src = RawFilename(src) + dirpart, fnamepart = os.path.split(src) + raw_src = File(True, dirpart, fnamepart) if is_unity: unity_src.append(os.path.join(self.environment.get_build_dir(), src)) header_deps.append(raw_src) @@ -1043,7 +1031,7 @@ int dummy; """Vala is compiled into C. Set up all necessary build steps here.""" (vala_src, vapi_src, other_src) = self.split_vala_sources(target) extra_dep_files = [] - if len(vala_src) == 0: + if not vala_src: msg = 'Vala library {!r} has no Vala source files.' raise InvalidArguments(msg.format(target.name)) @@ -1841,8 +1829,11 @@ rule FORTRAN_DEP_HACK # Compiler args for compiling this target commands += compilers.get_base_compile_args(self.environment.coredata.base_options, compiler) - if isinstance(src, (RawFilename, File)): - src_filename = src.fname + if isinstance(src, File): + if src.is_built: + src_filename = os.path.join(src.subdir, src.fname) + else: + src_filename = src.fname elif os.path.isabs(src): src_filename = os.path.basename(src) else: @@ -1851,7 +1842,7 @@ rule FORTRAN_DEP_HACK rel_obj = os.path.join(self.get_target_private_dir(target), obj_basename) rel_obj += '.' + self.environment.get_object_suffix() commands += self.get_compile_debugfile_args(compiler, target, rel_obj) - if isinstance(src, RawFilename): + if isinstance(src, File) and src.is_built: rel_src = src.fname elif isinstance(src, File): rel_src = src.rel_to_builddir(self.build_to_src) @@ -1973,13 +1964,7 @@ rule FORTRAN_DEP_HACK """ if isinstance(src, str) and src.endswith('.h'): raise AssertionError('BUG: sources should not contain headers {!r}'.format(src)) - if isinstance(src, RawFilename) and src.fname.endswith('.h'): - raise AssertionError('BUG: sources should not contain headers {!r}'.format(src.fname)) - if isinstance(src, str) and src.endswith('.h'): - raise AssertionError('BUG: sources should not contain headers {!r}'.format(src)) - if isinstance(src, RawFilename) and src.fname.endswith('.h'): - raise AssertionError('BUG: sources should not contain headers {!r}'.format(src.fname)) compiler = get_compiler_for_source(target.compilers.values(), src) key = (target, compiler, is_generated) if key in self.target_arg_cache: @@ -1989,14 +1974,12 @@ rule FORTRAN_DEP_HACK self.target_arg_cache[key] = commands commands = CompilerArgs(commands.compiler, commands) - # FIXME: This file handling is atrocious and broken. We need to - # replace it with File objects used consistently everywhere. - if isinstance(src, RawFilename): - rel_src = src.fname - if os.path.isabs(src.fname): - abs_src = src.fname - else: - abs_src = os.path.join(self.environment.get_build_dir(), src.fname) + if isinstance(src, mesonlib.File) and src.is_built: + rel_src = os.path.join(src.subdir, src.fname) + if os.path.isabs(rel_src): + assert(rel_src.startswith(self.environment.get_build_dir())) + rel_src = rel_src[len(self.environment.get_build_dir())+1:] + abs_src = os.path.join(self.environment.get_build_dir(), rel_src) elif isinstance(src, mesonlib.File): rel_src = src.rel_to_builddir(self.build_to_src) abs_src = src.absolute_path(self.environment.get_source_dir(), @@ -2009,8 +1992,14 @@ rule FORTRAN_DEP_HACK else: raise InvalidArguments('Invalid source type: {!r}'.format(src)) abs_src = os.path.join(self.environment.get_build_dir(), rel_src) - if isinstance(src, (RawFilename, File)): - src_filename = src.fname + if isinstance(src, File): + if src.is_built: + src_filename = os.path.join(src.subdir, src.fname) + if os.path.isabs(src_filename): + assert(src_filename.startswith(self.environment.get_build_dir())) + src_filename = src_filename[len(self.environment.get_build_dir())+1:] + else: + src_filename = src.fname elif os.path.isabs(src): src_filename = os.path.basename(src) else: @@ -2029,7 +2018,7 @@ rule FORTRAN_DEP_HACK pchlist = target.get_pch(compiler.language) else: pchlist = [] - if len(pchlist) == 0: + if not pchlist: pch_dep = [] elif compiler.id == 'intel': pch_dep = [] @@ -2063,16 +2052,16 @@ rule FORTRAN_DEP_HACK element = NinjaBuildElement(self.all_outputs, rel_obj, compiler_name, rel_src) for d in header_deps: - if isinstance(d, RawFilename): - d = d.fname + if isinstance(d, File): + d = d.rel_to_builddir(self.build_to_src) elif not self.has_dir_part(d): d = os.path.join(self.get_target_private_dir(target), d) element.add_dep(d) for d in extra_deps: element.add_dep(d) for d in order_deps: - if isinstance(d, RawFilename): - d = d.fname + if isinstance(d, File): + d = d.rel_to_builddir(self.build_to_src) elif not self.has_dir_part(d): d = os.path.join(self.get_target_private_dir(target), d) element.add_orderdep(d) @@ -2089,6 +2078,8 @@ rule FORTRAN_DEP_HACK def has_dir_part(self, fname): # FIXME FIXME: The usage of this is a terrible and unreliable hack + if isinstance(fname, File): + return fname.subdir != '' return '/' in fname or '\\' in fname # Fortran is a bit weird (again). When you link against a library, just compiling a source file @@ -2134,7 +2125,7 @@ rule FORTRAN_DEP_HACK cstr = '_CROSS' for lang in ['c', 'cpp']: pch = target.get_pch(lang) - if len(pch) == 0: + if not pch: continue if '/' not in pch[0] or '/' not in pch[-1]: msg = 'Precompiled header of {!r} must not be in the same ' \ diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 432bdd0..16e96c9 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -865,7 +865,7 @@ class Vs2010Backend(backends.Backend): pch_sources = {} for lang in ['c', 'cpp']: pch = target.get_pch(lang) - if len(pch) == 0: + if not pch: continue pch_node.text = 'Use' pch_sources[lang] = [pch[0], pch[1], lang] diff --git a/mesonbuild/build.py b/mesonbuild/build.py index a5ebc34..c8d692e 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -115,7 +115,7 @@ class Build: self.compilers[lang] = compiler def add_cross_compiler(self, compiler): - if len(self.cross_compilers) == 0: + if not self.cross_compilers: self.static_cross_linker = self.environment.detect_static_linker(compiler) lang = compiler.get_language() if lang not in self.cross_compilers: @@ -340,9 +340,7 @@ class BuildTarget(Target): self.process_objectlist(objects) self.process_kwargs(kwargs, environment) self.check_unknown_kwargs(kwargs) - if len(self.sources) == 0 \ - and len(self.generated) == 0 \ - and len(self.objects) == 0: + if not self.sources and not self.generated and not self.objects: raise InvalidArguments('Build target %s has no sources.' % name) self.process_compilers() self.validate_sources() @@ -433,7 +431,7 @@ class BuildTarget(Target): We also add compilers that were used by extracted objects to simplify dynamic linker determination. ''' - if len(self.sources) + len(self.generated) + len(self.objects) == 0: + if not self.sources and not self.generated and not self.objects: return # Populate list of compilers if self.is_cross: @@ -488,7 +486,7 @@ class BuildTarget(Target): self.compilers['c'] = compilers['c'] def validate_sources(self): - if len(self.sources) == 0: + if not self.sources: return for lang in ('cs', 'java'): if lang in self.compilers: @@ -675,7 +673,7 @@ class BuildTarget(Target): if 'name_prefix' in kwargs: name_prefix = kwargs['name_prefix'] if isinstance(name_prefix, list): - if len(name_prefix) != 0: + if name_prefix: raise InvalidArguments('name_prefix array must be empty to signify null.') elif not isinstance(name_prefix, str): raise InvalidArguments('name_prefix must be a string.') @@ -684,7 +682,7 @@ class BuildTarget(Target): if 'name_suffix' in kwargs: name_suffix = kwargs['name_suffix'] if isinstance(name_suffix, list): - if len(name_suffix) != 0: + if name_suffix: raise InvalidArguments('name_suffix array must be empty to signify null.') else: if not isinstance(name_suffix, str): @@ -825,7 +823,7 @@ You probably should put it in link_with instead.''') self.link_whole_targets.append(t) def add_pch(self, language, pchlist): - if len(pchlist) == 0: + if not pchlist: return elif len(pchlist) == 1: if not environment.is_header(pchlist[0]): diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 188bd8f..ba0fb4e 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -317,12 +317,12 @@ def get_base_link_args(options, linker, is_shared_module): return args def build_unix_rpath_args(build_dir, rpath_paths, install_rpath): - if len(rpath_paths) == 0 and len(install_rpath) == 0: + if not rpath_paths and not install_rpath: return [] paths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) if len(paths) < len(install_rpath): padding = 'X' * (len(install_rpath) - len(paths)) - if len(paths) == 0: + if not paths: paths = padding else: paths = paths + ':' + padding @@ -388,7 +388,7 @@ class CompilerArgs(list): if len(args) > 2: raise TypeError("CompilerArgs() only accepts at most 2 arguments: " "The compiler, and optionally an initial list") - elif len(args) == 0: + elif not args: return cargs elif len(args) == 1: if isinstance(args[0], (Compiler, StaticLinker)): @@ -708,7 +708,7 @@ class Compiler: return self.get_std_shared_lib_link_args() def get_link_whole_for(self, args): - if isinstance(args, list) and len(args) == 0: + if isinstance(args, list) and not args: return [] raise EnvironmentException('Language %s does not support linking whole archives.' % self.language) @@ -1360,7 +1360,7 @@ class CCompiler(Compiler): extra_dirs = [extra_dirs] # Gcc + co seem to prefer builtin lib dirs to -L dirs. # Only try to find std libs if no extra dirs specified. - if len(extra_dirs) == 0: + if not extra_dirs: args = ['-l' + libname] if self.links(code, env, extra_args=args): return args @@ -1700,7 +1700,7 @@ class ValaCompiler(Compiler): extra_dirs = [extra_dirs] # Valac always looks in the default vapi dir, so only search there if # no extra dirs are specified. - if len(extra_dirs) == 0: + if not extra_dirs: code = 'class MesonFindLibrary : Object { }' vapi_args = ['--pkg', libname] args = self.get_cross_extra_flags(env, link=False) @@ -1892,12 +1892,12 @@ class DCompiler(Compiler): def build_rpath_args(self, build_dir, rpath_paths, install_rpath): # This method is to be used by LDC and DMD. # GDC can deal with the verbatim flags. - if len(rpath_paths) == 0 and len(install_rpath) == 0: + if not rpath_paths and not install_rpath: return [] paths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) if len(paths) < len(install_rpath): padding = 'X' * (len(install_rpath) - len(paths)) - if len(paths) == 0: + if not paths: paths = padding else: paths = paths + ':' + padding diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index 04a22f9..c512bf3 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -777,7 +777,7 @@ class BoostDependency(Dependency): else: libdir = [] # Can't find libdir, bail - if len(libdir) == 0: + if not libdir: return libdir = libdir[0] self.libdir = libdir @@ -1021,7 +1021,7 @@ class QtBaseDependency(Dependency): self.is_found = False if isinstance(mods, str): mods = [mods] - if len(mods) == 0: + if not mods: raise DependencyException('No ' + self.qtname + ' modules specified.') type_text = 'cross' if env.is_cross_build() else 'native' found_msg = '{} {} {{}} dependency (modules: {}) found:' \ @@ -1136,7 +1136,7 @@ class QtBaseDependency(Dependency): self.cargs.append('-I' + incdir) libdir = qvars['QT_INSTALL_LIBS'] # Used by self.compilers_detect() - self.bindir = qvars['QT_INSTALL_BINS'] + self.bindir = self.get_qmake_host_bins(qvars) self.is_found = True for module in mods: mincdir = os.path.join(incdir, 'Qt' + module) @@ -1168,7 +1168,15 @@ class QtBaseDependency(Dependency): self.cargs += fwdep.get_compile_args() self.largs += fwdep.get_link_args() # Used by self.compilers_detect() - self.bindir = qvars['QT_INSTALL_BINS'] + self.bindir = self.get_qmake_host_bins(qvars) + + def get_qmake_host_bins(self, qvars): + # Prefer QT_HOST_BINS (qt5, correct for cross and native compiling) + # but fall back to QT_INSTALL_BINS (qt4) + if 'QT_HOST_BINS' in qvars: + return qvars['QT_HOST_BINS'] + else: + return qvars['QT_INSTALL_BINS'] def get_version(self): return self.version @@ -1324,7 +1332,7 @@ class AppleFrameworks(Dependency): modules = kwargs.get('modules', []) if isinstance(modules, str): modules = [modules] - if len(modules) == 0: + if not modules: raise DependencyException("AppleFrameworks dependency requires at least one module.") self.frameworks = modules diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b0ba78d..13bbe62 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -872,7 +872,7 @@ class CrossBuildInfo: if ' ' in entry or '\t' in entry or "'" in entry or '"' in entry: raise EnvironmentException('Malformed variable name %s in cross file..' % entry) try: - res = eval(value, {'true': True, 'false': False}) + res = eval(value, {'__builtins__': None}, {'true': True, 'false': False}) except Exception: raise EnvironmentException('Malformed value in cross file variable %s.' % entry) if self.ok_type(res): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index eaaea73..979cdcc 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1581,7 +1581,7 @@ class Interpreter(InterpreterBase): @noKwargs def func_configuration_data(self, node, args, kwargs): - if len(args) != 0: + if args: raise InterpreterException('configuration_data takes no arguments') return ConfigurationDataHolder() @@ -1818,7 +1818,7 @@ class Interpreter(InterpreterBase): self.coredata.base_options[optname] = oobj def func_find_program(self, node, args, kwargs): - if len(args) == 0: + if not args: raise InterpreterException('No program name specified.') required = kwargs.get('required', True) if not isinstance(required, bool): @@ -2533,7 +2533,7 @@ different subdirectory. self.coredata.target_guids[idname] = str(uuid.uuid4()).upper() def build_target(self, node, args, kwargs, targetholder): - if len(args) == 0: + if not args: raise InterpreterException('Target does not have a name.') name = args[0] sources = args[1:] diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index e59557a..86a6b47 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -34,7 +34,7 @@ def check_stringlist(a, msg='Arguments must be strings.'): def noPosargs(f): @wraps(f) def wrapped(self, node, args, kwargs): - if len(args) != 0: + if args: raise InvalidArguments('Function does not take positional arguments.') return f(self, node, args, kwargs) return wrapped @@ -42,7 +42,7 @@ def noPosargs(f): def noKwargs(f): @wraps(f) def wrapped(self, node, args, kwargs): - if len(kwargs) != 0: + if kwargs: raise InvalidArguments('Function does not take keyword arguments.') return f(self, node, args, kwargs) return wrapped @@ -94,7 +94,7 @@ class InterpreterBase: raise InvalidArguments('Missing Meson file in %s' % mesonfile) with open(mesonfile, encoding='utf8') as mf: code = mf.read() - if len(code.strip()) == 0: + if code.isspace(): raise InvalidCode('Builder file is empty.') assert(isinstance(code, str)) try: @@ -113,7 +113,7 @@ class InterpreterBase: def sanity_check_ast(self): if not isinstance(self.ast, mparser.CodeBlockNode): raise InvalidCode('AST is of invalid type. Possibly a bug in the parser.') - if len(self.ast.lines) == 0: + if not self.ast.lines: raise InvalidCode('No statements in code.') first = self.ast.lines[0] if not isinstance(first, mparser.FunctionNode) or first.func_name != 'project': @@ -405,7 +405,7 @@ class InterpreterBase: obj = self.to_native(obj) (posargs, _) = self.reduce_arguments(args) if method_name == 'to_string': - if len(posargs) == 0: + if not posargs: if obj: return 'true' else: @@ -429,12 +429,12 @@ class InterpreterBase: obj = self.to_native(obj) (posargs, _) = self.reduce_arguments(args) if method_name == 'is_even': - if len(posargs) == 0: + if not posargs: return obj % 2 == 0 else: raise InterpreterException('int.is_even() must have no arguments.') elif method_name == 'is_odd': - if len(posargs) == 0: + if not posargs: return obj % 2 != 0 else: raise InterpreterException('int.is_odd() must have no arguments.') diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 2ab5f92..b4add65 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -56,7 +56,7 @@ class Conf: # Ninja is run. def print_aligned(self, arr): - if len(arr) == 0: + if not arr: return titles = ['Option', 'Description', 'Current Value', ''] longest_name = len(titles[0]) @@ -139,7 +139,7 @@ class Conf: print('') print('Base options:') okeys = sorted(self.coredata.base_options.keys()) - if len(okeys) == 0: + if not okeys: print(' No base options\n') else: coarr = [] @@ -158,7 +158,7 @@ class Conf: print('') print('Compiler options:') okeys = sorted(self.coredata.compiler_options.keys()) - if len(okeys) == 0: + if not okeys: print(' No compiler options\n') else: coarr = [] @@ -188,7 +188,7 @@ class Conf: self.print_aligned(parr) print('') print('Project options:') - if len(self.coredata.user_options) == 0: + if not self.coredata.user_options: print(' This project does not have any options') else: options = self.coredata.user_options @@ -197,7 +197,7 @@ class Conf: optarr = [] for key in keys: opt = options[key] - if (opt.choices is None) or (len(opt.choices) == 0): + if (opt.choices is None) or (not opt.choices): # Zero length list or string choices = '' else: @@ -222,7 +222,7 @@ def run(args): print('%s <build directory>' % args[0]) print('If you omit the build directory, the current directory is substituted.') return 1 - if len(options.directory) == 0: + if not options.directory: builddir = os.getcwd() else: builddir = options.directory[0] diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index df112b3..bce0965 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -87,8 +87,8 @@ class MesonApp: return os.path.exists(fname) def validate_core_dirs(self, dir1, dir2): - ndir1 = os.path.abspath(dir1) - ndir2 = os.path.abspath(dir2) + ndir1 = os.path.abspath(os.path.realpath(dir1)) + ndir2 = os.path.abspath(os.path.realpath(dir2)) if not os.path.exists(ndir1): os.makedirs(ndir1) if not os.path.exists(ndir2): @@ -272,10 +272,10 @@ def run(mainfile, args): args = mesonlib.expand_arguments(args) options = parser.parse_args(args) args = options.directories - if len(args) == 0 or len(args) > 2: + if not args or len(args) > 2: # if there's a meson.build in the dir above, and not in the current # directory, assume we're in the build directory - if len(args) == 0 and not os.path.exists('meson.build') and os.path.exists('../meson.build'): + if not args and not os.path.exists('meson.build') and os.path.exists('../meson.build'): dir1 = '..' dir2 = '.' else: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index b4dfd12..134060f 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -566,7 +566,7 @@ class GnomeModule(ExtensionModule): return ModuleReturnValue(rv, rv) def compile_schemas(self, state, args, kwargs): - if len(args) != 0: + if args: raise MesonException('Compile_schemas does not take positional arguments.') srcdir = os.path.join(state.build_to_src, state.subdir) outdir = state.subdir diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 16050d7..fa76a95 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -305,7 +305,7 @@ class Elf(DataSizes): # the chance of obliterating other strings. It might still happen # but our behaviour is identical to what chrpath does and it has # been in use for ages so based on that this should be rare. - if len(new_rpath) == 0: + if not new_rpath: self.remove_rpath_entry(entrynum) else: self.bf.seek(rp_off) diff --git a/mesonbuild/scripts/uninstall.py b/mesonbuild/scripts/uninstall.py index 85c4bba..1480921 100644 --- a/mesonbuild/scripts/uninstall.py +++ b/mesonbuild/scripts/uninstall.py @@ -36,7 +36,7 @@ def do_uninstall(log): print('\nRemember that files created by custom scripts have not been removed.') def run(args): - if len(args) != 0: + if args: print('Weird error.') return 1 if not os.path.exists(logfile): diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py index 79bd5df..79b00e0 100644 --- a/mesonbuild/wrap/wraptool.py +++ b/mesonbuild/wrap/wraptool.py @@ -135,7 +135,7 @@ def update(name): def info(name): jd = get_result(API_ROOT + 'projects/' + name) versions = jd['versions'] - if len(versions) == 0: + if not versions: print('No available versions of', name) sys.exit(0) print('Available versions of %s:' % name) @@ -162,7 +162,7 @@ def status(): print('', name, 'not up to date. Have %s %d, but %s %d is available.' % (current_branch, current_revision, latest_branch, latest_revision)) def run(args): - if len(args) == 0 or args[0] == '-h' or args[0] == '--help': + if not args or args[0] == '-h' or args[0] == '--help': print_help() return 0 command = args[0] |