Ejemplo n.º 1
0
def _get_python_variables(python_exe, variables, imports=None):
	"""Run a python interpreter and print some variables"""
	if imports is None:
		imports = ['import sys']
	program = list(imports)
	program.append('')
	for v in variables:
		program.append("print(repr({0!s}))".format(v))
	os_env = dict(os.environ)
	try:
		del os_env['MACOSX_DEPLOYMENT_TARGET'] # see comments in the OSX tool
	except KeyError:
		pass
	proc = Utils.pproc.Popen([python_exe, "-c", '\n'.join(program)], stdout=Utils.pproc.PIPE, env=os_env)
	output = proc.communicate()[0].split("\n") # do not touch, python3
	if proc.returncode:
		if Options.options.verbose:
			warn("Python program to extract python configuration variables failed:\n{0!s}".format('\n'.join(["line {0:03d}: {1!s}".format(lineno+1, line) for lineno, line in enumerate(program)])))
		raise RuntimeError
	return_values = []
	for s in output:
		s = s.strip()
		if not s:
			continue
		if s == 'None':
			return_values.append(None)
		elif (s[0] == "'" and s[-1] == "'") or (s[0] == '"' and s[-1] == '"'):
			return_values.append(eval(s))
		elif s[0].isdigit():
			return_values.append(int(s))
		else: break
	return return_values
Ejemplo n.º 2
0
Archivo: Task.py Proyecto: patrou/node
    def post_run(self):
        "called after a successful task run"
        bld = self.generator.bld
        env = self.env
        sig = self.signature()

        cnt = 0
        variant = env.variant()
        for node in self.outputs:
            # check if the node exists ..
            try:
                os.stat(node.abspath(env))
            except OSError:
                self.has_run = MISSING
                self.err_msg = '-> missing file: %r' % node.abspath(env)
                raise Utils.WafError

            # important, store the signature for the next run
            bld.node_sigs[variant][node.id] = sig

            # We could re-create the signature of the task with the signature of the outputs
            # in practice, this means hashing the output files
            # this is unnecessary
            if Options.cache_global:
                ssig = sig.encode('hex')
                dest = os.path.join(Options.cache_global,
                                    '%s_%d_%s' % (ssig, cnt, node.name))
                try:
                    shutil.copy2(node.abspath(env), dest)
                except IOError:
                    warn('Could not write the file to the cache')
                cnt += 1

        bld.task_sigs[self.unique_id()] = self.cache_sig
Ejemplo n.º 3
0
	def runnable_status(self):
		if self.inputs and(not self.outputs):
			if not getattr(self.__class__,'quiet',None):
				warn("invalid task (no inputs OR outputs): override in a Task subclass or set the attribute 'quiet' %r"%self)
		for t in self.run_after:
			if not t.hasrun:
				return ASK_LATER
		env=self.env
		bld=self.generator.bld
		new_sig=self.signature()
		key=self.unique_id()
		try:
			prev_sig=bld.task_sigs[key][0]
		except KeyError:
			debug("task: task %r must run as it was never run before or the task code changed",self)
			return RUN_ME
		for node in self.outputs:
			variant=node.variant(env)
			try:
				if bld.node_sigs[variant][node.id]!=new_sig:
					return RUN_ME
			except KeyError:
				debug("task: task %r must run as the output nodes do not exist",self)
				return RUN_ME
		if Logs.verbose:self.debug_why(bld.task_sigs[key])
		if new_sig!=prev_sig:
			return RUN_ME
		return SKIP_ME
Ejemplo n.º 4
0
def _get_python_variables(python_exe, variables, imports=['import sys']):
	"""Run a python interpreter and print some variables"""
	program = list(imports)
	program.append('')
	for v in variables:
		program.append("print repr(%s)" % v)
	proc = pproc.Popen([python_exe, "-c", '\n'.join(program)], stdout=pproc.PIPE)
	output = proc.communicate()[0].split("\n")
	if proc.returncode:
		if Logs.verbose:
			warn("Python program to extract python configuration variables failed:\n%s"
				       % '\n'.join(["line %03i: %s" % (lineno+1, line) for lineno, line in enumerate(program)]))
		raise ValueError
	return_values = []
	for s in output:
		s = s.strip()
		if not s:
			continue
		if s == 'None':
			return_values.append(None)
		elif s[0] == "'" and s[-1] == "'":
			return_values.append(s[1:-1])
		elif s[0].isdigit():
			return_values.append(int(s))
		else: break
	return return_values
Ejemplo n.º 5
0
def _get_python_variables(python_exe, variables, imports=['import sys']):
	"""Run a python interpreter and print some variables"""
	program = list(imports)
	program.append('')
	for v in variables:
		program.append("print(repr(%s))" % v)
	os_env = dict(os.environ)
	try:
		del os_env['MACOSX_DEPLOYMENT_TARGET'] # see comments in the OSX tool
	except KeyError:
		pass
	proc = Utils.pproc.Popen([python_exe, "-c", '\n'.join(program)], stdout=Utils.pproc.PIPE, env=os_env)
	output = proc.communicate()[0].split("\n") # do not touch, python3
	if proc.returncode:
		if Options.options.verbose:
			warn("Python program to extract python configuration variables failed:\n%s"
				       % '\n'.join(["line %03i: %s" % (lineno+1, line) for lineno, line in enumerate(program)]))
		raise RuntimeError
	return_values = []
	for s in output:
		s = s.strip()
		if not s:
			continue
		if s == 'None':
			return_values.append(None)
		elif (s[0] == "'" and s[-1] == "'") or (s[0] == '"' and s[-1] == '"'):
			return_values.append(eval(s))
		elif s[0].isdigit():
			return_values.append(int(s))
		else: break
	return return_values
Ejemplo n.º 6
0
Archivo: Task.py Proyecto: blaine/node
	def post_run(self):
		"called after a successful task run"
		bld = self.generator.bld
		env = self.env
		sig = self.signature()

		cnt = 0
		variant = env.variant()
		for node in self.outputs:
			# check if the node exists ..
			try:
				os.stat(node.abspath(env))
			except OSError:
				self.has_run = MISSING
				self.err_msg = '-> missing file: %r' % node.abspath(env)
				raise Utils.WafError

			# important, store the signature for the next run
			bld.node_sigs[variant][node.id] = sig

			# We could re-create the signature of the task with the signature of the outputs
			# in practice, this means hashing the output files
			# this is unnecessary
			if Options.cache_global:
				ssig = sig.encode('hex')
				dest = os.path.join(Options.cache_global, '%s_%d_%s' % (ssig, cnt, node.name))
				try: shutil.copy2(node.abspath(env), dest)
				except IOError: warn('Could not write the file to the cache')
				cnt += 1

		bld.task_sigs[self.unique_id()] = self.cache_sig
Ejemplo n.º 7
0
	def __setattr__(self, name, attr):
		real = typos.get(name, name)
		if real != name:
			warn('typo %s -> %s' % (name, real))
			if Logs.verbose > 0:
				traceback.print_stack()
		object.__setattr__(self, real, attr)
Ejemplo n.º 8
0
 def runnable_status(self):
     if self.inputs and (not self.outputs):
         if not getattr(self.__class__, 'quiet', None):
             warn(
                 "invalid task (no inputs OR outputs): override in a Task subclass or set the attribute 'quiet' %r"
                 % self)
     for t in self.run_after:
         if not t.hasrun:
             return ASK_LATER
     env = self.env
     bld = self.generator.bld
     new_sig = self.signature()
     key = self.unique_id()
     try:
         prev_sig = bld.task_sigs[key][0]
     except KeyError:
         debug(
             "task: task %r must run as it was never run before or the task code changed",
             self)
         return RUN_ME
     for node in self.outputs:
         variant = node.variant(env)
         try:
             if bld.node_sigs[variant][node.id] != new_sig:
                 return RUN_ME
         except KeyError:
             debug(
                 "task: task %r must run as the output nodes do not exist",
                 self)
             return RUN_ME
     if Logs.verbose: self.debug_why(bld.task_sigs[key])
     if new_sig != prev_sig:
         return RUN_ME
     return SKIP_ME
Ejemplo n.º 9
0
	def __setattr__(self, name, attr):
		real = typos.get(name, name)
		if real != name:
			warn('typo {0!s} -> {1!s}'.format(name, real))
			if Logs.verbose > 0:
				traceback.print_stack()
		object.__setattr__(self, real, attr)
