Ejemplo n.º 1
0
def get_pgi_version(conf, cc):
	"""Find the version of a pgi compiler."""
	version_re = re.compile(r"The Portland Group", re.I).search
	cmd = cc + ['-V', '-E'] # Issue 1078, prevent wrappers from linking

	try:
		out, err = conf.cmd_and_log(cmd, output=0)
	except Exception:
		conf.fatal('Could not find pgi compiler %r' % cmd)

	if out: match = version_re(out)
	else: match = version_re(err)

	if not match:
		conf.fatal('Could not verify PGI signature')

	cmd = cc + ['-help=variable']
	try:
		out, err = conf.cmd_and_log(cmd, output=0)
	except Exception:
		conf.fatal('Could not find pgi compiler %r' % cmd)

	version = re.findall('^COMPVER\s*=(.*)', out, re.M)
	if len(version) != 1:
		conf.fatal('Could not determine the compiler version')
	return version[0]
Ejemplo n.º 2
0
def find_sxx(conf):
    """
	Detect the sun C++ compiler
	"""
    v = conf.env
    cc = None
    if v["CXX"]:
        cc = v["CXX"]
    elif "CXX" in conf.environ:
        cc = conf.environ["CXX"]
    if not cc:
        cc = conf.find_program("CC", var="CXX")  # studio
    if not cc:
        cc = conf.find_program("c++", var="CXX")
    if not cc:
        conf.fatal("Could not find a Sun C++ compiler")

    try:
        conf.cmd_and_log(cc + ["-flags"])
    except Exception:
        conf.fatal("%r is not a Sun compiler" % cc)

    v["CXX"] = cc
    v["CXX_NAME"] = "sun"
    conf.get_suncc_version(cc)
Ejemplo n.º 3
0
def find_dmd(conf):
	conf.find_program(['dmd','dmd2','ldc'],var='D')
	out=conf.cmd_and_log([conf.env.D,'--help'])
	if out.find("D Compiler v")==-1:
		out=conf.cmd_and_log([conf.env.D,'-version'])
		if out.find("based on DMD v1.")==-1:
			conf.fatal("detected compiler is not dmd/ldc")
Ejemplo n.º 4
0
def check_python_module(conf, module_name):
    conf.start_msg("Python module %s" % module_name)
    try:
        conf.cmd_and_log(conf.env["PYTHON"] + ["-c", PYTHON_MODULE_TEMPLATE % module_name])
    except:
        conf.end_msg(False)
        conf.fatal("Could not find the python module %r" % module_name)
    conf.end_msg(True)
Ejemplo n.º 5
0
def check_python_module(conf,module_name):
	conf.start_msg('Python module %s'%module_name)
	try:
		conf.cmd_and_log([conf.env['PYTHON'],'-c','import %s\nprint(1)\n'%module_name])
	except:
		conf.end_msg(False)
		conf.fatal('Could not find the python module %r'%module_name)
	conf.end_msg(True)
Ejemplo n.º 6
0
def check_python_module(conf,module_name):
	conf.start_msg('Python module %s'%module_name)
	try:
		conf.cmd_and_log(conf.env['PYTHON']+['-c',PYTHON_MODULE_TEMPLATE%module_name])
	except:
		conf.end_msg(False)
		conf.fatal('Could not find the python module %r'%module_name)
	conf.end_msg(True)
Ejemplo n.º 7
0
def find_scc(conf):
	v=conf.env
	cc=conf.find_program('cc',var='CC')
	try:
		conf.cmd_and_log(cc+['-flags'])
	except Exception:
		conf.fatal('%r is not a Sun compiler'%cc)
	v.CC_NAME='sun'
	conf.get_suncc_version(cc)
Ejemplo n.º 8
0
Archivo: suncc.py Proyecto: faddat/lib
def find_scc(conf):
    v = conf.env
    cc = conf.find_program("cc", var="CC")
    try:
        conf.cmd_and_log(cc + ["-flags"])
    except Exception:
        conf.fatal("%r is not a Sun compiler" % cc)
    v.CC_NAME = "sun"
    conf.get_suncc_version(cc)
Ejemplo n.º 9
0
def find_sxx(conf):
    v = conf.env
    cc = conf.find_program(["CC", "c++"], var="CXX")
    try:
        conf.cmd_and_log(cc + ["-flags"])
    except Exception:
        conf.fatal("%r is not a Sun compiler" % cc)
    v.CXX_NAME = "sun"
    conf.get_suncc_version(cc)
Ejemplo n.º 10
0
def find_sxx(conf):
	v=conf.env
	cc=conf.find_program(['CC','c++'],var='CXX')
	try:
		conf.cmd_and_log(cc+['-flags'])
	except Exception:
		conf.fatal('%r is not a Sun compiler'%cc)
	v.CXX_NAME='sun'
	conf.get_suncc_version(cc)
