Example #1
0
def scan(task):
	"""
	Get the dependencies using a c/c++ preprocessor, this is required for finding dependencies of the kind::

		#include some_macro()

	This function is bound as a task method on :py:class:`waflib.Tools.c.c` and :py:class:`waflib.Tools.cxx.cxx` for example
	"""

	global go_absolute

	try:
		incn = task.generator.includes_nodes
	except AttributeError:
		raise Errors.WafError('%r is missing a feature such as "c", "cxx" or "includes": ' % task.generator)

	if go_absolute:
		nodepaths = incn + [task.generator.bld.root.find_dir(x) for x in standard_includes]
	else:
		nodepaths = [x for x in incn if x.is_child_of(x.ctx.srcnode) or x.is_child_of(x.ctx.bldnode)]

	tmp = c_parser(nodepaths)
	tmp.start(task.inputs[0], task.env)
	if Logs.verbose:
		debug('deps: deps for %r: %r; unresolved %r' % (task.inputs, tmp.nodes, tmp.names))
	return (tmp.nodes, tmp.names)
Example #2
0
def configure(conf):
    try:
        test_for_compiler = conf.options.check_c_compiler or default_compilers(
        )
    except AttributeError:
        conf.fatal("Add options(opt): opt.load('compiler_c')")
    for compiler in re.split('[ ,]+', test_for_compiler):
        conf.env.stash()
        conf.start_msg('Checking for %r (C compiler)' % compiler)
        try:
            conf.load(compiler)
        except conf.errors.ConfigurationError as e:
            conf.env.revert()
            conf.end_msg(False)
            debug('compiler_c: %r', e)
        else:
            if conf.env.CC:
                conf.end_msg(conf.env.get_flat('CC'))
                conf.env.COMPILER_CC = compiler
                conf.env.commit()
                break
            conf.env.revert()
            conf.end_msg(False)
    else:
        conf.fatal('could not configure a C compiler!')
Example #3
0
File: msvc.py Project: RONNCC/pysoy
def libname_msvc(self,libname,is_static=False):
	lib=libname.lower()
	lib=re.sub('\.lib$','',lib)
	if lib in g_msvc_systemlibs:
		return lib
	lib=re.sub('^lib','',lib)
	if lib=='m':
		return None
	(lt_path,lt_libname,lt_static)=self.find_lt_names_msvc(lib,is_static)
	if lt_path!=None and lt_libname!=None:
		if lt_static==True:
			return os.path.join(lt_path,lt_libname)
	if lt_path!=None:
		_libpaths=[lt_path]+self.env['LIBPATH']
	else:
		_libpaths=self.env['LIBPATH']
	static_libs=['lib%ss.lib'%lib,'lib%s.lib'%lib,'%ss.lib'%lib,'%s.lib'%lib,]
	dynamic_libs=['lib%s.dll.lib'%lib,'lib%s.dll.a'%lib,'%s.dll.lib'%lib,'%s.dll.a'%lib,'lib%s_d.lib'%lib,'%s_d.lib'%lib,'%s.lib'%lib,]
	libnames=static_libs
	if not is_static:
		libnames=dynamic_libs+static_libs
	for path in _libpaths:
		for libn in libnames:
			if os.path.exists(os.path.join(path,libn)):
				debug('msvc: lib found: %s'%os.path.join(path,libn))
				return re.sub('\.lib$','',libn)
	self.fatal("The library %r could not be found"%libname)
	return re.sub('\.lib$','',libname)
Example #4
0
File: msvc.py Project: RONNCC/pysoy
def exec_mf(self):
	env=self.env
	mtool=env['MT']
	if not mtool:
		return 0
	self.do_manifest=False
	outfile=self.outputs[0].abspath()
	manifest=None
	for out_node in self.outputs:
		if out_node.name.endswith('.manifest'):
			manifest=out_node.abspath()
			break
	if manifest is None:
		return 0
	mode=''
	if'cprogram'in self.generator.features or'cxxprogram'in self.generator.features:
		mode='1'
	elif'cshlib'in self.generator.features or'cxxshlib'in self.generator.features:
		mode='2'
	debug('msvc: embedding manifest in mode %r'%mode)
	lst=[]
	lst.append(env['MT'])
	lst.extend(Utils.to_list(env['MTFLAGS']))
	lst.extend(['-manifest',manifest])
	lst.append('-outputresource:%s;%s'%(outfile,mode))
	lst=[lst]
	return self.exec_command(*lst)
Example #5
0
	def run(self):
		env = self.env
		gen = self.generator
		path = gen.path
		bld = gen.bld
		bjam = gen.bld.root.find_dir(env.BJAM_SRC)
		if not bjam:
			error('Can not find bjam source')
			return -1
		bjam_exe_relpath = 'bin.' + env.BJAM_UNAME + '/bjam'
		bjam_exe = bjam.find_resource(bjam_exe_relpath)
		if bjam_exe:
			env.BJAM = bjam_exe.srcpath()
			return 0
		bjam_cmd = ['./build.sh']
		debug('runner: ' + bjam.srcpath() + '> ' + str(bjam_cmd))
		result = self.exec_command(bjam_cmd, cwd=bjam.srcpath())
		if not result == 0:
			error('bjam failed')
			return -1
		bjam_exe = bjam.find_resource(bjam_exe_relpath)
		if bjam_exe:
			env.BJAM = bjam_exe.srcpath()
			return 0
		error('bjam failed')
		return -1
Example #6
0
File: tex.py Project: sky4D/mavsim
	def scan(self):
		node=self.inputs[0]
		env=self.env
		nodes=[]
		names=[]
		seen=[]
		if not node:return(nodes,names)
		def parse_node(node):
			if node in seen:
				return
			seen.append(node)
			code=node.read()
			global re_tex
			for match in re_tex.finditer(code):
				path=match.group('file')
				if path:
					add_name=True
					found=None
					for k in exts_deps_tex:
						debug('tex: trying %s%s'%(path,k))
						found=node.parent.find_resource(path+k)
						if found and not found in self.outputs:
							nodes.append(found)
							add_name=False
							if found.name.endswith('.tex')or found.name.endswith('.ltx'):
								parse_node(found)
					if add_name:
						names.append(path)
		parse_node(node)
		for x in nodes:
			x.parent.get_bld().mkdir()
		debug("tex: found the following : %s and names %s"%(nodes,names))
		return(nodes,names)
Example #7
0
def scan(task):
    """
	Get the dependencies using a c/c++ preprocessor, this is required for finding dependencies of the kind::

		#include some_macro()

	This function is bound as a task method on :py:class:`waflib.Tools.c.c` and :py:class:`waflib.Tools.cxx.cxx` for example
	"""

    global go_absolute

    try:
        incn = task.generator.includes_nodes
    except AttributeError:
        raise Errors.WafError(
            '%r is missing a feature such as "c", "cxx" or "includes": ' %
            task.generator)

    if go_absolute:
        nodepaths = incn + [
            task.generator.bld.root.find_dir(x) for x in standard_includes
        ]
    else:
        nodepaths = [
            x for x in incn
            if x.is_child_of(x.ctx.srcnode) or x.is_child_of(x.ctx.bldnode)
        ]

    tmp = c_parser(nodepaths)
    tmp.start(task.inputs[0], task.env)
    if Logs.verbose:
        debug('deps: deps for %r: %r; unresolved %r' %
              (task.inputs, tmp.nodes, tmp.names))
    return (tmp.nodes, tmp.names)
Example #8
0
 def addlines(self, node):
     self.currentnode_stack.append(node.parent)
     filepath = node.abspath()
     self.count_files += 1
     if self.count_files > recursion_limit:
         raise PreprocError("recursion limit exceeded")
     pc = self.parse_cache
     debug('preproc: reading file %r', filepath)
     try:
         lns = pc[filepath]
     except KeyError:
         pass
     else:
         self.lines.extend(lns)
         return
     try:
         lines = filter_comments(filepath)
         lines.append((POPFILE, ''))
         lines.reverse()
         pc[filepath] = lines
         self.lines.extend(lines)
     except IOError:
         raise PreprocError("could not read the file %s" % filepath)
     except Exception:
         if Logs.verbose > 0:
             error("parsing %s failed" % filepath)
             traceback.print_exc()
Example #9
0
def configure(conf):
	"""
	Detects a suitable C compiler

	:raises: :py:class:`waflib.Errors.ConfigurationError` when no suitable compiler is found
	"""
	try:
		test_for_compiler = conf.options.check_c_compiler or default_compilers()
	except AttributeError:
		conf.fatal("Add options(opt): opt.load('compiler_c')")

	for compiler in re.split('[ ,]+', test_for_compiler):
		conf.env.stash()
		conf.start_msg('Checking for %r (C compiler)' % compiler)
		try:
			conf.load(compiler)
		except conf.errors.ConfigurationError as e:
			conf.env.revert()
			conf.end_msg(False)
			debug('compiler_c: %r', e)
		else:
			if conf.env.CC:
				conf.end_msg(conf.env.get_flat('CC'))
				conf.env.COMPILER_CC = compiler
				conf.env.commit()
				break
			conf.env.revert()
			conf.end_msg(False)
	else:
		conf.fatal('could not configure a C compiler!')
