Beispiel #1
0
Datei: Build.py Projekt: zsx/waf
	def load_envs(self):
		"""load the data from the project directory into self.allenvs"""
		try:
			lst = Utils.listdir(self.cache_dir)
		except OSError as e:
			if e.errno == errno.ENOENT:
				raise Errors.WafError('The project was not configured: run "waf configure" first!')
			else:
				raise

		if not lst:
			raise Errors.WafError('The cache directory is empty: reconfigure the project')

		for fname in lst:
			if fname.endswith(CACHE_SUFFIX):
				env = ConfigSet.ConfigSet(os.path.join(self.cache_dir, fname))
				name = fname[:-len(CACHE_SUFFIX)]
				self.all_envs[name] = env

				for f in env[CFG_FILES]:
					newnode = self.path.find_or_declare(f)
					try:
						h = Utils.h_file(newnode.abspath())
					except (IOError, AttributeError):
						Logs.error('cannot find %r' % f)
						h = Utils.SIG_NIL
					newnode.sig = h
Beispiel #2
0
def set_qt5_libs_to_check(self):
	self.qt5_vars = Utils.to_list(getattr(self, 'qt5_vars', []))
	if not self.qt5_vars:
		dirlst = Utils.listdir(self.env.QTLIBS)

		pat = self.env.cxxshlib_PATTERN
		if Utils.is_win32:
			pat = pat.replace('.dll', '.lib')
		if self.environ.get('QT5_FORCE_STATIC'):
			pat = self.env.cxxstlib_PATTERN
		if Utils.unversioned_sys_platform() == 'darwin':
			pat = "%s\.framework"
		re_qt = re.compile(pat%'Qt5?(?P<name>.*)'+'$')
		for x in dirlst:
			m = re_qt.match(x)
			if m:
				self.qt5_vars.append("Qt5%s" % m.group('name'))
		if not self.qt5_vars:
			self.fatal('cannot find any Qt5 library (%r)' % self.env.QTLIBS)

	qtextralibs = getattr(Options.options, 'qtextralibs', None)
	if qtextralibs:
		self.qt5_vars.extend(qtextralibs.split(','))

	if not hasattr(self, 'qt5_vars_debug'):
		self.qt5_vars_debug = [a + '_DEBUG' for a in self.qt5_vars]
	self.qt5_vars_debug = Utils.to_list(self.qt5_vars_debug)
Beispiel #3
0
Datei: Build.py Projekt: SjB/waf
	def load_envs(self):
		"""
		The configuration command creates files of the form ``build/c4che/NAMEcache.py``. This method
		creates a :py:class:`waflib.ConfigSet.ConfigSet` instance for each ``NAME`` by reading those
		files. The config sets are then stored in the dict :py:attr:`waflib.Build.BuildContext.allenvs`.
		"""
		try:
			lst = Utils.listdir(self.cache_dir)
		except OSError as e:
			if e.errno == errno.ENOENT:
				raise Errors.WafError('The project was not configured: run "waf configure" first!')
			else:
				raise

		if not lst:
			raise Errors.WafError('The cache directory is empty: reconfigure the project')

		for fname in lst:
			if fname.endswith(CACHE_SUFFIX):
				env = ConfigSet.ConfigSet(os.path.join(self.cache_dir, fname))
				name = fname[:-len(CACHE_SUFFIX)]
				self.all_envs[name] = env

				for f in env[CFG_FILES]:
					newnode = self.root.find_resource(f)
					try:
						h = Utils.h_file(newnode.abspath())
					except (IOError, AttributeError):
						Logs.error('cannot find %r' % f)
						h = Utils.SIG_NIL
					newnode.sig = h
Beispiel #4
0
 def load_envs(self):
     try:
         lst = Utils.listdir(self.cache_dir)
     except OSError, e:
         if e.errno == errno.ENOENT:
             raise Errors.WafError('The project was not configured: run "waf configure" first!')
         else:
             raise
Beispiel #5
0
	def listdir(self):
		"""
		Lists the folder contents

		:returns: list of file/folder names ordered alphabetically
		:rtype: list of string
		"""
		lst = Utils.listdir(self.abspath())
		lst.sort()
		return lst
Beispiel #6
0
def update(ctx):
	lst=Options.options.files.split(',')
	if not lst:
		lst=[x for x in Utils.listdir(Context.waf_dir+'/waflib/extras')if x.endswith('.py')]
	for x in lst:
		tool=x.replace('.py','')
		try:
			Configure.download_tool(tool,force=True,ctx=ctx)
		except Errors.WafError:
			Logs.error('Could not find the tool %s in the remote repository'%x)
def update(ctx):
	'''updates the plugins from the *waflib/extras* directory'''
	lst=Options.options.files.split(',')
	if not lst:
		lst=[x for x in Utils.listdir(Context.waf_dir+'/waflib/extras')if x.endswith('.py')]
	for x in lst:
		tool=x.replace('.py','')
		try:
			Configure.download_tool(tool,force=True,ctx=ctx)
		except Errors.WafError:
			Logs.error('Could not find the tool %s in the remote repository'%x)
Beispiel #8
0
def update(ctx):
    """updates the plugins from the *waflib/extras* directory"""
    lst = Options.options.files.split(",")
    if not lst:
        lst = [x for x in Utils.listdir(Context.waf_dir + "/waflib/extras") if x.endswith(".py")]
    for x in lst:
        tool = x.replace(".py", "")
        try:
            Configure.download_tool(tool, force=True, ctx=ctx)
        except Errors.WafError:
            Logs.error("Could not find the tool %s in the remote repository" % x)
Beispiel #9
0
Datei: javaw.py Projekt: zsx/waf
	def post_run(self):
		"""record the inner class files created (Class$Foo) - for cleaning the folders mostly
		it is not possible to know which inner classes in advance"""

		lst = set([x.parent for x in self.outputs])

		inner = []
		for k in lst:
			lst = Utils.listdir(k.abspath())
			for u in lst:
				if u.find('$') >= 0:
					node = k.find_or_declare(u)
					inner.append(node)

		to_add = set(inner) - set(self.outputs)
		self.outputs.extend(list(to_add))
		return super(javac, self).post_run()
def update(ctx):
	lst = Options.options.files
	if lst:
		lst = lst.split(',')
	else:
		path = os.path.join(Context.waf_dir, 'waflib', 'extras')
		lst = [x for x in Utils.listdir(path) if x.endswith('.py')]
	for x in lst:
		tool = x.replace('.py', '')
		if not tool:
			continue
		try:
			dl = Configure.download_tool
		except AttributeError:
			ctx.fatal('The command "update" is dangerous; include the tool "use_config" in your project!')
		try:
			dl(tool, force=True, ctx=ctx)
		except Errors.WafError:
			Logs.error('Could not find the tool %r in the remote repository' % x)
		else:
			Logs.warn('Updated %r' % tool)
Beispiel #11
0
def set_qt5_libs_to_check(self):
    self.qt5_vars = Utils.to_list(getattr(self, 'qt5_vars', []))
    if not self.qt5_vars:
        dirlst = Utils.listdir(self.env.QTLIBS)
        pat = self.env.cxxshlib_PATTERN
        if Utils.is_win32:
            pat = pat.replace('.dll', '.lib')
        if self.environ.get('QT5_FORCE_STATIC'):
            pat = self.env.cxxstlib_PATTERN
        if Utils.unversioned_sys_platform() == 'darwin':
            pat = r"%s\.framework"
        re_qt = re.compile(pat % 'Qt5?(?P<name>.*)' + '$')
        for x in dirlst:
            m = re_qt.match(x)
            if m:
                self.qt5_vars.append("Qt5%s" % m.group('name'))
        if not self.qt5_vars:
            self.fatal('cannot find any Qt5 library (%r)' % self.env.QTLIBS)
    qtextralibs = getattr(Options.options, 'qtextralibs', None)
    if qtextralibs:
        self.qt5_vars.extend(qtextralibs.split(','))
def set_qt5_libs_to_check(self):
    self.qt5_vars = Utils.to_list(getattr(self, "qt5_vars", []))
    if not self.qt5_vars:
        dirlst = Utils.listdir(self.env.QTLIBS)

        pat = self.env.cxxshlib_PATTERN
        if Utils.is_win32:
            pat = pat.replace(".dll", ".lib")
        if self.environ.get("QT5_FORCE_STATIC"):
            pat = self.env.cxxstlib_PATTERN
        if Utils.unversioned_sys_platform() == "darwin":
            pat = r"%s\.framework"
        re_qt = re.compile(pat % "Qt5?(?P<name>.*)" + "$")
        for x in dirlst:
            m = re_qt.match(x)
            if m:
                self.qt5_vars.append("Qt5%s" % m.group("name"))
        if not self.qt5_vars:
            self.fatal("cannot find any Qt5 library (%r)" % self.env.QTLIBS)

    qtextralibs = getattr(Options.options, "qtextralibs", None)
    if qtextralibs:
        self.qt5_vars.extend(qtextralibs.split(","))
