aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-10-20 00:54:09 +0300
committerGitHub <noreply@github.com>2018-10-20 00:54:09 +0300
commit066060e8c9402b3ae510de7fbddeeb3b528247c9 (patch)
tree494e8036b8871fd02189d43dd35643147d2d9dd4 /mesonbuild/interpreter.py
parent648b2c579915a75a6d8e65cab4ffc283769cea29 (diff)
parent76ac4f568988d405e65c500fca61259b75ffe396 (diff)
downloadmeson-066060e8c9402b3ae510de7fbddeeb3b528247c9.zip
meson-066060e8c9402b3ae510de7fbddeeb3b528247c9.tar.gz
meson-066060e8c9402b3ae510de7fbddeeb3b528247c9.tar.bz2
Merge pull request #4327 from xclaesse/wrap
wrap: Support using local files instead of downloading
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py49
1 files changed, 23 insertions, 26 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 9b3fdc7..98424ec 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2261,19 +2261,21 @@ external dependencies (including libraries) must go to "dependencies".''')
r = wrap.Resolver(subproject_dir_abs, self.coredata.get_builtin_option('wrap_mode'))
try:
resolved = r.resolve(dirname)
- except RuntimeError as e:
- # if the reason subproject execution failed was because
- # the directory doesn't exist, try to give some helpful
- # advice if it's a nested subproject that needs
- # promotion...
- self.print_nested_info(dirname)
-
- if required:
- msg = 'Subproject directory {!r} does not exist and cannot be downloaded:\n{}'
- raise InterpreterException(msg.format(os.path.join(self.subproject_dir, dirname), e))
-
- mlog.log('\nSubproject ', mlog.bold(dirname), 'is buildable:', mlog.red('NO'), '(disabling)\n')
- return self.disabled_subproject(dirname)
+ except wrap.WrapException as e:
+ subprojdir = os.path.join(self.subproject_dir, r.directory)
+ if not required:
+ mlog.log('\nSubproject ', mlog.bold(subprojdir), 'is buildable:', mlog.red('NO'), '(disabling)\n')
+ return self.disabled_subproject(dirname)
+
+ if isinstance(e, wrap.WrapNotFoundException):
+ # if the reason subproject execution failed was because
+ # the directory doesn't exist, try to give some helpful
+ # advice if it's a nested subproject that needs
+ # promotion...
+ self.print_nested_info(dirname)
+
+ msg = 'Failed to initialize {!r}:\n{}'
+ raise InterpreterException(msg.format(subprojdir, e))
subdir = os.path.join(self.subproject_dir, resolved)
os.makedirs(os.path.join(self.build.environment.get_build_dir(), subdir), exist_ok=True)
@@ -2979,26 +2981,21 @@ external dependencies (including libraries) must go to "dependencies".''')
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.
-
-'''
+ message = ['Dependency', mlog.bold(dependency_name), 'not found but it is available in a sub-subproject.\n' +
+ 'To use it in the current project, promote it by going in the project source\n'
+ 'root and issuing']
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'
+ message.append('one of the following commands:')
else:
- suffix = 'the following command'
- message = message_templ % (dependency_name, suffix)
- cmds = []
- command_templ = 'meson wrap promote '
+ message.append('the following command:')
+ command_templ = '\nmeson 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)
+ message.append(mlog.bold(command_templ.format(l[len(self.source_root) + 1:])))
+ mlog.warning(*message)
def get_subproject_infos(self, kwargs):
fbinfo = kwargs['fallback']