Ejemplo n.º 11
0
Archivo: msvc.py Proyecto: 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)
Ejemplo n.º 12
0
Archivo: msvc.py Proyecto: 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)
Ejemplo n.º 13
0
def check_python_module(conf, module_name):
	"""
	Check if the selected python interpreter can import the given python module.
	"""
	conf.start_msg('Python module %s' % module_name)
	try:
		conf.cmd_and_log([conf.env['PYTHON'], '-c', 'import %s\nprint(1)\n' % module_name])
	except:
		conf.end_msg(False)
		conf.fatal('Could not find the python module %r' % module_name)
	conf.end_msg(True)
Ejemplo n.º 14
0
def find_scc(conf):
	"""
	Detects the Sun C compiler
	"""
	v = conf.env
	cc = conf.find_program('cc', var='CC')
	try:
		conf.cmd_and_log(cc + ['-flags'])
	except Errors.WafError:
		conf.fatal('%r is not a Sun compiler' % cc)
	v.CC_NAME = 'sun'
	conf.get_suncc_version(cc)
Ejemplo n.º 15
0
Archivo: dmd.py Proyecto: afeldman/waf
def find_dmd(conf):
	"""
	Finds the program *dmd*, *dmd2*, or *ldc* and set the variable *D*
	"""
	conf.find_program(['dmd', 'dmd2', 'ldc'], var='D')

	# make sure that we're dealing with dmd1, dmd2, or ldc(1)
	out = conf.cmd_and_log(conf.env.D + ['--help'])
	if out.find("D Compiler v") == -1:
		out = conf.cmd_and_log(conf.env.D + ['-version'])
		if out.find("based on DMD v1.") == -1:
			conf.fatal("detected compiler is not dmd/ldc")
Ejemplo n.º 16
0
def find_sxx(conf):
	"""
	Detects the sun C++ compiler
	"""
	v = conf.env
	cc = conf.find_program(['CC', 'c++'], var='CXX')
	try:
		conf.cmd_and_log(cc + ['-flags'])
	except Errors.WafError:
		conf.fatal('%r is not a Sun compiler' % cc)
	v.CXX_NAME = 'sun'
	conf.get_suncc_version(cc)
Ejemplo n.º 17
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)
Ejemplo n.º 18
0
def find_scc(conf):
	v=conf.env
	cc=None
	if v['CC']:cc=v['CC']
	elif'CC'in conf.environ:cc=conf.environ['CC']
	if not cc:cc=conf.find_program('cc',var='CC')
	if not cc:conf.fatal('suncc was not found')
	try:
		conf.cmd_and_log('%s -flags'%cc)
	except:
		conf.fatal('suncc %r was not found'%cc)
	v['CC']=cc
	v['CC_NAME']='sun'
Ejemplo n.º 19
0
def find_irixcc(conf):
	v=conf.env
	cc=None
	if v['CC']:cc=v['CC']
	elif'CC'in conf.environ:cc=conf.environ['CC']
	if not cc:cc=conf.find_program('cc',var='CC')
	if not cc:conf.fatal('irixcc was not found')
	try:
		conf.cmd_and_log(cc+['-version'])
	except Exception:
		conf.fatal('%r -version could not be executed'%cc)
	v['CC']=cc
	v['CC_NAME']='irix'
Ejemplo n.º 20
0
def find_scc(conf):
	v=conf.env
	cc=None
	if v['CC']:cc=v['CC']
	elif'CC'in conf.environ:cc=conf.environ['CC']
	if not cc:cc=conf.find_program('cc',var='CC')
	if not cc:conf.fatal('Could not find a Sun C compiler')
	try:
		conf.cmd_and_log('%s -flags'%cc)
	except:
		conf.fatal('%r is not a Sun compiler'%cc)
	v['CC']=cc
	v['CC_NAME']='sun'
Ejemplo n.º 21
0
def find_sxx(conf):
	v=conf.env
	cc=None
	if v['CXX']:cc=v['CXX']
	elif'CXX'in conf.environ:cc=conf.environ['CXX']
	if not cc:cc=conf.find_program('CC',var='CXX')
	if not cc:cc=conf.find_program('c++',var='CXX')
	if not cc:conf.fatal('Could not find a Sun C++ compiler')
	cc=conf.cmd_to_list(cc)
	try:
		conf.cmd_and_log(cc+['-flags'])
	except:
		conf.fatal('%r is not a Sun compiler'%cc)
	v['CXX']=cc
	v['CXX_NAME']='sun'
Ejemplo n.º 22
0
def find_scc(conf):
	v=conf.env
	cc=None
	if v['CC']:cc=v['CC']
	elif'CC'in conf.environ:cc=conf.environ['CC']
	if not cc:cc=conf.find_program('cc',var='CC')
	if not cc:conf.fatal('Could not find a Sun C compiler')
	cc=conf.cmd_to_list(cc)
	try:
		conf.cmd_and_log(cc+['-flags'])
	except Exception:
		conf.fatal('%r is not a Sun compiler'%cc)
	v['CC']=cc
	v['CC_NAME']='sun'
	conf.get_suncc_version(cc)