Ejemplo n.º 10
0
def find_msvc(conf):
	if sys.platform!='win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')
	v=conf.env
	cxx=None
	if v['CXX']:cxx=v['CXX']
	elif'CXX'in os.environ:cxx=os.environ['CXX']
	if not cxx:cxx=conf.find_program('CL',var='CXX')
	if not cxx:conf.fatal('CL was not found (compiler)')
	v['CXX']=cxx
	v['CC']=v['CXX']
	v['CXX_NAME']='msvc'
	v['CC_NAME']='msvc'
	if not v['LINK_CXX']:
		link=conf.find_program('LINK')
		if link:v['LINK_CXX']=link
		else:conf.fatal('LINK was not found (linker)')
	v['LINK']=link
	if not v['LINK_CC']:v['LINK_CC']=v['LINK_CXX']
	if not v['STLIBLINK']:
		stliblink=conf.find_program('LIB')
		if not stliblink:return
		v['STLIBLINK']=stliblink
	manifesttool=conf.find_program('MT')
	if manifesttool:
		v['MT']=manifesttool
		v['MTFLAGS']=['/NOLOGO']
	conf.check_tool('winres')
	if not conf.env['WINRC']:
		warn('Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 11
0
 def __setattr__(self, name, attr):
     real = typos.get(name, name)
     if real != name:
         warn('typo %s -> %s' % (name, real))
         if Logs.verbose > 0:
             traceback.print_stack()
     object.__setattr__(self, real, attr)
Ejemplo n.º 12
0
def _get_python_variables(python_exe,variables,imports=['import sys']):
	program=list(imports)
	program.append('')
	for v in variables:
		program.append("print(repr(%s))"%v)
	os_env=dict(os.environ)
	try:
		del os_env['MACOSX_DEPLOYMENT_TARGET']
	except KeyError:
		pass
	proc=Utils.pproc.Popen([python_exe,"-c",'\n'.join(program)],stdout=Utils.pproc.PIPE,env=os_env)
	output=proc.communicate()[0].split("\n")
	if proc.returncode:
		if Options.options.verbose:
			warn("Python program to extract python configuration variables failed:\n%s"%'\n'.join(["line %03i: %s"%(lineno+1,line)for lineno,line in enumerate(program)]))
		raise RuntimeError
	return_values=[]
	for s in output:
		s=s.strip()
		if not s:
			continue
		if s=='None':
			return_values.append(None)
		elif s[0]=="'"and s[-1]=="'":
			return_values.append(s[1:-1])
		elif s[0].isdigit():
			return_values.append(int(s))
		else:break
	return return_values
Ejemplo n.º 13
0
def find_boost_includes(self, kw):
    """
	check every path in kw['cpppath'] 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 CPPPATH_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['cpppath'])

    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 = glob.glob(os.path.join(include_path, 'boost*'))
        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['CPPPATH_BOOST'] = boost_path
    env['BOOST_VERSION'] = found_version
    self.found_includes = 1
    ret = 'Version %s (%s)' % (found_version, boost_path)
    return ret
Ejemplo n.º 14
0
	def apply(self):
		"order the methods to execute using self.prec or task_gen.prec"
		keys = set(self.meths)

		# add the methods listed in the features
		self.features = Utils.to_list(self.features)
		for x in self.features + ['*']:
			st = task_gen.traits[x]
			if not st:
				warn('feature %r does not exist - bind at least one method to it' % x)
			keys.update(st)

		# copy the precedence table
		prec = {}
		prec_tbl = self.prec or task_gen.prec
		for x in prec_tbl:
			if x in keys:
				prec[x] = prec_tbl[x]

		# elements disconnected
		tmp = []
		for a in keys:
			for x in prec.values():
				if a in x: break
			else:
				tmp.append(a)

		# topological sort
		out = []
		while tmp:
			e = tmp.pop()
			if e in keys: out.append(e)
			try:
				nlst = prec[e]
			except KeyError:
				pass
			else:
				del prec[e]
				for x in nlst:
					for y in prec:
						if x in prec[y]:
							break
					else:
						tmp.append(x)

		if prec: raise Utils.WafError("graph has a cycle %s" % str(prec))
		out.reverse()
		self.meths = out

		# then we run the methods in order
		debug('task_gen: posting %s %d', self, id(self))
		for x in out:
			try:
				v = getattr(self, x)
			except AttributeError:
				raise Utils.WafError("tried to retrieve %s which is not a valid method" % x)
			debug('task_gen: -> %s (%d)', x, id(self))
			v()
Ejemplo n.º 15
0
def find_msvc(conf):
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )
    v = conf.env
    compiler, version, path, includes, libdirs = detect_msvc(conf)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or (
        compiler == 'wsdk'
        and float(version) >= 6) or (compiler == 'intel'
                                     and float(version) >= 11)
    cxx = None
    if v.CXX: cxx = v.CXX
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name,
                                var='CXX',
                                path_list=path,
                                mandatory=True)
    cxx = conf.cmd_to_list(cxx)
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')
    link = v.LINK_CXX
    if not link:
        link = conf.find_program(linker_name, path_list=path, mandatory=True)
    ar = v.AR
    if not ar:
        ar = conf.find_program(lib_name, path_list=path, mandatory=True)
    mt = v.MT
    if has_msvc_manifest:
        mt = conf.find_program('MT', path_list=path, mandatory=True)
    v.MSVC_MANIFEST = has_msvc_manifest
    v.PATH = path
    v.CPPPATH = includes
    v.LIBPATH = libdirs
    v.CC = v.CXX = cxx
    v.CC_NAME = v.CXX_NAME = 'msvc'
    v.LINK = v.LINK_CXX = link
    if not v.LINK_CC:
        v.LINK_CC = v.LINK_CXX
    v.AR = ar
    v.MT = mt
    v.MTFLAGS = v.ARFLAGS = ['/NOLOGO']
    conf.check_tool('winres')
    if not conf.env.WINRC:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass
Ejemplo n.º 16
0
	def apply(self):
		"order the methods to execute using self.prec or task_gen.prec"
		keys = set(self.meths)

		# add the methods listed in the features
		self.features = Utils.to_list(self.features)
		for x in self.features + ['*']:
			st = task_gen.traits[x]
			if not st:
				warn('feature %r does not exist - bind at least one method to it' % x)
			keys.update(st)

		# copy the precedence table
		prec = {}
		prec_tbl = self.prec or task_gen.prec
		for x in prec_tbl:
			if x in keys:
				prec[x] = prec_tbl[x]

		# elements disconnected
		tmp = []
		for a in keys:
			for x in prec.values():
				if a in x: break
			else:
				tmp.append(a)

		# topological sort
		out = []
		while tmp:
			e = tmp.pop()
			if e in keys: out.append(e)
			try:
				nlst = prec[e]
			except KeyError:
				pass
			else:
				del prec[e]
				for x in nlst:
					for y in prec:
						if x in prec[y]:
							break
					else:
						tmp.append(x)

		if prec: raise Utils.WafError("graph has a cycle %s" % str(prec))
		out.reverse()
		self.meths = out

		# then we run the methods in order
		debug('task_gen: posting %s %d' % (self, id(self)))
		for x in out:
			try:
				v = getattr(self, x)
			except AttributeError:
				raise Utils.WafError("tried to retrieve %s which is not a valid method" % x)
			debug('task_gen: -> %s (%d)' % (x, id(self)))
			v()
Ejemplo n.º 17
0
	def retrieve(self,name,fromenv=None):
		try:
			env=self.all_envs[name]
		except KeyError:
			env=Environment.Environment()
			self.all_envs[name]=env
		else:
			if fromenv:warn("The environment %s may have been configured already"%name)
		return env
Ejemplo n.º 18
0
def detect(conf):
    from Logs import warn
    if 'DEVKITARM' not in os.environ:
        warn("`DEVKITARM' variable is not set, compiler may not be found")

    def prog(name, var=None):
        arm_eabi = 'arm-eabi-%s'
        if not var:
            var = name
        var = var.upper()
        exe = conf.find_program(arm_eabi % name,
                                path_list=[get_devkitarm_bin()])
        if exe:
            conf.env[var] = exe

    prog('ar')
    prog('cpp')
    prog('gcc', 'cc')
    prog('g++', 'cxx')
    prog('g++', 'link_cxx')
    prog('objcopy')
    prog('ranlib')

    # update the compiler flags
    dkp = '/'
    try:
        dkp = os.environ['DEVKITPRO']
    except KeyError:
        warn("`DEVKITPRO' variable is not set, libraries may not be found")

    ARCH = '-mthumb -mthumb-interwork'.split()
    CFLAGS = '''-O2 -ffast-math -Wall -march=armv5te -mtune=arm946e-s
                -Wno-array-bounds -fomit-frame-pointer'''.split()
    CFLAGS += ARCH
    CXXFLAGS = CFLAGS + '-fno-rtti -fno-exceptions'.split()
    LINKFLAGS = '''-specs=ds_arm9.specs -Wl,-Map,map9.map
                   -Wl,-gc-sections'''.split()
    LINKFLAGS += ARCH
    OBJCOPYFLAGS = ''' -I binary -O elf32-littlearm -B arm
        --rename-section .data=.rodata,readonly,contents '''.split()
    CCDEFINES = ['ARM9']

    libnds = os.path.join(dkp, 'libnds')
    env = conf.env
    flags = {
        'CXXFLAGS': CXXFLAGS,
        'CCFLAGS': CFLAGS,
        'CCDEFINES': CCDEFINES,
        'CXXDEFINES': CCDEFINES,
        'CPPPATH': [os.path.join(libnds, 'include')],
        'LIBPATH': [os.path.join(libnds, 'lib')],
        'LINKFLAGS': LINKFLAGS,
        'OBJCOPYFLAGS': OBJCOPYFLAGS,
        'DEVKITARM': os.getenv('DEVKITARM'),
        'DEVKITPRO': os.getenv('DEVKITPRO'),
    }
    env.update(flags)
Ejemplo n.º 19
0
def check_configured(bld):
    if not Configure.autoconfig:
        return bld

    conf_cls = getattr(Utils.g_module, 'configure_context', Utils.Context)
    bld_cls = getattr(Utils.g_module, 'build_context', Utils.Context)

    def reconf(proj):
        back = (Options.commands, Options.options.__dict__, Logs.zones,
                Logs.verbose)

        Options.commands = proj['commands']
        Options.options.__dict__ = proj['options']
        conf = conf_cls()
        conf.environ = proj['environ']
        configure(conf)

        (Options.commands, Options.options.__dict__, Logs.zones,
         Logs.verbose) = back

    try:
        proj = Environment.Environment(Options.lockfile)
    except IOError:
        conf = conf_cls()
        configure(conf)
    else:
        try:
            bld = bld_cls()
            bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
            bld.load_envs()
        except Utils.WafError:
            reconf(proj)
            return bld_cls()

    try:
        proj = Environment.Environment(Options.lockfile)
    except IOError:
        raise Utils.WafError('Auto-config: project does not configure (bug)')

    h = 0
    try:
        for file in proj['files']:
            if file.endswith('configure'):
                h = hash((h, Utils.readf(file)))
            else:
                mod = Utils.load_module(file)
                h = hash((h, mod.waf_hash_val))
    except (OSError, IOError):
        warn('Reconfiguring the project: a file is unavailable')
        reconf(proj)
    else:
        if (h != proj['hash']):
            warn('Reconfiguring the project: the configuration has changed')
            reconf(proj)

    return bld_cls()
Ejemplo n.º 20
0
def detect(conf):
    from Logs import warn
    if 'DEVKITARM' not in os.environ:
        warn("`DEVKITARM' variable is not set, compiler may not be found")
    def prog(name, var=None):
        arm_eabi = 'arm-eabi-%s'
        if not var:
            var = name
        var = var.upper()
        exe = conf.find_program(arm_eabi % name,
                path_list=[get_devkitarm_bin()])
        if exe:
            conf.env[var] = exe

    prog('ar')
    prog('cpp')
    prog('gcc', 'cc')
    prog('g++', 'cxx')
    prog('g++', 'link_cxx')
    prog('objcopy')
    prog('ranlib')

    # update the compiler flags
    dkp = '/'
    try:
        dkp = os.environ['DEVKITPRO']
    except KeyError:
        warn("`DEVKITPRO' variable is not set, libraries may not be found")

    ARCH = '-mthumb -mthumb-interwork'.split()
    CFLAGS = '''-O2 -ffast-math -Wall -march=armv5te -mtune=arm946e-s
                -Wno-array-bounds -fomit-frame-pointer'''.split()
    CFLAGS += ARCH
    CXXFLAGS = CFLAGS + '-fno-rtti -fno-exceptions'.split()
    LINKFLAGS = '''-specs=ds_arm9.specs -Wl,-Map,map9.map
                   -Wl,-gc-sections'''.split()
    LINKFLAGS += ARCH
    OBJCOPYFLAGS = ''' -I binary -O elf32-littlearm -B arm
        --rename-section .data=.rodata,readonly,contents '''.split()
    CCDEFINES = ['ARM9']

    libnds = os.path.join(dkp, 'libnds')
    env = conf.env
    flags = {
        'CXXFLAGS': CXXFLAGS,
        'CCFLAGS': CFLAGS,
        'CCDEFINES': CCDEFINES,
        'CXXDEFINES': CCDEFINES,
        'CPPPATH': [os.path.join(libnds, 'include')],
        'LIBPATH': [os.path.join(libnds, 'lib')],
        'LINKFLAGS': LINKFLAGS,
        'OBJCOPYFLAGS': OBJCOPYFLAGS,
        'DEVKITARM': os.getenv('DEVKITARM'),
        'DEVKITPRO': os.getenv('DEVKITPRO'),
    }
    env.update(flags)
Ejemplo n.º 21
0
	def retrieve(self,name,fromenv=None):
		try:
			env=self.all_envs[name]
		except KeyError:
			env=Environment.Environment()
			env['PREFIX']=os.path.abspath(os.path.expanduser(Options.options.prefix))
			self.all_envs[name]=env
		else:
			if fromenv:warn("The environment %s may have been configured already"%name)
		return env
Ejemplo n.º 22
0
def get_cc_version(conf, cc, version_var):
	v = conf.env
	output = Utils.cmd_output('%s -dumpversion' % cc)
	if output:
		match = get_version_re.search(output)
		if match:
			v[version_var] = match.group(0)
			conf.check_message('compiler', 'version', 1, v[version_var])
			return v[version_var]
	warn('could not determine the compiler version')
Ejemplo n.º 23
0
	def retrieve(self,name,fromenv=None):
		try:
			env=self.all_envs[name]
		except KeyError:
			env=Environment.Environment()
			env['PREFIX']=os.path.abspath(os.path.expanduser(Options.options.prefix))
			self.all_envs[name]=env
		else:
			if fromenv:warn("The environment %s may have been configured already"%name)
		return env
Ejemplo n.º 24
0
def find_boost_includes(self, kw):
	"""
	check every path in kw['cpppath'] 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 CPPPATH_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['cpppath'])

	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['CPPPATH_BOOST'] = boost_path
	env['BOOST_VERSION'] = found_version
	self.found_includes = 1
	ret = 'Version %s (%s)' % (found_version, boost_path)
	return ret