Beispiel #13
0
def check_boost(self, *k, **kw):
    """
	Initialize boost libraries to be used.

	Keywords: you can pass the same parameters as with the command line (without "--boost-").
	Note that the command line has the priority, and should preferably be used.
	"""
    if not self.env["CXX"]:
        self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')

    params = {"lib": k and k[0] or kw.get("lib", None)}
    for key, value in self.options.__dict__.items():
        if not key.startswith("boost_"):
            continue
        key = key[len("boost_") :]
        params[key] = value and value or kw.get(key, "")

    var = kw.get("uselib_store", "BOOST")

    self.start_msg("Checking boost includes")
    try:
        self.env["INCLUDES_%s" % var] = self.boost_get_includes(**params)
        self.env.BOOST_VERSION = self.boost_get_version(self.env["INCLUDES_%s" % var])
    except WafError:
        self.end_msg("not found", "YELLOW")
        raise
        # self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
        # self.env.BOOST_VERSION = self.boost_get_version(inc)
    self.end_msg(self.env.BOOST_VERSION)
    if Logs.verbose:
        Logs.pprint("CYAN", "	path : %s" % self.env["INCLUDES_%s" % var])

    if not params["lib"]:
        return
    self.start_msg("Checking boost libs")
    try:
        suffix = params.get("static", "ST") or ""
        path, libs = self.boost_get_libs(**params)
    except WafError:
        self.end_msg("not found", "YELLOW")
        raise
        # suffix = params.get('static', None) and 'ST' or ''
        # path, libs = self.boost_get_libs(**params)
    self.env["%sLIBPATH_%s" % (suffix, var)] = [path]
    self.env["%sLIB_%s" % (suffix, var)] = libs
    self.end_msg("ok")
    if Logs.verbose:
        Logs.pprint("CYAN", "	path : %s" % path)
        Logs.pprint("CYAN", "	libs : %s" % libs)

    def try_link():
        if "system" in params["lib"]:
            self.check_cxx(
                fragment="\n".join(
                    ["#include <boost/system/error_code.hpp>", "int main() { boost::system::error_code c; }"]
                ),
                use=var,
                execute=False,
            )
        if "thread" in params["lib"]:
            self.check_cxx(
                fragment="\n".join(["#include <boost/thread.hpp>", "int main() { boost::thread t; }"]),
                use=var,
                execute=False,
            )

    if params.get("linkage_autodetect", False):
        self.start_msg("Attempting to detect boost linkage flags")
        toolset = self.boost_get_toolset(kw.get("toolset", ""))
        if toolset in ["vc"]:
            # disable auto-linking feature, causing error LNK1181
            # because the code wants to be linked against
            self.env["DEFINES_%s" % var] += ["BOOST_ALL_NO_LIB"]

            # if no dlls are present, we guess the .lib files are not stubs
            has_dlls = False
            for x in Utils.listdir(path):
                if x.endswith(self.env.cxxshlib_PATTERN % ""):
                    has_dlls = True
                    break
            if not has_dlls:
                self.env["STLIBPATH_%s" % var] = [path]
                self.env["STLIB_%s" % var] = libs
                del self.env["LIB_%s" % var]
                del self.env["LIBPATH_%s" % var]

                # we attempt to play with some known-to-work CXXFLAGS combinations
            for cxxflags in (["/MD", "/EHsc"], []):
                self.env.stash()
                self.env["CXXFLAGS_%s" % var] += cxxflags
                try:
                    try_link()
                    self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
                    e = None
                    break
                except Errors.ConfigurationError, exc:
                    self.env.revert()
                    e = exc

            if e is not None:
                self.fatal(
                    "Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e
                )
        else:
            self.fatal("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
Beispiel #14
0
def check_boost(self,*k,**kw):
	if not self.env['CXX']:
		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
	params={'lib':k and k[0]or kw.get('lib',None)}
	for key,value in list(self.options.__dict__.items()):
		if not key.startswith('boost_'):
			continue
		key=key[len('boost_'):]
		params[key]=value and value or kw.get(key,'')
	var=kw.get('uselib_store','BOOST')
	self.start_msg('Checking boost includes')
	self.env['INCLUDES_%s'%var]=inc=self.boost_get_includes(**params)
	self.env.BOOST_VERSION=self.boost_get_version(inc)
	self.end_msg(self.env.BOOST_VERSION)
	if Logs.verbose:
		Logs.pprint('CYAN','	path : %s'%self.env['INCLUDES_%s'%var])
	if not params['lib']:
		return
	self.start_msg('Checking boost libs')
	suffix=params.get('static',None)and'ST'or''
	path,libs=self.boost_get_libs(**params)
	self.env['%sLIBPATH_%s'%(suffix,var)]=[path]
	self.env['%sLIB_%s'%(suffix,var)]=libs
	self.end_msg('ok')
	if Logs.verbose:
		Logs.pprint('CYAN','	path : %s'%path)
		Logs.pprint('CYAN','	libs : %s'%libs)
	def try_link():
		if'system'in params['lib']:
			self.check_cxx(fragment="\n".join(['#include <boost/system/error_code.hpp>','int main() { boost::system::error_code c; }',]),use=var,execute=False,)
		if'thread'in params['lib']:
			self.check_cxx(fragment="\n".join(['#include <boost/thread.hpp>','int main() { boost::thread t; }',]),use=var,execute=False,)
	if params.get('linkage_autodetect',False):
		self.start_msg("Attempting to detect boost linkage flags")
		toolset=self.boost_get_toolset(kw.get('toolset',''))
		if toolset in['vc']:
			self.env['DEFINES_%s'%var]+=['BOOST_ALL_NO_LIB']
			has_dlls=False
			for x in Utils.listdir(path):
				if x.endswith(self.env.cxxshlib_PATTERN%''):
					has_dlls=True
					break
			if not has_dlls:
				self.env['STLIBPATH_%s'%var]=[path]
				self.env['STLIB_%s'%var]=libs
				del self.env['LIB_%s'%var]
				del self.env['LIBPATH_%s'%var]
			for cxxflags in(['/MD','/EHsc'],[]):
				self.env.stash()
				self.env["CXXFLAGS_%s"%var]+=cxxflags
				try:
					try_link()
					self.end_msg("ok: winning cxxflags combination: %s"%(self.env["CXXFLAGS_%s"%var]))
					exc=None
					break
				except Errors.ConfigurationError as e:
					self.env.revert()
					exc=e
			if exc is not None:
				self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author",ex=exc)
				self.fatal('The configuration failed')
		else:
			self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
			self.fatal('The configuration failed')
	else:
		self.start_msg('Checking for boost linkage')
		try:
			try_link()
		except Errors.ConfigurationError as e:
			self.end_msg("Could not link against boost libraries using supplied options")
			self.fatal('The configuration failed')
		self.end_msg('ok')
def find_qt5_binaries(self):

    env = self.env

    opt = Options.options
    qtdir = getattr(opt, 'qtdir', '')
    qtbin = getattr(opt, 'qtbin', '')

    if not qtdir:
        qtdir = os.path.normpath(
            self.CreateRootRelativePath('Code/Sandbox/SDKs/Qt'))

    paths = []

    if qtdir:
        qtbin = os.path.join(qtdir, 'bin')

    # the qt directory has been given from QT5_ROOT - deduce the qt binary path
    if not qtdir:
        qtdir = os.environ.get('QT5_ROOT', '')
        qtbin = os.environ.get('QT5_BIN', None) or os.path.join(qtdir, 'bin')

    if qtbin:
        paths = [qtbin]

    # no qtdir, look in the path and in /usr/local/Trolltech
    if not qtdir:
        paths = os.environ.get('PATH', '').split(os.pathsep)
        paths.append('/usr/share/qt5/bin/')
        try:
            lst = Utils.listdir('/usr/local/Trolltech/')
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()

                # keep the highest version
                qtdir = '/usr/local/Trolltech/%s/' % lst[0]
                qtbin = os.path.join(qtdir, 'bin')
                paths.append(qtbin)

    # at the end, try to find qmake in the paths given
    # keep the one with the highest version
    cand = None
    prev_ver = ['5', '0', '0']
    for qmk in ('qmake-qt5', 'qmake5', 'qmake'):
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log([qmake] +
                                           ['-query', 'QT_VERSION']).strip()
            except self.errors.WafError:
                pass
            else:
                if version:
                    new_ver = version.split('.')
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver

    # qmake could not be found easily, rely on qtchooser
    if not cand:
        try:
            self.find_program('qtchooser')
        except self.errors.ConfigurationError:
            pass
        else:
            cmd = [self.env.QTCHOOSER] + ['-qt=5', '-run-tool=qmake']
            try:
                version = self.cmd_and_log(cmd + ['-query', 'QT_VERSION'])
            except self.errors.WafError:
                pass
            else:
                cand = cmd

    if cand:
        self.env.QMAKE = cand
    else:
        # If we cannot find qmake, we will assume that QT is not available or a selected option
        return False

    self.env.QT_INSTALL_BINS = qtbin = self.cmd_and_log(
        [self.env.QMAKE] + ['-query', 'QT_INSTALL_BINS']).strip() + os.sep
    paths.insert(0, qtbin)

    def find_bin(lst, var):
        if var in env:
            return
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(['uic-qt5', 'uic'], 'QT_UIC')
    if not env.QT_UIC:
        # If we find qmake but not the uic compiler, then the QT installation is corrupt/invalid
        self.fatal(
            'Detected an invalid/corrupt version of QT, please check your installation'
        )

    self.start_msg('Checking for uic version')
    uicver = self.cmd_and_log([env.QT_UIC] + ['-version'], output=Context.BOTH)
    uicver = ''.join(uicver).strip()
    uicver = uicver.replace('Qt User Interface Compiler ',
                            '').replace('User Interface Compiler for Qt', '')
    self.end_msg(uicver)
    if uicver.find(' 3.') != -1 or uicver.find(' 4.') != -1:
        self.fatal(
            'this uic compiler is for qt3 or qt5, add uic for qt5 to your path'
        )

    find_bin(['moc-qt5', 'moc'], 'QT_MOC')
    find_bin(['rcc-qt5', 'rcc'], 'QT_RCC')
    find_bin(['lrelease-qt5', 'lrelease'], 'QT_LRELEASE')
    find_bin(['lupdate-qt5', 'lupdate'], 'QT_LUPDATE')

    env['UIC_ST'] = '%s -o %s'
    env['MOC_ST'] = '-o'
    env['ui_PATTERN'] = 'ui_%s.h'
    env['QT_LRELEASE_FLAGS'] = ['-silent']
    env.MOCCPPPATH_ST = '-I%s'
    env.MOCDEFINES_ST = '-D%s'

    return True
Beispiel #16
0
def find_qt4_binaries(self):
	env=self.env
	opt=Options.options
	qtdir=getattr(opt,'qtdir','')
	qtbin=getattr(opt,'qtbin','')
	paths=[]
	if qtdir:
		qtbin=os.path.join(qtdir,'bin')
	if not qtdir:
		qtdir=os.environ.get('QT4_ROOT','')
		qtbin=os.environ.get('QT4_BIN',None)or os.path.join(qtdir,'bin')
	if qtbin:
		paths=[qtbin]
	if not qtdir:
		paths=os.environ.get('PATH','').split(os.pathsep)
		paths.append('/usr/share/qt4/bin/')
		try:
			lst=Utils.listdir('/usr/local/Trolltech/')
		except OSError:
			pass
		else:
			if lst:
				lst.sort()
				lst.reverse()
				qtdir='/usr/local/Trolltech/%s/'%lst[0]
				qtbin=os.path.join(qtdir,'bin')
				paths.append(qtbin)
	cand=None
	prev_ver=['4','0','0']
	for qmk in('qmake-qt4','qmake4','qmake'):
		try:
			qmake=self.find_program(qmk,path_list=paths)
		except self.errors.ConfigurationError:
			pass
		else:
			try:
				version=self.cmd_and_log(qmake+['-query','QT_VERSION']).strip()
			except self.errors.WafError:
				pass
			else:
				if version:
					new_ver=version.split('.')
					if new_ver>prev_ver:
						cand=qmake
						prev_ver=new_ver
	if cand:
		self.env.QMAKE=cand
	else:
		self.fatal('Could not find qmake for qt4')
	qtbin=self.cmd_and_log(self.env.QMAKE+['-query','QT_INSTALL_BINS']).strip()+os.sep
	def find_bin(lst,var):
		if var in env:
			return
		for f in lst:
			try:
				ret=self.find_program(f,path_list=paths)
			except self.errors.ConfigurationError:
				pass
			else:
				env[var]=ret
				break
	find_bin(['uic-qt3','uic3'],'QT_UIC3')
	find_bin(['uic-qt4','uic'],'QT_UIC')
	if not env.QT_UIC:
		self.fatal('cannot find the uic compiler for qt4')
	self.start_msg('Checking for uic version')
	uicver=self.cmd_and_log(env.QT_UIC+["-version"],output=Context.BOTH)
	uicver=''.join(uicver).strip()
	uicver=uicver.replace('Qt User Interface Compiler ','').replace('User Interface Compiler for Qt','')
	self.end_msg(uicver)
	if uicver.find(' 3.')!=-1:
		self.fatal('this uic compiler is for qt3, add uic for qt4 to your path')
	find_bin(['moc-qt4','moc'],'QT_MOC')
	find_bin(['rcc-qt4','rcc'],'QT_RCC')
	find_bin(['lrelease-qt4','lrelease'],'QT_LRELEASE')
	find_bin(['lupdate-qt4','lupdate'],'QT_LUPDATE')
	env['UIC3_ST']='%s -o %s'
	env['UIC_ST']='%s -o %s'
	env['MOC_ST']='-o'
	env['ui_PATTERN']='ui_%s.h'
	env['QT_LRELEASE_FLAGS']=['-silent']
	env.MOCCPPPATH_ST='-I%s'
	env.MOCDEFINES_ST='-D%s'
def find_qt5_binaries(self):
    """
    Detects Qt programs such as qmake, moc, uic, lrelease
    """
    env = self.env
    opt = Options.options

    qtdir = getattr(opt, "qtdir", "")
    qtbin = getattr(opt, "qtbin", "")

    paths = []

    if qtdir:
        qtbin = os.path.join(qtdir, "bin")

    # the qt directory has been given from QT5_ROOT - deduce the qt binary path
    if not qtdir:
        qtdir = self.environ.get("QT5_ROOT", "")
        qtbin = self.environ.get("QT5_BIN") or os.path.join(qtdir, "bin")

    if qtbin:
        paths = [qtbin]

    # no qtdir, look in the path and in /usr/local/Trolltech
    if not qtdir:
        paths = self.environ.get("PATH", "").split(os.pathsep)
        paths.extend(["/usr/share/qt5/bin", "/usr/local/lib/qt5/bin"])
        try:
            lst = Utils.listdir("/usr/local/Trolltech/")
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()

                # keep the highest version
                qtdir = "/usr/local/Trolltech/%s/" % lst[0]
                qtbin = os.path.join(qtdir, "bin")
                paths.append(qtbin)

    # at the end, try to find qmake in the paths given
    # keep the one with the highest version
    cand = None
    prev_ver = ["5", "0", "0"]
    for qmk in ("qmake-qt5", "qmake5", "qmake"):
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log(qmake +
                                           ["-query", "QT_VERSION"]).strip()
            except self.errors.WafError:
                pass
            else:
                if version:
                    new_ver = version.split(".")
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver

    # qmake could not be found easily, rely on qtchooser
    if not cand:
        try:
            self.find_program("qtchooser")
        except self.errors.ConfigurationError:
            pass
        else:
            cmd = self.env.QTCHOOSER + ["-qt=5", "-run-tool=qmake"]
            try:
                version = self.cmd_and_log(cmd + ["-query", "QT_VERSION"])
            except self.errors.WafError:
                pass
            else:
                cand = cmd

    if cand:
        self.env.QMAKE = cand
    else:
        self.fatal("Could not find qmake for qt5")

    self.env.QT_HOST_BINS = qtbin = self.cmd_and_log(
        self.env.QMAKE + ["-query", "QT_HOST_BINS"]).strip()
    paths.insert(0, qtbin)

    def find_bin(lst, var):
        if var in env:
            return
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(["uic-qt5", "uic"], "QT_UIC")
    if not env.QT_UIC:
        self.fatal("cannot find the uic compiler for qt5")

    self.start_msg("Checking for uic version")
    uicver = self.cmd_and_log(env.QT_UIC + ["-version"], output=Context.BOTH)
    uicver = "".join(uicver).strip()
    uicver = uicver.replace("Qt User Interface Compiler ",
                            "").replace("User Interface Compiler for Qt", "")
    self.end_msg(uicver)
    if uicver.find(" 3.") != -1 or uicver.find(" 4.") != -1:
        self.fatal(
            "this uic compiler is for qt3 or qt4, add uic for qt5 to your path"
        )

    find_bin(["moc-qt5", "moc"], "QT_MOC")
    find_bin(["rcc-qt5", "rcc"], "QT_RCC")
    find_bin(["lrelease-qt5", "lrelease"], "QT_LRELEASE")
    find_bin(["lupdate-qt5", "lupdate"], "QT_LUPDATE")

    env.UIC_ST = "%s -o %s"
    env.MOC_ST = "-o"
    env.ui_PATTERN = "ui_%s.h"
    env.QT_LRELEASE_FLAGS = ["-silent"]
    env.MOCCPPPATH_ST = "-I%s"
    env.MOCDEFINES_ST = "-D%s"
Beispiel #18
0
def check_boost(self,*k,**kw):
	if not self.env['CXX']:
		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
	params={'lib':k and k[0]or kw.get('lib',None)}
	for key,value in self.options.__dict__.items():
		if not key.startswith('boost_'):
			continue
		key=key[len('boost_'):]
		params[key]=value and value or kw.get(key,'')
	var=kw.get('uselib_store','BOOST')
	self.start_msg('Checking boost includes')
	self.env['INCLUDES_%s'%var]=inc=self.boost_get_includes(**params)
	self.env.BOOST_VERSION=self.boost_get_version(inc)
	self.end_msg(self.env.BOOST_VERSION)
	if Logs.verbose:
		Logs.pprint('CYAN','	path : %s'%self.env['INCLUDES_%s'%var])
	if not params['lib']:
		return
	self.start_msg('Checking boost libs')
	suffix=params.get('static',None)and'ST'or''
	path,libs=self.boost_get_libs(**params)
	self.env['%sLIBPATH_%s'%(suffix,var)]=[path]
	self.env['%sLIB_%s'%(suffix,var)]=libs
	self.end_msg('ok')
	if Logs.verbose:
		Logs.pprint('CYAN','	path : %s'%path)
		Logs.pprint('CYAN','	libs : %s'%libs)
	def try_link():
		if'system'in params['lib']:
			self.check_cxx(fragment="\n".join(['#include <boost/system/error_code.hpp>','int main() { boost::system::error_code c; }',]),use=var,execute=False,)
		if'thread'in params['lib']:
			self.check_cxx(fragment="\n".join(['#include <boost/thread.hpp>','int main() { boost::thread t; }',]),use=var,execute=False,)
	if params.get('linkage_autodetect',False):
		self.start_msg("Attempting to detect boost linkage flags")
		toolset=self.boost_get_toolset(kw.get('toolset',''))
		if toolset in['vc']:
			self.env['DEFINES_%s'%var]+=['BOOST_ALL_NO_LIB']
			has_dlls=False
			for x in Utils.listdir(path):
				if x.endswith(self.env.cxxshlib_PATTERN%''):
					has_dlls=True
					break
			if not has_dlls:
				self.env['STLIBPATH_%s'%var]=[path]
				self.env['STLIB_%s'%var]=libs
				del self.env['LIB_%s'%var]
				del self.env['LIBPATH_%s'%var]
			for cxxflags in(['/MD','/EHsc'],[]):
				self.env.stash()
				self.env["CXXFLAGS_%s"%var]+=cxxflags
				try:
					try_link()
					self.end_msg("ok: winning cxxflags combination: %s"%(self.env["CXXFLAGS_%s"%var]))
					e=None
					break
				except Errors.ConfigurationError as exc:
					self.env.revert()
					e=exc
			if e is not None:
				self.fatal("Could not auto-detect boost linking flags combination, you may report it to boost.py author",ex=e)
		else:
			self.fatal("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
	else:
		self.start_msg('Checking for boost linkage')
		try:
			try_link()
		except Errors.ConfigurationError ,e:
			self.fatal("Could not link against boost libraries using supplied options")
		self.end_msg('ok')
Beispiel #19
0
	def listdir(self):
		"""List the folder contents"""
		lst = Utils.listdir(self.abspath())
		lst.sort()
		return lst
Beispiel #20
0
def check_boost(self, *k, **kw):
	"""
	Initialize boost libraries to be used.

	Keywords: you can pass the same parameters as with the command line (without "--boost-").
	Note that the command line has the priority, and should preferably be used.
	"""
	if not self.env['CXX']:
		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')

	params = {
		'lib': k and k[0] or kw.get('lib', None),
		'stlib': kw.get('stlib', None)
	}
	for key, value in self.options.__dict__.items():
		if not key.startswith('boost_'):
			continue
		key = key[len('boost_'):]
		params[key] = value and value or kw.get(key, '')

	var = kw.get('uselib_store', 'BOOST')

	if not self.env.DONE_FIND_BOOST_COMMON:
		self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
		if self.env.DPKG_ARCHITECTURE:
			deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
			BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())

		self.start_msg('Checking boost includes')
		self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
		versions = self.boost_get_version(inc)
		self.env.BOOST_VERSION = versions[0]
		self.env.BOOST_VERSION_NUMBER = int(versions[1])
		self.end_msg('%d.%d.%d' % (int(versions[1]) / 100000,
								   int(versions[1]) / 100 % 1000,
								   int(versions[1]) % 100))
		if Logs.verbose:
			Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])

		self.env.DONE_FIND_BOOST_COMMON = True

	if not params['lib'] and not params['stlib']:
		return
	if 'static' in kw or 'static' in params:
		Logs.warn('boost: static parameter is deprecated, use stlib instead.')
	self.start_msg('Checking boost libs')
	path, libs, stlibs = self.boost_get_libs(**params)
	self.env['LIBPATH_%s' % var] = [path]
	self.env['STLIBPATH_%s' % var] = [path]
	self.env['LIB_%s' % var] = libs
	self.env['STLIB_%s' % var] = stlibs
	self.end_msg(' '.join(libs + stlibs))
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % path)
		Logs.pprint('CYAN', '	shared libs : %s' % libs)
		Logs.pprint('CYAN', '	static libs : %s' % stlibs)

	def has_shlib(lib):
		return params['lib'] and lib in params['lib']
	def has_stlib(lib):
		return params['stlib'] and lib in params['stlib']
	def has_lib(lib):
		return has_shlib(lib) or has_stlib(lib)
	if has_lib('thread'):
		# not inside try_link to make check visible in the output
		self._check_pthread_flag(k, kw)

	def try_link():
		if has_lib('system'):
			self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
		if has_lib('thread'):
			self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
		if has_lib('log') or has_lib('log_setup'):
			if not has_lib('thread'):
				self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
			if has_shlib('log') or has_shlib('log_setup'):
				self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
			if has_lib('log_setup'):
				self.check_cxx(fragment=BOOST_LOG_SETUP_CODE, use=var, execute=False)
			else:
				self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)

	if params.get('linkage_autodetect', False):
		self.start_msg('Attempting to detect boost linkage flags')
		toolset = self.boost_get_toolset(kw.get('toolset', ''))
		if toolset in ('vc',):
			# disable auto-linking feature, causing error LNK1181
			# because the code wants to be linked against
			self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']

			# if no dlls are present, we guess the .lib files are not stubs
			has_dlls = False
			for x in Utils.listdir(path):
				if x.endswith(self.env.cxxshlib_PATTERN % ''):
					has_dlls = True
					break
			if not has_dlls:
				self.env['STLIBPATH_%s' % var] = [path]
				self.env['STLIB_%s' % var] = libs
				del self.env['LIB_%s' % var]
				del self.env['LIBPATH_%s' % var]

			# we attempt to play with some known-to-work CXXFLAGS combinations
			for cxxflags in (['/MD', '/EHsc'], []):
				self.env.stash()
				self.env['CXXFLAGS_%s' % var] += cxxflags
				try:
					try_link()
					self.end_msg('ok: winning cxxflags combination: %s' % (self.env['CXXFLAGS_%s' % var]))
					exc = None
					break
				except Errors.ConfigurationError as e:
					self.env.revert()
					exc = e

			if exc is not None:
				self.end_msg('Could not auto-detect boost linking flags combination, you may report it to boost.py author', ex=exc)
				self.fatal('The configuration failed')
		else:
			self.end_msg('Boost linkage flags auto-detection not implemented (needed ?) for this toolchain')
			self.fatal('The configuration failed')
	else:
		self.start_msg('Checking for boost linkage')
		try:
			try_link()
		except Errors.ConfigurationError as e:
			self.end_msg('Could not link against boost libraries using supplied options', 'YELLOW')
			self.fatal('The configuration failed')
		self.end_msg('ok')
