aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 9ad0668..8da08d3 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -881,6 +881,35 @@ def windows_proof_rmtree(f):
# Try one last time and throw if it fails.
shutil.rmtree(f)
+def unholder_array(entries):
+ result = []
+ entries = flatten(entries)
+ for e in entries:
+ if hasattr(e, 'held_object'):
+ e = e.held_object
+ result.append(e)
+ return result
+
+
+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
+ if not os.path.isdir(trial):
+ continue
+ if basename in result:
+ result[basename].append(trial)
+ else:
+ result[basename] = [trial]
+ detect_subprojects(spdir_name, trial, result)
+ return result
+
class OrderedSet(collections.MutableSet):
"""A set that preserves the order in which items are added, by first
insertion.