Ejemplo n.º 23
0
def _check_default_arch(conf,
                        start_msg,
                        fragment,
                        output_var,
                        compile_filename="test.c",
                        features="c cprogram"):
    env = conf.env

    if not "FILE_BIN" in conf.env:
        file_bin = conf.find_program(["file"], var="FILE_BIN")
    else:
        file_bin = conf.env.FILE_BIN

    conf.start_msg(start_msg)
    ret = conf.check_cc(fragment=fragment,
                        compile_filename=compile_filename,
                        features=features)
    task_gen = conf.test_bld.groups[0][0]
    obj_filename = task_gen.tasks[0].outputs[0].abspath()
    out = conf.cmd_and_log([file_bin, obj_filename])
    m = FILE_MACHO_RE.search(out)
    if m is None:
        conf.fatal("Could not determine arch from output %r" % out)
    else:
        default_arch = m.group(1)
        conf.env[output_var] = default_arch
        conf.end_msg(default_arch)
Ejemplo n.º 24
0
def find_ifort_win32(conf):
    v = conf.env
    path = v['PATH']
    compiler = v['MSVC_COMPILER']
    version = v['MSVC_VERSION']
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    v.IFORT_MANIFEST = (compiler == 'intel' and version >= 11)
    fc = conf.find_program(compiler_name, var='FC', path_list=path)
    env = dict(conf.environ)
    if path: env.update(PATH=';'.join(path))
    if not conf.cmd_and_log(fc + ['/nologo', '/help'], env=env):
        conf.fatal('not intel fortran compiler could not be identified')
    v['FC_NAME'] = 'IFORT'
    if not v['LINK_FC']:
        conf.find_program(linker_name,
                          var='LINK_FC',
                          path_list=path,
                          mandatory=True)
    if not v['AR']:
        conf.find_program(lib_name, path_list=path, var='AR', mandatory=True)
        v['ARFLAGS'] = ['/NOLOGO']
    if v.IFORT_MANIFEST:
        conf.find_program('MT', path_list=path, var='MT')
        v['MTFLAGS'] = ['/NOLOGO']
    try:
        conf.load('winres')
    except Errors.WafError:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
def getoutput(conf, cmd, stdin=False):
    """
	Obtains Fortran command outputs
	"""
    from waflib import Errors
    if conf.env.env:
        env = conf.env.env
    else:
        env = dict(os.environ)
        env['LANG'] = 'C'
    input = stdin and '\n'.encode() or None
    try:
        out, err = conf.cmd_and_log(cmd, env=env, output=0, input=input)
    except Errors.WafError as e:
        # An WafError might indicate an error code during the command
        # execution, in this case we still obtain the stderr and stdout,
        # which we can use to find the version string.
        if not (hasattr(e, 'stderr') and hasattr(e, 'stdout')):
            raise e
        else:
            # Ignore the return code and return the original
            # stdout and stderr.
            out = e.stdout
            err = e.stderr
    except Exception:
        conf.fatal('could not determine the compiler version %r' % cmd)
    return (out, err)
Ejemplo n.º 26
0
def check_python_module(conf, module_name, condition=''):
    msg = "Checking for python module '%s'" % module_name
    if condition:
        msg = '%s (%s)' % (msg, condition)
    conf.start_msg(msg)
    try:
        ret = conf.cmd_and_log(conf.env['PYTHON'] +
                               ['-c', PYTHON_MODULE_TEMPLATE % module_name])
    except Exception:
        conf.end_msg(False)
        conf.fatal('Could not find the python module %r' % module_name)
    ret = ret.strip()
    if condition:
        conf.end_msg(ret)
        if ret == 'unknown version':
            conf.fatal('Could not check the %s version' % module_name)
        from distutils.version import LooseVersion

        def num(*k):
            if isinstance(k[0], int):
                return LooseVersion('.'.join([str(x) for x in k]))
            else:
                return LooseVersion(k[0])

        d = {'num': num, 'ver': LooseVersion(ret)}
        ev = eval(condition, {}, d)
        if not ev:
            conf.fatal('The %s version does not satisfy the requirements' %
                       module_name)
    else:
        if ret == 'unknown version':
            conf.end_msg(True)
        else:
            conf.end_msg(ret)
Ejemplo n.º 27
0
def configure(conf):
    """
	Detect the python interpreter
	"""
    v = conf.env
    if getattr(Options.options, 'pythondir', None):
        v.PYTHONDIR = Options.options.pythondir
    if getattr(Options.options, 'pythonarchdir', None):
        v.PYTHONARCHDIR = Options.options.pythonarchdir
    if getattr(Options.options, 'nopycache', None):
        v.NOPYCACHE = Options.options.nopycache

    if not v.PYTHON:
        v.PYTHON = [getattr(Options.options, 'python', None) or sys.executable]
    v.PYTHON = Utils.to_list(v.PYTHON)
    conf.find_program('python', var='PYTHON')

    v.PYFLAGS = ''
    v.PYFLAGS_OPT = '-O'

    v.PYC = getattr(Options.options, 'pyc', 1)
    v.PYO = getattr(Options.options, 'pyo', 1)

    try:
        v.PYTAG = conf.cmd_and_log(
            conf.env.PYTHON +
            ['-c', "import imp;print(imp.get_tag())"]).strip()
    except Errors.WafError:
        pass