Beispiel #21
0
    def run(self):
        env = self.env
        gen = self.generator
        bld = gen.bld
        zpy = bld.zpy
        out = self.outputs[0].parent

        dist = self.dist
        signode = self.signode

        out_path = out.abspath()
        bld_path = bld.bldnode.abspath()
        source_url = dist.source_url or ''
        url = urlparse.urlsplit(source_url)
        # normalize initially to dist.key
        name = pth.basename(url.path).lower() or dist.key
        # ensure sdist filename matches dist.name!
        # otherwise dist.name != dist.metadata.name if the object was created
        # from a filename, even if metadata is loaded later!
        #FIXME: upstream fix to above...
        name = name.replace(dist.key, dist.name, 1)
        if dist.name not in name:
            # probably a hash
            ext = name[name.find('.'):]
            if len(ext) > 1:
                name = dist.metadata.name_and_version + ext
        # no raison other than consistency
        if name.endswith('.tgz'):
            name = name[:-4] + '.tar.gz'
        path = pth.join(zpy.top_xsrc, name)
        meta = path + '.' + metadata.METADATA_FILENAME
        meta_alt = pth.join(url.path, metadata.METADATA_FILENAME)
        meta_out = pth.join(out_path, metadata.METADATA_FILENAME)

        if url.scheme and url.path and url.path != path:
            path, message = urllib.urlretrieve(url.geturl(), path)

        if url.path and pth.isdir(url.path):
            try:
                git_dir = subprocess.check_output(
                    ['git', 'rev-parse', '--show-toplevel'],
                    cwd=url.path,
                ).strip()
                # avoid checking out the wrong repo due to nesting; ie. don't
                # checkout someone's dotfile repo just because they happen to
                # technically be "under" it
                if pth.abspath(git_dir) == pth.abspath(url.path):
                    git_dir = subprocess.check_output(
                        args=['git', 'rev-parse', '--git-dir'],
                        cwd=url.path,
                    )
                    git_dir = pth.join(url.path, git_dir.strip())
                else:
                    git_dir = None
            except subprocess.CalledProcessError:
                git_dir = None
            if git_dir:
                if not pth.exists(out_path):
                    os.mkdir(out_path)
                subprocess.call([
                    'git',
                    '--git-dir={0}'.format(git_dir),
                    '--work-tree={0}'.format(out_path),
                    'checkout-index',
                    '--all',
                    '--quiet',
                    '--force',
                ])
                if pth.exists(meta):
                    shutil.copy2(meta, meta_out)
                elif pth.exists(meta_alt):
                    shutil.copy2(meta_alt, meta_out)
            else:
                # symlink local dist checkout
                local_path = pth.join(zpy.top, url.path)
                local_path = pth.abspath(local_path)
                local_sym = pth.relpath(local_path, bld_path)
                try:
                    # clear broken symlinks
                    os.unlink(out_path)
                except OSError:
                    pass
                finally:
                    os.symlink(local_sym, out_path)
        elif pth.isfile(path):
            _zip = ('.zip', )
            _whl = ('.whl', )
            _tar = tuple(
                set(distlib.util.ARCHIVE_EXTENSIONS) - set(_zip + _whl))
            if path.endswith(_whl):
                dist.metadata = wheel.Wheel(path).metadata
                dist_dir = pth.join(out_path, 'dist')
                Utils.check_dir(dist_dir)
                self.outputs[0].write(
                    json.dumps(
                        dist.metadata.dictionary,
                        ensure_ascii=True,
                        sort_keys=True,
                        indent=2,
                    ))
                whl_dst = pth.join(dist_dir, pth.basename(path))
                whl_sym = pth.relpath(path, dist_dir)
                if not pth.exists(whl_dst):
                    os.symlink(whl_sym, whl_dst)
            else:
                if pth.isfile(meta):
                    #TODO: needs to use zpy.dist
                    dist.metadata = metadata.Metadata(path=meta)
                else:
                    pydist = normalize_pydist(dist.metadata.dictionary)
                    pydist.update(source_url=pth.relpath(path, zpy.top))

                    with codecs.open(meta, 'w', 'utf-8') as fp:
                        json.dump(
                            pydist,
                            fp=fp,
                            ensure_ascii=True,
                            sort_keys=True,
                            indent=2,
                        )

                    dist.metadata._legacy = None
                    dist.metadata._data = pydist

                sig_path = signode.abspath()
                for sfx, cmd in (
                    (_tar, '{env.TAR}\0-C\0{sig_path}\0-xf\0{path}\0'),
                    (_zip, '{env.UNZIP}\0-q\0-o\0-d\0{sig_path}\0{path}\0'),
                    (None, None),
                ):
                    if sfx is None:
                        distlib.util.unarchive(path, bld_path)
                        break

                    try:
                        cmd = cmd.format(**locals())
                        cmd = cmd.strip('\0').split('\0')
                    except AttributeError:
                        continue

                    rc = self.exec_command(cmd, env=env.env)
                    if rc == 0:
                        if not pth.exists(out_path):
                            tmp = signode.make_node(
                                Utils.listdir(signode.abspath()))
                            os.rename(tmp.abspath(), out_path)
                        break
                shutil.copy2(meta,
                             pth.join(out_path, metadata.METADATA_FILENAME))

        if dist.key == 'python':
            lib = pth.join(out_path, 'Lib')
            zippy_src = pth.join(zpy.top, 'zippy')
            zippy_dst = pth.join(lib, 'zippy')
            zippy_sym = pth.relpath(zippy_src, lib)
            if not pth.lexists(zippy_dst):
                os.symlink(zippy_sym, zippy_dst)
            incl_src = pth.join(out_path, 'Include')
            incl_dst = pth.join(zpy.o_inc, 'python' + dist.version[0:3])
            incl_sym = pth.relpath(incl_src, zpy.o_inc)
            if not pth.lexists(incl_dst):
                os.symlink(incl_sym, incl_dst)
            pyconfig = pth.join(out_path, 'Include', 'pyconfig.h')
            if not pth.lexists(pyconfig):
                os.symlink('../pyconfig.h', pyconfig)

        return 0