Ejemplo n.º 25
0
Archivo: Task.py Proyecto: patrou/node
    def runnable_status(self):
        "SKIP_ME RUN_ME or ASK_LATER"
        #return 0 # benchmarking

        if self.inputs and (not self.outputs):
            if not getattr(self.__class__, 'quiet', None):
                warn(
                    "invalid task (no inputs OR outputs): override in a Task subclass or set the attribute 'quiet' %r"
                    % self)

        for t in self.run_after:
            if not t.hasrun:
                return ASK_LATER

        env = self.env
        bld = self.generator.bld

        # first compute the signature
        try:
            new_sig = self.signature()
        except KeyError:
            debug(
                "task: something is wrong, computing the task %r signature failed"
                % self)
            return RUN_ME

        # compare the signature to a signature computed previously
        key = self.unique_id()
        try:
            prev_sig = bld.task_sigs[key][0]
        except KeyError:
            debug(
                "task: task %r must run as it was never run before or the task code changed"
                % self)
            return RUN_ME

        # compare the signatures of the outputs
        for node in self.outputs:
            variant = node.variant(env)
            try:
                if bld.node_sigs[variant][node.id] != new_sig:
                    return RUN_ME
            except KeyError:
                debug(
                    "task: task %r must run as the output nodes do not exist" %
                    self)
                return RUN_ME

        # debug if asked to
        if Logs.verbose: self.debug_why(bld.task_sigs[key])

        if new_sig != prev_sig:
            return RUN_ME
        return SKIP_ME
Ejemplo n.º 26
0
def check_configured(bld):
	if not Configure.autoconfig:
		return bld

	conf_cls = getattr(Utils.g_module, 'configure_context', Utils.Context)
	bld_cls = getattr(Utils.g_module, 'build_context', Utils.Context)

	def reconf(proj):
		back = (Options.commands, Options.options.__dict__, Logs.zones, Logs.verbose)

		Options.commands = proj['commands']
		Options.options.__dict__ = proj['options']
		conf = conf_cls()
		conf.environ = proj['environ']
		configure(conf)

		(Options.commands, Options.options.__dict__, Logs.zones, Logs.verbose) = back

	try:
		proj = Environment.Environment(Options.lockfile)
	except IOError:
		conf = conf_cls()
		configure(conf)
	else:
		try:
			bld = bld_cls()
			bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
			bld.load_envs()
		except Utils.WafError:
			reconf(proj)
			return bld_cls()

	try:
		proj = Environment.Environment(Options.lockfile)
	except IOError:
		raise Utils.WafError('Auto-config: project does not configure (bug)')

	h = 0
	try:
		for file in proj['files']:
			if file.endswith('configure'):
				h = hash((h, Utils.readf(file)))
			else:
				mod = Utils.load_module(file)
				h = hash((h, mod.waf_hash_val))
	except (OSError, IOError):
		warn('Reconfiguring the project: a file is unavailable')
		reconf(proj)
	else:
		if (h != proj['hash']):
			warn('Reconfiguring the project: the configuration has changed')
			reconf(proj)

	return bld_cls()
Ejemplo n.º 27
0
def find_msvc(conf):
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )
    v = conf.env
    compiler, path, includes, libdirs = detect_msvc(conf)
    v['PATH'] = path
    v['CPPPATH'] = includes
    v['LIBPATH'] = libdirs
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    cxx = None
    if v['CXX']: cxx = v['CXX']
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name, var='CXX', path_list=path)
    if not cxx: conf.fatal('%s was not found (compiler)' % compiler_name)
    cxx = conf.cmd_to_list(cxx)
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')
    v['CC'] = v['CXX'] = cxx
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass
    if not v['LINK_CXX']:
        link = conf.find_program(linker_name, path_list=path)
        if link: v['LINK_CXX'] = link
        else: conf.fatal('%s was not found (linker)' % linker_name)
    v['LINK'] = link
    if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX']
    if not v['AR']:
        stliblink = conf.find_program(lib_name, path_list=path)
        if not stliblink: return
        v['AR'] = stliblink
        v['ARFLAGS'] = ['/NOLOGO']
    manifesttool = conf.find_program('MT', path_list=path)
    if manifesttool:
        v['MT'] = manifesttool
        v['MTFLAGS'] = ['/NOLOGO']
    conf.check_tool('winres')
    if not conf.env['WINRC']:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 28
