diff options
| author | Charlie Hutcheson <chaz.hutcheson@gmail.com> | 2025-08-08 20:19:39 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-10-17 14:55:35 -0700 |
| commit | 1e7f6f09eba8f9ac121d8f58593bbbabebdc773a (patch) | |
| tree | d570cf10d7cd18d66b3588866e354fdb86373638 /mesonbuild/utils | |
| parent | f4ad0ef5a3c9ff69daed2987249c9a6fe30465c6 (diff) | |
| download | meson-1e7f6f09eba8f9ac121d8f58593bbbabebdc773a.tar.gz | |
make wrap search custom subprojects dirs
Changes from Dylan:
- Don't use Path
- merge the lint fixes
- Fix some typing issues
- Handle non-meson projects
- Remove some code duplication by putting `get_subproject_dir` in
utils
Diffstat (limited to 'mesonbuild/utils')
| -rw-r--r-- | mesonbuild/utils/universal.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index 6ba5474e4..e117f862f 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -108,6 +108,7 @@ __all__ = [ 'get_compiler_for_source', 'get_filenames_templates_dict', 'get_rsp_threshold', + 'get_subproject_dir', 'get_variable_regex', 'get_wine_shortpath', 'git', @@ -2065,6 +2066,8 @@ def detect_subprojects(spdir_name: str, current_dir: str = '', continue append_this = True if os.path.isdir(trial): + spdir_name = get_subproject_dir(trial) or 'subprojects' + detect_subprojects(spdir_name, trial, result) elif trial.endswith('.wrap') and os.path.isfile(trial): basename = os.path.splitext(basename)[0] @@ -2502,3 +2505,23 @@ class lazy_property(T.Generic[_T]): value = self.__func(instance) setattr(instance, self.__name, value) return value + + +def get_subproject_dir(directory: str = '.') -> T.Optional[str]: + """Get the name of the subproject directory for a specific project. + + If the subproject does not have a meson.build file, it is called in an + invalid directory, it returns None + + :param directory: Where to search, defaults to current working directory + :return: the name of the subproject directory or None. + """ + from ..ast import IntrospectionInterpreter + from ..interpreterbase.exceptions import InvalidArguments + intr = IntrospectionInterpreter(directory, '', 'none') + try: + intr.load_root_meson_file() + except InvalidArguments: # Root meson file cannot be found + return None + + return intr.extract_subproject_dir() or 'subprojects' |