Beispiel #22
0
def find_qt4_binaries(self):
	env = self.env
	opt = Options.options

	qtdir = getattr(opt, 'qtdir', '')
	qtbin = getattr(opt, 'qtbin', '')

	paths = []

	if qtdir:
		qtbin = os.path.join(qtdir, 'bin')

	# the qt directory has been given from QT4_ROOT - deduce the qt binary path
	if not qtdir:
		qtdir = self.environ.get('QT4_ROOT', '')
		qtbin = os.path.join(qtdir, 'bin')

	if qtbin:
		paths = [qtbin]

	# no qtdir, look in the path and in /usr/local/Trolltech
	if not qtdir:
		paths = os.environ.get('PATH', '').split(os.pathsep)
		paths.append('/usr/share/qt4/bin/')
		try:
			lst = Utils.listdir('/usr/local/Trolltech/')
		except OSError:
			pass
		else:
			if lst:
				lst.sort()
				lst.reverse()

				# keep the highest version
				qtdir = '/usr/local/Trolltech/%s/' % lst[0]
				qtbin = os.path.join(qtdir, 'bin')
				paths.append(qtbin)

	# at the end, try to find qmake in the paths given
	# keep the one with the highest version
	cand = None
	prev_ver = ['4', '0', '0']
	for qmk in ['qmake-qt4', 'qmake4', 'qmake']:
		try:
			qmake = self.find_program(qmk, path_list=paths)
		except self.errors.ConfigurationError:
			pass
		else:
			try:
				version = self.cmd_and_log([qmake, '-query', 'QT_VERSION']).strip()
			except self.errors.ConfigurationError:
				pass
			else:
				if version:
					new_ver = version.split('.')
					if new_ver > prev_ver:
						cand = qmake
						prev_ver = new_ver
	if cand:
		self.env.QMAKE = cand
	else:
		self.fatal('Could not find qmake for qt4')

	qtbin = self.cmd_and_log([self.env.QMAKE, '-query', 'QT_INSTALL_BINS']).strip() + os.sep

	def find_bin(lst, var):
		for f in lst:
			try:
				ret = self.find_program(f, path_list=paths)
			except self.errors.ConfigurationError:
				pass
			else:
				env[var]=ret
				break

	find_bin(['uic-qt3', 'uic3'], 'QT_UIC3')
	find_bin(['uic-qt4', 'uic'], 'QT_UIC')
	if not env['QT_UIC']:
		self.fatal('cannot find the uic compiler for qt4')

	try:
		uicver = self.cmd_and_log(env['QT_UIC'] + " -version 2>&1").strip()
	except self.errors.ConfigurationError:
		self.fatal('this uic compiler is for qt3, add uic for qt4 to your path')
	uicver = uicver.replace('Qt User Interface Compiler ','').replace('User Interface Compiler for Qt', '')
	self.msg('Checking for uic version', '%s' % uicver)
	if uicver.find(' 3.') != -1:
		self.fatal('this uic compiler is for qt3, add uic for qt4 to your path')

	find_bin(['moc-qt4', 'moc'], 'QT_MOC')
	find_bin(['rcc'], 'QT_RCC')
	find_bin(['lrelease-qt4', 'lrelease'], 'QT_LRELEASE')
	find_bin(['lupdate-qt4', 'lupdate'], 'QT_LUPDATE')

	env['UIC3_ST']= '%s -o %s'
	env['UIC_ST'] = '%s -o %s'
	env['MOC_ST'] = '-o'
	env['ui_PATTERN'] = 'ui_%s.h'
	env['QT_LRELEASE_FLAGS'] = ['-silent']
	env.MOCCPPPATH_ST = '-I%s'
	env.MOCDEFINES_ST = '-D%s'
Beispiel #23
0
def check_boost(self, *k, **kw):
	"""
	Initialize boost libraries to be used.

	Keywords: you can pass the same parameters as with the command line (without "--boost-").
	Note that the command line has the priority, and should preferably be used.
	"""
	if not self.env['CXX']:
		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')

	params = {
		'lib': k and k[0] or kw.get('lib'),
		'stlib': kw.get('stlib')
	}
	for key, value in self.options.__dict__.items():
		if not key.startswith('boost_'):
			continue
		key = key[len('boost_'):]
		params[key] = value and value or kw.get(key, '')

	var = kw.get('uselib_store', 'BOOST')

	self.start_msg('Checking boost includes')
	self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
	versions = self.boost_get_version(inc)
	self.env.BOOST_VERSION = versions[0]
	self.env.BOOST_VERSION_NUMBER = int(versions[1])
	self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
							   int(versions[1]) / 100 % 1000,
							   int(versions[1]) % 100))
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])

	if not params['lib'] and not params['stlib']:
		return
	if 'static' in kw or 'static' in params:
		Logs.warn('boost: static parameter is deprecated, use stlib instead.')
	self.start_msg('Checking boost libs')
	path, libs, stlibs = self.boost_get_libs(**params)
	self.env['LIBPATH_%s' % var] = [path]
	self.env['STLIBPATH_%s' % var] = [path]
	self.env['LIB_%s' % var] = libs
	self.env['STLIB_%s' % var] = stlibs
	self.end_msg('ok')
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % path)
		Logs.pprint('CYAN', '	shared libs : %s' % libs)
		Logs.pprint('CYAN', '	static libs : %s' % stlibs)


	def try_link():
		if (params['lib'] and 'system' in params['lib']) or \
			params['stlib'] and 'system' in params['stlib']:
			self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
		if (params['lib'] and 'thread' in params['lib']) or \
			params['stlib'] and 'thread' in params['stlib']:
			self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)

		def is_log_mt():
			'''Check if found boost_log library is multithread-safe'''
			for lib in libs:
				if lib.startswith('boost_log'):
					lib_log = lib
					break
			return '-mt' in lib_log

		if params['lib'] and 'log' in params['lib']:
			self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
			if not is_log_mt():
				self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
			self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
		if params['stlib'] and 'log' in params['stlib']:
			# Static linking is assumed by default
			if not is_log_mt():
				self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
			self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)

	if params.get('linkage_autodetect', False):
		self.start_msg("Attempting to detect boost linkage flags")
		toolset = self.boost_get_toolset(kw.get('toolset', ''))
		if toolset in ('vc',):
			# disable auto-linking feature, causing error LNK1181
			# because the code wants to be linked against
			self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']

			# if no dlls are present, we guess the .lib files are not stubs
			has_dlls = False
			for x in Utils.listdir(path):
				if x.endswith(self.env.cxxshlib_PATTERN % ''):
					has_dlls = True
					break
			if not has_dlls:
				self.env['STLIBPATH_%s' % var] = [path]
				self.env['STLIB_%s' % var] = libs
				del self.env['LIB_%s' % var]
				del self.env['LIBPATH_%s' % var]

			# we attempt to play with some known-to-work CXXFLAGS combinations
			for cxxflags in (['/MD', '/EHsc'], []):
				self.env.stash()
				self.env["CXXFLAGS_%s" % var] += cxxflags
				try:
					try_link()
				except Errors.ConfigurationError as e:
					self.env.revert()
					exc = e
				else:
					self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
					exc = None
					self.env.commit()
					break

			if exc is not None:
				self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)
				self.fatal('The configuration failed')
		else:
			self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
			self.fatal('The configuration failed')
	else:
		self.start_msg('Checking for boost linkage')
		try:
			try_link()
		except Errors.ConfigurationError as e:
			self.end_msg("Could not link against boost libraries using supplied options")
			self.fatal('The configuration failed')
		self.end_msg('ok')