0
 def apply(self):
     keys = set(self.meths)
     self.features = Utils.to_list(self.features)
     for x in self.features + ['*']:
         st = task_gen.traits[x]
         if not st:
             warn(
                 'feature %r does not exist - bind at least one method to it'
                 % x)
         keys.update(st)
     prec = {}
     prec_tbl = self.prec or task_gen.prec
     for x in prec_tbl:
         if x in keys:
             prec[x] = prec_tbl[x]
     tmp = []
     for a in keys:
         for x in prec.values():
             if a in x: break
         else:
             tmp.append(a)
     out = []
     while tmp:
         e = tmp.pop()
         if e in keys: out.append(e)
         try:
             nlst = prec[e]
         except KeyError:
             pass
         else:
             del prec[e]
             for x in nlst:
                 for y in prec:
                     if x in prec[y]:
                         break
                 else:
                     tmp.append(x)
     if prec: raise Utils.WafError("graph has a cycle %s" % str(prec))
     out.reverse()
     self.meths = out
     debug('task_gen: posting %s %d', self, id(self))
     for x in out:
         try:
             v = getattr(self, x)
         except AttributeError:
             raise Utils.WafError(
                 "tried to retrieve %s which is not a valid method" % x)
         debug('task_gen: -> %s (%d)', x, id(self))
         v()
Ejemplo n.º 29
0
def find_boost_includes(self, kw):
    boostPath = getattr(Options.options, 'boostincludes', '')
    if boostPath:
        boostPath = [
            os.path.normpath(os.path.expandvars(os.path.expanduser(boostPath)))
        ]
    else:
        boostPath = Utils.to_list(kw['cpppath'])
    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['CPPPATH_BOOST'] = boost_path
    env['BOOST_VERSION'] = found_version
    self.found_includes = 1
    ret = 'Version %s (%s)' % (found_version, boost_path)
    return ret
Ejemplo n.º 30
0
	def apply(self):
		keys=set(self.meths)
		self.features=Utils.to_list(self.features)
		for x in self.features+['*']:
			st=task_gen.traits[x]
			if not st:
				warn('feature %r does not exist - bind at least one method to it'%x)
			keys.update(st)
		prec={}
		prec_tbl=self.prec or task_gen.prec
		for x in prec_tbl:
			if x in keys:
				prec[x]=prec_tbl[x]
		tmp=[]
		for a in keys:
			for x in prec.values():
				if a in x:break
			else:
				tmp.append(a)
		out=[]
		while tmp:
			e=tmp.pop()
			if e in keys:out.append(e)
			try:
				nlst=prec[e]
			except KeyError:
				pass
			else:
				del prec[e]
				for x in nlst:
					for y in prec:
						if x in prec[y]:
							break
					else:
						tmp.append(x)
		if prec:raise Utils.WafError("graph has a cycle %s"%str(prec))
		out.reverse()
		self.meths=out
		debug('task_gen: posting %s %d',self,id(self))
		for x in out:
			try:
				v=getattr(self,x)
			except AttributeError:
				raise Utils.WafError("tried to retrieve %s which is not a valid method"%x)
			debug('task_gen: -> %s (%d)',x,id(self))
			v()
Ejemplo n.º 31
0
	def post_run(self):
		bld=self.generator.bld
		env=self.env
		sig=self.signature()
		cnt=0
		for node in self.outputs:
			variant=node.variant(env)
			os.stat(node.abspath(env))
			bld.node_sigs[variant][node.id]=sig
			if Options.cache_global:
				ssig=sig.encode('hex')
				dest=os.path.join(Options.cache_global,ssig+'-'+str(cnt))
				try:shutil.copy2(node.abspath(env),dest)
				except IOError:warn('Could not write the file to the cache')
				cnt+=1
		bld.task_sigs[self.unique_id()]=self.cache_sig
		self.executed=1
Ejemplo n.º 32
0
Archivo: Task.py Proyecto: blaine/node
	def runnable_status(self):
		"SKIP_ME RUN_ME or ASK_LATER"
		#return 0 # benchmarking

		if self.inputs and (not self.outputs):
			if not getattr(self.__class__, 'quiet', None):
				warn("invalid task (no inputs OR outputs): override in a Task subclass or set the attribute 'quiet' %r" % self)

		for t in self.run_after:
			if not t.hasrun:
				return ASK_LATER

		env = self.env
		bld = self.generator.bld

		# first compute the signature
		try:
			new_sig = self.signature()
		except KeyError:
			debug("task: something is wrong, computing the task %r signature failed" % self)
			return RUN_ME

		# compare the signature to a signature computed previously
		key = self.unique_id()
		try:
			prev_sig = bld.task_sigs[key][0]
		except KeyError:
			debug("task: task %r must run as it was never run before or the task code changed" % self)
			return RUN_ME

		# compare the signatures of the outputs
		for node in self.outputs:
			variant = node.variant(env)
			try:
				if bld.node_sigs[variant][node.id] != new_sig:
					return RUN_ME
			except KeyError:
				debug("task: task %r must run as the output nodes do not exist" % self)
				return RUN_ME

		# debug if asked to
		if Logs.verbose: self.debug_why(bld.task_sigs[key])

		if new_sig != prev_sig:
			return RUN_ME
		return SKIP_ME
Ejemplo n.º 33
0
def find_msvc(conf):
	# due to path format limitations, limit operation only to native Win32. Yeah it sucks.
	if sys.platform != 'win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')

	v = conf.env

	# compiler
	cxx = None
	if v['CXX']: cxx = v['CXX']
	elif 'CXX' in os.environ: cxx = os.environ['CXX']
	if not cxx: cxx = conf.find_program('CL', var='CXX')
	if not cxx: conf.fatal('CL was not found (compiler)')

	# c/c++ compiler - check for whitespace, and if so, add quotes
	v['CXX']  = cxx
	v['CC'] = v['CXX']
	v['CXX_NAME'] = 'msvc'
	v['CC_NAME'] = 'msvc'

	# linker
	if not v['LINK_CXX']:
		link = conf.find_program('LINK')
		if link: v['LINK_CXX'] = link
		else: conf.fatal('LINK was not found (linker)')
	v['LINK']            = link

	if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX']

	# staticlib linker
	if not v['STLIBLINK']:
		stliblink = conf.find_program('LIB')
		if not stliblink: return
		v['STLIBLINK']       = stliblink
		v["STLINKFLAGS"]  = ['/NOLOGO']

	# manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
	manifesttool = conf.find_program('MT')
	if manifesttool:
		v['MT'] = manifesttool
		v['MTFLAGS']=['/NOLOGO']

	conf.check_tool('winres')

	if not conf.env['WINRC']:
		warn('Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 34
0
def find_msvc(conf):
	if sys.platform!='win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')
	v=conf.env
	compiler,version,path,includes,libdirs=detect_msvc(conf)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	has_msvc_manifest=(compiler=='msvc'and float(version)>=8)or(compiler=='wsdk'and float(version)>=6)or(compiler=='intel'and float(version)>=11)
	cxx=None
	if v.CXX:cxx=v.CXX
	elif'CXX'in conf.environ:cxx=conf.environ['CXX']
	if not cxx:cxx=conf.find_program(compiler_name,var='CXX',path_list=path,mandatory=True)
	cxx=conf.cmd_to_list(cxx)
	env=dict(conf.environ)
	env.update(PATH=';'.join(path))
	if not Utils.cmd_output([cxx,'/nologo','/?'],silent=True,env=env):
		conf.fatal('the msvc compiler could not be identified')
	link=v.LINK_CXX
	if not link:
		link=conf.find_program(linker_name,path_list=path,mandatory=True)
	ar=v.AR
	if not ar:
		ar=conf.find_program(lib_name,path_list=path,mandatory=True)
	mt=v.MT
	if has_msvc_manifest:
		mt=conf.find_program('MT',path_list=path,mandatory=True)
	v.MSVC_MANIFEST=has_msvc_manifest
	v.PATH=path
	v.CPPPATH=includes
	v.LIBPATH=libdirs
	v.CC=v.CXX=cxx
	v.CC_NAME=v.CXX_NAME='msvc'
	v.LINK=v.LINK_CXX=link
	if not v.LINK_CC:
		v.LINK_CC=v.LINK_CXX
	v.AR=ar
	v.MT=mt
	v.MTFLAGS=v.ARFLAGS=['/NOLOGO']
	conf.check_tool('winres')
	if not conf.env.WINRC:
		warn('Resource compiler not found. Compiling resource file is disabled')
	try:v.prepend_value('CPPPATH',conf.environ['INCLUDE'])
	except KeyError:pass
	try:v.prepend_value('LIBPATH',conf.environ['LIB'])
	except KeyError:pass
Ejemplo n.º 35
0
def detect(conf):

	if not conf.env.PYTHON:
		conf.env.PYTHON = sys.executable

	python = conf.find_program('python', var='PYTHON')
	if not python:
		conf.fatal('Could not find the path of the python executable')

	if conf.env.PYTHON != sys.executable:
		warn("python executable '%s' different from sys.executable '%s'" % (conf.env.PYTHON, sys.executable))

	v = conf.env
	v['PYCMD'] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
	v['PYFLAGS'] = ''
	v['PYFLAGS_OPT'] = '-O'

	v['PYC'] = getattr(Options.options, 'pyc', 1)
	v['PYO'] = getattr(Options.options, 'pyo', 1)
