aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-05-26 13:15:13 -0700
committerEli Schwartz <eschwartz93@gmail.com>2022-06-01 22:49:10 -0400
commit618b187f70f9267eaf5112373aa9925b38f44da0 (patch)
treeb459b5015e7f9f3fe4ff499fb9bd9b530aa50700
parent50e9769403a8e3f7c281aff1ff8f9cad7bfe2276 (diff)
downloadmeson-618b187f70f9267eaf5112373aa9925b38f44da0.zip
meson-618b187f70f9267eaf5112373aa9925b38f44da0.tar.gz
meson-618b187f70f9267eaf5112373aa9925b38f44da0.tar.bz2
interpreter: use a shared KwargInfo for install_dir
CustomTarget allows multiple install dirs, while basically everything else allows only one. So this provides a shared instance for that.
-rw-r--r--mesonbuild/interpreter/interpreter.py9
-rw-r--r--mesonbuild/interpreter/type_checking.py2
-rw-r--r--mesonbuild/modules/cmake.py6
-rw-r--r--mesonbuild/modules/gnome.py12
-rw-r--r--mesonbuild/modules/i18n.py4
-rw-r--r--mesonbuild/modules/qt.py6
6 files changed, 21 insertions, 18 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 6e25b9b..11eb816 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -68,6 +68,7 @@ from .type_checking import (
ENV_METHOD_KW,
ENV_SEPARATOR_KW,
INSTALL_KW,
+ INSTALL_DIR_KW,
INSTALL_MODE_KW,
CT_INSTALL_TAG_KW,
INSTALL_TAG_KW,
@@ -2093,10 +2094,10 @@ class Interpreter(InterpreterBase, HoldableObject):
@typed_pos_args('install_headers', varargs=(str, mesonlib.File))
@typed_kwargs(
'install_headers',
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('preserve_path', bool, default=False, since='0.63.0'),
KwargInfo('subdir', (str, NoneType)),
INSTALL_MODE_KW.evolve(since='0.47.0'),
+ INSTALL_DIR_KW,
)
def func_install_headers(self, node: mparser.BaseNode,
args: T.Tuple[T.List['mesonlib.FileOrString']],
@@ -2131,9 +2132,9 @@ class Interpreter(InterpreterBase, HoldableObject):
@typed_pos_args('install_man', varargs=(str, mesonlib.File))
@typed_kwargs(
'install_man',
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('locale', (str, NoneType), since='0.58.0'),
- INSTALL_MODE_KW.evolve(since='0.47.0')
+ INSTALL_MODE_KW.evolve(since='0.47.0'),
+ INSTALL_DIR_KW,
)
def func_install_man(self, node: mparser.BaseNode,
args: T.Tuple[T.List['mesonlib.FileOrString']],
@@ -2296,11 +2297,11 @@ class Interpreter(InterpreterBase, HoldableObject):
@typed_pos_args('install_data', varargs=(str, mesonlib.File))
@typed_kwargs(
'install_data',
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('sources', ContainerTypeInfo(list, (str, mesonlib.File)), listify=True, default=[]),
KwargInfo('rename', ContainerTypeInfo(list, str), default=[], listify=True, since='0.46.0'),
INSTALL_MODE_KW.evolve(since='0.38.0'),
INSTALL_TAG_KW.evolve(since='0.60.0'),
+ INSTALL_DIR_KW,
)
def func_install_data(self, node: mparser.BaseNode,
args: T.Tuple[T.List['mesonlib.FileOrString']],
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index 5075f85..d3f2d34 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -325,6 +325,8 @@ CT_BUILD_ALWAYS_STALE: KwargInfo[T.Optional[bool]] = KwargInfo(
since='0.47.0',
)
+INSTALL_DIR_KW: KwargInfo[T.Optional[str]] = KwargInfo('install_dir', (str, NoneType))
+
INCLUDE_DIRECTORIES: KwargInfo[T.List[T.Union[str, IncludeDirs]]] = KwargInfo(
'include_dirs',
ContainerTypeInfo(list, (str, IncludeDirs)),
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
index a219268..1950254 100644
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -23,7 +23,7 @@ from . import ExtensionModule, ModuleReturnValue, ModuleObject
from .. import build, mesonlib, mlog, dependencies
from ..cmake import TargetOptions, cmake_defines_to_args
from ..interpreter import SubprojectHolder
-from ..interpreter.type_checking import REQUIRED_KW, NoneType, in_set_validator
+from ..interpreter.type_checking import REQUIRED_KW, INSTALL_DIR_KW, NoneType, in_set_validator
from ..interpreterbase import (
FeatureNew,
FeatureNewKwargs,
@@ -296,9 +296,9 @@ class CmakeModule(ExtensionModule):
'cmake.write_basic_package_version_file',
KwargInfo('arch_independent', bool, default=False, since='0.62.0'),
KwargInfo('compatibility', str, default='AnyNewerVersion', validator=in_set_validator(set(COMPATIBILITIES))),
- KwargInfo('install_dir', (str, NoneType), default=None),
KwargInfo('name', str, required=True),
KwargInfo('version', str, required=True),
+ INSTALL_DIR_KW,
)
def write_basic_package_version_file(self, state, args, kwargs: 'WriteBasicPackageVersionFile'):
arch_independent = kwargs['arch_independent']
@@ -365,8 +365,8 @@ class CmakeModule(ExtensionModule):
(str, mesonlib.File, ContainerTypeInfo(list, mesonlib.File)), required=True,
validator=lambda x: 'requires exactly one file' if isinstance(x, list) and len(x) != 1 else None,
convertor=lambda x: x[0] if isinstance(x, list) else x),
- KwargInfo('install_dir', (str, NoneType), default=None),
KwargInfo('name', str, required=True),
+ INSTALL_DIR_KW,
)
def configure_package_config_file(self, state, args, kwargs: 'ConfigurePackageConfigFile'):
inputfile = kwargs['input']
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index f44b759..1f4f140 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -32,7 +32,7 @@ from .. import mesonlib
from .. import mlog
from ..build import CustomTarget, CustomTargetIndex, Executable, GeneratedList, InvalidArguments
from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
-from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, INSTALL_KW, NoneType, in_set_validator
+from ..interpreter.type_checking import DEPENDS_KW, DEPEND_FILES_KW, INSTALL_DIR_KW, INSTALL_KW, NoneType, in_set_validator
from ..interpreterbase import noPosargs, noKwargs, FeatureNew, FeatureDeprecated
from ..interpreterbase import typed_kwargs, KwargInfo, ContainerTypeInfo
from ..interpreterbase.decorators import typed_pos_args
@@ -213,13 +213,13 @@ _EXTRA_ARGS_KW: KwargInfo[T.List[str]] = KwargInfo(
_MK_ENUMS_COMMON_KWS: T.List[KwargInfo] = [
INSTALL_KW.evolve(name='install_header'),
+ INSTALL_DIR_KW,
KwargInfo(
'sources',
ContainerTypeInfo(list, (str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)),
listify=True,
required=True,
),
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('identifier_prefix', (str, NoneType)),
KwargInfo('symbol_prefix', (str, NoneType)),
]
@@ -408,11 +408,11 @@ class GnomeModule(ExtensionModule):
_EXTRA_ARGS_KW,
INSTALL_KW,
INSTALL_KW.evolve(name='install_header', since='0.37.0'),
+ INSTALL_DIR_KW,
KwargInfo('c_name', (str, NoneType)),
KwargInfo('dependencies', ContainerTypeInfo(list, (mesonlib.File, build.CustomTarget, build.CustomTargetIndex)), default=[], listify=True),
KwargInfo('export', bool, default=False, since='0.37.0'),
KwargInfo('gresource_bundle', bool, default=False, since='0.37.0'),
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('source_dir', ContainerTypeInfo(list, str), default=[], listify=True),
)
def compile_resources(self, state: 'ModuleState', args: T.Tuple[str, 'FileOrString'],
@@ -1594,11 +1594,11 @@ class GnomeModule(ExtensionModule):
convertor=lambda x: [x] if x and isinstance(x[0], str) else x,
),
KwargInfo('install_header', bool, default=False, since='0.46.0'),
- KwargInfo('install_dir', (str, NoneType), since='0.46.0'),
KwargInfo('docbook', (str, NoneType)),
KwargInfo(
'autocleanup', str, default='default', since='0.47.0',
validator=in_set_validator({'all', 'none', 'objects'})),
+ INSTALL_DIR_KW.evolve(since='0.46.0')
)
def gdbus_codegen(self, state: 'ModuleState', args: T.Tuple[str, T.Optional['FileOrString']],
kwargs: 'GdbusCodegen') -> ModuleReturnValue:
@@ -1948,8 +1948,8 @@ class GnomeModule(ExtensionModule):
DEPEND_FILES_KW.evolve(since='0.61.0'),
DEPENDS_KW.evolve(since='0.61.0'),
INSTALL_KW.evolve(name='install_header'),
+ INSTALL_DIR_KW,
KwargInfo('extra_args', ContainerTypeInfo(list, str), listify=True, default=[]),
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('internal', bool, default=False),
KwargInfo('nostdinc', bool, default=False),
KwargInfo('prefix', (str, NoneType)),
@@ -2089,13 +2089,13 @@ class GnomeModule(ExtensionModule):
@typed_kwargs(
'gnome.generate_vapi',
INSTALL_KW,
+ INSTALL_DIR_KW,
KwargInfo(
'sources',
ContainerTypeInfo(list, (str, GirTarget), allow_empty=False),
listify=True,
required=True,
),
- KwargInfo('install_dir', (str, NoneType)),
KwargInfo('vapi_dirs', ContainerTypeInfo(list, str), listify=True, default=[]),
KwargInfo('metadata_dirs', ContainerTypeInfo(list, str), listify=True, default=[]),
KwargInfo('gir_dirs', ContainerTypeInfo(list, str), listify=True, default=[]),
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index 5fd3171..5c2644e 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -20,7 +20,7 @@ from . import ExtensionModule, ModuleReturnValue
from .. import build
from .. import mesonlib
from .. import mlog
-from ..interpreter.type_checking import CT_BUILD_BY_DEFAULT, CT_INPUT_KW, INSTALL_TAG_KW, OUTPUT_KW, INSTALL_KW, NoneType, in_set_validator
+from ..interpreter.type_checking import CT_BUILD_BY_DEFAULT, CT_INPUT_KW, INSTALL_TAG_KW, OUTPUT_KW, INSTALL_DIR_KW, INSTALL_KW, NoneType, in_set_validator
from ..interpreterbase import FeatureNew
from ..interpreterbase.decorators import ContainerTypeInfo, KwargInfo, noPosargs, typed_kwargs, typed_pos_args
from ..scripts.gettext import read_linguas
@@ -212,7 +212,7 @@ class I18nModule(ExtensionModule):
_ARGS,
_DATA_DIRS.evolve(since='0.36.0'),
INSTALL_KW.evolve(default=True),
- KwargInfo('install_dir', (str, NoneType), since='0.50.0'),
+ INSTALL_DIR_KW.evolve(since='0.50.0'),
KwargInfo('languages', ContainerTypeInfo(list, str), default=[], listify=True),
KwargInfo(
'preset',
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index 55faa91..49374d4 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -26,7 +26,7 @@ from .. import mlog
from ..dependencies import find_external_dependency, Dependency, ExternalLibrary
from ..mesonlib import MesonException, File, version_compare, Popen_safe
from ..interpreter import extract_required_kwarg
-from ..interpreter.type_checking import NoneType
+from ..interpreter.type_checking import INSTALL_DIR_KW, INSTALL_KW, NoneType
from ..interpreterbase import ContainerTypeInfo, FeatureDeprecated, KwargInfo, noPosargs, FeatureNew, typed_kwargs
from ..programs import NonExistingExternalProgram
@@ -534,8 +534,8 @@ class QtBaseModule(ExtensionModule):
@typed_kwargs(
'qt.compile_translations',
KwargInfo('build_by_default', bool, default=False),
- KwargInfo('install', bool, default=False),
- KwargInfo('install_dir', (str, NoneType)),
+ INSTALL_KW,
+ INSTALL_DIR_KW,
KwargInfo('method', str, default='auto'),
KwargInfo('qresource', (str, NoneType), since='0.56.0'),
KwargInfo('rcc_extra_arguments', ContainerTypeInfo(list, str), listify=True, default=[], since='0.56.0'),