6 Obtain packages, unpack them in a location, and add associated uselib variables
7 (CFLAGS_pkgname, LIBPATH_pkgname, etc).
9 The default is use a Dependencies.txt file in the source directory.
11 This is a work in progress.
22 from waflib import Logs
23 from waflib.Configure import conf
26 from urllib import request
28 from urllib import urlopen
30 urlopen = request.urlopen
33 CACHEVAR = 'WAFCACHE_PACKAGE'
36 def get_package_cache_dir(self):
38 if CACHEVAR in conf.environ:
39 cache = conf.environ[CACHEVAR]
40 cache = self.root.make_node(cache)
41 elif self.env[CACHEVAR]:
42 cache = self.env[CACHEVAR]
43 cache = self.root.make_node(cache)
45 cache = self.srcnode.make_node('.wafcache_package')
50 def download_archive(self, src, dst):
51 for x in self.env.PACKAGE_REPO:
52 url = '/'.join((x, src))
56 if web.getcode() != 200:
58 except AttributeError:
61 # on python3 urlopen throws an exception
62 # python 2.3 does not have getcode and throws an exception to fail
65 tmp = self.root.make_node(dst)
67 Logs.warn('Downloaded %s from %s' % (tmp.abspath(), url))
70 self.fatal('Could not get the package %s' % src)
73 def load_packages(self):
74 self.get_package_cache_dir()
75 # read the dependencies, get the archives, ..