Example #10
0
	def addlines(self,node):
		self.currentnode_stack.append(node.parent)
		filepath=node.abspath()
		self.count_files+=1
		if self.count_files>recursion_limit:
			raise PreprocError("recursion limit exceeded")
		pc=self.parse_cache
		debug('preproc: reading file %r',filepath)
		try:
			lns=pc[filepath]
		except KeyError:
			pass
		else:
			self.lines.extend(lns)
			return
		try:
			lines=filter_comments(filepath)
			lines.append((POPFILE,''))
			lines.reverse()
			pc[filepath]=lines
			self.lines.extend(lines)
		except IOError:
			raise PreprocError("could not read the file %s"%filepath)
		except Exception:
			if Logs.verbose>0:
				error("parsing %s failed"%filepath)
				traceback.print_exc()
Example #11
0
def libname_msvc(self,libname,is_static=False):
	lib=libname.lower()
	lib=re.sub('\.lib$','',lib)
	if lib in g_msvc_systemlibs:
		return lib
	lib=re.sub('^lib','',lib)
	if lib=='m':
		return None
	(lt_path,lt_libname,lt_static)=self.find_lt_names_msvc(lib,is_static)
	if lt_path!=None and lt_libname!=None:
		if lt_static==True:
			return os.path.join(lt_path,lt_libname)
	if lt_path!=None:
		_libpaths=[lt_path]+self.env['LIBPATH']
	else:
		_libpaths=self.env['LIBPATH']
	static_libs=['lib%ss.lib'%lib,'lib%s.lib'%lib,'%ss.lib'%lib,'%s.lib'%lib,]
	dynamic_libs=['lib%s.dll.lib'%lib,'lib%s.dll.a'%lib,'%s.dll.lib'%lib,'%s.dll.a'%lib,'lib%s_d.lib'%lib,'%s_d.lib'%lib,'%s.lib'%lib,]
	libnames=static_libs
	if not is_static:
		libnames=dynamic_libs+static_libs
	for path in _libpaths:
		for libn in libnames:
			if os.path.exists(os.path.join(path,libn)):
				debug('msvc: lib found: %s'%os.path.join(path,libn))
				return re.sub('\.lib$','',libn)
	self.fatal("The library %r could not be found"%libname)
	return re.sub('\.lib$','',libname)
Example #12
0
	def run(task):
		command = 'SAS'
		env = task.env
		bld = task.generator.bld

		fun = sas_fun

		node = task.inputs[0]
		logfilenode = node.change_ext('.log')
		lstfilenode = node.change_ext('.lst')

		# set the cwd
		task.cwd = task.inputs[0].parent.get_src().abspath()
		debug('runner: %s on %s' % (command, node.abspath))

		SASINPUTS = node.parent.get_bld().abspath() + os.pathsep + node.parent.get_src().abspath() + os.pathsep
		task.env.env = {'SASINPUTS': SASINPUTS}

		task.env.SRCFILE = node.abspath()
		task.env.LOGFILE = logfilenode.abspath()
		task.env.LSTFILE = lstfilenode.abspath()
		ret = fun(task)
		if ret:
			error('Running %s on %r returned a non-zero exit' % (command, node))
			error('SRCFILE = %r' % node)
			error('LOGFILE = %r' % logfilenode)
			error('LSTFILE = %r' % lstfilenode)
		return ret
Example #13
0
def get_ifort_version_win32(conf, compiler, version, target, vcvars):
    try:
        conf.msvc_cnt += 1
    except AttributeError:
        conf.msvc_cnt = 1
    batfile = conf.bldnode.make_node('waf-print-msvc-%d.bat' % conf.msvc_cnt)
    batfile.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%;%%LIBPATH%%