def find_msvc(conf):
	if sys.platform!='win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')
	v=conf.env
	compiler,path,includes,libdirs=detect_msvc(conf)
	v['PATH']=path
	v['CPPPATH']=includes
	v['LIBPATH']=libdirs
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	cxx=None
	if v['CXX']:cxx=v['CXX']
	elif'CXX'in conf.environ:cxx=conf.environ['CXX']
	if not cxx:cxx=conf.find_program(compiler_name,var='CXX',path_list=path)
	if not cxx:conf.fatal('%s was not found (compiler)'%compiler_name)
	cxx=conf.cmd_to_list(cxx)
	env=dict(conf.environ)
	env.update(PATH=';'.join(path))
	if not Utils.cmd_output([cxx,'/nologo','/?'],silent=True,env=env):
		conf.fatal('the msvc compiler could not be identified')
	v['CC']=v['CXX']=cxx
	v['CC_NAME']=v['CXX_NAME']='msvc'
	try:v.prepend_value('CPPPATH',conf.environ['INCLUDE'])
	except KeyError:pass
	try:v.prepend_value('LIBPATH',conf.environ['LIB'])
	except KeyError:pass
	if not v['LINK_CXX']:
		link=conf.find_program(linker_name,path_list=path)
		if link:v['LINK_CXX']=link
		else:conf.fatal('%s was not found (linker)'%linker_name)
	v['LINK']=link
	if not v['LINK_CC']:v['LINK_CC']=v['LINK_CXX']
	if not v['AR']:
		stliblink=conf.find_program(lib_name,path_list=path)
		if not stliblink:return
		v['AR']=stliblink
		v['ARFLAGS']=['/NOLOGO']
	manifesttool=conf.find_program('MT',path_list=path)
	if manifesttool:
		v['MT']=manifesttool
		v['MTFLAGS']=['/NOLOGO']
	conf.check_tool('winres')
	if not conf.env['WINRC']:
		warn('Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 37
0
def detect(conf):

	if not conf.env.PYTHON:
		conf.env.PYTHON = sys.executable

	python = conf.find_program('python', var='PYTHON')
	if not python:
		conf.fatal('Could not find the path of the python executable')

	if conf.env.PYTHON != sys.executable:
		warn("python executable '%s' different from sys.executable '%s'" % (conf.env.PYTHON, sys.executable))

	v = conf.env
	v['PYCMD'] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
	v['PYFLAGS'] = ''
	v['PYFLAGS_OPT'] = '-O'

	v['PYC'] = getattr(Options.options, 'pyc', 1)
	v['PYO'] = getattr(Options.options, 'pyo', 1)
Ejemplo n.º 38
0
Archivo: python.py Proyecto: hef/samba
def detect(conf):

    if not conf.env.PYTHON:
        conf.env.PYTHON = sys.executable

    python = conf.find_program("python", var="PYTHON")
    if not python:
        conf.fatal("Could not find the path of the python executable")

    if conf.env.PYTHON != sys.executable:
        warn("python executable '%s' different from sys.executable '%s'" % (conf.env.PYTHON, sys.executable))

    v = conf.env
    v["PYCMD"] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
    v["PYFLAGS"] = ""
    v["PYFLAGS_OPT"] = "-O"

    v["PYC"] = getattr(Options.options, "pyc", 1)
    v["PYO"] = getattr(Options.options, "pyo", 1)
Ejemplo n.º 39
0
	def post_run(self):
		bld=self.generator.bld
		env=self.env
		sig=self.signature()
		cnt=0
		variant=env.variant()
		for node in self.outputs:
			try:
				os.stat(node.abspath(env))
			except OSError:
				self.has_run=MISSING
				self.err_msg='-> missing file: %r'%node.abspath(env)
				raise Utils.WafError
			bld.node_sigs[variant][node.id]=sig
			if Options.cache_global:
				ssig=sig.encode('hex')
				dest=os.path.join(Options.cache_global,'%s_%d_%s'%(ssig,cnt,node.name))
				try:shutil.copy2(node.abspath(env),dest)
				except IOError:warn('Could not write the file to the cache')
				cnt+=1
		bld.task_sigs[self.unique_id()]=self.cache_sig
Ejemplo n.º 40
0
def find_boost_includes(self,kw):
	boostPath=getattr(Options.options,'boostincludes','')
	if boostPath:
		boostPath=[os.path.normpath(os.path.expandvars(os.path.expanduser(boostPath)))]
	else:
		boostPath=Utils.to_list(kw['cpppath'])
	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=glob.glob(os.path.join(include_path,'boost*'))
		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['CPPPATH_BOOST']=boost_path
	env['BOOST_VERSION']=found_version
	self.found_includes=1
	ret='Version %s (%s)'%(found_version,boost_path)
	return ret
Ejemplo n.º 41
0
 def post_run(self):
     bld = self.generator.bld
     env = self.env
     sig = self.signature()
     cnt = 0
     variant = env.variant()
     for node in self.outputs:
         try:
             os.stat(node.abspath(env))
         except OSError:
             self.has_run = MISSING
             self.err_msg = '-> missing file: %r' % node.abspath(env)
             raise Utils.WafError
         bld.node_sigs[variant][node.id] = sig
         if Options.cache_global:
             ssig = sig.encode('hex')
             dest = os.path.join(Options.cache_global,
                                 '%s_%d_%s' % (ssig, cnt, node.name))
             try:
                 shutil.copy2(node.abspath(env), dest)
             except IOError:
                 warn('Could not write the file to the cache')
             cnt += 1
     bld.task_sigs[self.unique_id()] = self.cache_sig
Ejemplo n.º 42
0
def main():
	if Options.commands['configure']:
		ini = time.time()
		configure()
		ela = ''
		if not Options.options.progress_bar: ela = time.strftime(' (%H:%M:%S)', time.gmtime(time.time() - ini))
		info('Configuration finished successfully%s; project is now ready to build.' % ela)
		sys.exit(0)

	# compile the project and/or install the files
	bld = Build.BuildContext()
	try:
		proj = Environment.Environment(Options.lockfile)
	except IOError:
		if Options.commands['clean']:
			raise Utils.WafError("Nothing to clean (project not configured)")
		else:
			if Configure.autoconfig:
				warn("Reconfiguring the project")
				configure()
				bld = Build.BuildContext()
				proj = Environment.Environment(Options.lockfile)
			else:
				raise Utils.WafError("Project not configured (run 'waf configure' first)")

	if Configure.autoconfig:
		if not Options.commands['clean'] and not Options.commands['uninstall']:
			reconf = 0
			h = 0
			try:
				for file in proj['files']:
					mod = Utils.load_module(file)
					h = Utils.hash_function_with_globals(h, mod.configure)
				reconf = (h != proj['hash'])
			except Exception, e:
				warn("Reconfiguring the project (an exception occurred: %s)" % (str(e),))
				reconf = 1

			if reconf:
				warn("Reconfiguring the project (the configuration has changed)")

				back = (Options.commands, Options.options, Logs.zones, Logs.verbose)

				Options.commands = proj['commands']
				Options.options.__dict__ = proj['options']
				configure()

				(Options.commands, Options.options, Logs.zones, Logs.verbose) = back

				bld = Build.BuildContext()
				proj = Environment.Environment(Options.lockfile)
Ejemplo n.º 43
0
def tex_build(task, command='LATEX'):
    env = task.env
    bld = task.generator.bld
    com = '%s %s' % (env[command], env.get_flat(command + 'FLAGS'))
    if not env['PROMPT_LATEX']: com = "%s %s" % (com, '-interaction=batchmode')
    node = task.inputs[0]
    reldir = node.bld_dir(env)
    srcfile = node.srcpath(env)
    lst = []
    for c in Utils.split_path(reldir):
        if c: lst.append('..')
    sr = os.path.join(*(lst + [srcfile]))
    sr2 = os.path.join(*(lst + [node.parent.srcpath(env)]))
    aux_node = node.change_ext('.aux')
    idx_node = node.change_ext('.idx')
    hash = ''
    old_hash = ''
    nm = aux_node.name
    docuname = nm[:len(nm) - 4]
    latex_compile_cmd = 'cd %s && TEXINPUTS=%s:$TEXINPUTS %s %s' % (
        reldir, sr2, com, sr)
    warn('first pass on %s' % command)
    ret = bld.exec_command(latex_compile_cmd)
    if ret: return ret
    try:
        ct = Utils.readf(aux_node.abspath(env))
    except (OSError, IOError):
        error('error bibtex scan')
    else:
        fo = g_bibtex_re.findall(ct)
        if fo:
            bibtex_compile_cmd = 'cd %s && BIBINPUTS=%s:$BIBINPUTS %s %s' % (
                reldir, sr2, env['BIBTEX'], docuname)
            warn('calling bibtex')
            ret = bld.exec_command(bibtex_compile_cmd)
            if ret:
                error('error when calling bibtex %s' % bibtex_compile_cmd)
                return ret
    try:
        idx_path = idx_node.abspath(env)
        os.stat(idx_path)
    except OSError:
        error('error file.idx scan')
    else:
        makeindex_compile_cmd = 'cd %s && %s %s' % (reldir, env['MAKEINDEX'],
                                                    idx_path)
        warn('calling makeindex')
        ret = bld.exec_command(makeindex_compile_cmd)
        if ret:
            error('error when calling makeindex %s' % makeindex_compile_cmd)
            return ret
    i = 0
    while i < 10:
        i += 1
        old_hash = hash
        try:
            hash = Utils.h_file(aux_node.abspath(env))
        except KeyError:
            error('could not read aux.h -> %s' % aux_node.abspath(env))
            pass
        if hash and hash == old_hash: break
        warn('calling %s' % command)
        ret = bld.exec_command(latex_compile_cmd)
        if ret:
            error('error when calling %s %s' % (command, latex_compile_cmd))
            return ret
    return 0
Ejemplo n.º 44
0
def find_msvc(conf):
    # due to path format limitations, limit operation only to native Win32. Yeah it sucks.
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )

    v = conf.env

    compiler, version, path, includes, libdirs = detect_msvc(conf)

    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or (
        compiler == 'wsdk'
        and float(version) >= 6) or (compiler == 'intel'
                                     and float(version) >= 11)

    # compiler
    cxx = None
    if v.CXX: cxx = v.CXX
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name,
                                var='CXX',
                                path_list=path,
                                mandatory=True)
    cxx = conf.cmd_to_list(cxx)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')

    link = v.LINK_CXX
    if not link:
        link = conf.find_program(linker_name, path_list=path, mandatory=True)
    ar = v.AR
    if not ar:
        ar = conf.find_program(lib_name, path_list=path, mandatory=True)

    # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
    mt = v.MT
    if has_msvc_manifest:
        mt = conf.find_program('MT', path_list=path, mandatory=True)

    # no more possibility of failure means the data state will be consistent
    # we may store the data safely now

    v.MSVC_MANIFEST = has_msvc_manifest
    v.PATH = path
    v.CPPPATH = includes
    v.LIBPATH = libdirs

    # c/c++ compiler
    v.CC = v.CXX = cxx
    v.CC_NAME = v.CXX_NAME = 'msvc'

    v.LINK = v.LINK_CXX = link
    if not v.LINK_CC:
        v.LINK_CC = v.LINK_CXX

    v.AR = ar
    v.MT = mt
    v.MTFLAGS = v.ARFLAGS = ['/NOLOGO']

    conf.check_tool('winres')

    if not conf.env.WINRC:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')

    # environment flags
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass
Ejemplo n.º 45
0
Archivo: tex.py Proyecto: anandu/pylibs
def tex_build(task, command='LATEX'):
	env = task.env
	bld = task.generator.bld

	if not env['PROMPT_LATEX']:
		env.append_value('LATEXFLAGS', '-interaction=batchmode')
		env.append_value('PDFLATEXFLAGS', '-interaction=batchmode')

	fun = latex_fun
	if command == 'PDFLATEX':
		fun = pdflatex_fun

	node = task.inputs[0]
	reldir  = node.bld_dir(env)

	lst = []
	for c in Utils.split_path(reldir):
		if c: lst.append('..')
	srcfile = os.path.join(*(lst + [node.srcpath(env)]))
	sr2 = os.path.join(*(lst + [node.parent.srcpath(env)]))

	aux_node = node.change_ext('.aux')
	idx_node = node.change_ext('.idx')

	nm = aux_node.name
	docuname = nm[ : len(nm) - 4 ] # 4 is the size of ".aux"

	# important, set the cwd for everybody
	task.cwd = task.inputs[0].parent.abspath(task.env)


	warn('first pass on %s' % command)

	task.env.env = {'TEXINPUTS': sr2 + os.pathsep}
	task.env.SRCFILE = srcfile
	ret = fun(task)
	if ret:
		return ret

	# look in the .aux file if there is a bibfile to process
	try:
		ct = Utils.readf(aux_node.abspath(env))
	except (OSError, IOError):
		error('error bibtex scan')
	else:
		fo = g_bibtex_re.findall(ct)

		# there is a .aux file to process
		if fo:
			warn('calling bibtex')

			task.env.env = {'BIBINPUTS': sr2 + os.pathsep, 'BSTINPUTS': sr2 + os.pathsep}
			task.env.SRCFILE = docuname
			ret = bibtex_fun(task)
			if ret:
				error('error when calling bibtex %s' % docuname)
				return ret

	# look on the filesystem if there is a .idx file to process
	try:
		idx_path = idx_node.abspath(env)
		os.stat(idx_path)
	except OSError:
		error('error file.idx scan')
	else:
		warn('calling makeindex')

		task.env.SRCFILE = idx_node.name
		task.env.env = {}
		ret = makeindex_fun(task)
		if ret:
			error('error when calling makeindex %s' % idx_path)
			return ret


	hash = ''
	i = 0
	while i < 10:
		# prevent against infinite loops - one never knows
		i += 1

		# watch the contents of file.aux
		prev_hash = hash
		try:
			hash = Utils.h_file(aux_node.abspath(env))
		except KeyError:
			error('could not read aux.h -> %s' % aux_node.abspath(env))
			pass

		# debug
		#print "hash is, ", hash, " ", old_hash

		# stop if file.aux does not change anymore
		if hash and hash == prev_hash:
			break

		# run the command
		warn('calling %s' % command)

		task.env.env = {'TEXINPUTS': sr2 + os.pathsep}
		task.env.SRCFILE = srcfile
		ret = fun(task)
		if ret:
			error('error when calling %s %s' % (command, latex_compile_cmd))
			return ret

	return None # ok
