third_party:waf: update to upstream 2.0.4 release
[samba.git] / third_party / waf / waflib / extras / use_config.py
index ffaafce85d5f4a0cf2f346199b7ecf279a4dd541..b5a73d7f3e102bfe518283d2d1862f391b30d426 100644 (file)
@@ -1,3 +1,7 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
+
 #!/usr/bin/env python
 # coding=utf-8
 # Mathieu Courtois - EDF R&D, 2013 - http://www.code-aster.org
@@ -50,6 +54,21 @@ import sys
 import os.path as osp
 import os
 
+local_repo = ''
+"""Local repository containing additional Waf tools (plugins)"""
+remote_repo = 'https://raw.githubusercontent.com/waf-project/waf/master/'
+"""
+Remote directory containing downloadable waf tools. The missing tools can be downloaded by using::
+
+       $ waf configure --download
+"""
+
+remote_locs = ['waflib/extras', 'waflib/Tools']
+"""
+Remote directories for use with :py:const:`waflib.extras.use_config.remote_repo`
+"""
+
+
 try:
        from urllib import request
 except ImportError:
@@ -94,12 +113,12 @@ def download_check(node):
 
 def download_tool(tool, force=False, ctx=None):
        """
-       Download a Waf tool from the remote repository defined in :py:const:`waflib.Context.remote_repo`::
+       Download a Waf tool from the remote repository defined in :py:const:`waflib.extras.use_config.remote_repo`::
 
                $ waf configure --download
        """
-       for x in Utils.to_list(Context.remote_repo):
-               for sub in Utils.to_list(Context.remote_locs):
+       for x in Utils.to_list(remote_repo):
+               for sub in Utils.to_list(remote_locs):
                        url = '/'.join((x, sub, tool + '.py'))
                        try:
                                web = urlopen(url)
@@ -115,12 +134,12 @@ def download_tool(tool, force=False, ctx=None):
                        else:
                                tmp = ctx.root.make_node(os.sep.join((Context.waf_dir, 'waflib', 'extras', tool + '.py')))
                                tmp.write(web.read(), 'wb')
-                               Logs.warn('Downloaded %s from %s' % (tool, url))
+                               Logs.warn('Downloaded %s from %s', tool, url)
                                download_check(tmp)
                                try:
                                        module = Context.load_tool(tool)
                                except Exception:
-                                       Logs.warn('The tool %s from %s is unusable' % (tool, url))
+                                       Logs.warn('The tool %s from %s is unusable', tool, url)
                                        try:
                                                tmp.delete()
                                        except Exception:
@@ -134,6 +153,9 @@ def load_tool(tool, tooldir=None, ctx=None, with_sys_path=True):
        try:
                module = Context.load_tool_default(tool, tooldir, ctx, with_sys_path)
        except ImportError as e:
+               if not ctx or not hasattr(Options.options, 'download'):
+                       Logs.error('Could not load %r during options phase (download unavailable at this point)' % tool)
+                       raise
                if Options.options.download:
                        module = download_tool(tool, ctx=ctx)
                        if not module:
@@ -164,3 +186,4 @@ def configure(self):
                self.load(cfg, tooldir=tooldir, **kwargs)
        self.start_msg('Checking for configuration')
        self.end_msg(use_cfg)
+