""" % (vcvars, target))
    sout = conf.cmd_and_log(
        ['cmd.exe', '/E:on', '/V:on', '/C',
         batfile.abspath()])
    batfile.delete()
    lines = sout.splitlines()
    if not lines[0]:
        lines.pop(0)
    MSVC_PATH = MSVC_INCDIR = MSVC_LIBDIR = None
    for line in lines:
        if line.startswith('PATH='):
            path = line[5:]
            MSVC_PATH = path.split(';')
        elif line.startswith('INCLUDE='):
            MSVC_INCDIR = [i for i in line[8:].split(';') if i]
        elif line.startswith('LIB='):
            MSVC_LIBDIR = [i for i in line[4:].split(';') if i]
    if None in (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR):
        conf.fatal(
            'msvc: Could not find a valid architecture for building (get_ifort_version_win32)'
        )
    env = dict(os.environ)
    env.update(PATH=path)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    fc = conf.find_program(compiler_name, path_list=MSVC_PATH)
    if 'CL' in env:
        del (env['CL'])
    try:
        try:
            conf.cmd_and_log(fc + ['/help'], env=env)
        except UnicodeError:
            st = Utils.ex_stack()
            if conf.logger:
                conf.logger.error(st)
            conf.fatal('msvc: Unicode error - check the code page?')
        except Exception as e:
            debug('msvc: get_ifort_version: %r %r %r -> failure %s' %
                  (compiler, version, target, str(e)))
            conf.fatal(
                'msvc: cannot run the compiler in get_ifort_version (run with -v to display errors)'
            )
        else:
            debug('msvc: get_ifort_version: %r %r %r -> OK', compiler, version,
                  target)
    finally:
        conf.env[compiler_name] = ''
    return (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR)
Example #14
0
def configure(conf):
	"""
	for each compiler for the platform, try to configure the compiler
	in theory the tools should raise a configuration error if the compiler
	pretends to be something it is not (setting CC=icc and trying to configure gcc)
	"""
	try: test_for_compiler = conf.options.check_c_compiler
	except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_c')")
	for compiler in test_for_compiler.split():
		conf.env.stash()
		conf.start_msg('Checking for %r (c compiler)' % compiler)
		try:
			conf.load(compiler)
		except conf.errors.ConfigurationError as e:
			conf.env.revert()
			conf.end_msg(False)
			debug('compiler_c: %r' % e)
		else:
			if conf.env['CC']:
				conf.end_msg(True)
				conf.env['COMPILER_CC'] = compiler
				break
			conf.end_msg(False)
	else:
		conf.fatal('could not configure a c compiler!')
Example #15
0
 def run(self):
     env = self.env
     gen = self.generator
     path = gen.path
     bld = gen.bld
     bjam = gen.bld.root.find_dir(env.BJAM_SRC)
     if not bjam:
         error('Can not find bjam source')
         return -1
     bjam_exe_relpath = 'bin.' + env.BJAM_UNAME + '/bjam'
     bjam_exe = bjam.find_resource(bjam_exe_relpath)
     if bjam_exe:
         env.BJAM = bjam_exe.srcpath()
         return 0
     bjam_cmd = ['./build.sh']
     debug('runner: ' + bjam.srcpath() + '> ' + str(bjam_cmd))
     result = self.exec_command(bjam_cmd, cwd=bjam.srcpath())
     if not result == 0:
         error('bjam failed')
         return -1
     bjam_exe = bjam.find_resource(bjam_exe_relpath)
     if bjam_exe:
         env.BJAM = bjam_exe.srcpath()
         return 0
     error('bjam failed')
     return -1
Example #16
0
	def scan(self):
		node=self.inputs[0]
		env=self.env
		nodes=[]
		names=[]
		seen=[]
		if not node:return(nodes,names)
		def parse_node(node):
			if node in seen:
				return
			seen.append(node)
			code=node.read()
			global re_tex
			for match in re_tex.finditer(code):
				for path in match.group('file').split(','):
					if path:
						add_name=True
						found=None
						for k in exts_deps_tex:
							debug('tex: trying %s%s'%(path,k))
							found=node.parent.find_resource(path+k)
							if found and not found in self.outputs:
								nodes.append(found)
								add_name=False
								if found.name.endswith('.tex')or found.name.endswith('.ltx'):
									parse_node(found)
						if add_name:
							names.append(path)
		parse_node(node)
		for x in nodes:
			x.parent.get_bld().mkdir()
		debug("tex: found the following : %s and names %s"%(nodes,names))
		return(nodes,names)
Example #17
0
File: c_preproc.py Project: SjB/waf
def scan(task):
	"""
	Get the dependencies using a c/c++ preprocessor, this is required for finding dependencies of the kind
	#include some_macro()

	replacing this method may be a better choice than replacing "ccroot.scan" from all the tasks that use it
	"""

	global go_absolute

	try:
		incn = task.generator.includes_nodes
	except AttributeError:
		raise Errors.WafError('%r is missing a feature such as "c" or "cxx"' % task.generator)

	if go_absolute:
		nodepaths = incn
	else:
		nodepaths = [x for x in incn if x.is_child_of(x.ctx.srcnode) or x.is_child_of(x.ctx.bldnode)]

	tmp = c_parser(nodepaths)
	tmp.start(task.inputs[0], task.env)
	if Logs.verbose:
		debug('deps: deps for %r: %r; unresolved %r' % (task.inputs, tmp.nodes, tmp.names))
	return (tmp.nodes, tmp.names)
def configure(conf):
    """
    Detects a suitable C compiler

    :raises: :py:class:`waflib.Errors.ConfigurationError` when no suitable compiler is found
    """
    try:
        test_for_compiler = conf.options.check_c_compiler or default_compilers()
    except AttributeError:
        conf.fatal("Add options(opt): opt.load('compiler_c')")

    for compiler in re.split("[ ,]+", test_for_compiler):
        conf.env.stash()
        conf.start_msg("Checking for %r (C compiler)" % compiler)
        try:
            conf.load(compiler)
        except conf.errors.ConfigurationError as e:
            conf.env.revert()
            conf.end_msg(False)
            debug("compiler_c: %r", e)
        else:
            if conf.env.CC:
                conf.end_msg(conf.env.get_flat("CC"))
                conf.env.COMPILER_CC = compiler
                conf.env.commit()
                break
            conf.env.revert()
            conf.end_msg(False)
    else:
        conf.fatal("could not configure a C compiler!")
Example #19
0
File: msvc.py Project: zsx/waf
def exec_mf(self):
	env = self.env
	outfile = self.inputs[0].bldpath()
	manifest = outfile + '.manifest'
	if os.path.exists(manifest):
		debug('msvc: manifesttool')
		mtool = env['MT']
		if not mtool:
			return 0

		mode = ''
		# embedding mode. Different for EXE's and DLL's.
		# see: http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx
		if 'cprogram' in self.generator.features:
			mode = '1'
		elif 'cshlib' in self.generator.features or 'cxxshlib' in self.generator.features:
			mode = '2'

		debug('msvc: embedding manifest')
		#flags = ' '.join(env['MTFLAGS'] or [])

		lst = []
		lst.extend(Utils.to_list(env['MT']))
		lst.extend(Utils.to_list(env['MTFLAGS']))
		lst.extend(Utils.to_list("-manifest"))
		lst.extend(Utils.to_list(manifest))
		lst.extend(Utils.to_list("-outputresource:%s;%s" % (outfile, mode)))

		#cmd='%s %s -manifest "%s" -outputresource:"%s";#%s' % (mtool, flags,
		#	manifest, outfile, mode)
		lst = [lst]
		ret = self.exec_command(*lst)

		return ret
Example #20
0
def replace_grouping_libraries(bld, tgt_list):
    '''replace dependencies based on grouping libraries

    If a library is marked as a grouping library, then any target that
    depends on a subsystem that is part of that grouping library gets
    that dependency replaced with a dependency on the grouping library
    '''

    targets  = LOCAL_CACHE(bld, 'TARGET_TYPE')

    grouping = {}

    # find our list of grouping libraries, mapped from the subsystems they depend on
    for t in tgt_list:
        if not getattr(t, 'grouping_library', False):
            continue
        for dep in t.samba_deps_extended:
            bld.ASSERT(dep in targets, "grouping library target %s not declared in %s" % (dep, t.sname))
            if targets[dep] == 'SUBSYSTEM':
                grouping[dep] = t.sname

    # now replace any dependencies on elements of grouping libraries
    for t in tgt_list:
        for i in range(len(t.samba_deps_extended)):
            dep = t.samba_deps_extended[i]
            if dep in grouping:
                if t.sname != grouping[dep]:
                    debug("deps: target %s: replacing dependency %s with grouping library %s" % (t.sname, dep, grouping[dep]))
                    t.samba_deps_extended[i] = grouping[dep]
Example #21
0
	def run(task):
		command = 'SAS'
		env = task.env
		bld = task.generator.bld

		fun = sas_fun

		node = task.inputs[0]
		logfilenode = node.change_ext('.log')
		lstfilenode = node.change_ext('.lst')

		# set the cwd
		task.cwd = task.inputs[0].parent.get_src().abspath()
		debug('runner: %s on %s' % (command, node.abspath))

		SASINPUTS = node.parent.get_bld().abspath() + os.pathsep + node.parent.get_src().abspath() + os.pathsep
		task.env.env = {'SASINPUTS': SASINPUTS}

		task.env.SRCFILE = node.abspath()
		task.env.LOGFILE = logfilenode.abspath()
		task.env.LSTFILE = lstfilenode.abspath()
		ret = fun(task)
		if ret:
			error('Running %s on %r returned a non-zero exit' % (command, node))
			error('SRCFILE = %r' % node)
			error('LOGFILE = %r' % logfilenode)
			error('LSTFILE = %r' % lstfilenode)
		return ret
Example #22
0
def exec_mf(self):
	env=self.env
	mtool=env['MT']
	if not mtool:
		return 0
	self.do_manifest=False
	outfile=self.outputs[0].abspath()
	manifest=None
	for out_node in self.outputs:
		if out_node.name.endswith('.manifest'):
			manifest=out_node.abspath()
			break
	if manifest is None:
		return 0
	mode=''
	if'cprogram'in self.generator.features or'cxxprogram'in self.generator.features:
		mode='1'
	elif'cshlib'in self.generator.features or'cxxshlib'in self.generator.features:
		mode='2'
	debug('msvc: embedding manifest in mode %r'%mode)
	lst=[]
	lst.append(env['MT'])
	lst.extend(Utils.to_list(env['MTFLAGS']))
	lst.extend(['-manifest',manifest])
	lst.append('-outputresource:%s;%s'%(outfile,mode))
	lst=[lst]
	return self.exec_command(*lst)
Example #23
0
def configure(conf):
    """
	Try to find a suitable C compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
	"""
    try:
        test_for_compiler = conf.options.check_c_compiler or default_compilers(
        )
    except AttributeError:
        conf.fatal("Add options(opt): opt.load('compiler_c')")

    for compiler in re.split('[ ,]+', test_for_compiler):
        conf.env.stash()
        conf.start_msg('Checking for %r (C compiler)' % compiler)
        try:
            conf.load(compiler)
        except conf.errors.ConfigurationError as e:
            conf.env.revert()
            conf.end_msg(False)
            debug('compiler_c: %r' % e)
        else:
            if conf.env['CC']:
                conf.end_msg(conf.env.get_flat('CC'))
                conf.env['COMPILER_CC'] = compiler
                break
            conf.end_msg(False)
    else:
        conf.fatal('could not configure a C compiler!')
Example #24
0
File: c_preproc.py Project: zsx/waf
	def start(self, node, env):
		debug('preproc: scanning %s (in %s)', node.name, node.parent.name)

		self.env = env
		bld = node.ctx
		try:
			self.parse_cache = bld.parse_cache
		except AttributeError:
			bld.parse_cache = {}
			self.parse_cache = bld.parse_cache

		self.addlines(node)

		# macros may be defined on the command-line, so they must be parsed as if they were part of the file
		if env['DEFINES']:
			lst = ['%s %s' % (x[0], Utils.trimquotes('='.join(x[1:]))) for x in [y.split('=') for y in env['DEFINES']]]
			self.lines = [('define', x) for x in lst] + self.lines

		while self.lines:
			(kind, line) = self.lines.pop(0)
			if kind == POPFILE:
				self.currentnode_stack.pop()
				continue
			try:
				self.process_line(kind, line)
			except Exception as e:
				if Logs.verbose:
					debug('preproc: line parsing failed (%s): %s %s', e, line, Utils.ex_stack())
Example #25
0
def configure(conf):
	"""
	for each compiler for the platform, try to configure the compiler
	in theory the tools should raise a configuration error if the compiler
	pretends to be something it is not (setting CC=icc and trying to configure gcc)
	"""
	try: test_for_compiler = Options.options.check_c_compiler
	except AttributeError: conf.fatal("Add options(opt): opt.tool_options('compiler_cc')")
	orig = conf.env
	for compiler in test_for_compiler.split():
		try:
			conf.start_msg('Checking for %r (c compiler)' % compiler)
			conf.env = orig.derive()
			conf.check_tool(compiler)
		except conf.errors.ConfigurationError as e:
			conf.end_msg(False)
			debug('compiler_cc: %r' % e)
		else:
			if conf.env['CC']:
				orig.table = conf.env.get_merged_dict()
				conf.env = orig
				conf.end_msg(True)
				conf.env['COMPILER_CC'] = compiler
				break
			conf.end_msg(False)
	else:
		conf.fatal('could not configure a c compiler!')
Example #26
0
def check_syslib_dependencies(bld, t):
    '''check for syslib depenencies'''

    if bld.get_tgen_by_name(t.sname + ".objlist"):
        return

    sname = real_name(t.sname)

    remaining = set()

    features = TO_LIST(t.features)
    if 'pyembed' in features or 'pyext' in features:
        if 'python' in bld.env.public_symbols:
            t.unsatisfied_symbols = t.unsatisfied_symbols.difference(bld.env.public_symbols['python'])

    needed = {}
    for sym in t.unsatisfied_symbols:
        if sym in bld.env.symbol_map:
            dep = bld.env.symbol_map[sym][0]
            if dep == 'c':
                continue
            if not dep in needed:
                needed[dep] = set()
            needed[dep].add(sym)
        else:
            remaining.add(sym)

    for dep in needed:
        Logs.info("Target '%s' should add syslib dep '%s' for symbols %s" % (sname, dep, " ".join(needed[dep])))

    if remaining:
        debug("deps: Target '%s' has unsatisfied symbols: %s" % (sname, " ".join(remaining)))
Example #27
0
File: tex.py Project: SjB/waf
	def scan(self):
		"""
		A simple regex-based scanner for latex dependencies, uses re_tex from above

		Depending on your needs you might want:

		* to change re_tex

		::

			from waflib.Tools import tex
			tex.re_tex = myregex

		* or to change the method scan from the latex tasks

		::

			from waflib.Task import classes
			classes['latex'].scan = myscanfunction

		"""
		node = self.inputs[0]
		env = self.env

		nodes = []
		names = []
		seen = []
		if not node: return (nodes, names)

		def parse_node(node):
			if node in seen:
				return
			seen.append(node
)
			code = node.read()
			global re_tex
			for match in re_tex.finditer(code):
				path = match.group('file')
				if path:
					add_name = True
					found = None
					for k in exts_deps_tex:
						debug('tex: trying %s%s' % (path, k))
						found = node.parent.find_resource(path + k)
						if found:
							nodes.append(found)
							add_name = False
							if found.name.endswith('.tex') or found.name.endswith('.ltx'):
								parse_node(found)
						# no break, people are crazy
					if add_name:
						names.append(path)
		parse_node(node)

		for x in nodes:
			x.parent.get_bld().mkdir()

		debug("tex: found the following : %s and names %s" % (nodes, names))
		return (nodes, names)
Example #28
0
def build_direct_deps(bld, tgt_list):
    '''build the direct_objects and direct_libs sets for each target'''

    targets  = LOCAL_CACHE(bld, 'TARGET_TYPE')
    syslib_deps  = LOCAL_CACHE(bld, 'SYSLIB_DEPS')

    global_deps = bld.env.GLOBAL_DEPENDENCIES
    global_deps_exclude = set()
    for dep in global_deps:
        t = bld.get_tgen_by_name(dep)
        for d in t.samba_deps:
            # prevent loops from the global dependencies list
            global_deps_exclude.add(d)
            global_deps_exclude.add(d + '.objlist')

    for t in tgt_list:
        t.direct_objects = set()
        t.direct_libs = set()
        t.direct_syslibs = set()
        deps = t.samba_deps_extended[:]
        if getattr(t, 'samba_use_global_deps', False) and not t.sname in global_deps_exclude:
            deps.extend(global_deps)
        for d in deps:
            if d == t.sname: continue
            if not d in targets:
                Logs.error("Unknown dependency '%s' in '%s'" % (d, t.sname))
                sys.exit(1)
            if targets[d] in [ 'EMPTY', 'DISABLED' ]:
                continue
            if targets[d] == 'PYTHON' and targets[t.sname] != 'PYTHON' and t.sname.find('.objlist') == -1:
                # this check should be more restrictive, but for now we have pidl-generated python
                # code that directly depends on other python modules
                Logs.error('ERROR: Target %s has dependency on python module %s' % (t.sname, d))
                sys.exit(1)
            if targets[d] == 'SYSLIB':
                t.direct_syslibs.add(d)
                if d in syslib_deps:
                    for implied in TO_LIST(syslib_deps[d]):
                        if BUILTIN_LIBRARY(bld, implied):
                            t.direct_objects.add(implied)
                        elif targets[implied] == 'SYSLIB':
                            t.direct_syslibs.add(implied)
                        elif targets[implied] in ['LIBRARY', 'MODULE']:
                            t.direct_libs.add(implied)
                        else:
                            Logs.error('Implied dependency %s in %s is of type %s' % (
                                implied, t.sname, targets[implied]))
                            sys.exit(1)
                continue
            t2 = bld.get_tgen_by_name(d)
            if t2 is None:
                Logs.error("no task %s of type %s in %s" % (d, targets[d], t.sname))
                sys.exit(1)
            if t2.samba_type in [ 'LIBRARY', 'MODULE' ]:
                t.direct_libs.add(d)
            elif t2.samba_type in [ 'SUBSYSTEM', 'ASN1', 'PYTHON' ]:
                t.direct_objects.add(d)
    debug('deps: built direct dependencies')
Example #29
0
def check_python_version(conf, minver=None):
    assert minver is None or isinstance(minver, tuple)
    python = conf.env['PYTHON']
    if not python:
        conf.fatal('could not find the python executable')
    cmd = [
        python, '-c', 'import sys\nfor x in sys.version_info: print(str(x))'
    ]
    debug('python: Running python command %r' % cmd)
    lines = conf.cmd_and_log(cmd).split()
    assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines),
                                                                lines)
    pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3],
                   int(lines[4]))
    result = (minver is None) or (pyver_tuple >= minver)
    if result:
        pyver = '.'.join([str(x) for x in pyver_tuple[:2]])
        conf.env['PYTHON_VERSION'] = pyver
        if 'PYTHONDIR' in conf.environ:
            pydir = conf.environ['PYTHONDIR']
        else:
            if sys.platform == 'win32':
                (
                    python_LIBDEST, pydir
                ) = conf.get_python_variables(python, [
                    "get_config_var('LIBDEST')",
                    "get_python_lib(standard_lib=0, prefix=%r)" %
                    conf.env['PREFIX']
                ], [
                    'from distutils.sysconfig import get_config_var, get_python_lib'
                ])
            else:
                python_LIBDEST = None
                (pydir, ) = conf.get_python_variables(python, [
                    "get_python_lib(standard_lib=0, prefix=%r)" %
                    conf.env['PREFIX']
                ], [
                    'from distutils.sysconfig import get_config_var, get_python_lib'
                ])
            if python_LIBDEST is None:
                if conf.env['LIBDIR']:
                    python_LIBDEST = os.path.join(conf.env['LIBDIR'],
                                                  "python" + pyver)
                else:
                    python_LIBDEST = os.path.join(conf.env['PREFIX'], "lib",
                                                  "python" + pyver)
        if hasattr(conf, 'define'):
            conf.define('PYTHONDIR', pydir)
        conf.env['PYTHONDIR'] = pydir
    pyver_full = '.'.join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.msg('Checking for python version', pyver_full)
    else:
        minver_str = '.'.join(map(str, minver))
        conf.msg('Checking for python version', pyver_tuple,
                 ">= %s" % (minver_str, ) and 'GREEN' or 'YELLOW')
    if not result:
        conf.fatal('The python version is too old, expecting %r' % (minver, ))
Example #30
0
def exec_mf(self):
    """
        Create the manifest file
        """
    env = self.env
    mtool = env['MT']
    if not mtool:
        return 0

    self.do_manifest = False

    outfile = self.outputs[0].abspath()

    manifest = None
    for out_node in self.outputs:
        if out_node.name.endswith('.manifest'):
            manifest = out_node.abspath()
            break

    #Disabling manifest for incremental link
    if '/INCREMENTAL' in env['LINKFLAGS']:
        manifest = None

    if manifest is None:
        # Should never get here.  If we do, it means the manifest file was
        # never added to the outputs list, thus we don't have a manifest file
        # to embed, so we just return.
        return 0

    # embedding mode. Different for EXE's and DLL's.
    # see: http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx
    mode = ''
    if 'cprogram' in self.generator.features or 'cxxprogram' in self.generator.features:
        mode = '1'
    elif 'cshlib' in self.generator.features or 'cxxshlib' in self.generator.features:
        mode = '2'

    debug('msvc: embedding manifest in mode %r' % mode)

    lst = []
    lst.append(env['MT'])
    lst.extend(Utils.to_list(env['MTFLAGS']))
    lst.extend(['-manifest', manifest])

    if hasattr(self.generator, 'additional_manifests'):
        if not isinstance(self.generator.additional_manifests,
                          list):  # the additional manifests could be a string
            self.generator.additional_manifests = [
                self.generator.additional_manifests
            ]
        for element in self.generator.additional_manifests:  # add each one with its own path
            lst.append(self.generator.path.abspath() + '/' + element)
    lst.append('-outputresource:%s;%s' % (outfile, mode))

    # note that because we call exec_command and give it a list of params, these become the subprocess argv*
    # and thus it is not necessary for us to escape them with quotes or anything like that.
    lst = [lst]
    return self.exec_command(*lst)
Example #31
0
def check_python_version(conf, minver=None):
    assert minver is None or isinstance(minver, tuple)
    pybin = conf.env["PYTHON"]
    if not pybin:
        conf.fatal("could not find the python executable")
    cmd = pybin + ["-c", "import sys\nfor x in sys.version_info: print(str(x))"]
    debug("python: Running python command %r" % cmd)
    lines = conf.cmd_and_log(cmd).split()
    assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
    pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))
    result = (minver is None) or (pyver_tuple >= minver)
    if result:
        pyver = ".".join([str(x) for x in pyver_tuple[:2]])
        conf.env["PYTHON_VERSION"] = pyver
        if "PYTHONDIR" in conf.environ:
            pydir = conf.environ["PYTHONDIR"]
        else:
            if Utils.is_win32:
                (python_LIBDEST, pydir) = conf.get_python_variables(
                    [
                        "get_config_var('LIBDEST') or ''",
                        "get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"],
                    ],
                    ["from distutils.sysconfig import get_config_var, get_python_lib"],
                )
            else:
                python_LIBDEST = None
                (pydir,) = conf.get_python_variables(
                    ["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"]],
                    ["from distutils.sysconfig import get_python_lib"],
                )
            if python_LIBDEST is None:
                if conf.env["LIBDIR"]:
                    python_LIBDEST = os.path.join(conf.env["LIBDIR"], "python" + pyver)
                else:
                    python_LIBDEST = os.path.join(conf.env["PREFIX"], "lib", "python" + pyver)
        if "PYTHONARCHDIR" in conf.environ:
            pyarchdir = conf.environ["PYTHONARCHDIR"]
        else:
            (pyarchdir,) = conf.get_python_variables(
                ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"]],
                ["from distutils.sysconfig import get_python_lib"],
            )
            if not pyarchdir:
                pyarchdir = pydir
        if hasattr(conf, "define"):
            conf.define("PYTHONDIR", pydir)
            conf.define("PYTHONARCHDIR", pyarchdir)
        conf.env["PYTHONDIR"] = pydir
        conf.env["PYTHONARCHDIR"] = pyarchdir
    pyver_full = ".".join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.msg("Checking for python version", pyver_full)
    else:
        minver_str = ".".join(map(str, minver))
        conf.msg("Checking for python version", pyver_tuple, ">= %s" % (minver_str,) and "GREEN" or "YELLOW")
    if not result:
        conf.fatal("The python version is too old, expecting %r" % (minver,))
Example #32
0
def SET_TARGET_TYPE(ctx, target, value):
    '''set the target type of a target'''
    cache = LOCAL_CACHE(ctx, 'TARGET_TYPE')
    if target in cache and cache[target] != 'EMPTY':
        Logs.error("ERROR: Target '%s' in directory %s re-defined as %s - was %s" % (target, ctx.path.abspath(), value, cache[target]))
        sys.exit(1)
    LOCAL_CACHE_SET(ctx, 'TARGET_TYPE', target, value)
    debug("task_gen: Target '%s' created of type '%s' in %s" % (target, value, ctx.path.abspath()))
    return True
Example #33
0
		def parse_node(node):
			code = node.read()
			for match in re_aux.finditer(code):
				path = match.group('file')
				found = node.parent.find_or_declare(path)
				if found and found not in nodes:
					debug('tex: found aux node ' + found.abspath())
					nodes.append(found)
					parse_node(found)
Example #34
0
 def parse_node(node):
     code = node.read()
     for match in re_aux.finditer(code):
         path = match.group('file')
         found = node.parent.find_or_declare(path)
         if found and found not in nodes:
             debug('tex: found aux node ' + found.abspath())
             nodes.append(found)
             parse_node(found)
Example #35
0
File: msvc.py Project: SjB/waf
def get_msvc_version(conf, compiler, version, target, vcvars):
	debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
	batfile = conf.bldnode.make_node('waf-print-msvc.bat')
	batfile.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
""" % (vcvars,target))
	sout = conf.cmd_and_log(['cmd', '/E:on', '/V:on', '/C', batfile.abspath()])
	lines = sout.splitlines()

	for x in ('Setting environment', 'Setting SDK environment', 'Intel(R) C++ Compiler'):
		if lines[0].find(x) != -1:
			break
	else:
		debug('msvc: get_msvc_version: %r %r %r -> not found', compiler, version, target)
		conf.fatal('msvc: Impossible to find a valid architecture for building (in get_msvc_version)')

	for line in lines[1:]:
		if line.startswith('PATH='):
			path = line[5:]
			MSVC_PATH = path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR = [i for i in line[8:].split(';') if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR = [i for i in line[4:].split(';') if i]

	# Check if the compiler is usable at all.
	# The detection may return 64-bit versions even on 32-bit systems, and these would fail to run.
	env = {}
	env.update(os.environ)
	env.update(PATH = path)
	compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
	cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
	cxx = conf.cmd_to_list(cxx)

	# delete CL if exists. because it could contain parameters wich can change cl's behaviour rather catastrophically.
	if 'CL' in env:
		del(env['CL'])

	try:
		try:
			conf.cmd_and_log(cxx + ['/help'], env=env)
		except Exception as e:
			debug('msvc: get_msvc_version: %r %r %r -> failure' % (compiler, version, target))
			debug(str(e))
			conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
		else:
			debug('msvc: get_msvc_version: %r %r %r -> OK', compiler, version, target)
	finally:
		conf.env[compiler_name] = ''

	return (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR)
Example #36
0
File: msvc.py Project: RONNCC/pysoy
def get_msvc_version(conf,compiler,version,target,vcvars):
	debug('msvc: get_msvc_version: %r %r %r',compiler,version,target)
	batfile=conf.bldnode.make_node('waf-print-msvc.bat')
	batfile.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
"""%(vcvars,target))
	sout=conf.cmd_and_log(['cmd','/E:on','/V:on','/C',batfile.abspath()])
	lines=sout.splitlines()
	if not lines[0]:
		lines.pop(0)
	if version=='11.0':
		if lines[0].startswith('Error'):
			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_1)')
	else:
		for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler','Intel Parallel Studio'):
			if lines[0].find(x)>-1:
				lines.pop(0)
				break
		else:
			debug('msvc: get_msvc_version: %r %r %r -> not found',compiler,version,target)
			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_2)')
	MSVC_PATH=MSVC_INCDIR=MSVC_LIBDIR=None
	for line in lines:
		if line.startswith('PATH='):
			path=line[5:]
			MSVC_PATH=path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR=[i for i in line[8:].split(';')if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR=[i for i in line[4:].split(';')if i]
	if None in(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR):
		conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_3)')
	env=dict(os.environ)
	env.update(PATH=path)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	cxx=conf.find_program(compiler_name,path_list=MSVC_PATH)
	cxx=conf.cmd_to_list(cxx)
	if'CL'in env:
		del(env['CL'])
	try:
		try:
			conf.cmd_and_log(cxx+['/help'],env=env)
		except Exception as e:
			debug('msvc: get_msvc_version: %r %r %r -> failure'%(compiler,version,target))
			debug(str(e))
			conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
		else:
			debug('msvc: get_msvc_version: %r %r %r -> OK',compiler,version,target)
	finally:
		conf.env[compiler_name]=''
	return(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR)
Example #37
0
def show_final_deps(bld, tgt_list):
    '''show the final dependencies for all targets'''

    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')

    for t in tgt_list:
        if not targets[t.sname] in ['LIBRARY', 'BINARY', 'PYTHON', 'SUBSYSTEM']:
            continue
        debug('deps: final dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
              t.sname, t.uselib, getattr(t, 'uselib_local', []), getattr(t, 'add_objects', []))
Example #38
0
    def run(self):
        task = self
        # assert len(task.inputs) > 0

        def input_path(node, template):
            if task.cwd is None:
                return template % node.bldpath()
            else:
                return template % node.abspath()

        def output_path(node, template):
            fun = node.abspath
            if task.cwd is None:
                fun = node.bldpath
            return template % fun()

        if isinstance(task.command, Node.Node):
            argv = [input_path(task.command, "%s")]
        else:
            argv = [task.command]

        for arg in task.command_args:
            if isinstance(arg, str):
                argv.append(arg)
            else:
                assert isinstance(arg, cmd_arg)
                argv.append(arg.get_path(task.env, (task.cwd is not None)))

        if task.stdin:
            stdin = open(input_path(task.stdin, "%s"))
        else:
            stdin = None

        if task.stdout:
            stdout = open(output_path(task.stdout, "%s"), "w")
        else:
            stdout = None

        if task.stderr:
            stderr = open(output_path(task.stderr, "%s"), "w")
        else:
            stderr = None

        if task.cwd is None:
            cwd = "None (actually %r)" % os.getcwd()
        else:
            cwd = repr(task.cwd)
        debug("command-output: cwd=%s, stdin=%r, stdout=%r, argv=%r" % (cwd, stdin, stdout, argv))

        if task.os_env is None:
            os_env = os.environ
        else:
            os_env = task.os_env
        command = subprocess.Popen(argv, stdin=stdin, stdout=stdout, stderr=stderr, cwd=task.cwd, env=os_env)
        return command.wait()
Example #39
0
    def scan(self):
        """
		A recursive regex-based scanner that finds latex dependencies. It uses :py:attr:`waflib.Tools.tex.re_tex`

		Depending on your needs you might want:

		* to change re_tex::

			from waflib.Tools import tex
			tex.re_tex = myregex

		* or to change the method scan from the latex tasks::

			from waflib.Task import classes
			classes['latex'].scan = myscanfunction
		"""
        node = self.inputs[0]

        nodes = []
        names = []
        seen = []
        if not node: return (nodes, names)

        def parse_node(node):
            if node in seen:
                return
            seen.append(node)
            code = node.read()
            global re_tex
            for match in re_tex.finditer(code):
                for path in match.group('file').split(','):
                    if path:
                        add_name = True
                        found = None
                        for k in exts_deps_tex:
                            debug('tex: trying %s%s' % (path, k))
                            found = node.parent.find_resource(path + k)
                            if found and not found in self.outputs:
                                nodes.append(found)
                                add_name = False
                                for ext in exts_tex:
                                    if found.name.endswith(ext):
                                        parse_node(found)
                                        break
                            # no break, people are crazy
                        if add_name:
                            names.append(path)

        parse_node(node)

        for x in nodes:
            x.parent.get_bld().mkdir()

        debug("tex: found the following : %s and names %s" % (nodes, names))
        return (nodes, names)
Example #40
0
File: boost.py Project: SjB/waf
def find_boost_includes(self, kw):
	"""
	check every path in kw['includes'] for subdir
	that either starts with boost- or is named boost.

	Then the version is checked and selected accordingly to
	min_version/max_version. The highest possible version number is
	selected!

	If no versiontag is set the versiontag is set accordingly to the
	selected library and INCLUDES_BOOST is set.
	"""
	boostPath = getattr(Options.options, 'boostincludes', '')
	if boostPath:
		boostPath = [os.path.normpath(os.path.expandvars(os.path.expanduser(boostPath)))]
	else:
		boostPath = Utils.to_list(kw['includes'])

	min_version = string_to_version(kw.get('min_version', ''))
	max_version = string_to_version(kw.get('max_version', '')) or (sys.maxint - 1)

	version = 0
	for include_path in boostPath:
		boost_paths = [p for p in glob.glob(os.path.join(include_path, 'boost*')) if os.path.isdir(p)]
		debug('BOOST Paths: %r' % boost_paths)
		for path in boost_paths:
			pathname = os.path.split(path)[-1]
			ret = -1
			if pathname == 'boost':
				path = include_path
				ret = self.get_boost_version_number(path)
			elif pathname.startswith('boost-'):
				ret = self.get_boost_version_number(path)
			ret = int(ret)

			if ret != -1 and ret >= min_version and ret <= max_version and ret > version:
				boost_path = path
				version = ret
	if not version:
		self.fatal('boost headers not found! (required version min: %s max: %s)'
			  % (kw['min_version'], kw['max_version']))
		return False

	found_version = version_string(version)
	versiontag = '^' + found_version + '$'
	if kw['tag_version'] is None:
		kw['tag_version'] = versiontag
	elif kw['tag_version'] != versiontag:
		warn('boost header version %r and tag_version %r do not match!' % (versiontag, kw['tag_version']))
	env = self.env
	env['INCLUDES_BOOST'] = boost_path
	env['BOOST_VERSION'] = found_version
	self.found_includes = 1
	ret = '%s (ver %s)' % (boost_path, found_version)
	return ret
Example #41
0
	def run(self):
		task = self
		#assert len(task.inputs) > 0

		def input_path(node, template):
			if task.cwd is None:
				return template % node.bldpath()
			else:
				return template % node.abspath()
		def output_path(node, template):
			fun = node.abspath
			if task.cwd is None: fun = node.bldpath
			return template % fun()

		if isinstance(task.command, Node.Node):
			argv = [input_path(task.command, '%s')]
		else:
			argv = [task.command]

		for arg in task.command_args:
			if isinstance(arg, str):
				argv.append(arg)
			else:
				assert isinstance(arg, cmd_arg)
				argv.append(arg.get_path(task.env, (task.cwd is not None)))

		if task.stdin:
			stdin = open(input_path(task.stdin, '%s'))
		else:
			stdin = None

		if task.stdout:
			stdout = open(output_path(task.stdout, '%s'), "w")
		else:
			stdout = None

		if task.stderr:
			stderr = open(output_path(task.stderr, '%s'), "w")
		else:
			stderr = None

		if task.cwd is None:
			cwd = ('None (actually %r)' % os.getcwd())
		else:
			cwd = repr(task.cwd)
		debug("command-output: cwd=%s, stdin=%r, stdout=%r, argv=%r" %
			     (cwd, stdin, stdout, argv))

		if task.os_env is None:
			os_env = os.environ
		else:
			os_env = task.os_env
		command = Utils.subprocess.Popen(argv, stdin=stdin, stdout=stdout, stderr=stderr, cwd=task.cwd, env=os_env)
		return command.wait()
Example #42
0
def get_ifort_version_win32(conf,compiler,version,target,vcvars):
	try:
		conf.msvc_cnt+=1
	except AttributeError:
		conf.msvc_cnt=1
	batfile=conf.bldnode.make_node('waf-print-msvc-%d.bat'%conf.msvc_cnt)
	batfile.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%;%%LIBPATH%%
"""%(vcvars,target))
	sout=conf.cmd_and_log(['cmd.exe','/E:on','/V:on','/C',batfile.abspath()])
	batfile.delete()
	lines=sout.splitlines()
	if not lines[0]:
		lines.pop(0)
	MSVC_PATH=MSVC_INCDIR=MSVC_LIBDIR=None
	for line in lines:
		if line.startswith('PATH='):
			path=line[5:]
			MSVC_PATH=path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR=[i for i in line[8:].split(';')if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR=[i for i in line[4:].split(';')if i]
	if None in(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR):
		conf.fatal('msvc: Could not find a valid architecture for building (get_ifort_version_win32)')
	env=dict(os.environ)
	env.update(PATH=path)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	fc=conf.find_program(compiler_name,path_list=MSVC_PATH)
	if'CL'in env:
		del(env['CL'])
	try:
		try:
			conf.cmd_and_log(fc+['/help'],env=env)
		except UnicodeError:
			st=Utils.ex_stack()
			if conf.logger:
				conf.logger.error(st)
			conf.fatal('msvc: Unicode error - check the code page?')
		except Exception as e:
			debug('msvc: get_ifort_version: %r %r %r -> failure %s'%(compiler,version,target,str(e)))
			conf.fatal('msvc: cannot run the compiler in get_ifort_version (run with -v to display errors)')
		else:
			debug('msvc: get_ifort_version: %r %r %r -> OK',compiler,version,target)
	finally:
		conf.env[compiler_name]=''
	return(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR)
Example #43
0
def check_duplicate_sources(bld, tgt_list):
    '''see if we are compiling the same source file more than once'''

    debug('deps: checking for duplicate sources')
    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')

    for t in tgt_list:
        source_list = TO_LIST(getattr(t, 'source', ''))
        tpath = os.path.normpath(
            os.path.relpath(t.path.abspath(bld.env),
                            t.env.BUILD_DIRECTORY + '/default'))
        obj_sources = set()
        for s in source_list:
            if not isinstance(s, str):
                print('strange path in check_duplicate_sources %r' % s)
                s = s.abspath()
            p = os.path.normpath(os.path.join(tpath, s))
            if p in obj_sources:
                Logs.error("ERROR: source %s appears twice in target '%s'" %
                           (p, t.sname))
                sys.exit(1)
            obj_sources.add(p)
        t.samba_source_set = obj_sources

    subsystems = {}

    # build a list of targets that each source file is part of
    for t in tgt_list:
        if not targets[t.sname] in ['LIBRARY', 'BINARY', 'PYTHON']:
            continue
        for obj in t.add_objects:
            t2 = t.bld.get_tgen_by_name(obj)
            source_set = getattr(t2, 'samba_source_set', set())
            for s in source_set:
                if not s in subsystems:
                    subsystems[s] = {}
                if not t.sname in subsystems[s]:
                    subsystems[s][t.sname] = []
                subsystems[s][t.sname].append(t2.sname)

    for s in subsystems:
        if len(subsystems[s]) > 1 and Options.options.SHOW_DUPLICATES:
            Logs.warn("WARNING: source %s is in more than one target: %s" %
                      (s, subsystems[s].keys()))
        for tname in subsystems[s]:
            if len(subsystems[s][tname]) > 1:
                raise Errors.WafError(
                    "ERROR: source %s is in more than one subsystem of target '%s': %s"
                    % (s, tname, subsystems[s][tname]))

    return True
Example #44
0
def libname_msvc(self, libname, is_static=False):
    lib = libname.lower()
    lib = re.sub("\.lib$", "", lib)

    if lib in g_msvc_systemlibs:
        return lib

    lib = re.sub("^lib", "", lib)

    if lib == "m":
        return None

    (lt_path, lt_libname, lt_static) = self.find_lt_names_msvc(lib, is_static)

    if lt_path != None and lt_libname != None:
        if lt_static == True:
            # file existance check has been made by find_lt_names
            return os.path.join(lt_path, lt_libname)

    if lt_path != None:
        _libpaths = [lt_path] + self.env["LIBPATH"]
    else:
        _libpaths = self.env["LIBPATH"]

    static_libs = ["lib%ss.lib" % lib, "lib%s.lib" % lib, "%ss.lib" % lib, "%s.lib" % lib]

    dynamic_libs = [
        "lib%s.dll.lib" % lib,
        "lib%s.dll.a" % lib,
        "%s.dll.lib" % lib,
        "%s.dll.a" % lib,
        "lib%s_d.lib" % lib,
        "%s_d.lib" % lib,
        "%s.lib" % lib,
    ]

    libnames = static_libs
    if not is_static:
        libnames = dynamic_libs + static_libs

    for path in _libpaths:
        for libn in libnames:
            if os.path.exists(os.path.join(path, libn)):
                debug("msvc: lib found: %s" % os.path.join(path, libn))
                return re.sub("\.lib$", "", libn)

                # if no lib can be found, just return the libname as msvc expects it
    self.fatal("The library %r could not be found" % libname)
    return re.sub("\.lib$", "", libname)
Example #45
0
def check_python_version(conf, minver=None):
    """
	Check if the python interpreter is found matching a given minimum version.
	minver should be a tuple, eg. to check for python >= 2.4.2 pass (2,4,2) as minver.

	If successful, PYTHON_VERSION is defined as 'MAJOR.MINOR'
	(eg. '2.4') of the actual python version found, and PYTHONDIR is
	defined, pointing to the site-packages directory appropriate for
	this python version, where modules/packages/extensions should be
	installed.

	:param minver: minimum version
	:type minver: tuple of int
	"""
    assert minver is None or isinstance(minver, tuple)
    pybin = conf.env['PYTHON']
    if not pybin:
        conf.fatal('could not find the python executable')

    # Get python version string
    cmd = pybin + [
        '-c', 'import sys\nfor x in sys.version_info: print(str(x))'
    ]
    debug('python: Running python command %r' % cmd)
    lines = conf.cmd_and_log(cmd).split()
    assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines),
                                                                lines)
    pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3],
                   int(lines[4]))

    # compare python version with the minimum required
    result = (minver is None) or (pyver_tuple >= minver)

    if result:
        # define useful environment variables
        pyver = '.'.join([str(x) for x in pyver_tuple[:2]])
        conf.env['PYTHON_VERSION'] = pyver

    # Feedback
    pyver_full = '.'.join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.msg('Checking for python version', pyver_full)
    else:
        minver_str = '.'.join(map(str, minver))
        conf.msg('Checking for python version', pyver_tuple,
                 ">= %s" % (minver_str, ) and 'GREEN' or 'YELLOW')

    if not result:
        conf.fatal('The python version is too old, expecting %r' % (minver, ))