Ejemplo n.º 46
0
def tex_build(task, command='LATEX'):
	env = task.env
	bld = task.generator.bld

	if not env['PROMPT_LATEX']:
		env.append_value('LATEXFLAGS', '-interaction=batchmode')
		env.append_value('PDFLATEXFLAGS', '-interaction=batchmode')

	fun = latex_fun
	if command == 'PDFLATEX':
		fun = pdflatex_fun

	node = task.inputs[0]
	reldir  = node.bld_dir(env)

	#lst = []
	#for c in Utils.split_path(reldir):
	#	if c: lst.append('..')
	#srcfile = os.path.join(*(lst + [node.srcpath(env)]))
	#sr2 = os.path.join(*(lst + [node.parent.srcpath(env)]))
	srcfile = node.abspath(env)
	sr2 = node.parent.abspath() + os.pathsep + node.parent.abspath(env) + os.pathsep

	aux_node = node.change_ext('.aux')
	idx_node = node.change_ext('.idx')

	nm = aux_node.name
	docuname = nm[ : len(nm) - 4 ] # 4 is the size of ".aux"

	# important, set the cwd for everybody
	task.cwd = task.inputs[0].parent.abspath(task.env)


	warn('first pass on %s' % command)

	task.env.env = {'TEXINPUTS': sr2}
	task.env.SRCFILE = srcfile
	ret = fun(task)
	if ret:
		return ret

	# look in the .aux file if there is a bibfile to process
	try:
		ct = Utils.readf(aux_node.abspath(env))
	except (OSError, IOError):
		error('error bibtex scan')
	else:
		fo = g_bibtex_re.findall(ct)

		# there is a .aux file to process
		if fo:
			warn('calling bibtex')

			task.env.env = {'BIBINPUTS': sr2, 'BSTINPUTS': sr2}
			task.env.SRCFILE = docuname
			ret = bibtex_fun(task)
			if ret:
				error('error when calling bibtex %s' % docuname)
				return ret

	# look on the filesystem if there is a .idx file to process
	try:
		idx_path = idx_node.abspath(env)
		os.stat(idx_path)
	except OSError:
		error('error file.idx scan')
	else:
		warn('calling makeindex')

		task.env.SRCFILE = idx_node.name
		task.env.env = {}
		ret = makeindex_fun(task)
		if ret:
			error('error when calling makeindex %s' % idx_path)
			return ret


	hash = ''
	i = 0
	while i < 10:
		# prevent against infinite loops - one never knows
		i += 1

		# watch the contents of file.aux
		prev_hash = hash
		try:
			hash = Utils.h_file(aux_node.abspath(env))
		except KeyError:
			error('could not read aux.h -> %s' % aux_node.abspath(env))
			pass

		# debug
		#print "hash is, ", hash, " ", old_hash

		# stop if file.aux does not change anymore
		if hash and hash == prev_hash:
			break

		# run the command
		warn('calling %s' % command)

		task.env.env = {'TEXINPUTS': sr2 + os.pathsep}
		task.env.SRCFILE = srcfile
		ret = fun(task)
		if ret:
			error('error when calling %s %s' % (command, latex_fun))
			return ret

	return None # ok