Ejemplo n.º 28
0
def configure(conf):
    """
	Detect the python interpreter
	"""
    v = conf.env
    v['PYTHON'] = Options.options.python or os.environ.get(
        'PYTHON', sys.executable)
    if Options.options.pythondir:
        v['PYTHONDIR'] = Options.options.pythondir
    if Options.options.pythonarchdir:
        v['PYTHONARCHDIR'] = Options.options.pythonarchdir

    conf.find_program('python', var='PYTHON')

    v['PYFLAGS'] = ''
    v['PYFLAGS_OPT'] = '-O'

    v['PYC'] = getattr(Options.options, 'pyc', 1)
    v['PYO'] = getattr(Options.options, 'pyo', 1)

    try:
        v.PYTAG = conf.cmd_and_log(
            conf.env.PYTHON +
            ['-c', "import imp;print(imp.get_tag())"]).strip()
    except Errors.WafError:
        pass
Ejemplo n.º 29
0
def gather_vswhere_versions(conf, versions):
    try:
        import json
    except ImportError:
        Logs.error('Visual Studio 2017 detection requires Python 2.6')
        return

    prg_path = os.environ.get(
        'ProgramFiles(x86)',
        os.environ.get('ProgramFiles', 'C:\\Program Files (x86)'))

    vswhere = os.path.join(prg_path, 'Microsoft Visual Studio', 'Installer',
                           'vswhere.exe')
    args = [vswhere, '-products', '*', '-legacy', '-format', 'json']
    try:
        txt = conf.cmd_and_log(args)
    except Errors.WafError as e:
        Logs.debug('msvc: vswhere.exe failed %s', e)
        return

    if sys.version_info[0] < 3:
        txt = txt.decode(Utils.console_encoding())

    arr = json.loads(txt)
    arr.sort(key=lambda x: x['installationVersion'])
    for entry in arr:
        ver = entry['installationVersion']
        ver = str('.'.join(ver.split('.')[:2]))
        path = str(os.path.abspath(entry['installationPath']))
        if os.path.exists(path) and ('msvc %s' % ver) not in versions:
            conf.gather_msvc_targets(versions, ver, path)
Ejemplo n.º 30
0
def configure(conf):
    """
    Detect the python interpreter
    """
    v = conf.env
    if getattr(Options.options, "pythondir", None):
        v.PYTHONDIR = Options.options.pythondir
    if getattr(Options.options, "pythonarchdir", None):
        v.PYTHONARCHDIR = Options.options.pythonarchdir
    if getattr(Options.options, "nopycache", None):
        v.NOPYCACHE = Options.options.nopycache

    if not v.PYTHON:
        v.PYTHON = [getattr(Options.options, "python", None) or sys.executable]
    v.PYTHON = Utils.to_list(v.PYTHON)
    conf.find_program("python", var="PYTHON")

    v.PYFLAGS = ""
    v.PYFLAGS_OPT = "-O"

    v.PYC = getattr(Options.options, "pyc", 1)
    v.PYO = getattr(Options.options, "pyo", 1)

    try:
        v.PYTAG = conf.cmd_and_log(
            conf.env.PYTHON + ["-c", "import imp;print(imp.get_tag())"]
        ).strip()
    except Errors.WafError:
        pass
Ejemplo n.º 31
0
def gather_vswhere_versions(conf, versions):
    try:
        import json
    except ImportError:
        Logs.error("Visual Studio 2017 detection requires Python 2.6")
        return

    prg_path = os.environ.get(
        "ProgramFiles(x86)",
        os.environ.get("ProgramFiles", "C:\\Program Files (x86)"))

    vswhere = os.path.join(prg_path, "Microsoft Visual Studio", "Installer",
                           "vswhere.exe")
    args = [vswhere, "-products", "*", "-legacy", "-format", "json"]
    try:
        txt = conf.cmd_and_log(args)
    except Errors.WafError as e:
        Logs.debug("msvc: vswhere.exe failed %s", e)
        return

    if sys.version_info[0] < 3:
        txt = txt.decode(Utils.console_encoding())

    arr = json.loads(txt)
    arr.sort(key=lambda x: x["installationVersion"])
    for entry in arr:
        ver = entry["installationVersion"]
        ver = str(".".join(ver.split(".")[:2]))
        path = str(os.path.abspath(entry["installationPath"]))
        if os.path.exists(path) and ("msvc %s" % ver) not in versions:
            conf.gather_msvc_targets(versions, ver, path)