Example #46
0
def scan(task):
	global go_absolute
	try:
		incn=task.generator.includes_nodes
	except AttributeError:
		raise Errors.WafError('%r is missing a feature such as "c", "cxx" or "includes": '%task.generator)
	if go_absolute:
		nodepaths=incn+[task.generator.bld.root.find_dir(x)for x in standard_includes]
	else:
		nodepaths=[x for x in incn if x.is_child_of(x.ctx.srcnode)or x.is_child_of(x.ctx.bldnode)]
	tmp=c_parser(nodepaths)
	tmp.start(task.inputs[0],task.env)
	if Logs.verbose:
		debug('deps: deps for %r: %r; unresolved %r'%(task.inputs,tmp.nodes,tmp.names))
	return(tmp.nodes,tmp.names)
Example #47
0
def scan(task):
	global go_absolute
	try:
		incn=task.generator.includes_nodes
	except AttributeError:
		raise Errors.WafError('%r is missing a feature such as "c", "cxx" or "includes": '%task.generator)
	if go_absolute:
		nodepaths=incn+[task.generator.bld.root.find_dir(x)for x in standard_includes]
	else:
		nodepaths=[x for x in incn if x.is_child_of(x.ctx.srcnode)or x.is_child_of(x.ctx.bldnode)]
	tmp=c_parser(nodepaths)
	tmp.start(task.inputs[0],task.env)
	if Logs.verbose:
		debug('deps: deps for %r: %r; unresolved %r'%(task.inputs,tmp.nodes,tmp.names))
	return(tmp.nodes,tmp.names)