Beispiel #24
0
def find_qt5_binaries(self):
	env = self.env
	opt = Options.options

	qtdir = getattr(opt, 'qtdir', '')
	qtbin = getattr(opt, 'qtbin', '')

	paths = []

	if qtdir:
		qtbin = os.path.join(qtdir, 'bin')

	# the qt directory has been given from QT5_ROOT - deduce the qt binary path
	if not qtdir:
		qtdir = os.environ.get('QT5_ROOT', '')
		qtbin = os.environ.get('QT5_BIN', None) or os.path.join(qtdir, 'bin')

	if qtbin:
		paths = [qtbin]

	# no qtdir, look in the path and in /usr/local/Trolltech
	if not qtdir:
		paths = os.environ.get('PATH', '').split(os.pathsep)
		paths.append('/usr/share/qt5/bin/')
		try:
			lst = Utils.listdir('/usr/local/Trolltech/')
		except OSError:
			pass
		else:
			if lst:
				lst.sort()
				lst.reverse()

				# keep the highest version
				qtdir = '/usr/local/Trolltech/%s/' % lst[0]
				qtbin = os.path.join(qtdir, 'bin')
				paths.append(qtbin)

	# at the end, try to find qmake in the paths given
	# keep the one with the highest version
	cand = None
	prev_ver = ['5', '0', '0']
	for qmk in ('qmake-qt5', 'qmake5', 'qmake'):
		try:
			qmake = self.find_program(qmk, path_list=paths)
		except self.errors.ConfigurationError:
			pass
		else:
			try:
				version = self.cmd_and_log(qmake + ['-query', 'QT_VERSION']).strip()
			except self.errors.WafError:
				pass
			else:
				if version:
					new_ver = version.split('.')
					if new_ver > prev_ver:
						cand = qmake
						prev_ver = new_ver

	# qmake could not be found easily, rely on qtchooser
	if not cand:
		try:
			self.find_program('qtchooser')
		except self.errors.ConfigurationError:
			pass
		else:
			cmd = self.env.QTCHOOSER + ['-qt=5', '-run-tool=qmake']
			try:
				version = self.cmd_and_log(cmd + ['-query', 'QT_VERSION'])
			except self.errors.WafError:
				pass
			else:
				cand = cmd

	if cand:
		self.env.QMAKE = cand
	else:
		self.fatal('Could not find qmake for qt5')

	self.env.QT_INSTALL_BINS = qtbin = self.cmd_and_log(self.env.QMAKE + ['-query', 'QT_INSTALL_BINS']).strip() + os.sep
	paths.insert(0, qtbin)

	def find_bin(lst, var):
		if var in env:
			return
		for f in lst:
			try:
				ret = self.find_program(f, path_list=paths)
			except self.errors.ConfigurationError:
				pass
			else:
				env[var]=ret
				break

	find_bin(['uic-qt5', 'uic'], 'QT_UIC')
	if not env.QT_UIC:
		self.fatal('cannot find the uic compiler for qt5')

	self.start_msg('Checking for uic version')
	uicver = self.cmd_and_log(env.QT_UIC + ['-version'], output=Context.BOTH)
	uicver = ''.join(uicver).strip()
	uicver = uicver.replace('Qt User Interface Compiler ','').replace('User Interface Compiler for Qt', '')
	self.end_msg(uicver)
	if uicver.find(' 3.') != -1 or uicver.find(' 4.') != -1:
		self.fatal('this uic compiler is for qt3 or qt5, add uic for qt5 to your path')

	find_bin(['moc-qt5', 'moc'], 'QT_MOC')
	find_bin(['rcc-qt5', 'rcc'], 'QT_RCC')
	find_bin(['lrelease-qt5', 'lrelease'], 'QT_LRELEASE')
	find_bin(['lupdate-qt5', 'lupdate'], 'QT_LUPDATE')

	env['UIC_ST'] = '%s -o %s'
	env['MOC_ST'] = '-o'
	env['ui_PATTERN'] = 'ui_%s.h'
	env['QT_LRELEASE_FLAGS'] = ['-silent']
	env.MOCCPPPATH_ST = '-I%s'
	env.MOCDEFINES_ST = '-D%s'
