summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-03-03 12:06:28 -0800
committerEli Schwartz <eschwartz93@gmail.com>2025-03-04 12:26:18 -0500
commit84f64b2378807837eecfdc42feb5ff83446433ff (patch)
tree89d5493163023d298cfefacc7e9b6050ff52b099 /mesonbuild
parent2073cf3c884c21c2a6951d3f5111c5c303cd60ef (diff)
downloadmeson-84f64b2378807837eecfdc42feb5ff83446433ff.tar.gz
msetup: remove bad warning about unused options
This is just a bad warning, while it *could* give the user useful information, it often doesn't since it can get values to warn about from: - environment variables - the command line - machine files - `project(default_options : ...)` - `subproject(default_options : ...)` - `dependency(default_options : ...)` The problem of course is that user may have no control over these values. 3 of them are hardcoded into the meson.build files, so the user can't do anything about them. And there are legitimate reasons to have unused values in those, like setting defaults for a language only used on specific platforms. Environment variables may be set by the distro (NixOS sets them for any enabled language, so just having a D compiler causes `DFLAGS` to be set, for example). They likely don't want to special case "only set the environment variables if the project is going to use them". For machine files it limits the utility of the files, since the user needs to be sure that they don't include any options that wont be used. Finally, the command line could be altered by wrapper scripts, or simply programmed to insert options that *may* be used but aren't required. like setting `objc_args` regardless of whether ObjectivC bindings are generated. However, passing completely unknown builtin options should be an error, as it was before the optionrefactor
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/msetup.py19
1 files changed, 4 insertions, 15 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 6753b0255..26e92ee5d 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2018 The Meson development team
-# Copyright © 2023-2024 Intel Corporation
+# Copyright © 2023-2025 Intel Corporation
from __future__ import annotations
@@ -189,9 +189,9 @@ class MesonApp:
return self._generate(env, capture, vslite_ctx)
def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Any, all_subprojects: T.Any) -> None:
+ from mesonbuild.compilers import BASE_OPTIONS
pending = coredata.optstore.pending_project_options
errlist: T.List[str] = []
- permitlist: T.List[str] = []
for opt in pending:
# Due to backwards compatibility setting build options in non-cross
# builds is permitted and is a no-op. This should be made
@@ -203,11 +203,9 @@ class MesonApp:
if opt.subproject and opt.subproject not in all_subprojects:
continue
if coredata.optstore.is_compiler_option(opt):
- permitlist.append(opt.name)
continue
- # Ditto for base options.
- if coredata.optstore.is_base_option(opt):
- permitlist.append(opt.name)
+ if (coredata.optstore.is_base_option(opt) and
+ opt.evolve(subproject=None, machine=mesonlib.MachineChoice.HOST) in BASE_OPTIONS):
continue
keystr = str(opt)
if keystr in cmd_line_options:
@@ -215,15 +213,6 @@ class MesonApp:
if errlist:
errstr = ', '.join(errlist)
raise MesonException(f'Unknown options: {errstr}')
- if permitlist:
- # This is needed due to backwards compatibility.
- # It was permitted to define some command line options that
- # were not used. This can be seen as a bug, since
- # if you define -Db_lto but the compiler class does not
- # support it, this option gets silently swallowed.
- # So at least print a message about it.
- optstr = ','.join(permitlist)
- mlog.warning(f'The following command line option(s) were not used: {optstr}', fatal=False)
coredata.optstore.clear_pending()