Example #48
0
def build_dependencies(self):
    '''This builds the dependency list for a target. It runs after all the targets are declared

    The reason this is not just done in the SAMBA_*() rules is that we have no way of knowing
    the full dependency list for a target until we have all of the targets declared.
    '''

    if self.samba_type in ['LIBRARY', 'BINARY', 'PYTHON']:
        self.uselib = list(self.final_syslibs)
        self.uselib_local = list(self.final_libs)
        self.add_objects = list(self.final_objects)

        # extra link flags from pkg_config
        libs = self.final_syslibs.copy()

        (cflags, ldflags, cpppath) = library_flags(self, list(libs))
        new_ldflags = getattr(self, 'samba_ldflags', [])[:]
        new_ldflags.extend(ldflags)
        self.ldflags = new_ldflags

        if getattr(self, 'allow_undefined_symbols',
                   False) and self.env.undefined_ldflags:
            for f in self.env.undefined_ldflags:
                self.ldflags.remove(f)

        if getattr(self, 'allow_undefined_symbols',
                   False) and self.env.undefined_ignore_ldflags:
            for f in self.env.undefined_ignore_ldflags:
                self.ldflags.append(f)

        debug(
            'deps: computed dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
            self.sname, self.uselib, self.uselib_local, self.add_objects)

    if self.samba_type in ['SUBSYSTEM']:
        # this is needed for the cflags of libs that come from pkg_config
        self.uselib = list(self.final_syslibs)
        self.uselib.extend(list(self.direct_syslibs))
        for lib in self.final_libs:
            t = self.bld.get_tgen_by_name(lib)
            self.uselib.extend(list(t.final_syslibs))
        self.uselib = unique_list(self.uselib)

    if getattr(self, 'uselib', None):
        up_list = []
        for l in self.uselib:
            up_list.append(l.upper())
        self.uselib = up_list
