From 39f6d117926c78d3505525e6798d71a6e9bf7d74 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 18 Mar 2024 23:13:45 -0400 Subject: [PATCH 1/4] micro-optimize iteration of evaluated set It is generally accepted practice to convert dict.keys() to a list before iterating over it and e.g. deleting values, as keys returns a live-action view. In this case, we use the difference of *two* dict keys, which returns a regular non-view set and doesn't need protecting. Iteration order doesn't matter (the set already randomizes it anyway). Avoid the cost of converting to a list. --- mesonbuild/coredata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index eeeb8d1fedc1..f6eb659896e9 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -923,7 +923,7 @@ def update_project_options(self, options: 'MutableKeyedOptionDictType', subproje fatal=False) # Find any extranious keys for this project and remove them - for key in list(self.options.keys() - options.keys()): + for key in self.options.keys() - options.keys(): if key.is_project() and key.subproject == subproject: del self.options[key] From c99fc40bb7bacfed4ea79b4b83bec46fdc5018f3 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 24 Mar 2024 00:01:38 -0400 Subject: [PATCH 2/4] compilers: fix crash when compiler check returns None output Popen_safe_logged has a small inefficiency. It evaluates the stripped version of stdout/stderr before checking if it exists, for logging purposes. This would sometimes crash, if it was None instead of ''. Fixes #12979 --- mesonbuild/utils/universal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index edb309f0d000..324fb94b073b 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -1587,7 +1587,7 @@ def Popen_safe_logged(args: T.List[str], msg: str = 'Called', **kwargs: T.Any) - mlog.debug(f'{msg}: `{join_args(args)}` -> {excp}') raise - rc, out, err = p.returncode, o.strip(), e.strip() + rc, out, err = p.returncode, o.strip() if o else None, e.strip() if e else None mlog.debug('-----------') mlog.debug(f'{msg}: `{join_args(args)}` -> {rc}') if out: From f9eef40982ba2715aa4ca1d925aca423646c48f3 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 26 Mar 2024 21:26:31 -0400 Subject: [PATCH 3/4] allow any alternative python freeze tool to work with meson Any code that needs to know mesonlib.python_command currently assumes the PyInstaller bundle reference is added to the sys module, which means that it assumes the only freeze tool used is PyInstaller. Really, all we need to check is sys.frozen as it's never normally set, but always set for a freeze. We don't care if it was PyInstaller specifically, and we don't need its bundle directory. See https://github.com/mesonbuild/meson/discussions/13007 --- mesonbuild/utils/universal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 324fb94b073b..ce9afd96be27 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -168,8 +168,11 @@ class _VerPickleLoadable(Protocol): from glob import glob -if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): - # using a PyInstaller bundle, e.g. the MSI installed executable +if getattr(sys, 'frozen', False): + # Using e.g. a PyInstaller bundle, such as the MSI installed executable. + # It is conventional for freeze programs to set this attribute to indicate + # that the program is self hosted, and for example there is no associated + # "python" executable. python_command = [sys.executable, 'runpython'] else: python_command = [sys.executable] From 1baabbc7f6729d2a94feb277054184233eae87d7 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 28 Mar 2024 23:48:20 -0400 Subject: [PATCH 4/4] tests: fix missing dependency causing flaky build failure We have two copies of other.h, one of which is generated. If we don't include the include/ directory then building fails unless the custom_target which copies it over, happens to run early enough. On parallel builds this may fall on its face. --- test cases/rust/12 bindgen/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test cases/rust/12 bindgen/meson.build b/test cases/rust/12 bindgen/meson.build index f31040ec7808..09cb02a6d319 100644 --- a/test cases/rust/12 bindgen/meson.build +++ b/test cases/rust/12 bindgen/meson.build @@ -105,9 +105,9 @@ if prog_bindgen.version().version_compare('>= 0.65') input : 'src/header3.h', output : 'header3.rs', output_inline_wrapper : 'header3.c', - include_directories : 'include', + include_directories : inc, ) - c_inline_wrapper = static_library('c_wrapper', gen3[1]) + c_inline_wrapper = static_library('c_wrapper', gen3[1], include_directories: inc) f = configure_file( input : 'src/main3.rs',