mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-23 19:25:25 +03:00
193 lines
9.6 KiB
Diff
193 lines
9.6 KiB
Diff
Patch-Source: https://github.com/mesonbuild/meson/pull/14529
|
|
--
|
|
From f941d4d3900b0490b4a19e2036eeb7a1c8b2f447 Mon Sep 17 00:00:00 2001
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Date: Tue, 29 Apr 2025 19:43:51 +0200
|
|
Subject: [PATCH 1/4] options: tighten type of cmd_line_options
|
|
|
|
Based on the SharedCMDOptions protocol it is guaranteed to be a dictionary.
|
|
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
---
|
|
mesonbuild/options.py | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
|
|
index 62413b1a7adf..043a0fbf864c 100644
|
|
--- a/mesonbuild/options.py
|
|
+++ b/mesonbuild/options.py
|
|
@@ -1243,7 +1243,7 @@ def prefix_split_options(self, coll: T.Union[T.List[str], OptionStringLikeDict])
|
|
|
|
def first_handle_prefix(self,
|
|
project_default_options: T.Union[T.List[str], OptionStringLikeDict],
|
|
- cmd_line_options: T.Union[T.List[str], OptionStringLikeDict],
|
|
+ cmd_line_options: OptionStringLikeDict,
|
|
machine_file_options: T.Mapping[OptionKey, ElementaryOptionValues]) \
|
|
-> T.Tuple[T.Union[T.List[str], OptionStringLikeDict],
|
|
T.Union[T.List[str], OptionStringLikeDict],
|
|
@@ -1282,7 +1282,7 @@ def hard_reset_from_prefix(self, prefix: str) -> None:
|
|
|
|
def initialize_from_top_level_project_call(self,
|
|
project_default_options_in: T.Union[T.List[str], OptionStringLikeDict],
|
|
- cmd_line_options_in: T.Union[T.List[str], OptionStringLikeDict],
|
|
+ cmd_line_options_in: OptionStringLikeDict,
|
|
machine_file_options_in: T.Mapping[OptionKey, ElementaryOptionValues]) -> None:
|
|
first_invocation = True
|
|
(project_default_options, cmd_line_options, machine_file_options) = self.first_handle_prefix(project_default_options_in,
|
|
|
|
From ad6df88ba133c224453d7b3e90d1b1c46691426e Mon Sep 17 00:00:00 2001
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Date: Tue, 29 Apr 2025 19:26:05 +0200
|
|
Subject: [PATCH 2/4] options: extract validation of command line options
|
|
|
|
Which command line options are valid is not entirely known until the backend
|
|
option is processed. Split the validation to a separate function so that it
|
|
can be done later, and while at it mention all unknown options instead of
|
|
just the first.
|
|
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
---
|
|
mesonbuild/interpreter/interpreter.py | 1 +
|
|
mesonbuild/options.py | 28 +++++++++++++++++++--------
|
|
2 files changed, 21 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
|
|
index bf41bfb55171..b32b8c6e78ec 100644
|
|
--- a/mesonbuild/interpreter/interpreter.py
|
|
+++ b/mesonbuild/interpreter/interpreter.py
|
|
@@ -1201,6 +1201,7 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str
|
|
self.coredata.initialized_subprojects.add(self.subproject)
|
|
|
|
if not self.is_subproject():
|
|
+ self.coredata.optstore.validate_cmd_line_options(self.user_defined_options.cmd_line_options)
|
|
self.build.project_name = proj_name
|
|
self.active_projectname = proj_name
|
|
|
|
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
|
|
index 043a0fbf864c..3b7d8b2c0825 100644
|
|
--- a/mesonbuild/options.py
|
|
+++ b/mesonbuild/options.py
|
|
@@ -1370,16 +1370,28 @@ def initialize_from_top_level_project_call(self,
|
|
if proj_key in self.options:
|
|
self.set_option(proj_key, valstr, True)
|
|
else:
|
|
- # Fail on unknown options that we can know must
|
|
- # exist at this point in time. Subproject and compiler
|
|
- # options are resolved later.
|
|
- #
|
|
- # Some base options (sanitizers etc) might get added later.
|
|
- # Permitting them all is not strictly correct.
|
|
- if key.subproject is None and not self.is_compiler_option(key) and not self.is_base_option(key):
|
|
- raise MesonException(f'Unknown options: "{keystr}"')
|
|
self.pending_options[key] = valstr
|
|
|
|
+ def validate_cmd_line_options(self, cmd_line_options: OptionStringLikeDict) -> None:
|
|
+ unknown_options = []
|
|
+ for keystr, valstr in cmd_line_options.items():
|
|
+ if isinstance(keystr, str):
|
|
+ key = OptionKey.from_string(keystr)
|
|
+ else:
|
|
+ key = keystr
|
|
+ # Fail on unknown options that we can know must exist at this point in time.
|
|
+ # Subproject and compiler options are resolved later.
|
|
+ #
|
|
+ # Some base options (sanitizers etc) might get added later.
|
|
+ # Permitting them all is not strictly correct.
|
|
+ if key.subproject is None and not self.is_compiler_option(key) and not self.is_base_option(key) and \
|
|
+ key in self.pending_options:
|
|
+ unknown_options.append(f'"{key}"')
|
|
+
|
|
+ if unknown_options:
|
|
+ keys = ', '.join(unknown_options)
|
|
+ raise MesonException(f'Unknown options: {keys}')
|
|
+
|
|
def hacky_mchackface_back_to_list(self, optdict: T.Dict[str, str]) -> T.List[str]:
|
|
if isinstance(optdict, dict):
|
|
return [f'{k}={v}' for k, v in optdict.items()]
|
|
|
|
From 847bbf7043af6dad212aa425485d99952eccacbe Mon Sep 17 00:00:00 2001
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Date: Tue, 29 Apr 2025 19:26:54 +0200
|
|
Subject: [PATCH 3/4] interpreter: add backend options before validating the
|
|
command line options
|
|
|
|
Allow specifying e.g. -Dbackend_max_links on the command line.
|
|
|
|
Fixes: #14524
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
---
|
|
mesonbuild/interpreter/interpreter.py | 26 +++++++++++++-------------
|
|
1 file changed, 13 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
|
|
index b32b8c6e78ec..abdc8899d8f6 100644
|
|
--- a/mesonbuild/interpreter/interpreter.py
|
|
+++ b/mesonbuild/interpreter/interpreter.py
|
|
@@ -1200,6 +1200,19 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str
|
|
self.user_defined_options.cmd_line_options)
|
|
self.coredata.initialized_subprojects.add(self.subproject)
|
|
|
|
+ if not self.is_subproject():
|
|
+ # We have to activate VS before adding languages and before calling
|
|
+ # self.set_backend() otherwise it wouldn't be able to detect which
|
|
+ # vs backend version we need. But after setting default_options in case
|
|
+ # the project sets vs backend by default.
|
|
+ backend = self.coredata.optstore.get_value_for(OptionKey('backend'))
|
|
+ assert backend is None or isinstance(backend, str), 'for mypy'
|
|
+ vsenv = self.coredata.optstore.get_value_for(OptionKey('vsenv'))
|
|
+ assert isinstance(vsenv, bool), 'for mypy'
|
|
+ force_vsenv = vsenv or backend.startswith('vs')
|
|
+ mesonlib.setup_vsenv(force_vsenv)
|
|
+ self.set_backend()
|
|
+
|
|
if not self.is_subproject():
|
|
self.coredata.optstore.validate_cmd_line_options(self.user_defined_options.cmd_line_options)
|
|
self.build.project_name = proj_name
|
|
@@ -1271,22 +1284,9 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str
|
|
mlog.log('Project name:', mlog.bold(proj_name))
|
|
mlog.log('Project version:', mlog.bold(self.project_version))
|
|
|
|
- if not self.is_subproject():
|
|
- # We have to activate VS before adding languages and before calling
|
|
- # self.set_backend() otherwise it wouldn't be able to detect which
|
|
- # vs backend version we need. But after setting default_options in case
|
|
- # the project sets vs backend by default.
|
|
- backend = self.coredata.optstore.get_value_for(OptionKey('backend'))
|
|
- assert backend is None or isinstance(backend, str), 'for mypy'
|
|
- vsenv = self.coredata.optstore.get_value_for(OptionKey('vsenv'))
|
|
- assert isinstance(vsenv, bool), 'for mypy'
|
|
- force_vsenv = vsenv or backend.startswith('vs')
|
|
- mesonlib.setup_vsenv(force_vsenv)
|
|
-
|
|
self.add_languages(proj_langs, True, MachineChoice.HOST)
|
|
self.add_languages(proj_langs, False, MachineChoice.BUILD)
|
|
|
|
- self.set_backend()
|
|
if not self.is_subproject():
|
|
self.check_stdlibs()
|
|
|
|
|
|
From 0c5701bac3230564cc60d86df1339039038a0810 Mon Sep 17 00:00:00 2001
|
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Date: Tue, 29 Apr 2025 19:51:43 +0200
|
|
Subject: [PATCH 4/4] unittests: smoke test the backend options
|
|
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
---
|
|
unittests/allplatformstests.py | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
|
|
index 2fee06c690fa..2b2c1e2c418b 100644
|
|
--- a/unittests/allplatformstests.py
|
|
+++ b/unittests/allplatformstests.py
|
|
@@ -529,7 +529,8 @@ def test_install_introspection(self):
|
|
if self.backend is not Backend.ninja:
|
|
raise SkipTest(f'{self.backend.name!r} backend can\'t install files')
|
|
testdir = os.path.join(self.common_test_dir, '8 install')
|
|
- self.init(testdir)
|
|
+ # sneak in a test that covers backend options...
|
|
+ self.init(testdir, extra_args=['-Dbackend_max_links=4'])
|
|
intro = self.introspect('--targets')
|
|
if intro[0]['type'] == 'executable':
|
|
intro = intro[::-1]
|