Example #49
0
def check_python_version(conf,minver=None):
	assert minver is None or isinstance(minver,tuple)
	pybin=conf.env['PYTHON']
	if not pybin:
		conf.fatal('could not find the python executable')
	cmd=pybin+['-c','import sys\nfor x in sys.version_info: print(str(x))']
	debug('python: Running python command %r'%cmd)
	lines=conf.cmd_and_log(cmd).split()
	assert len(lines)==5,"found %i lines, expected 5: %r"%(len(lines),lines)
	pyver_tuple=(int(lines[0]),int(lines[1]),int(lines[2]),lines[3],int(lines[4]))
	result=(minver is None)or(pyver_tuple>=minver)
	if result:
		pyver='.'.join([str(x)for x in pyver_tuple[:2]])
		conf.env['PYTHON_VERSION']=pyver
		if'PYTHONDIR'in conf.environ:
			pydir=conf.environ['PYTHONDIR']
		else:
			if Utils.is_win32:
				(python_LIBDEST,pydir)=conf.get_python_variables(["get_config_var('LIBDEST') or ''","get_python_lib(standard_lib=0, prefix=%r) or ''"%conf.env['PREFIX']])
			else:
				python_LIBDEST=None
				(pydir,)=conf.get_python_variables(["get_python_lib(standard_lib=0, prefix=%r) or ''"%conf.env['PREFIX']])
			if python_LIBDEST is None:
				if conf.env['LIBDIR']:
					python_LIBDEST=os.path.join(conf.env['LIBDIR'],"python"+pyver)
				else:
					python_LIBDEST=os.path.join(conf.env['PREFIX'],"lib","python"+pyver)
		if'PYTHONARCHDIR'in conf.environ:
			pyarchdir=conf.environ['PYTHONARCHDIR']
		else:
			(pyarchdir,)=conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''"%conf.env['PREFIX']])
			if not pyarchdir:
				pyarchdir=pydir
		if hasattr(conf,'define'):
			conf.define('PYTHONDIR',pydir)
			conf.define('PYTHONARCHDIR',pyarchdir)
		conf.env['PYTHONDIR']=pydir
		conf.env['PYTHONARCHDIR']=pyarchdir
	pyver_full='.'.join(map(str,pyver_tuple[:3]))
	if minver is None:
		conf.msg('Checking for python version',pyver_full)
	else:
		minver_str='.'.join(map(str,minver))
		conf.msg('Checking for python version',pyver_tuple,">= %s"%(minver_str,)and'GREEN'or'YELLOW')
	if not result:
		conf.fatal('The python version is too old, expecting %r'%(minver,))