Beispiel #25
0
def check_boost(self, *k, **kw):
	"""
	Initialize boost libraries to be used.

	Keywords: you can pass the same parameters as with the command line (without "--boost-").
	Note that the command line has the priority, and should preferably be used.
	"""
	if not self.env['CXX']:
		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')

	params = {'lib': k and k[0] or kw.get('lib', None)}
	for key, value in self.options.__dict__.items():
		if not key.startswith('boost_'):
			continue
		key = key[len('boost_'):]
		params[key] = value and value or kw.get(key, '')

	var = kw.get('uselib_store', 'BOOST')

	self.start_msg('Checking boost includes')
	self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
	self.env.BOOST_VERSION = self.boost_get_version(inc)
	self.end_msg(self.env.BOOST_VERSION)
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])

	if not params['lib']:
		return
	self.start_msg('Checking boost libs')
	suffix = params.get('static', None) and 'ST' or ''
	path, libs = self.boost_get_libs(**params)
	self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
	self.env['%sLIB_%s' % (suffix, var)] = libs
	self.end_msg('ok')
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % path)
		Logs.pprint('CYAN', '	libs : %s' % libs)


	def try_link():
		if 'system' in params['lib']:
			self.check_cxx(
			 fragment="\n".join([
			  '#include <boost/system/error_code.hpp>',
			  'int main() { boost::system::error_code c; }',
			 ]),
			 use=var,
			 execute=False,
			)
		if 'thread' in params['lib']:
			self.check_cxx(
			 fragment="\n".join([
			  '#include <boost/thread.hpp>',
			  'int main() { boost::thread t; }',
			 ]),
			 use=var,
			 execute=False,
			)

	if params.get('linkage_autodetect', False):
		self.start_msg("Attempting to detect boost linkage flags")
		toolset = self.boost_get_toolset(kw.get('toolset', ''))
		if toolset in ['vc']:
			# disable auto-linking feature, causing error LNK1181
			# because the code wants to be linked against
			self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']

			# if no dlls are present, we guess the .lib files are not stubs
			has_dlls = False
			for x in Utils.listdir(path):
				if x.endswith(self.env.cxxshlib_PATTERN % ''):
					has_dlls = True
					break
			if not has_dlls:
				self.env['STLIBPATH_%s' % var] = [path]
				self.env['STLIB_%s' % var] = libs
				del self.env['LIB_%s' % var]
				del self.env['LIBPATH_%s' % var]

			# we attempt to play with some known-to-work CXXFLAGS combinations
			for cxxflags in (['/MD', '/EHsc'], []):
				self.env.stash()
				self.env["CXXFLAGS_%s" % var] += cxxflags
				try:
					try_link()
					self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
					e = None
					break
				except Errors.ConfigurationError as exc:
					self.env.revert()
					e = exc

			if e is not None:
				self.fatal("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
		else:
			self.fatal("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
	else:
		self.start_msg('Checking for boost linkage')
		try:
			try_link()
		except Errors.ConfigurationError as e:
			self.fatal("Could not link against boost libraries using supplied options")
		self.end_msg('ok')
Beispiel #26
0
def find_qt4_binaries(self):
    env = self.env
    opt = Options.options

    qtdir = getattr(opt, 'qtdir', '')
    qtbin = getattr(opt, 'qtbin', '')

    paths = []

    if qtdir:
        qtbin = os.path.join(qtdir, 'bin')

    # the qt directory has been given from QT4_ROOT - deduce the qt binary path
    if not qtdir:
        qtdir = os.environ.get('QT4_ROOT', '')
        qtbin = os.environ.get('QT4_BIN', None) or os.path.join(qtdir, 'bin')

    if qtbin:
        paths = [qtbin]

    # no qtdir, look in the path and in /usr/local/Trolltech
    if not qtdir:
        paths = os.environ.get('PATH', '').split(os.pathsep)
        paths.append('/usr/share/qt4/bin/')
        try:
            lst = Utils.listdir('/usr/local/Trolltech/')
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()

                # keep the highest version
                qtdir = '/usr/local/Trolltech/%s/' % lst[0]
                qtbin = os.path.join(qtdir, 'bin')
                paths.append(qtbin)

    # at the end, try to find qmake in the paths given
    # keep the one with the highest version
    cand = None
    prev_ver = ['4', '0', '0']
    for qmk in ('qmake-qt4', 'qmake4', 'qmake'):
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log(qmake +
                                           ['-query', 'QT_VERSION']).strip()
            except self.errors.WafError:
                pass
            else:
                if version:
                    new_ver = version.split('.')
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver
    if cand:
        self.env.QMAKE = cand
    else:
        self.fatal('Could not find qmake for qt4')

    qtbin = self.cmd_and_log(self.env.QMAKE +
                             ['-query', 'QT_INSTALL_BINS']).strip() + os.sep

    def find_bin(lst, var):
        if var in env:
            return
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(['uic-qt3', 'uic3'], 'QT_UIC3')
    find_bin(['uic-qt4', 'uic'], 'QT_UIC')
    if not env.QT_UIC:
        self.fatal('cannot find the uic compiler for qt4')

    self.start_msg('Checking for uic version')
    uicver = self.cmd_and_log(env.QT_UIC + ["-version"], output=Context.BOTH)
    uicver = ''.join(uicver).strip()
    uicver = uicver.replace('Qt User Interface Compiler ',
                            '').replace('User Interface Compiler for Qt', '')
    self.end_msg(uicver)
    if uicver.find(' 3.') != -1:
        self.fatal(
            'this uic compiler is for qt3, add uic for qt4 to your path')

    find_bin(['moc-qt4', 'moc'], 'QT_MOC')
    find_bin(['rcc-qt4', 'rcc'], 'QT_RCC')
    find_bin(['lrelease-qt4', 'lrelease'], 'QT_LRELEASE')
    find_bin(['lupdate-qt4', 'lupdate'], 'QT_LUPDATE')

    env['UIC3_ST'] = '%s -o %s'
    env['UIC_ST'] = '%s -o %s'
    env['MOC_ST'] = '-o'
    env['ui_PATTERN'] = 'ui_%s.h'
    env['QT_LRELEASE_FLAGS'] = ['-silent']
    env.MOCCPPPATH_ST = '-I%s'
    env.MOCDEFINES_ST = '-D%s'
Beispiel #27
0
def find_qt4_binaries(self):
    env = self.env
    opt = Options.options
    qtdir = getattr(opt, "qtdir", "")
    qtbin = getattr(opt, "qtbin", "")
    paths = []
    if qtdir:
        qtbin = os.path.join(qtdir, "bin")
    if not qtdir:
        qtdir = self.environ.get("QT4_ROOT", "")
        qtbin = os.path.join(qtdir, "bin")
    if qtbin:
        paths = [qtbin]
    if not qtdir:
        paths = os.environ.get("PATH", "").split(os.pathsep)
        paths.append("/usr/share/qt4/bin/")
        try:
            lst = Utils.listdir("/usr/local/Trolltech/")
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()
                qtdir = "/usr/local/Trolltech/%s/" % lst[0]
                qtbin = os.path.join(qtdir, "bin")
                paths.append(qtbin)
    cand = None
    prev_ver = ["4", "0", "0"]
    for qmk in ["qmake-qt4", "qmake4", "qmake"]:
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log([qmake, "-query", "QT_VERSION"]).strip()
            except self.errors.ConfigurationError:
                pass
            else:
                if version:
                    new_ver = version.split(".")
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver
    if cand:
        self.env.QMAKE = cand
    else:
        self.fatal("Could not find qmake for qt4")
    qtbin = self.cmd_and_log([self.env.QMAKE, "-query", "QT_INSTALL_BINS"]).strip() + os.sep

    def find_bin(lst, var):
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(["uic-qt3", "uic3"], "QT_UIC3")
    find_bin(["uic-qt4", "uic"], "QT_UIC")
    if not env["QT_UIC"]:
        self.fatal("cannot find the uic compiler for qt4")
    try:
        uicver = self.cmd_and_log(env["QT_UIC"] + " -version 2>&1").strip()
    except self.errors.ConfigurationError:
        self.fatal("this uic compiler is for qt3, add uic for qt4 to your path")
    uicver = uicver.replace("Qt User Interface Compiler ", "").replace("User Interface Compiler for Qt", "")
    self.msg("Checking for uic version", "%s" % uicver)
    if uicver.find(" 3.") != -1:
        self.fatal("this uic compiler is for qt3, add uic for qt4 to your path")
    find_bin(["moc-qt4", "moc"], "QT_MOC")
    find_bin(["rcc"], "QT_RCC")
    find_bin(["lrelease-qt4", "lrelease"], "QT_LRELEASE")
    find_bin(["lupdate-qt4", "lupdate"], "QT_LUPDATE")
    env["UIC3_ST"] = "%s -o %s"
    env["UIC_ST"] = "%s -o %s"
    env["MOC_ST"] = "-o"
    env["ui_PATTERN"] = "ui_%s.h"
    env["QT_LRELEASE_FLAGS"] = ["-silent"]
    env.MOCCPPPATH_ST = "-I%s"
    env.MOCDEFINES_ST = "-D%s"
Beispiel #28
0
 def listdir(self):
     """List the folder contents"""
     lst = Utils.listdir(self.abspath())
     lst.sort()
     return lst
Beispiel #29
0
def configure(self):
	env=self.env
	opt=Options.options
	qtdir=getattr(opt,'qtdir','')
	qtbin=getattr(opt,'qtbin','')
	qtlibs=getattr(opt,'qtlibs','')
	useframework=getattr(opt,'use_qt4_osxframework',True)
	paths=[]
	if qtdir:
		qtbin=os.path.join(qtdir,'bin')
	if not qtdir:
		qtdir=self.environ.get('QT4_ROOT','')
		qtbin=os.path.join(qtdir,'bin')
	if qtbin:
		paths=[qtbin]
	if not qtdir:
		paths=os.environ.get('PATH','').split(os.pathsep)
		paths.append('/usr/share/qt4/bin/')
		try:
			lst=Utils.listdir('/usr/local/Trolltech/')
		except OSError:
			pass
		else:
			if lst:
				lst.sort()
				lst.reverse()
				qtdir='/usr/local/Trolltech/%s/'%lst[0]
				qtbin=os.path.join(qtdir,'bin')
				paths.append(qtbin)
	cand=None
	prev_ver=['4','0','0']
	for qmk in['qmake-qt4','qmake4','qmake']:
		try:
			qmake=self.find_program(qmk,path_list=paths)
		except self.errors.ConfigurationError:
			pass
		else:
			try:
				version=self.cmd_and_log([qmake,'-query','QT_VERSION']).strip()
			except self.errors.ConfigurationError:
				pass
			else:
				if version:
					new_ver=version.split('.')
					if new_ver>prev_ver:
						cand=qmake
						prev_ver=new_ver
	if cand:
		qmake=cand
	else:
		self.fatal('could not find qmake for qt4')
	self.env.QMAKE=qmake
	qtincludes=self.cmd_and_log([qmake,'-query','QT_INSTALL_HEADERS']).strip()
	qtdir=self.cmd_and_log([qmake,'-query','QT_INSTALL_PREFIX']).strip()+os.sep
	qtbin=self.cmd_and_log([qmake,'-query','QT_INSTALL_BINS']).strip()+os.sep
	if not qtlibs:
		try:
			qtlibs=self.cmd_and_log([qmake,'-query','QT_INSTALL_LIBS']).strip()
		except Errors.WafError:
			qtlibs=os.path.join(qtdir,'lib')
	def find_bin(lst,var):
		for f in lst:
			try:
				ret=self.find_program(f,path_list=paths)
			except self.errors.ConfigurationError:
				pass
			else:
				env[var]=ret
				break
	find_bin(['uic-qt3','uic3'],'QT_UIC3')
	find_bin(['uic-qt4','uic'],'QT_UIC')
	if not env['QT_UIC']:
		self.fatal('cannot find the uic compiler for qt4')
	try:
		version=self.cmd_and_log(env['QT_UIC']+" -version 2>&1").strip()
	except self.errors.ConfigurationError:
		self.fatal('your uic compiler is for qt3, add uic for qt4 to your path')
	version=version.replace('Qt User Interface Compiler ','')
	version=version.replace('User Interface Compiler for Qt','')
	if version.find(' 3.')!=-1:
		self.msg('Checking for uic version','(%s: too old)'%version,False)
		self.fatal('uic is too old')
	self.msg('Checking for uic version','(%s)'%version)
	find_bin(['moc-qt4','moc'],'QT_MOC')
	find_bin(['rcc'],'QT_RCC')
	find_bin(['lrelease-qt4','lrelease'],'QT_LRELEASE')
	find_bin(['lupdate-qt4','lupdate'],'QT_LUPDATE')
	env['UIC3_ST']='%s -o %s'
	env['UIC_ST']='%s -o %s'
	env['MOC_ST']='-o'
	env['ui_PATTERN']='ui_%s.h'
	env['QT_LRELEASE_FLAGS']=['-silent']
	vars="QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtWebKit Qt3Support".split()
	vars_debug=[a+'_debug'for a in vars]
	if not'PKG_CONFIG_PATH'in os.environ:
		os.environ['PKG_CONFIG_PATH']='%s:%s/pkgconfig:/usr/lib/qt4/lib/pkgconfig:/opt/qt4/lib/pkgconfig:/usr/lib/qt4/lib:/opt/qt4/lib'%(qtlibs,qtlibs)
	for i in vars_debug+vars:
		try:
			self.check_cfg(package=i,args='--cflags --libs')
		except self.errors.ConfigurationError:
			pass
	def process_lib(vars_,coreval):
		for d in vars_:
			var=d.upper()
			if var=='QTCORE':
				continue
			value=env['LIBPATH_'+var]
			if value:
				core=env[coreval]
				accu=[]
				for lib in value:
					if lib in core:
						continue
					accu.append(lib)
				env['LIBPATH_'+var]=accu
	process_lib(vars,'LIBPATH_QTCORE')
	process_lib(vars_debug,'LIBPATH_QTCORE_DEBUG')
	if Options.options.want_rpath:
		def process_rpath(vars_,coreval):
			for d in vars_:
				var=d.upper()
				value=env['LIBPATH_'+var]
				if value:
					core=env[coreval]
					accu=[]
					for lib in value:
						if var!='QTCORE':
							if lib in core:
								continue
						accu.append('-Wl,--rpath='+lib)
					env['RPATH_'+var]=accu
		process_rpath(vars,'LIBPATH_QTCORE')
		process_rpath(vars_debug,'LIBPATH_QTCORE_DEBUG')
	def listdir(self):
		lst=Utils.listdir(self.abspath())
		lst.sort()
		return lst
Beispiel #31
0
def configure(self):
    env = self.env
    opt = Options.options
    qtdir = getattr(opt, 'qtdir', '')
    qtbin = getattr(opt, 'qtbin', '')
    qtlibs = getattr(opt, 'qtlibs', '')
    useframework = getattr(opt, 'use_qt4_osxframework', True)
    paths = []
    if qtdir:
        qtbin = os.path.join(qtdir, 'bin')
    if not qtdir:
        qtdir = self.environ.get('QT4_ROOT', '')
        qtbin = os.path.join(qtdir, 'bin')
    if qtbin:
        paths = [qtbin]
    if not qtdir:
        paths = os.environ.get('PATH', '').split(os.pathsep)
        paths.append('/usr/share/qt4/bin/')
        try:
            lst = Utils.listdir('/usr/local/Trolltech/')
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()
                qtdir = '/usr/local/Trolltech/%s/' % lst[0]
                qtbin = os.path.join(qtdir, 'bin')
                paths.append(qtbin)
    cand = None
    prev_ver = ['4', '0', '0']
    for qmk in ['qmake-qt4', 'qmake4', 'qmake']:
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log([qmake, '-query',
                                            'QT_VERSION']).strip()
            except self.errors.ConfigurationError:
                pass
            else:
                if version:
                    new_ver = version.split('.')
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver
    if cand:
        qmake = cand
    else:
        self.fatal('could not find qmake for qt4')
    self.env.QMAKE = qmake
    qtincludes = self.cmd_and_log([qmake, '-query',
                                   'QT_INSTALL_HEADERS']).strip()
    qtdir = self.cmd_and_log([qmake, '-query', 'QT_INSTALL_PREFIX'
                              ]).strip() + os.sep
    qtbin = self.cmd_and_log([qmake, '-query', 'QT_INSTALL_BINS'
                              ]).strip() + os.sep
    if not qtlibs:
        try:
            qtlibs = self.cmd_and_log([qmake, '-query',
                                       'QT_INSTALL_LIBS']).strip()
        except Errors.WafError:
            qtlibs = os.path.join(qtdir, 'lib')

    def find_bin(lst, var):
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(['uic-qt3', 'uic3'], 'QT_UIC3')
    find_bin(['uic-qt4', 'uic'], 'QT_UIC')
    if not env['QT_UIC']:
        self.fatal('cannot find the uic compiler for qt4')
    try:
        version = self.cmd_and_log(env['QT_UIC'] + " -version 2>&1").strip()
    except self.errors.ConfigurationError:
        self.fatal(
            'your uic compiler is for qt3, add uic for qt4 to your path')
    version = version.replace('Qt User Interface Compiler ', '')
    version = version.replace('User Interface Compiler for Qt', '')
    if version.find(' 3.') != -1:
        self.msg('Checking for uic version', '(%s: too old)' % version, False)
        self.fatal('uic is too old')
    self.msg('Checking for uic version', '(%s)' % version)
    find_bin(['moc-qt4', 'moc'], 'QT_MOC')
    find_bin(['rcc'], 'QT_RCC')
    find_bin(['lrelease-qt4', 'lrelease'], 'QT_LRELEASE')
    find_bin(['lupdate-qt4', 'lupdate'], 'QT_LUPDATE')
    env['UIC3_ST'] = '%s -o %s'
    env['UIC_ST'] = '%s -o %s'
    env['MOC_ST'] = '-o'
    env['ui_PATTERN'] = 'ui_%s.h'
    env['QT_LRELEASE_FLAGS'] = ['-silent']
    vars = "QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtWebKit Qt3Support".split(
    )
    vars_debug = [a + '_debug' for a in vars]
    if not 'PKG_CONFIG_PATH' in os.environ:
        os.environ[
            'PKG_CONFIG_PATH'] = '%s:%s/pkgconfig:/usr/lib/qt4/lib/pkgconfig:/opt/qt4/lib/pkgconfig:/usr/lib/qt4/lib:/opt/qt4/lib' % (
                qtlibs, qtlibs)
    for i in vars_debug + vars:
        try:
            self.check_cfg(package=i, args='--cflags --libs')
        except self.errors.ConfigurationError:
            pass

    def process_lib(vars_, coreval):
        for d in vars_:
            var = d.upper()
            if var == 'QTCORE':
                continue
            value = env['LIBPATH_' + var]
            if value:
                core = env[coreval]
                accu = []
                for lib in value:
                    if lib in core:
                        continue
                    accu.append(lib)
                env['LIBPATH_' + var] = accu

    process_lib(vars, 'LIBPATH_QTCORE')
    process_lib(vars_debug, 'LIBPATH_QTCORE_DEBUG')
    if Options.options.want_rpath:

        def process_rpath(vars_, coreval):
            for d in vars_:
                var = d.upper()
                value = env['LIBPATH_' + var]
                if value:
                    core = env[coreval]
                    accu = []
                    for lib in value:
                        if var != 'QTCORE':
                            if lib in core:
                                continue
                        accu.append('-Wl,--rpath=' + lib)
                    env['RPATH_' + var] = accu

        process_rpath(vars, 'LIBPATH_QTCORE')
        process_rpath(vars_debug, 'LIBPATH_QTCORE_DEBUG')
Beispiel #32
0
def find_qt5_binaries(self):
    env = self.env
    opt = Options.options
    qtdir = getattr(opt, "qtdir", "")
    qtbin = getattr(opt, "qtbin", "")
    paths = []
    if qtdir:
        qtbin = os.path.join(qtdir, "bin")
    if not qtdir:
        qtdir = os.environ.get("QT5_ROOT", "")
        qtbin = os.environ.get("QT5_BIN", None) or os.path.join(qtdir, "bin")
    if qtbin:
        paths = [qtbin]
    if not qtdir:
        paths = os.environ.get("PATH", "").split(os.pathsep)
        paths.append("/usr/share/qt5/bin/")
        try:
            lst = Utils.listdir("/usr/local/Trolltech/")
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()
                qtdir = "/usr/local/Trolltech/%s/" % lst[0]
                qtbin = os.path.join(qtdir, "bin")
                paths.append(qtbin)
    cand = None
    prev_ver = ["5", "0", "0"]
    for qmk in ("qmake-qt5", "qmake5", "qmake"):
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log(qmake + ["-query", "QT_VERSION"]).strip()
            except self.errors.WafError:
                pass
            else:
                if version:
                    new_ver = version.split(".")
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver
    if not cand:
        try:
            self.find_program("qtchooser")
        except self.errors.ConfigurationError:
            pass
        else:
            cmd = self.env.QTCHOOSER + ["-qt=5", "-run-tool=qmake"]
            try:
                version = self.cmd_and_log(cmd + ["-query", "QT_VERSION"])
            except self.errors.WafError:
                pass
            else:
                cand = cmd
    if cand:
        self.env.QMAKE = cand
    else:
        self.fatal("Could not find qmake for qt5")
    self.env.QT_INSTALL_BINS = qtbin = self.cmd_and_log(self.env.QMAKE + ["-query", "QT_INSTALL_BINS"]).strip() + os.sep
    paths.insert(0, qtbin)

    def find_bin(lst, var):
        if var in env:
            return
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(["uic-qt5", "uic"], "QT_UIC")
    if not env.QT_UIC:
        self.fatal("cannot find the uic compiler for qt5")
    self.start_msg("Checking for uic version")
    uicver = self.cmd_and_log(env.QT_UIC + ["-version"], output=Context.BOTH)
    uicver = "".join(uicver).strip()
    uicver = uicver.replace("Qt User Interface Compiler ", "").replace("User Interface Compiler for Qt", "")
    self.end_msg(uicver)
    if uicver.find(" 3.") != -1 or uicver.find(" 4.") != -1:
        self.fatal("this uic compiler is for qt3 or qt5, add uic for qt5 to your path")
    find_bin(["moc-qt5", "moc"], "QT_MOC")
    find_bin(["rcc-qt5", "rcc"], "QT_RCC")
    find_bin(["lrelease-qt5", "lrelease"], "QT_LRELEASE")
    find_bin(["lupdate-qt5", "lupdate"], "QT_LUPDATE")
    env["UIC_ST"] = "%s -o %s"
    env["MOC_ST"] = "-o"
    env["ui_PATTERN"] = "ui_%s.h"
    env["QT_LRELEASE_FLAGS"] = ["-silent"]
    env.MOCCPPPATH_ST = "-I%s"
    env.MOCDEFINES_ST = "-D%s"
Beispiel #33
0
	def listdir(self):
		return Utils.listdir(self.abspath())
Beispiel #34
0
Datei: qt5.py Projekt: sm02/samba
def find_qt5_binaries(self):
    """
	Detects Qt programs such as qmake, moc, uic, lrelease
	"""
    env = self.env
    opt = Options.options

    qtdir = getattr(opt, 'qtdir', '')
    qtbin = getattr(opt, 'qtbin', '')

    paths = []

    if qtdir:
        qtbin = os.path.join(qtdir, 'bin')

    # the qt directory has been given from QT5_ROOT - deduce the qt binary path
    if not qtdir:
        qtdir = self.environ.get('QT5_ROOT', '')
        qtbin = self.environ.get('QT5_BIN') or os.path.join(qtdir, 'bin')

    if qtbin:
        paths = [qtbin]

    # no qtdir, look in the path and in /usr/local/Trolltech
    if not qtdir:
        paths = self.environ.get('PATH', '').split(os.pathsep)
        paths.extend(['/usr/share/qt5/bin', '/usr/local/lib/qt5/bin'])
        try:
            lst = Utils.listdir('/usr/local/Trolltech/')
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()

                # keep the highest version
                qtdir = '/usr/local/Trolltech/%s/' % lst[0]
                qtbin = os.path.join(qtdir, 'bin')
                paths.append(qtbin)

    # at the end, try to find qmake in the paths given
    # keep the one with the highest version
    cand = None
    prev_ver = ['5', '0', '0']
    for qmk in ('qmake-qt5', 'qmake5', 'qmake'):
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log(qmake +
                                           ['-query', 'QT_VERSION']).strip()
            except self.errors.WafError:
                pass
            else:
                if version:
                    new_ver = version.split('.')
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver

    # qmake could not be found easily, rely on qtchooser
    if not cand:
        try:
            self.find_program('qtchooser')
        except self.errors.ConfigurationError:
            pass
        else:
            cmd = self.env.QTCHOOSER + ['-qt=5', '-run-tool=qmake']
            try:
                version = self.cmd_and_log(cmd + ['-query', 'QT_VERSION'])
            except self.errors.WafError:
                pass
            else:
                cand = cmd

    if cand:
        self.env.QMAKE = cand
    else:
        self.fatal('Could not find qmake for qt5')

    self.env.QT_HOST_BINS = qtbin = self.cmd_and_log(
        self.env.QMAKE + ['-query', 'QT_HOST_BINS']).strip()
    paths.insert(0, qtbin)

    def find_bin(lst, var):
        if var in env:
            return
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(['uic-qt5', 'uic'], 'QT_UIC')
    if not env.QT_UIC:
        self.fatal('cannot find the uic compiler for qt5')

    self.start_msg('Checking for uic version')
    uicver = self.cmd_and_log(env.QT_UIC + ['-version'], output=Context.BOTH)
    uicver = ''.join(uicver).strip()
    uicver = uicver.replace('Qt User Interface Compiler ',
                            '').replace('User Interface Compiler for Qt', '')
    self.end_msg(uicver)
    if uicver.find(' 3.') != -1 or uicver.find(' 4.') != -1:
        self.fatal(
            'this uic compiler is for qt3 or qt4, add uic for qt5 to your path'
        )

    find_bin(['moc-qt5', 'moc'], 'QT_MOC')
    find_bin(['rcc-qt5', 'rcc'], 'QT_RCC')
    find_bin(['lrelease-qt5', 'lrelease'], 'QT_LRELEASE')
    find_bin(['lupdate-qt5', 'lupdate'], 'QT_LUPDATE')

    env.UIC_ST = '%s -o %s'
    env.MOC_ST = '-o'
    env.ui_PATTERN = 'ui_%s.h'
    env.QT_LRELEASE_FLAGS = ['-silent']
    env.MOCCPPPATH_ST = '-I%s'
    env.MOCDEFINES_ST = '-D%s'
Beispiel #35
0
	def listdir(self):
		"list the directory contents"
		return Utils.listdir(self.abspath())
Beispiel #36
0
 def listdir(self):
     """List the folder contents"""
     return Utils.listdir(self.abspath())
Beispiel #37
0
def check_boost(self, *k, **kw):
	"""
	Initialize boost libraries to be used.

	Keywords: you can pass the same parameters as with the command line (without "--boost-").
	Note that the command line has the priority, and should preferably be used.
	"""
	if not self.env['CXX']:
		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')

	params = {'lib': k and k[0] or kw.get('lib', None)}
	for key, value in self.options.__dict__.items():
		if not key.startswith('boost_'):
			continue
		key = key[len('boost_'):]
		params[key] = value and value or kw.get(key, '')

	var = kw.get('uselib_store', 'BOOST')

	self.start_msg('Checking boost includes')
	try:
		self.env['INCLUDES_%s' % var] = self.boost_get_includes(**params)
		self.env.BOOST_VERSION = self.boost_get_version(self.env['INCLUDES_%s' % var])
	except WafError:
		self.end_msg("not found", 'YELLOW')
		raise
	#self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
	#self.env.BOOST_VERSION = self.boost_get_version(inc)
	self.end_msg(self.env.BOOST_VERSION)
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])

	if not params['lib']:
		return
	self.start_msg('Checking boost libs')
	try:
		suffix = params.get('static', 'ST') or ''
		path, libs = self.boost_get_libs(**params)
	except WafError:
		self.end_msg("not found", 'YELLOW')
		raise
	#suffix = params.get('static', None) and 'ST' or ''
	#path, libs = self.boost_get_libs(**params)
	self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
	self.env['%sLIB_%s' % (suffix, var)] = libs
	self.end_msg('ok')
	if Logs.verbose:
		Logs.pprint('CYAN', '	path : %s' % path)
		Logs.pprint('CYAN', '	libs : %s' % libs)


	def try_link():
		if 'system' in params['lib']:
			self.check_cxx(
			 fragment="\n".join([
			  '#include <boost/system/error_code.hpp>',
			  'int main() { boost::system::error_code c; }',
			 ]),
			 use=var,
			 execute=False,
			)
		if 'thread' in params['lib']:
			self.check_cxx(
			 fragment="\n".join([
			  '#include <boost/thread.hpp>',
			  'int main() { boost::thread t; }',
			 ]),
			 use=var,
			 execute=False,
			)

	if params.get('linkage_autodetect', False):
		self.start_msg("Attempting to detect boost linkage flags")
		toolset = self.boost_get_toolset(kw.get('toolset', ''))
		if toolset in ['vc']:
			# disable auto-linking feature, causing error LNK1181
			# because the code wants to be linked against
			self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']

			# if no dlls are present, we guess the .lib files are not stubs
			has_dlls = False
			for x in Utils.listdir(path):
				if x.endswith(self.env.cxxshlib_PATTERN % ''):
					has_dlls = True
					break
			if not has_dlls:
				self.env['STLIBPATH_%s' % var] = [path]
				self.env['STLIB_%s' % var] = libs
				del self.env['LIB_%s' % var]
				del self.env['LIBPATH_%s' % var]

			# we attempt to play with some known-to-work CXXFLAGS combinations
			for cxxflags in (['/MD', '/EHsc'], []):
				self.env.stash()
				self.env["CXXFLAGS_%s" % var] += cxxflags
				try:
					try_link()
					self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
					e = None
					break
				except Errors.ConfigurationError, exc:
					self.env.revert()
					e = exc

			if e is not None:
				self.fatal("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
		else:
			self.fatal("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
Beispiel #38
0
def check_boost(self, *k, **kw):
    """
	Initialize boost libraries to be used.

	Keywords: you can pass the same parameters as with the command line (without "--boost-").
	Note that the command line has the priority, and should preferably be used.
	"""
    if not self.env['CXX']:
        self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')

    params = {
        'lib': k and k[0] or kw.get('lib', None),
        'stlib': kw.get('stlib', None)
    }
    for key, value in self.options.__dict__.items():
        if not key.startswith('boost_'):
            continue
        key = key[len('boost_'):]
        params[key] = value and value or kw.get(key, '')

    var = kw.get('uselib_store', 'BOOST')

    self.find_program('dpkg-architecture',
                      var='DPKG_ARCHITECTURE',
                      mandatory=False)
    if self.env.DPKG_ARCHITECTURE:
        deb_host_multiarch = self.cmd_and_log(
            [self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
        BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())

    self.start_msg('Checking boost includes')
    self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
    versions = self.boost_get_version(inc)
    self.env.BOOST_VERSION = versions[0]
    self.env.BOOST_VERSION_NUMBER = int(versions[1])
    self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000, int(versions[1]) /
                               100 % 1000, int(versions[1]) % 100))
    if Logs.verbose:
        Logs.pprint('CYAN', '	path : %s' % self.env['INCLUDES_%s' % var])

    if not params['lib'] and not params['stlib']:
        return
    if 'static' in kw or 'static' in params:
        Logs.warn('boost: static parameter is deprecated, use stlib instead.')
    self.start_msg('Checking boost libs')
    path, libs, stlibs = self.boost_get_libs(**params)
    self.env['LIBPATH_%s' % var] = [path]
    self.env['STLIBPATH_%s' % var] = [path]
    self.env['LIB_%s' % var] = libs
    self.env['STLIB_%s' % var] = stlibs
    self.end_msg('ok')
    if Logs.verbose:
        Logs.pprint('CYAN', '	path : %s' % path)
        Logs.pprint('CYAN', '	shared libs : %s' % libs)
        Logs.pprint('CYAN', '	static libs : %s' % stlibs)

    def has_shlib(lib):
        return params['lib'] and lib in params['lib']

    def has_stlib(lib):
        return params['stlib'] and lib in params['stlib']

    def has_lib(lib):
        return has_shlib(lib) or has_stlib(lib)

    if has_lib('thread'):
        # not inside try_link to make check visible in the output
        self._check_pthread_flag(k, kw)

    def try_link():
        if has_lib('system'):
            self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
        if has_lib('thread'):
            self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
        if has_lib('log'):
            if not has_lib('thread'):
                self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
            if has_shlib('log'):
                self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
            self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)

    if params.get('linkage_autodetect', False):
        self.start_msg("Attempting to detect boost linkage flags")
        toolset = self.boost_get_toolset(kw.get('toolset', ''))
        if toolset in ('vc', ):
            # disable auto-linking feature, causing error LNK1181
            # because the code wants to be linked against
            self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']

            # if no dlls are present, we guess the .lib files are not stubs
            has_dlls = False
            for x in Utils.listdir(path):
                if x.endswith(self.env.cxxshlib_PATTERN % ''):
                    has_dlls = True
                    break
            if not has_dlls:
                self.env['STLIBPATH_%s' % var] = [path]
                self.env['STLIB_%s' % var] = libs
                del self.env['LIB_%s' % var]
                del self.env['LIBPATH_%s' % var]

            # we attempt to play with some known-to-work CXXFLAGS combinations
            for cxxflags in (['/MD', '/EHsc'], []):
                self.env.stash()
                self.env["CXXFLAGS_%s" % var] += cxxflags
                try:
                    try_link()
                    self.end_msg("ok: winning cxxflags combination: %s" %
                                 (self.env["CXXFLAGS_%s" % var]))
                    exc = None
                    break
                except Errors.ConfigurationError as e:
                    self.env.revert()
                    exc = e

            if exc is not None:
                self.end_msg(
                    "Could not auto-detect boost linking flags combination, you may report it to boost.py author",
                    ex=exc)
                self.fatal('The configuration failed')
        else:
            self.end_msg(
                "Boost linkage flags auto-detection not implemented (needed ?) for this toolchain"
            )
            self.fatal('The configuration failed')
    else:
        self.start_msg('Checking for boost linkage')
        try:
            try_link()
        except Errors.ConfigurationError as e:
            self.end_msg(
                "Could not link against boost libraries using supplied options"
            )
            self.fatal('The configuration failed')
        self.end_msg('ok')