Ejemplo n.º 32
0
def find_sxx(conf):
    v = conf.env
    cc = None
    if v['CXX']: cc = v['CXX']
    elif 'CXX' in conf.environ: cc = conf.environ['CXX']
    if not cc: cc = conf.find_program('CC', var='CXX')
    if not cc: cc = conf.find_program('c++', var='CXX')
    if not cc: conf.fatal('Could not find a Sun C++ compiler')
    cc = conf.cmd_to_list(cc)
    try:
        conf.cmd_and_log(cc + ['-flags'])
    except Exception:
        conf.fatal('%r is not a Sun compiler' % cc)
    v['CXX'] = cc
    v['CXX_NAME'] = 'sun'
    conf.get_suncc_version(cc)
Ejemplo n.º 33
0
def configure(conf):
	"""
	Detect the python interpreter
	"""
	v = conf.env
	if getattr(Options.options, 'pythondir', None):
		v.PYTHONDIR = Options.options.pythondir
	if getattr(Options.options, 'pythonarchdir', None):
		v.PYTHONARCHDIR = Options.options.pythonarchdir
	if getattr(Options.options, 'nopycache', None):
		v.NOPYCACHE=Options.options.nopycache

	if not v.PYTHON:
		v.PYTHON = [getattr(Options.options, 'python', None) or sys.executable]
	v.PYTHON = Utils.to_list(v.PYTHON)
	conf.find_program('python', var='PYTHON')

	v.PYFLAGS = ''
	v.PYFLAGS_OPT = '-O'

	v.PYC = getattr(Options.options, 'pyc', 1)
	v.PYO = getattr(Options.options, 'pyo', 1)

	try:
		v.PYTAG = conf.cmd_and_log(conf.env.PYTHON + ['-c', "import imp;print(imp.get_tag())"]).strip()
	except Errors.WafError:
		pass
Ejemplo n.º 34
0
def check_python_module(conf, module_name, condition=""):
    msg = "Checking for python module '%s'" % module_name
    if condition:
        msg = "%s (%s)" % (msg, condition)
    conf.start_msg(msg)
    try:
        ret = conf.cmd_and_log(conf.env["PYTHON"] + ["-c", PYTHON_MODULE_TEMPLATE % module_name])
    except Exception:
        conf.end_msg(False)
        conf.fatal("Could not find the python module %r" % module_name)
    ret = ret.strip()
    if condition:
        conf.end_msg(ret)
        if ret == "unknown version":
            conf.fatal("Could not check the %s version" % module_name)
        from distutils.version import LooseVersion

        def num(*k):
            if isinstance(k[0], int):
                return LooseVersion(".".join([str(x) for x in k]))
            else:
                return LooseVersion(k[0])

        d = {"num": num, "ver": LooseVersion(ret)}
        ev = eval(condition, {}, d)
        if not ev:
            conf.fatal("The %s version does not satisfy the requirements" % module_name)
    else:
        if ret == "unknown version":
            conf.end_msg(True)
        else:
            conf.end_msg(ret)
Ejemplo n.º 35
0
def get_suncc_version(conf, cc):
	"""
	Returns the Sun compiler version

	:raise: :py:class:`waflib.Errors.ConfigurationError`
	"""
	cmd = cc + ['-V']
	try:
		out, err = conf.cmd_and_log(cmd, output=0)
	except Errors.WafError as e:
		# Older versions of the compiler exit with non-zero status when reporting their version
		if not (hasattr(e, 'returncode') and hasattr(e, 'stdout') and hasattr(e, 'stderr')):
			conf.fatal('Could not find suncc %r' % cmd)
		out = e.stdout
		err = e.stderr

	version = (out or err)
	version = version.splitlines()[0]

	# cc: Sun C 5.10 SunOS_i386 2009/06/03
	# cc: Studio 12.5 Sun C++ 5.14 SunOS_sparc Beta 2015/11/17
	# cc: WorkShop Compilers 5.0 98/12/15 C 5.0
	version_re = re.compile(r'cc: (studio.*?|\s+)?(sun\s+(c\+\+|c)|(WorkShop\s+Compilers))?\s+(?P<major>\d*)\.(?P<minor>\d*)', re.I).search
	match = version_re(version)
	if match:
		k = match.groupdict()
		conf.env.CC_VERSION = (k['major'], k['minor'])
	else:
		conf.fatal('Could not determine the suncc version.')