Example #50
0
def reduce_objects(bld, tgt_list):
    '''reduce objects by looking for indirect object dependencies'''
    rely_on = {}

    for t in tgt_list:
        t.extended_objects = None

    changed = False

    for type in ['BINARY', 'PYTHON', 'LIBRARY']:
        for t in tgt_list:
            if t.samba_type != type: continue
            # if we will indirectly link to a target then we don't need it
            new = t.final_objects.copy()
            for l in t.final_libs:
                t2 = bld.get_tgen_by_name(l)
                t2_obj = extended_objects(bld, t2, set())
                dup = new.intersection(t2_obj)
                if t.sname in rely_on:
                    dup = dup.difference(rely_on[t.sname])
                if dup:
                    # Do not remove duplicates of BUILTINS
                    d = next(iter(dup))
                    if BUILTIN_LIBRARY(bld, d):
                        continue

                    debug(
                        'deps: removing dups from %s of type %s: %s also in %s %s',
                        t.sname, t.samba_type, dup, t2.samba_type, l)
                    new = new.difference(dup)
                    changed = True
                    if not l in rely_on:
                        rely_on[l] = set()
                    rely_on[l] = rely_on[l].union(dup)
            t.final_objects = new

    if not changed:
        return False

    # add back in any objects that were relied upon by the reduction rules
    for r in rely_on:
        t = bld.get_tgen_by_name(r)
        t.final_objects = t.final_objects.union(rely_on[r])

    return True
Example #51
0
File: msvc.py Project: ita1024/node
def exec_mf(self):
    """
	Create the manifest file
	"""
    env = self.env
    mtool = env["MT"]
    if not mtool:
        return 0

    self.do_manifest = False

    outfile = self.outputs[0].abspath()

    manifest = None
    for out_node in self.outputs:
        if out_node.name.endswith(".manifest"):
            manifest = out_node.abspath()
            break
    if manifest is None:
        # Should never get here.  If we do, it means the manifest file was
        # never added to the outputs list, thus we don't have a manifest file
        # to embed, so we just return.
        return 0

        # embedding mode. Different for EXE's and DLL's.
        # see: http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx
    mode = ""
    if "cprogram" in self.generator.features or "cxxprogram" in self.generator.features:
        mode = "1"
    elif "cshlib" in self.generator.features or "cxxshlib" in self.generator.features:
        mode = "2"

    debug("msvc: embedding manifest in mode %r" % mode)

    lst = []
    lst.extend([env["MT"]])
    lst.extend(Utils.to_list(env["MTFLAGS"]))
    lst.extend(Utils.to_list("-manifest"))
    lst.extend(Utils.to_list(manifest))
    lst.extend(Utils.to_list("-outputresource:%s;%s" % (outfile, mode)))

    # cmd='%s %s -manifest "%s" -outputresource:"%s";#%s' % (mtool, flags,
    # 	manifest, outfile, mode)
    lst = [lst]
    return self.exec_command(*lst)