Ejemplo n.º 47
0
def prepare_impl(t, cwd, ver, wafdir):
    Options.tooldir = [t]
    Options.launch_dir = cwd

    # some command-line options can be processed immediately
    if '--version' in sys.argv:
        opt_obj = Options.Handler()
        opt_obj.curdir = cwd
        opt_obj.parse_args()
        sys.exit(0)

    # now find the wscript file
    msg1 = 'Waf: Please run waf from a directory containing a file named "%s" or run distclean' % WSCRIPT_FILE

    # in theory projects can be configured in an autotool-like manner:
    # mkdir build && cd build && ../waf configure && ../waf
    build_dir_override = None
    candidate = None

    lst = os.listdir(cwd)

    search_for_candidate = True
    if WSCRIPT_FILE in lst:
        candidate = cwd

    elif 'configure' in sys.argv and not WSCRIPT_BUILD_FILE in lst:
        # autotool-like configuration
        calldir = os.path.abspath(os.path.dirname(sys.argv[0]))
        if WSCRIPT_FILE in os.listdir(calldir):
            candidate = calldir
            search_for_candidate = False
        else:
            error('arg[0] directory does not contain a wscript file')
            sys.exit(1)
        build_dir_override = cwd

    # climb up to find a script if it is not found
    while search_for_candidate:
        if len(cwd) <= 3:
            break  # stop at / or c:
        dirlst = os.listdir(cwd)
        if WSCRIPT_FILE in dirlst:
            candidate = cwd
        if 'configure' in sys.argv and candidate:
            break
        if Options.lockfile in dirlst:
            env = Environment.Environment()
            try:
                env.load(os.path.join(cwd, Options.lockfile))
            except:
                error('could not load %r' % Options.lockfile)
            try:
                os.stat(env['cwd'])
            except:
                candidate = cwd
            else:
                candidate = env['cwd']
            break
        cwd = os.path.dirname(cwd)  # climb up

    if not candidate:
        # check if the user only wanted to display the help
        if '-h' in sys.argv or '--help' in sys.argv:
            warn('No wscript file found: the help message may be incomplete')
            opt_obj = Options.Handler()
            opt_obj.curdir = cwd
            opt_obj.parse_args()
        else:
            error(msg1)
        sys.exit(0)

    # We have found wscript, but there is no guarantee that it is valid
    try:
        os.chdir(candidate)
    except OSError:
        raise Utils.WafError("the folder %r is unreadable" % candidate)

    # define the main module containing the functions init, shutdown, ..
    Utils.set_main_module(os.path.join(candidate, WSCRIPT_FILE))

    if build_dir_override:
        d = getattr(Utils.g_module, BLDDIR, None)
        if d:
            # test if user has set the blddir in wscript.
            msg = ' Overriding build directory %s with %s' % (
                d, build_dir_override)
            warn(msg)
        Utils.g_module.blddir = build_dir_override

    # bind a few methods and classes by default

    def set_def(obj, name=''):
        n = name or obj.__name__
        if not n in Utils.g_module.__dict__:
            setattr(Utils.g_module, n, obj)

    for k in [dist, distclean, distcheck, clean, install, uninstall]:
        set_def(k)

    set_def(Configure.ConfigurationContext, 'configure_context')

    for k in ['build', 'clean', 'install', 'uninstall']:
        set_def(Build.BuildContext, k + '_context')

    # now parse the options from the user wscript file
    opt_obj = Options.Handler(Utils.g_module)
    opt_obj.curdir = candidate
    try:
        f = Utils.g_module.set_options
    except AttributeError:
        pass
    else:
        opt_obj.sub_options([''])
    opt_obj.parse_args()

    if not 'init' in Utils.g_module.__dict__:
        Utils.g_module.init = Utils.nada
    if not 'shutdown' in Utils.g_module.__dict__:
        Utils.g_module.shutdown = Utils.nada

    main()
Ejemplo n.º 48
0
def tex_build(task, command='LATEX'):
    env = task.env
    bld = task.generator.bld
    if not env['PROMPT_LATEX']:
        env.append_value('LATEXFLAGS', '-interaction=batchmode')
        env.append_value('PDFLATEXFLAGS', '-interaction=batchmode')
    fun = latex_fun
    if command == 'PDFLATEX':
        fun = pdflatex_fun
    node = task.inputs[0]
    reldir = node.bld_dir(env)
    lst = []
    for c in Utils.split_path(reldir):
        if c: lst.append('..')
    srcfile = os.path.join(*(lst + [node.srcpath(env)]))
    sr2 = os.path.join(*(lst + [node.parent.srcpath(env)]))
    aux_node = node.change_ext('.aux')
    idx_node = node.change_ext('.idx')
    nm = aux_node.name
    docuname = nm[:len(nm) - 4]
    task.cwd = task.inputs[0].parent.abspath(task.env)
    warn('first pass on %s' % command)
    task.env.env = {'TEXINPUTS': sr2 + os.pathsep}
    task.env.SRCFILE = srcfile
    ret = fun(task)
    if ret:
        return ret
    try:
        ct = Utils.readf(aux_node.abspath(env))
    except (OSError, IOError):
        error('error bibtex scan')
    else:
        fo = g_bibtex_re.findall(ct)
        if fo:
            warn('calling bibtex')
            task.env.env = {
                'BIBINPUTS': sr2 + os.pathsep,
                'BSTINPUTS': sr2 + os.pathsep
            }
            task.env.SRCFILE = docuname
            ret = bibtex_fun(task)
            if ret:
                error('error when calling bibtex %s' % docuname)
                return ret
    try:
        idx_path = idx_node.abspath(env)
        os.stat(idx_path)
    except OSError:
        error('error file.idx scan')
    else:
        warn('calling makeindex')
        task.env.SRCFILE = idx_node.name
        task.env.env = {}
        ret = makeindex_fun(task)
        if ret:
            error('error when calling makeindex %s' % idx_path)
            return ret
    hash = ''
    i = 0
    while i < 10:
        i += 1
        prev_hash = hash
        try:
            hash = Utils.h_file(aux_node.abspath(env))
        except KeyError:
            error('could not read aux.h -> %s' % aux_node.abspath(env))
            pass
        if hash and hash == prev_hash:
            break
        warn('calling %s' % command)
        task.env.env = {'TEXINPUTS': sr2 + os.pathsep}
        task.env.SRCFILE = srcfile
        ret = fun(task)
        if ret:
            error('error when calling %s %s' % (command, latex_compile_cmd))
            return ret
    return None
Ejemplo n.º 49
0
def find_msvc(conf):
    # due to path format limitations, limit operation only to native Win32. Yeah it sucks.
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )

    v = conf.env

    compiler, path, includes, libdirs = detect_msvc(conf)
    v['PATH'] = path
    v['CPPPATH'] = includes
    v['LIBPATH'] = libdirs

    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)

    # compiler
    cxx = None
    if v['CXX']: cxx = v['CXX']
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name, var='CXX', path_list=path)
    if not cxx: conf.fatal('%s was not found (compiler)' % compiler_name)
    cxx = conf.cmd_to_list(cxx)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')

    # c/c++ compiler
    v['CC'] = v['CXX'] = cxx
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'

    # environment flags
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass

    # linker
    if not v['LINK_CXX']:
        link = conf.find_program(linker_name, path_list=path)
        if link: v['LINK_CXX'] = link
        else: conf.fatal('%s was not found (linker)' % linker_name)
    v['LINK'] = link

    if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX']

    # staticlib linker
    if not v['AR']:
        stliblink = conf.find_program(lib_name, path_list=path)
        if not stliblink: return
        v['AR'] = stliblink
        v['ARFLAGS'] = ['/NOLOGO']

    # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
    manifesttool = conf.find_program('MT', path_list=path)
    if manifesttool:
        v['MT'] = manifesttool
        v['MTFLAGS'] = ['/NOLOGO']

    conf.check_tool('winres')

    if not conf.env['WINRC']:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 50
0
Archivo: tex.py Proyecto: wf744/node
def tex_build(task, command='LATEX'):
    env = task.env
    bld = task.generator.bld

    com = '%s %s' % (env[command], env.get_flat(command + 'FLAGS'))
    if not env['PROMPT_LATEX']: com = "%s %s" % (com, '-interaction=batchmode')

    node = task.inputs[0]
    reldir = node.bld_dir(env)
    srcfile = node.srcpath(env)

    lst = []
    for c in Utils.split_path(reldir):
        if c: lst.append('..')
    sr = os.path.join(*(lst + [srcfile]))
    sr2 = os.path.join(*(lst + [node.parent.srcpath(env)]))

    aux_node = node.change_ext('.aux')
    idx_node = node.change_ext('.idx')

    hash = ''
    old_hash = ''

    nm = aux_node.name
    docuname = nm[:len(nm) - 4]  # 4 is the size of ".aux"

    latex_compile_cmd = 'cd %s && TEXINPUTS=%s:$TEXINPUTS %s %s' % (
        reldir, sr2, com, sr)
    warn('first pass on %s' % command)
    ret = bld.exec_command(latex_compile_cmd)
    if ret: return ret

    # look in the .aux file if there is a bibfile to process
    try:
        ct = Utils.readf(aux_node.abspath(env))
    except (OSError, IOError):
        error('error bibtex scan')
    else:
        fo = g_bibtex_re.findall(ct)

        # yes, there is a .aux file to process
        if fo:
            bibtex_compile_cmd = 'cd %s && BIBINPUTS=%s:$BIBINPUTS %s %s' % (
                reldir, sr2, env['BIBTEX'], docuname)

            warn('calling bibtex')
            ret = bld.exec_command(bibtex_compile_cmd)
            if ret:
                error('error when calling bibtex %s' % bibtex_compile_cmd)
                return ret

    # look on the filesystem if there is a .idx file to process
    try:
        idx_path = idx_node.abspath(env)
        os.stat(idx_path)
    except OSError:
        error('error file.idx scan')
    else:
        makeindex_compile_cmd = 'cd %s && %s %s' % (reldir, env['MAKEINDEX'],
                                                    idx_path)
        warn('calling makeindex')
        ret = bld.exec_command(makeindex_compile_cmd)
        if ret:
            error('error when calling makeindex %s' % makeindex_compile_cmd)
            return ret

    i = 0
    while i < 10:
        # prevent against infinite loops - one never knows
        i += 1

        # watch the contents of file.aux
        old_hash = hash
        try:
            hash = Utils.h_file(aux_node.abspath(env))
        except KeyError:
            error('could not read aux.h -> %s' % aux_node.abspath(env))
            pass

        # debug
        #print "hash is, ", hash, " ", old_hash

        # stop if file.aux does not change anymore
        if hash and hash == old_hash: break

        # run the command
        warn('calling %s' % command)
        ret = bld.exec_command(latex_compile_cmd)
        if ret:
            error('error when calling %s %s' % (command, latex_compile_cmd))
            return ret

    # 0 means no error
    return 0
