From c9ac73a4da52b093feac90591efa8fe1b5ef2f42 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 30 Oct 2022 13:08:47 -0400 Subject: simplify instantiation of builtin type using builtins instead of functions --- mesonbuild/backend/ninjabackend.py | 2 +- mesonbuild/modules/cuda.py | 4 ++-- mesonbuild/munstable_coredata.py | 2 +- mesonbuild/rewriter.py | 2 +- mesonbuild/scripts/env2mfile.py | 18 ++++++++++-------- mesonbuild/utils/universal.py | 36 ++++++++++++++++++++++++++++++++---- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index a83913d..0ce7f43 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2143,7 +2143,7 @@ class NinjaBackend(backends.Backend): rsp_file_syntax() is only guaranteed to be implemented if can_linker_accept_rsp() returns True. """ - options = dict(rspable=tool.can_linker_accept_rsp()) + options = {'rspable': tool.can_linker_accept_rsp()} if options['rspable']: options['rspfile_quote_style'] = tool.rsp_file_syntax() return options diff --git a/mesonbuild/modules/cuda.py b/mesonbuild/modules/cuda.py index 67ed8ec..72ca306 100644 --- a/mesonbuild/modules/cuda.py +++ b/mesonbuild/modules/cuda.py @@ -336,8 +336,8 @@ class CudaModule(NewExtensionModule): arch_ptx = arch_bin cuda_arch_ptx += arch_ptx - cuda_arch_bin = sorted(list(set(cuda_arch_bin))) - cuda_arch_ptx = sorted(list(set(cuda_arch_ptx))) + cuda_arch_bin = sorted(set(cuda_arch_bin)) + cuda_arch_ptx = sorted(set(cuda_arch_ptx)) nvcc_flags = [] nvcc_archs_readable = [] diff --git a/mesonbuild/munstable_coredata.py b/mesonbuild/munstable_coredata.py index 37c8490..e6c543b 100644 --- a/mesonbuild/munstable_coredata.py +++ b/mesonbuild/munstable_coredata.py @@ -104,7 +104,7 @@ def run(options): print(' version: ' + repr(dep.get_version())) for for_machine in iter(MachineChoice): - items_list = list(sorted(v[for_machine].items())) + items_list = sorted(v[for_machine].items()) if items_list: print(f'Cached dependencies for {for_machine.get_lower_case_name()} machine') for dep_key, deps in items_list: diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py index 8a1021c..1497d93 100644 --- a/mesonbuild/rewriter.py +++ b/mesonbuild/rewriter.py @@ -884,7 +884,7 @@ class Rewriter: # Sort based on line and column in reversed order work_nodes = [{'node': x, 'action': 'modify'} for x in self.modified_nodes] work_nodes += [{'node': x, 'action': 'rm'} for x in self.to_remove_nodes] - work_nodes = list(sorted(work_nodes, key=lambda x: (x['node'].lineno, x['node'].colno), reverse=True)) + work_nodes = sorted(work_nodes, key=lambda x: (x['node'].lineno, x['node'].colno), reverse=True) work_nodes += [{'node': x, 'action': 'add'} for x in self.to_add_nodes] # Generating the new replacement string diff --git a/mesonbuild/scripts/env2mfile.py b/mesonbuild/scripts/env2mfile.py index 35049ae..af7ffc6 100755 --- a/mesonbuild/scripts/env2mfile.py +++ b/mesonbuild/scripts/env2mfile.py @@ -131,16 +131,18 @@ def get_args_from_envvars(infos: MachineInfo) -> None: if objcpp_link_args: infos.link_args['objcpp'] = objcpp_link_args -cpu_family_map = dict(mips64el="mips64", - i686='x86') -cpu_map = dict(armhf="arm7hlf", - mips64el="mips64", - powerpc64le="ppc64", - ) +cpu_family_map = { + 'mips64el': 'mips64', + 'i686': 'x86', +} +cpu_map = { + 'armhf': 'arm7hlf', + 'mips64el': 'mips64' +} def deb_detect_cmake(infos: MachineInfo, data: T.Dict[str, str]) -> None: - system_name_map = dict(linux="Linux", kfreebsd="kFreeBSD", hurd="GNU") - system_processor_map = dict(arm='armv7l', mips64el='mips64', powerpc64le='ppc64le') + system_name_map = {'linux': 'Linux', 'kfreebsd': 'kFreeBSD', 'hurd': 'GNU'} + system_processor_map = {'arm': 'armv7l', 'mips64el': 'mips64', 'powerpc64le': 'ppc64le'} infos.cmake["CMAKE_C_COMPILER"] = infos.compilers['c'] infos.cmake["CMAKE_CXX_COMPILER"] = infos.compilers['cpp'] diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 5c91449..b0cc252 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -736,10 +736,38 @@ def windows_detect_native_arch() -> str: def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]: vcs_systems = [ - dict(name = 'git', cmd = 'git', repo_dir = '.git', get_rev = 'git describe --dirty=+', rev_regex = '(.*)', dep = '.git/logs/HEAD'), - dict(name = 'mercurial', cmd = 'hg', repo_dir = '.hg', get_rev = 'hg id -i', rev_regex = '(.*)', dep = '.hg/dirstate'), - dict(name = 'subversion', cmd = 'svn', repo_dir = '.svn', get_rev = 'svn info', rev_regex = 'Revision: (.*)', dep = '.svn/wc.db'), - dict(name = 'bazaar', cmd = 'bzr', repo_dir = '.bzr', get_rev = 'bzr revno', rev_regex = '(.*)', dep = '.bzr'), + { + 'name': 'git', + 'cmd': 'git', + 'repo_dir': '.git', + 'get_rev': 'git describe --dirty=+', + 'rev_regex': '(.*)', + 'dep': '.git/logs/HEAD' + }, + { + 'name': 'mercurial', + 'cmd': 'hg', + 'repo_dir': '.hg', + 'get_rev': 'hg id -i', + 'rev_regex': '(.*)', + 'dep': '.hg/dirstate' + }, + { + 'name': 'subversion', + 'cmd': 'svn', + 'repo_dir': '.svn', + 'get_rev': 'svn info', + 'rev_regex': 'Revision: (.*)', + 'dep': '.svn/wc.db' + }, + { + 'name': 'bazaar', + 'cmd': 'bzr', + 'repo_dir': '.bzr', + 'get_rev': 'bzr revno', + 'rev_regex': '(.*)', + 'dep': '.bzr' + }, ] if isinstance(source_dir, str): source_dir = Path(source_dir) -- cgit v1.1