Example #52
0
def configure(conf):
	try:test_for_compiler=conf.options.check_cxx_compiler
	except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_cxx')")
	for compiler in test_for_compiler.split():
		conf.env.stash()
		conf.start_msg('Checking for %r (c++ compiler)'%compiler)
		try:
			conf.load(compiler)
		except conf.errors.ConfigurationError ,e:
			conf.env.revert()
			conf.end_msg(False)
			debug('compiler_cxx: %r'%e)
		else:
			if conf.env['CXX']:
				conf.end_msg(True)
				conf.env['COMPILER_CXX']=compiler
				break
			conf.end_msg(False)
Example #53
0
def configure(conf):
	try:test_for_compiler=conf.options.check_cxx_compiler
	except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_cxx')")
	for compiler in test_for_compiler.split():
		conf.env.stash()
		conf.start_msg('Checking for %r (c++ compiler)'%compiler)
		try:
			conf.load(compiler)
		except conf.errors.ConfigurationError ,e:
			conf.env.revert()
			conf.end_msg(False)
			debug('compiler_cxx: %r'%e)
		else:
			if conf.env['CXX']:
				conf.end_msg(conf.env.get_flat('CXX'))
				conf.env['COMPILER_CXX']=compiler
				break
			conf.end_msg(False)
Example #54
0
def configure(conf):
	try:test_for_compiler=conf.options.check_c_compiler or default_compilers()
	except AttributeError:conf.fatal("Add options(opt): opt.load('compiler_c')")
	for compiler in re.split('[ ,]+',test_for_compiler):
		conf.env.stash()
		conf.start_msg('Checking for %r (C compiler)'%compiler)
		try:
			conf.load(compiler)
		except conf.errors.ConfigurationError ,e:
			conf.env.revert()
			conf.end_msg(False)
			debug('compiler_c: %r'%e)
		else:
			if conf.env['CC']:
				conf.end_msg(conf.env.get_flat('CC'))
				conf.env['COMPILER_CC']=compiler
				break
			conf.end_msg(False)
def mkspec_msvc_configure(conf, version):

    conf.env.MSVC_VERSIONS = ['msvc %s' % version]

    # Here we suppress all the "Checking for program CL"
    # messages printed by waf when loading the msvc tool
    conf.env.stash()
    conf.start_msg('Checking for msvc %s compiler' % version)
    try:
        conf.load('msvc')
    except conf.errors.ConfigurationError as e:
        conf.env.revert()
        conf.end_msg(False)
        debug('msvc_common: %r' % e)
    else:
        conf.end_msg(conf.env.get_flat('CXX'))
        conf.end_msg(False)
        conf.mkspec_set_msvc_flags()
def mkspec_msvc_configure(conf, version):

    conf.env.MSVC_VERSIONS = ['msvc %s' % version]

    # Here we suppress all the "Checking for program CL"
    # messages printed by waf when loading the msvc tool
    conf.env.stash()
    conf.start_msg('Checking for msvc %s compiler' % version)
    try:
        conf.load('msvc')
    except conf.errors.ConfigurationError as e:
        conf.env.revert()
        conf.end_msg(False)
        debug('msvc_common: %r' % e)
    else:
        conf.end_msg(conf.env.get_flat('CXX'))
        conf.end_msg(False)
        conf.mkspec_set_msvc_flags()
Example #57
0
def exec_mf(self):
        """
        Create the manifest file
        """        
        env = self.env
        mtool = env['MT']
        if not mtool:
                return 0

        self.do_manifest = False

        outfile = self.outputs[0].abspath()

        manifest = None
        for out_node in self.outputs:
                if out_node.name.endswith('.manifest'):
                        manifest = out_node.abspath()
                        break
        if manifest is None:
                # Should never get here.  If we do, it means the manifest file was
                # never added to the outputs list, thus we don't have a manifest file
                # to embed, so we just return.
                return 0

        # embedding mode. Different for EXE's and DLL's.
        # see: http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx
        mode = ''
        if 'cprogram' in self.generator.features or 'cxxprogram' in self.generator.features:
                mode = '1'
        elif 'cshlib' in self.generator.features or 'cxxshlib' in self.generator.features:
                mode = '2'

        debug('msvc: embedding manifest in mode %r' % mode)

        lst = []
        lst.append(env['MT'])
        lst.extend(Utils.to_list(env['MTFLAGS']))
        lst.extend(['-manifest', manifest])
        if hasattr(self.generator, 'additional_manifests'):
			lst.append( self.generator.path.abspath() + '/' + self.generator.additional_manifests )
        lst.append('-outputresource:%s;%s' % (outfile, mode))

        lst = [lst]        
        return self.exec_command(*lst)
Example #58
0
def check_python_version(conf, minver=None):
	"""
	Check if the python interpreter is found matching a given minimum version.
	minver should be a tuple, eg. to check for python >= 2.4.2 pass (2,4,2) as minver.

	If successful, PYTHON_VERSION is defined as 'MAJOR.MINOR'
	(eg. '2.4') of the actual python version found, and PYTHONDIR is
	defined, pointing to the site-packages directory appropriate for
	this python version, where modules/packages/extensions should be
	installed.

	:param minver: minimum version
	:type minver: tuple of int
	"""
	assert minver is None or isinstance(minver, tuple)
	pybin = conf.env['PYTHON']
	if not pybin:
		conf.fatal('could not find the python executable')

	# Get python version string
	cmd = pybin + ['-c', 'import sys\nfor x in sys.version_info: print(str(x))']
	debug('python: Running python command %r' % cmd)
	lines = conf.cmd_and_log(cmd).split()
	assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
	pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))

	# compare python version with the minimum required
	result = (minver is None) or (pyver_tuple >= minver)

	if result:
		# define useful environment variables
		pyver = '.'.join([str(x) for x in pyver_tuple[:2]])
		conf.env['PYTHON_VERSION'] = pyver

	# Feedback
	pyver_full = '.'.join(map(str, pyver_tuple[:3]))
	if minver is None:
		conf.msg('Checking for python version', pyver_full)
	else:
		minver_str = '.'.join(map(str, minver))
		conf.msg('Checking for python version', pyver_tuple, ">= %s" % (minver_str,) and 'GREEN' or 'YELLOW')

	if not result:
		conf.fatal('The python version is too old, expecting %r' % (minver,))
Example #59
0
def get_msvc_version(conf,compiler,version,target,vcvars):
	debug('msvc: get_msvc_version: %r %r %r',compiler,version,target)
	batfile=conf.bldnode.make_node('waf-print-msvc.bat')
	batfile.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
"""%(vcvars,target))
	sout=conf.cmd_and_log(['cmd','/E:on','/V:on','/C',batfile.abspath()])
	lines=sout.splitlines()
	if not lines[0]:
		lines.pop(0)
	if version=='11.0':
		if lines[0].startswith('Error'):
			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_1)')
	else:
		for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler','Intel Parallel Studio','Intel(R) Parallel Studio','Intel(R) Composer','Intel Corporation. All rights reserved.'):
			if lines[0].find(x)>-1:
				lines.pop(0)
				break
		else:
			debug('msvc: get_msvc_version: %r %r %r -> not found',compiler,version,target)
			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_2)')
	MSVC_PATH=MSVC_INCDIR=MSVC_LIBDIR=None
	for line in lines:
		if line.startswith('PATH='):
			path=line[5:]
			MSVC_PATH=path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR=[i for i in line[8:].split(';')if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR=[i for i in line[4:].split(';')if i]
	if None in(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR):
		conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_3)')
	env=dict(os.environ)
	env.update(PATH=path)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	cxx=conf.find_program(compiler_name,path_list=MSVC_PATH)
	cxx=conf.cmd_to_list(cxx)
	if'CL'in env:
		del(env['CL'])
	try:
		try:
			conf.cmd_and_log(cxx+['/help'],env=env)
		except Exception ,e:
			debug('msvc: get_msvc_version: %r %r %r -> failure'%(compiler,version,target))
			debug(str(e))
			conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
		else:
Example #60
0
def exec_mf(self):
    """
	Create the manifest file
	"""
    env = self.env
    mtool = env['MT']
    if not mtool:
        return 0

    self.do_manifest = False

    outfile = self.outputs[0].abspath()

    manifest = None
    for out_node in self.outputs:
        if out_node.name.endswith('.manifest'):
            manifest = out_node.abspath()
            break
    if manifest is None:
        # Should never get here.  If we do, it means the manifest file was
        # never added to the outputs list, thus we don't have a manifest file
        # to embed, so we just return.
        return 0

    # embedding mode. Different for EXE's and DLL's.
    # see: http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx
    mode = ''
    if 'cprogram' in self.generator.features or 'cxxprogram' in self.generator.features:
        mode = '1'
    elif 'cshlib' in self.generator.features or 'cxxshlib' in self.generator.features:
        mode = '2'

    debug('msvc: embedding manifest in mode %r' % mode)

    lst = []
    lst.append(env['MT'])
    lst.extend(Utils.to_list(env['MTFLAGS']))
    lst.extend(['-manifest', manifest])
    lst.append('-outputresource:%s;%s' % (outfile, mode))

    lst = [lst]
    return self.exec_command(*lst)