diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-12-26 13:24:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-26 13:24:30 +0200 |
commit | ac8d6087bfe1a2dacbd13d6cc9c4c526fc997fb5 (patch) | |
tree | fb443ccd4bdfa44670cc78a6b14b386cdf625a7a /mesonbuild/mesonlib.py | |
parent | 1806aac37669fe5b4a50175b7b8298f119248be3 (diff) | |
parent | a5507404ab24c307b1ca5127b59e73759790746a (diff) | |
download | meson-ac8d6087bfe1a2dacbd13d6cc9c4c526fc997fb5.zip meson-ac8d6087bfe1a2dacbd13d6cc9c4c526fc997fb5.tar.gz meson-ac8d6087bfe1a2dacbd13d6cc9c4c526fc997fb5.tar.bz2 |
Merge pull request #2334 from mesonbuild/promotedep
Add functionality to promote nested dependencies to top level.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 9ad0668..6bf31db 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -881,6 +881,31 @@ def windows_proof_rmtree(f): # Try one last time and throw if it fails. shutil.rmtree(f) + +def detect_subprojects(spdir_name, current_dir='', result=None): + if result is None: + result = {} + spdir = os.path.join(current_dir, spdir_name) + if not os.path.exists(spdir): + return result + for trial in glob(os.path.join(spdir, '*')): + basename = os.path.split(trial)[1] + if trial == 'packagecache': + continue + append_this = True + if os.path.isdir(trial): + detect_subprojects(spdir_name, trial, result) + elif trial.endswith('.wrap') and os.path.isfile(trial): + basename = os.path.splitext(basename)[0] + else: + append_this = False + if append_this: + if basename in result: + result[basename].append(trial) + else: + result[basename] = [trial] + return result + class OrderedSet(collections.MutableSet): """A set that preserves the order in which items are added, by first insertion. |