Print instructions on how to promote subsubprojects.

pull/2334/head
Jussi Pakkanen 8 years ago
parent 46c071ea5c
commit 5b9d79b902
  1. 23
      mesonbuild/interpreter.py
  2. 29
      mesonbuild/mesonlib.py
  3. 23
      mesonbuild/wrap/wraptool.py

@ -2196,6 +2196,7 @@ to directly access options of other subprojects.''')
# we won't actually read all the build files.
return fallback_dep
if not dep:
self.print_nested_info(name)
assert(exception is not None)
raise exception
@ -2209,6 +2210,28 @@ to directly access options of other subprojects.''')
def func_disabler(self, node, args, kwargs):
return Disabler()
def print_nested_info(self, dependency_name):
message_templ = '''\nDependency %s not found but it is available in a sub-subproject.
To use it in the current project, promote it by going in the project source
root and issuing %s.
'''
sprojs = mesonlib.detect_subprojects('subprojects', self.source_root)
if dependency_name not in sprojs:
return
found = sprojs[dependency_name]
if len(found) > 1:
suffix = 'one of the following commands'
else:
suffix = 'the following command'
message = message_templ % (dependency_name, suffix)
cmds = []
command_templ = 'meson wrap promote '
for l in found:
cmds.append(command_templ + l[len(self.source_root)+1:])
final_message = message + '\n'.join(cmds)
print(final_message)
def get_subproject_infos(self, kwargs):
fbinfo = kwargs['fallback']
check_stringlist(fbinfo)

@ -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.

@ -21,6 +21,8 @@ from glob import glob
from .wrap import API_ROOT, open_wrapdburl
from .. import mesonlib
help_templ = '''This program allows you to manage your Wrap dependencies
using the online wrap database http://wrapdb.mesonbuild.com.
@ -149,29 +151,10 @@ def do_promotion(from_path, spdir_name):
sys.exit('Output dir %s already exists. Will not overwrite.' % outputdir)
shutil.copytree(from_path, outputdir, ignore=shutil.ignore_patterns('subprojects'))
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
def promote(argument):
path_segment, subproject_name = os.path.split(argument)
spdir_name = 'subprojects'
sprojs = detect_subprojects(spdir_name)
sprojs = mesonlib.detect_subprojects(spdir_name)
if subproject_name not in sprojs:
sys.exit('Subproject %s not found in directory tree.' % subproject_name)
matches = sprojs[subproject_name]

Loading…
Cancel
Save