Beispiel #39
0
def find_qt4_binaries(self):
    env = self.env
    opt = Options.options
    qtdir = getattr(opt, 'qtdir', '')
    qtbin = getattr(opt, 'qtbin', '')
    paths = []
    if qtdir:
        qtbin = os.path.join(qtdir, 'bin')
    if not qtdir:
        qtdir = self.environ.get('QT4_ROOT', '')
        qtbin = os.path.join(qtdir, 'bin')
    if qtbin:
        paths = [qtbin]
    if not qtdir:
        paths = os.environ.get('PATH', '').split(os.pathsep)
        paths.append('/usr/share/qt4/bin/')
        try:
            lst = Utils.listdir('/usr/local/Trolltech/')
        except OSError:
            pass
        else:
            if lst:
                lst.sort()
                lst.reverse()
                qtdir = '/usr/local/Trolltech/%s/' % lst[0]
                qtbin = os.path.join(qtdir, 'bin')
                paths.append(qtbin)
    cand = None
    prev_ver = ['4', '0', '0']
    for qmk in ['qmake-qt4', 'qmake4', 'qmake']:
        try:
            qmake = self.find_program(qmk, path_list=paths)
        except self.errors.ConfigurationError:
            pass
        else:
            try:
                version = self.cmd_and_log([qmake, '-query',
                                            'QT_VERSION']).strip()
            except self.errors.ConfigurationError:
                pass
            else:
                if version:
                    new_ver = version.split('.')
                    if new_ver > prev_ver:
                        cand = qmake
                        prev_ver = new_ver
    if cand:
        self.env.QMAKE = cand
    else:
        self.fatal('Could not find qmake for qt4')
    qtbin = self.cmd_and_log([self.env.QMAKE, '-query', 'QT_INSTALL_BINS'
                              ]).strip() + os.sep

    def find_bin(lst, var):
        for f in lst:
            try:
                ret = self.find_program(f, path_list=paths)
            except self.errors.ConfigurationError:
                pass
            else:
                env[var] = ret
                break

    find_bin(['uic-qt3', 'uic3'], 'QT_UIC3')
    find_bin(['uic-qt4', 'uic'], 'QT_UIC')
    if not env['QT_UIC']:
        self.fatal('cannot find the uic compiler for qt4')
    try:
        uicver = self.cmd_and_log(env['QT_UIC'] + " -version 2>&1").strip()
    except self.errors.ConfigurationError:
        self.fatal(
            'this uic compiler is for qt3, add uic for qt4 to your path')
    uicver = uicver.replace('Qt User Interface Compiler ',
                            '').replace('User Interface Compiler for Qt', '')
    self.msg('Checking for uic version', '%s' % uicver)
    if uicver.find(' 3.') != -1:
        self.fatal(
            'this uic compiler is for qt3, add uic for qt4 to your path')
    find_bin(['moc-qt4', 'moc'], 'QT_MOC')
    find_bin(['rcc'], 'QT_RCC')
    find_bin(['lrelease-qt4', 'lrelease'], 'QT_LRELEASE')
    find_bin(['lupdate-qt4', 'lupdate'], 'QT_LUPDATE')
    env['UIC3_ST'] = '%s -o %s'
    env['UIC_ST'] = '%s -o %s'
    env['MOC_ST'] = '-o'
    env['ui_PATTERN'] = 'ui_%s.h'
    env['QT_LRELEASE_FLAGS'] = ['-silent']
    env.MOCCPPPATH_ST = '-I%s'
    env.MOCDEFINES_ST = '-D%s'