Ejemplo n.º 51
0
def find_msvc(conf):
	# due to path format limitations, limit operation only to native Win32. Yeah it sucks.
	if sys.platform != 'win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')

	v = conf.env

	compiler, version, path, includes, libdirs = detect_msvc(conf)

	compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
	has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or (compiler == 'wsdk' and float(version) >= 6)	or (compiler == 'intel' and float(version) >= 11)

	# compiler
	cxx = None
	if v.CXX: cxx = v.CXX
	elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
	if not cxx: cxx = conf.find_program(compiler_name, var='CXX', path_list=path, mandatory=True)
	cxx = conf.cmd_to_list(cxx)

	# before setting anything, check if the compiler is really msvc
	env = dict(conf.environ)
	env.update(PATH = ';'.join(path))
	if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
		conf.fatal('the msvc compiler could not be identified')

	link = v.LINK_CXX
	if not link:
		link = conf.find_program(linker_name, path_list=path, mandatory=True)
	ar = v.AR
	if not ar:
		ar = conf.find_program(lib_name, path_list=path, mandatory=True)

	# manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
	mt = v.MT
	if has_msvc_manifest:
		mt = conf.find_program('MT', path_list=path, mandatory=True)

	# no more possibility of failure means the data state will be consistent
	# we may store the data safely now

	v.MSVC_MANIFEST = has_msvc_manifest
	v.PATH = path
	v.CPPPATH = includes
	v.LIBPATH = libdirs

	# c/c++ compiler
	v.CC = v.CXX = cxx
	v.CC_NAME = v.CXX_NAME = 'msvc'

	v.LINK = v.LINK_CXX = link
	if not v.LINK_CC:
		v.LINK_CC = v.LINK_CXX

	v.AR = ar
	v.MT = mt
	v.MTFLAGS = v.ARFLAGS = ['/NOLOGO']


	conf.check_tool('winres')

	if not conf.env.WINRC:
		warn('Resource compiler not found. Compiling resource file is disabled')

	# environment flags
	try: v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
	except KeyError: pass
	try: v.prepend_value('LIBPATH', conf.environ['LIB'])
	except KeyError: pass
Ejemplo n.º 52
0
def prepare_impl(t, cwd, ver, wafdir):
	Options.tooldir = [t]
	Options.launch_dir = cwd

	# some command-line options can be processed immediately
	if '--version' in sys.argv:
		opt_obj = Options.Handler()
		opt_obj.curdir = cwd
		opt_obj.parse_args()
		sys.exit(0)

	# now find the wscript file
	msg1 = 'Waf: Please run waf from a directory containing a file named "%s" or run distclean' % WSCRIPT_FILE

	# in theory projects can be configured in an autotool-like manner:
	# mkdir build && cd build && ../waf configure && ../waf
	build_dir_override = None
	candidate = None

	lst = os.listdir(cwd)

	search_for_candidate = True
	if WSCRIPT_FILE in lst:
		candidate = cwd

	elif 'configure' in sys.argv and not WSCRIPT_BUILD_FILE in lst:
		# autotool-like configuration
		calldir = os.path.abspath(os.path.dirname(sys.argv[0]))
		if WSCRIPT_FILE in os.listdir(calldir):
			candidate = calldir
			search_for_candidate = False
		else:
			error('arg[0] directory does not contain a wscript file')
			sys.exit(1)
		build_dir_override = cwd

	# climb up to find a script if it is not found
	while search_for_candidate:
		if len(cwd) <= 3:
			break # stop at / or c:
		dirlst = os.listdir(cwd)
		if WSCRIPT_FILE in dirlst:
			candidate = cwd
		if 'configure' in sys.argv and candidate:
			break
		if Options.lockfile in dirlst:
			env = Environment.Environment()
			try:
				env.load(os.path.join(cwd, Options.lockfile))
			except:
				error('could not load %r' % Options.lockfile)
			try:
				os.stat(env['cwd'])
			except:
				candidate = cwd
			else:
				candidate = env['cwd']
			break
		cwd = os.path.dirname(cwd) # climb up

	if not candidate:
		# check if the user only wanted to display the help
		if '-h' in sys.argv or '--help' in sys.argv:
			warn('No wscript file found: the help message may be incomplete')
			opt_obj = Options.Handler()
			opt_obj.curdir = cwd
			opt_obj.parse_args()
		else:
			error(msg1)
		sys.exit(0)

	# We have found wscript, but there is no guarantee that it is valid
	try:
		os.chdir(candidate)
	except OSError:
		raise Utils.WafError("the folder %r is unreadable" % candidate)

	# define the main module containing the functions init, shutdown, ..
	Utils.set_main_module(os.path.join(candidate, WSCRIPT_FILE))

	if build_dir_override:
		d = getattr(Utils.g_module, BLDDIR, None)
		if d:
			# test if user has set the blddir in wscript.
			msg = ' Overriding build directory %s with %s' % (d, build_dir_override)
			warn(msg)
		Utils.g_module.blddir = build_dir_override

	# bind a few methods and classes by default

	def set_def(obj, name=''):
		n = name or obj.__name__
		if not n in Utils.g_module.__dict__:
			setattr(Utils.g_module, n, obj)

	for k in [dist, distclean, distcheck, clean, install, uninstall]:
		set_def(k)

	set_def(Configure.ConfigurationContext, 'configure_context')

	for k in ['build', 'clean', 'install', 'uninstall']:
		set_def(Build.BuildContext, k + '_context')

	# now parse the options from the user wscript file
	opt_obj = Options.Handler(Utils.g_module)
	opt_obj.curdir = candidate
	try:
		f = Utils.g_module.set_options
	except AttributeError:
		pass
	else:
		opt_obj.sub_options([''])
	opt_obj.parse_args()

	if not 'init' in Utils.g_module.__dict__:
		Utils.g_module.init = Utils.nada
	if not 'shutdown' in Utils.g_module.__dict__:
		Utils.g_module.shutdown = Utils.nada

	main()
Ejemplo n.º 53
0
def prepare_impl(t,cwd,ver,wafdir):
	Options.tooldir=[t]
	Options.launch_dir=cwd
	if'--version'in sys.argv:
		opt_obj=Options.Handler()
		opt_obj.curdir=cwd
		opt_obj.parse_args()
		sys.exit(0)
	msg1='Waf: Please run waf from a directory containing a file named "%s" or run distclean'%WSCRIPT_FILE
	build_dir_override=None
	candidate=None
	lst=os.listdir(cwd)
	search_for_candidate=True
	if WSCRIPT_FILE in lst:
		candidate=cwd
	elif'configure'in sys.argv and not WSCRIPT_BUILD_FILE in lst:
		calldir=os.path.abspath(os.path.dirname(sys.argv[0]))
		if WSCRIPT_FILE in os.listdir(calldir):
			candidate=calldir
			search_for_candidate=False
		else:
			error('arg[0] directory does not contain a wscript file')
			sys.exit(1)
		build_dir_override=cwd
	while search_for_candidate:
		if len(cwd)<=3:
			break
		dirlst=os.listdir(cwd)
		if WSCRIPT_FILE in dirlst:
			candidate=cwd
		if'configure'in sys.argv and candidate:
			break
		if Options.lockfile in dirlst:
			env=Environment.Environment()
			try:
				env.load(os.path.join(cwd,Options.lockfile))
			except:
				error('could not load %r'%Options.lockfile)
			try:
				os.stat(env['cwd'])
			except:
				candidate=cwd
			else:
				candidate=env['cwd']
			break
		cwd=os.path.dirname(cwd)
	if not candidate:
		if'-h'in sys.argv or'--help'in sys.argv:
			warn('No wscript file found: the help message may be incomplete')
			opt_obj=Options.Handler()
			opt_obj.curdir=cwd
			opt_obj.parse_args()
		else:
			error(msg1)
		sys.exit(0)
	try:
		os.chdir(candidate)
	except OSError:
		raise Utils.WafError("the folder %r is unreadable"%candidate)
	Utils.set_main_module(os.path.join(candidate,WSCRIPT_FILE))
	if build_dir_override:
		d=getattr(Utils.g_module,BLDDIR,None)
		if d:
			msg=' Overriding build directory %s with %s'%(d,build_dir_override)
			warn(msg)
		Utils.g_module.blddir=build_dir_override
	def set_def(obj,name=''):
		n=name or obj.__name__
		if not n in Utils.g_module.__dict__:
			setattr(Utils.g_module,n,obj)
	for k in[dist,distclean,distcheck,clean,install,uninstall]:
		set_def(k)
	set_def(Configure.ConfigurationContext,'configure_context')
	for k in['build','clean','install','uninstall']:
		set_def(Build.BuildContext,k+'_context')
	opt_obj=Options.Handler(Utils.g_module)
	opt_obj.curdir=candidate
	try:
		f=Utils.g_module.set_options
	except AttributeError:
		pass
	else:
		opt_obj.sub_options([''])
	opt_obj.parse_args()
	if not'init'in Utils.g_module.__dict__:
		Utils.g_module.init=Utils.nada
	if not'shutdown'in Utils.g_module.__dict__:
		Utils.g_module.shutdown=Utils.nada
	main()