Ejemplo n.º 36
0
def get_python_variables(conf, 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
    out = conf.cmd_and_log([python_exe, '-c', '\n'.join(program)], env=os_env)
    return_values = []
    for s in out.split('\n'):
        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.º 37
0
def get_python_variables(conf,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
	try:
		out=conf.cmd_and_log(conf.env.PYTHON+['-c','\n'.join(program)],env=os_env)
	except Errors.WafError:
		conf.fatal('The distutils module is unusable: install "python-devel"?')
	return_values=[]
	for s in out.split('\n'):
		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.º 38
0
def get_suncc_version(conf, cc):
    """
	Returns the Sun compiler version

	:raise: :py:class:`waflib.Errors.ConfigurationError`
	"""
    cmd = cc + ['-V']
    try:
        out, err = conf.cmd_and_log(cmd, output=0)
    except Errors.WafError as e:
        # Older versions of the compiler exit with non-zero status when reporting their version
        if not (hasattr(e, 'returncode') and hasattr(e, 'stdout')
                and hasattr(e, 'stderr')):
            conf.fatal('Could not find suncc %r' % cmd)
        out = e.stdout
        err = e.stderr

    version = (out or err)
    version = version.splitlines()[0]

    # cc: Sun C 5.10 SunOS_i386 2009/06/03
    # cc: Studio 12.5 Sun C++ 5.14 SunOS_sparc Beta 2015/11/17
    # cc: WorkShop Compilers 5.0 98/12/15 C 5.0
    version_re = re.compile(
        r'cc: (studio.*?|\s+)?(sun\s+(c\+\+|c)|(WorkShop\s+Compilers))?\s+(?P<major>\d*)\.(?P<minor>\d*)',
        re.I).search
    match = version_re(version)
    if match:
        k = match.groupdict()
        conf.env.CC_VERSION = (k['major'], k['minor'])
    else:
        conf.fatal('Could not determine the suncc version.')
Ejemplo n.º 39
0
def find_ifort_win32(conf):
	v=conf.env
	path=v.PATH
	compiler=v.MSVC_COMPILER
	version=v.MSVC_VERSION
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	v.IFORT_MANIFEST=(compiler=='intel'and version>=11)
	fc=conf.find_program(compiler_name,var='FC',path_list=path)
	env=dict(conf.environ)
	if path:env.update(PATH=';'.join(path))
	if not conf.cmd_and_log(fc+['/nologo','/help'],env=env):
		conf.fatal('not intel fortran compiler could not be identified')
	v.FC_NAME='IFORT'
	if not v.LINK_FC:
		conf.find_program(linker_name,var='LINK_FC',path_list=path,mandatory=True)
	if not v.AR:
		conf.find_program(lib_name,path_list=path,var='AR',mandatory=True)
		v.ARFLAGS=['/nologo']
	if v.IFORT_MANIFEST:
		conf.find_program('MT',path_list=path,var='MT')
		v.MTFLAGS=['/nologo']
	try:
		conf.load('winres')
	except Errors.WafError:
		Logs.warn('Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 40
0
def gather_vswhere_versions(conf, versions):
	try:
		import json
	except ImportError:
		Logs.error('Visual Studio 2017 detection requires Python 2.6')
		return

	prg_path = os.environ.get('ProgramFiles(x86)', os.environ.get('ProgramFiles', 'C:\\Program Files (x86)'))

	vswhere = os.path.join(prg_path, 'Microsoft Visual Studio', 'Installer', 'vswhere.exe')
	args = [vswhere, '-products', '*', '-legacy', '-format', 'json']
	try:
		txt = conf.cmd_and_log(args)
	except Errors.WafError as e:
		Logs.debug('msvc: vswhere.exe failed %s', e)
		return

	if sys.version_info[0] < 3:
		txt = txt.decode(sys.stdout.encoding or 'windows-1252')
	arr = json.loads(txt)
	arr.sort(key=lambda x: x['installationVersion'])
	for entry in arr:
		ver = entry['installationVersion']
		ver = str('.'.join(ver.split('.')[:2]))
		path = str(os.path.abspath(entry['installationPath']))
		if os.path.exists(path) and ('msvc %s' % ver) not in versions:
			conf.gather_msvc_targets(versions, ver, path)
Ejemplo n.º 41
0
def getoutput(conf, cmd, stdin=False):
	"""
	Obtains Fortran command outputs
	"""
	from waflib import Errors
	if conf.env.env:
		env = conf.env.env
	else:
		env = dict(os.environ)
		env['LANG'] = 'C'
	input = stdin and '\n'.encode() or None
	try:
		out, err = conf.cmd_and_log(cmd, env=env, output=0, input=input)
	except Errors.WafError as e:
		# An WafError might indicate an error code during the command
		# execution, in this case we still obtain the stderr and stdout,
		# which we can use to find the version string.
		if not (hasattr(e, 'stderr') and hasattr(e, 'stdout')):
			raise e
		else:
			# Ignore the return code and return the original
			# stdout and stderr.
			out = e.stdout
			err = e.stderr
	except Exception:
		conf.fatal('could not determine the compiler version %r' % cmd)
	return (out, err)
Ejemplo n.º 42
0
def get_suncc_version(conf, cc):
    """Get the compiler version"""

    cmd = cc + ['-V']
    try:
        out, err = conf.cmd_and_log(cmd, output=0)
    except Errors.WafError as e:
        # Older versions of the compiler exit with non-zero status when reporting their version
        if not (hasattr(e, 'returncode') and hasattr(e, 'stdout')
                and hasattr(e, 'stderr')):
            conf.fatal('Could not find suncc %r' % cmd)
        out = e.stdout
        err = e.stderr

    version = (out or err)
    version = version.splitlines()[0]

    version_re = re.compile(
        r'cc:\s+sun\s+(c\+\+|c)\s+(?P<major>\d*)\.(?P<minor>\d*)', re.I).search
    match = version_re(version)
    if match:
        k = match.groupdict()
        conf.env['CC_VERSION'] = (k['major'], k['minor'])
    else:
        conf.fatal('Could not determine the suncc version.')
Ejemplo n.º 43
0
def check_python_module(conf,module_name,condition=''):
	msg="Checking for python module '%s'"%module_name
	if condition:
		msg='%s (%s)'%(msg,condition)
	conf.start_msg(msg)
	try:
		ret=conf.cmd_and_log(conf.env['PYTHON']+['-c',PYTHON_MODULE_TEMPLATE%module_name])
	except Exception:
		conf.end_msg(False)
		conf.fatal('Could not find the python module %r'%module_name)
	ret=ret.strip()
	if condition:
		conf.end_msg(ret)
		if ret=='unknown version':
			conf.fatal('Could not check the %s version'%module_name)
		from distutils.version import LooseVersion
		def num(*k):
			if isinstance(k[0],int):
				return LooseVersion('.'.join([str(x)for x in k]))
			else:
				return LooseVersion(k[0])
		d={'num':num,'ver':LooseVersion(ret)}
		ev=eval(condition,{},d)
		if not ev:
			conf.fatal('The %s version does not satisfy the requirements'%module_name)
	else:
		if ret=='unknown version':
			conf.end_msg(True)
		else:
			conf.end_msg(ret)
Ejemplo n.º 44
0
def get_python_variables(conf, 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
    try:
        out = conf.cmd_and_log(conf.env.PYTHON + ['-c', '\n'.join(program)],
                               env=os_env)
    except Errors.WafError:
        conf.fatal('The distutils module is unusable: install "python-devel"?')
    return_values = []
    for s in out.split('\n'):
        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.º 45
0
def get_msvc_version(conf, compiler, version, target, vcvars):
    debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
    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', '/E:on', '/V:on', '/C', batfile.abspath()])
    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_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)
    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:
Ejemplo n.º 46
0
def find_msvc(conf):
    """Due to path format limitations, limit operation only to native Win32. Yeah it sucks."""
    if sys.platform == 'cygwin':
        conf.fatal('MSVC module does not work under cygwin Python!')

    # the autodetection is supposed to be performed before entering in this method
    v = conf.env
    path = v['PATH']
    compiler = v['MSVC_COMPILER']
    version = v['MSVC_VERSION']

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

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

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    if path: env.update(PATH=';'.join(path))
    if not conf.cmd_and_log(cxx + ['/nologo', '/help'], 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'

    # 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, var='AR')
        if not stliblink: return
        v['ARFLAGS'] = ['/NOLOGO']

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

    try:
        conf.load('winres')
    except Errors.WafError:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 47
0
def find_msvc(conf):
    """Due to path format limitations, limit operation only to native Win32. Yeah it sucks."""
    if sys.platform == "cygwin":
        conf.fatal("MSVC module does not work under cygwin Python!")

    # the autodetection is supposed to be performed before entering in this method
    v = conf.env
    path = v.PATH
    compiler = v.MSVC_COMPILER
    version = v.MSVC_VERSION

    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    v.MSVC_MANIFEST = ((compiler == "msvc" and version >= 8)
                       or (compiler == "wsdk" and version >= 6)
                       or (compiler == "intel" and version >= 11))

    # compiler
    cxx = conf.find_program(compiler_name, var="CXX", path_list=path)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    if path:
        env.update(PATH=";".join(path))
    if not conf.cmd_and_log(cxx + ["/nologo", "/help"], 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"

    # linker
    if not v.LINK_CXX:
        conf.find_program(
            linker_name,
            path_list=path,
            errmsg="%s was not found (linker)" % linker_name,
            var="LINK_CXX",
        )

    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, var="AR")
        if not stliblink:
            return
        v.ARFLAGS = ["/nologo"]

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

    try:
        conf.load("winres")
    except Errors.ConfigurationError:
        Logs.warn(
            "Resource compiler not found. Compiling resource file is disabled")
Ejemplo n.º 48
0
def check_python_module(conf, module_name):
    """
    Check if the selected python interpreter can import the given python module::

        def configure(conf):
            conf.check_python_module('pygccxml')

    :param module_name: module
    :type module_name: string
    """
    conf.start_msg('Python module %s' % module_name)
    try:
        conf.cmd_and_log(conf.env['PYTHON'] + ['-c', PYTHON_MODULE_TEMPLATE % module_name])
    except:
        conf.end_msg(False)
        conf.fatal('Could not find the python module %r' % module_name)
    conf.end_msg(True)
Ejemplo n.º 49
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('ifort: 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:
		conf.cmd_and_log(fc+['/help'],env=env)
	except UnicodeError:
		st=traceback.format_exc()
		if conf.logger:
			conf.logger.error(st)
		conf.fatal('ifort: Unicode error - check the code page?')
	except Exception ,e:
		Logs.debug('ifort: get_ifort_version: %r %r %r -> failure %s',compiler,version,target,str(e))
		conf.fatal('ifort: cannot run the compiler in get_ifort_version (run with -v to display errors)')
Ejemplo n.º 50
0
def find_irixcc(conf):
    v = conf.env
    cc = None
    if v.CC:
        cc = v.CC
    elif 'CC' in conf.environ:
        cc = conf.environ['CC']
    if not cc:
        cc = conf.find_program('cc', var='CC')
    if not cc:
        conf.fatal('irixcc was not found')
    try:
        conf.cmd_and_log(cc + ['-version'])
    except Errors.WafError:
        conf.fatal('%r -version could not be executed' % cc)
    v.CC = cc
    v.CC_NAME = 'irix'
Ejemplo n.º 51
0
Archivo: msvc.py Proyecto: ralic/waf
def find_msvc(conf):
    """Due to path format limitations, limit operation only to native Win32. Yeah it sucks."""
    if sys.platform == 'cygwin':
        conf.fatal('MSVC module does not work under cygwin Python!')

    # the autodetection is supposed to be performed before entering in this method
    v = conf.env
    path = v.PATH
    compiler = v.MSVC_COMPILER
    version = v.MSVC_VERSION

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

    # compiler
    cxx = conf.find_program(compiler_name, var='CXX', path_list=path)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    if path:
        env.update(PATH=';'.join(path))
    if not conf.cmd_and_log(cxx + ['/nologo', '/help'], 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'

    # linker
    if not v.LINK_CXX:
        # TODO: var=LINK_CXX to let so that LINK_CXX can be overridden?
        v.LINK_CXX = conf.find_program(linker_name,
                                       path_list=path,
                                       errmsg='%s was not found (linker)' %
                                       linker_name)

    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, var='AR')
        if not stliblink:
            return
        v.ARFLAGS = ['/nologo']

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

    try:
        conf.load('winres')
    except Errors.ConfigurationError:
        Logs.warn(
            'Resource compiler not found. Compiling resource file is disabled')
Ejemplo n.º 52
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, ))
Ejemplo n.º 53
0
def find_gdc(conf):
    """
    Finds the program gdc and set the variable *D*
    """
    conf.find_program("gdc", var="D")

    out = conf.cmd_and_log(conf.env.D + ["--version"])
    if out.find("gdc") == -1:
        conf.fatal("detected compiler is not gdc")
Ejemplo n.º 54
0
def find_ldc2(conf):
    """
	Finds the program *ldc2* and set the variable *D*
	"""
    conf.find_program(['ldc2'], var='D')

    out = conf.cmd_and_log(conf.env.D + ['-version'])
    if out.find("based on DMD v2.") == -1:
        conf.fatal("detected compiler is not ldc2")
Ejemplo n.º 55
0
def get_suncc_version(conf,cc):
	cmd=cc+['-V']
	try:
		out,err=conf.cmd_and_log(cmd,output=0)
	except Errors.WafError ,e:
		if not(hasattr(e,'returncode')and hasattr(e,'stdout')and hasattr(e,'stderr')):
			conf.fatal('Could not find suncc %r'%cmd)
		out=e.stdout
		err=e.stderr
Ejemplo n.º 56
0
def find_gdc(conf):
    """
	Find the program gdc and set the variable *D*
	"""
    conf.find_program('gdc', var='D')

    out = conf.cmd_and_log([conf.env.D, '--version'])
    if out.find("gdc (GCC)") == -1:
        conf.fatal("detected compiler is not gdc")
Ejemplo n.º 57
0
def getoutput(conf, cmd, stdin=False):
    input = stdin and '\n' or None
    try:
        out, err = conf.cmd_and_log(cmd,
                                    env=conf.env.env or None,
                                    output=0,
                                    input=input)
    except Exception:
        conf.fatal('could not determine the compiler version %r' % cmd)
    return (out, err)
Ejemplo n.º 58
0
def find_irixcc(conf):
    v = conf.env
    cc = None
    if v.CC:
        cc = v.CC
    elif "CC" in conf.environ:
        cc = conf.environ["CC"]
    if not cc:
        cc = conf.find_program("cc", var="CC")
    if not cc:
        conf.fatal("irixcc was not found")

    try:
        conf.cmd_and_log(cc + ["-version"])
    except Errors.WafError:
        conf.fatal("%r -version could not be executed" % cc)

    v.CC = cc
    v.CC_NAME = "irix"
Ejemplo n.º 59
0
def find_scc(conf):
    """
	Detect the Sun C compiler
	"""
    v = conf.env
    cc = None
    if v['CC']: cc = v['CC']
    elif 'CC' in conf.environ: cc = conf.environ['CC']
    if not cc: cc = conf.find_program('cc', var='CC')
    if not cc: conf.fatal('Could not find a Sun C compiler')

    try:
        conf.cmd_and_log(cc + ['-flags'])
    except Exception:
        conf.fatal('%r is not a Sun compiler' % cc)

    v['CC'] = cc
    v['CC_NAME'] = 'sun'
    conf.get_suncc_version(cc)
Ejemplo n.º 60
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()
	for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler','Intel Parallel Studio'):
		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]
	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)
	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: