From 9e153c74dea2c2e6f83b6eb4f9d75994c3164656 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 3 Feb 2025 11:12:14 -0800 Subject: [PATCH] backend/vs2010: stop using `len` to test for container emptiness --- mesonbuild/backend/vs2010backend.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 1a8ff67fff3f..e63717a0a828 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -746,7 +746,7 @@ def gen_run_target_vcxproj(self, target: build.RunTarget, ofname: str, guid: str # enough to emit the references to the other projects for them to # be built/run/..., if necessary. assert isinstance(target, build.AliasTarget) - assert len(depend_files) == 0 + assert not depend_files else: assert not isinstance(target, build.AliasTarget) @@ -1006,7 +1006,7 @@ def _get_cl_compiler(self, target: build.BuildTarget) -> Compiler: return c # No source files, only objects, but we still need a compiler, so # return a found compiler - if len(target.objects) > 0: + if target.objects: for lang, c in self.environment.coredata.compilers[target.for_machine].items(): if lang in {'c', 'cpp'}: return c @@ -1408,7 +1408,7 @@ def add_non_makefile_vcxproj_elements( else: # 'sc' or 'default' ET.SubElement(clconf, 'ExceptionHandling').text = 'Sync' - if len(target_args) > 0: + if target_args: target_args.append('%(AdditionalOptions)') ET.SubElement(clconf, "AdditionalOptions").text = ' '.join(target_args) ET.SubElement(clconf, 'AdditionalIncludeDirectories').text = ';'.join(target_inc_dirs) @@ -1552,13 +1552,13 @@ def add_non_makefile_vcxproj_elements( for lib in self.get_custom_target_provided_libraries(target): additional_links.append(self.relpath(lib, self.get_target_dir(target))) - if len(extra_link_args) > 0: + if extra_link_args: extra_link_args.append('%(AdditionalOptions)') ET.SubElement(link, "AdditionalOptions").text = ' '.join(extra_link_args) - if len(additional_libpaths) > 0: + if additional_libpaths: additional_libpaths.insert(0, '%(AdditionalLibraryDirectories)') ET.SubElement(link, 'AdditionalLibraryDirectories').text = ';'.join(additional_libpaths) - if len(additional_links) > 0: + if additional_links: additional_links.append('%(AdditionalDependencies)') ET.SubElement(link, 'AdditionalDependencies').text = ';'.join(additional_links) ofile = ET.SubElement(link, 'OutputFile') @@ -1738,7 +1738,7 @@ def path_normalize_add(path: str, lis: T.List[str]) -> bool: pch_sources[lang] = (pch[0], None, lang, None) previous_includes: T.List[str] = [] - if len(headers) + len(gen_hdrs) + len(target.extra_files) + len(pch_sources) > 0: + if headers or gen_hdrs or target.extra_files or pch_sources: if self.gen_lite and gen_hdrs: # Although we're constructing our .vcxproj under our '..._vs' directory, we want to reference generated files # in our concrete build directories (e.g. '..._debug'), where generated files will exist after building. @@ -1762,7 +1762,7 @@ def path_normalize_add(path: str, lis: T.List[str]) -> bool: ET.SubElement(inc_hdrs, 'CLInclude', Include=path) previous_sources: T.List[str] = [] - if len(sources) + len(gen_src) + len(pch_sources) > 0: + if sources or gen_src or pch_sources: if self.gen_lite: # Get data to fill in intellisense fields for sources that can't reference the project-wide values defs_paths_opts_per_lang_and_buildtype = get_non_primary_lang_intellisense_fields( @@ -1834,7 +1834,7 @@ def path_normalize_add(path: str, lis: T.List[str]) -> bool: explicit_link_gen_objs = [obj for obj in gen_objs if not obj.endswith(('.obj', '.res'))] previous_objects: T.List[str] = [] - if len(objects) + len(additional_objects) + len(explicit_link_gen_objs) > 0: + if objects or additional_objects or explicit_link_gen_objs: inc_objs = ET.SubElement(root, 'ItemGroup') for s in objects: relpath = os.path.join(proj_to_build_root, s.rel_to_builddir(self.build_to_src))