Beispiel #40
0
 def listdir(self):
     lst = Utils.listdir(self.abspath())
     lst.sort()
     return lst
Beispiel #41
0
    def run(self):
        env = self.env
        gen = self.generator
        bld = gen.bld
        zpy = bld.zpy
        out = self.outputs[0].parent

        dist = self.dist
        signode = self.signode

        out_path = out.abspath()
        bld_path = bld.bldnode.abspath()
        source_url = dist.source_url or ''
        url = urlparse.urlsplit(source_url)
        # normalize initially to dist.key
        name = pth.basename(url.path).lower() or dist.key
        # ensure sdist filename matches dist.name!
        # otherwise dist.name != dist.metadata.name if the object was created
        # from a filename, even if metadata is loaded later!
        #FIXME: upstream fix to above...
        name = name.replace(dist.key, dist.name, 1)
        if dist.name not in name:
            # probably a hash
            ext = name[name.find('.'):]
            if len(ext) > 1:
                name = dist.metadata.name_and_version + ext
        # no raison other than consistency
        if name.endswith('.tgz'):
            name = name[:-4] + '.tar.gz'
        path = pth.join(zpy.top_xsrc, name)
        meta = path + '.' + metadata.METADATA_FILENAME
        meta_alt = pth.join(url.path, metadata.METADATA_FILENAME)
        meta_out = pth.join(out_path, metadata.METADATA_FILENAME)

        if url.scheme and url.path and url.path != path:
            path, message = urllib.urlretrieve(url.geturl(), path)

        if url.path and pth.isdir(url.path):
            try:
                git_dir = subprocess.check_output(
                    ['git', 'rev-parse', '--show-toplevel'], cwd=url.path,
                    ).strip()
                # avoid checking out the wrong repo due to nesting; ie. don't
                # checkout someone's dotfile repo just because they happen to
                # technically be "under" it
                if pth.abspath(git_dir) == pth.abspath(url.path):
                    git_dir = subprocess.check_output(
                        args=['git', 'rev-parse', '--git-dir'], cwd=url.path,
                        )
                    git_dir = pth.join(url.path, git_dir.strip())
                else:
                    git_dir = None
            except subprocess.CalledProcessError:
                git_dir = None
            if git_dir:
                if not pth.exists(out_path):
                    os.mkdir(out_path)
                subprocess.call([
                    'git',
                        '--git-dir={0}'.format(git_dir),
                        '--work-tree={0}'.format(out_path),
                            'checkout-index',
                                '--all',
                                '--quiet',
                                '--force',
                                ])
                if pth.exists(meta):
                    shutil.copy2(meta, meta_out)
                elif pth.exists(meta_alt):
                    shutil.copy2(meta_alt, meta_out)
            else:
                # symlink local dist checkout
                local_path = pth.join(zpy.top, url.path)
                local_path = pth.abspath(local_path)
                local_sym = pth.relpath(local_path, bld_path)
                try:
                    # clear broken symlinks
                    os.unlink(out_path)
                except OSError:
                    pass
                finally:
                    os.symlink(local_sym, out_path)
        elif pth.isfile(path):
            _zip = ('.zip',)
            _whl = ('.whl',)
            _tar = tuple(
                set(distlib.util.ARCHIVE_EXTENSIONS) - set(_zip + _whl)
                )
            if path.endswith(_whl):
                dist.metadata = wheel.Wheel(path).metadata
                dist_dir = pth.join(out_path, 'dist')
                Utils.check_dir(dist_dir)
                self.outputs[0].write(
                    json.dumps(
                        dist.metadata.dictionary,
                        ensure_ascii=True,
                        sort_keys=True,
                        indent=2,
                        ))
                whl_dst = pth.join(dist_dir, pth.basename(path))
                whl_sym = pth.relpath(path, dist_dir)
                if not pth.exists(whl_dst):
                    os.symlink(whl_sym, whl_dst)
            else:
                if pth.isfile(meta):
                    #TODO: needs to use zpy.dist
                    dist.metadata = metadata.Metadata(path=meta)
                else:
                    pydist = normalize_pydist(dist.metadata.dictionary)
                    pydist.update(source_url=pth.relpath(path, zpy.top))

                    with codecs.open(meta, 'w', 'utf-8') as fp:
                        json.dump(
                            pydist,
                            fp=fp,
                            ensure_ascii=True,
                            sort_keys=True,
                            indent=2,
                            )

                    dist.metadata._legacy = None
                    dist.metadata._data = pydist

                sig_path = signode.abspath()
                for sfx, cmd in (
                    (_tar, '{env.TAR}\0-C\0{sig_path}\0-xf\0{path}\0'),
                    (_zip, '{env.UNZIP}\0-q\0-o\0-d\0{sig_path}\0{path}\0'),
                    (None, None),
                    ):
                    if sfx is None:
                        distlib.util.unarchive(path, bld_path)
                        break

                    try:
                        cmd = cmd.format(**locals())
                        cmd = cmd.strip('\0').split('\0')
                    except AttributeError:
                        continue

                    rc = self.exec_command(cmd, env=env.env)
                    if rc == 0:
                        if not pth.exists(out_path):
                            tmp = signode.make_node(
                                Utils.listdir(signode.abspath())
                                )
                            os.rename(tmp.abspath(), out_path)
                        break
                shutil.copy2(meta, pth.join(out_path, metadata.METADATA_FILENAME))

        if dist.key == 'python':
            lib = pth.join(out_path, 'Lib')
            zippy_src = pth.join(zpy.top, 'zippy')
            zippy_dst = pth.join(lib, 'zippy')
            zippy_sym = pth.relpath(zippy_src, lib)
            if not pth.lexists(zippy_dst):
                os.symlink(zippy_sym, zippy_dst)
            incl_src = pth.join(out_path, 'Include')
            incl_dst = pth.join(zpy.o_inc, 'python'+dist.version[0:3])
            incl_sym = pth.relpath(incl_src, zpy.o_inc)
            if not pth.lexists(incl_dst):
                os.symlink(incl_sym, incl_dst)
            pyconfig = pth.join(out_path, 'Include', 'pyconfig.h')
            if not pth.lexists(pyconfig):
                os.symlink('../pyconfig.h', pyconfig)

        return 0