def mkspec_gxx_configure(conf, major, minor, prefix=None, minimum=False): """ :param major: The major version number of the compiler, e.g. 4 :param minor: The minor version number of the compiler, e.g. 6 :param prefix: Prefix to the compiler name, e.g. 'arm-linux-androideabi' :param minimum: Only check for a minimum compiler version, if true """ # Where to look for the compiler paths = conf.mkspec_get_toolchain_paths() # Find g++ first gxx_names = conf.mkspec_get_gnu_binary_name('g++', major, minor, prefix) if minimum: gxx_names = 'g++' cxx = conf.find_program(gxx_names, path_list=paths) cxx = conf.cmd_to_list(cxx) conf.env['CXX'] = cxx conf.env['CXX_NAME'] = os.path.basename(conf.env.get_flat('CXX')) if minimum: conf.mkspec_check_minimum_cc_version(cxx, major, minor) else: conf.mkspec_check_cc_version(cxx, major, minor) # Also find gcc gcc_names = conf.mkspec_get_gnu_binary_name('gcc', major, minor, prefix) if minimum: gcc_names = 'gcc' cc = conf.find_program(gcc_names, path_list=paths) cc = conf.cmd_to_list(cc) conf.env['CC'] = cc conf.env['CC_NAME'] = os.path.basename(conf.env.get_flat('CC')) if minimum: conf.mkspec_check_minimum_cc_version(cc, major, minor) else: conf.mkspec_check_cc_version(cc, major, minor) # Find the archiver ar = conf.mkspec_get_ar_binary_name(prefix) conf.find_program(ar, path_list=paths, var='AR') conf.env.ARFLAGS = 'rcs' # Set up C++ tools and flags conf.gxx_common_flags() conf.gxx_modifier_platform() conf.cxx_load_tools() conf.cxx_add_flags() # Also set up C tools and flags conf.gcc_common_flags() conf.gcc_modifier_platform() conf.cc_load_tools() conf.cc_add_flags() # Add linker flags conf.link_add_flags() # Add our own cxx flags conf.mkspec_set_gxx_cxxflags() # Add our own cc flags conf.mkspec_set_gcc_ccflags()
def find_xlf(conf): """Find the xlf program (will look in the environment variable 'FC')""" fc = conf.find_program(['xlf2003_r', 'xlf2003', 'xlf95_r', 'xlf95', 'xlf90_r', 'xlf90', 'xlf_r', 'xlf'], var='FC') fc = conf.cmd_to_list(fc) conf.get_xlf_version(fc) conf.env.FC_NAME='XLF'
def find_crayftn(conf): """Find the Cray fortran compiler (will look in the environment variable 'FC')""" fc = conf.find_program(['crayftn'], var='FC') fc = conf.cmd_to_list(fc) conf.get_crayftn_version(fc) conf.env.FC_NAME = 'CRAY' conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod'
def find_gfortran(conf): """Find the gfortran program (will look in the environment variable 'FC')""" fc = conf.find_program(["gfortran", "g77"], var="FC") # (fallback to g77 for systems, where no gfortran is available) fc = conf.cmd_to_list(fc) conf.get_gfortran_version(fc) conf.env.FC_NAME = "GFORTRAN"
def find_openf95(conf): """Find the Open64 Fortran Compiler (will look in the environment variable 'FC')""" fc = conf.find_program(['openf95', 'openf90'], var='FC') fc = conf.cmd_to_list(fc) conf.get_open64_version(fc) conf.env.FC_NAME='OPEN64'
def check_cython_version(conf, minver): conf.start_msg("Checking cython version") minver = tuple(minver) import re version_re = re.compile(r'cython\s*version\s*(?P<major>\d*)\.(?P<minor>\d*)(?:\.(?P<micro>\d*))?', re.I).search cmd = conf.cmd_to_list(conf.env['CYTHON']) cmd = cmd + ['--version'] from waflib.Tools import fc_config stdout, stderr = fc_config.getoutput(conf, cmd) if stdout: match = version_re(stdout) else: match = version_re(stderr) if not match: conf.fatal("cannot determine the Cython version") cy_ver = [match.group('major'), match.group('minor')] if match.group('micro'): cy_ver.append(match.group('micro')) else: cy_ver.append('0') cy_ver = tuple([int(x) for x in cy_ver]) if cy_ver < minver: conf.end_msg(False) conf.fatal("cython version %s < %s" % (cy_ver, minver)) conf.end_msg(str(cy_ver))
def find_solstudio(conf): """Find the Solaris Studio compiler (will look in the environment variable 'FC')""" fc = conf.find_program(['sunf95', 'f95', 'sunf90', 'f90'], var='FC') fc = conf.cmd_to_list(fc) conf.get_solstudio_version(fc) conf.env.FC_NAME = 'SOL'
def find_android_gxx(conf): exeDir = os.path.join(conf.options.ndk, "toolchains", "arm-linux-androideabi-4.6", "prebuilt", "windows-x86_64", "bin") cxx=conf.find_program(['arm-linux-androideabi-g++'], var = "CXX", path_list=[exeDir]) cxx=conf.cmd_to_list(cxx) conf.get_cc_version(cxx,gcc=True) conf.env.CXX_NAME='gcc' conf.env.CXX=cxx
def find_xlcxx(conf): """ Detect the Aix C++ compiler """ cxx = conf.find_program(['xlc++_r', 'xlc++'], var='CXX') cxx = conf.cmd_to_list(cxx) conf.env.CXX_NAME = 'xlc++' conf.env.CXX = cxx
def find_nag(conf): """Find the NAG Fortran Compiler (will look in the environment variable 'FC')""" fc = conf.find_program(['nagfor'], var='FC') fc = conf.cmd_to_list(fc) conf.get_nag_version(fc) conf.env.FC_NAME = 'NAG' conf.env.FC_MOD_CAPITALIZATION = 'lower'
def find_xlcxx(conf): """ Detect the Aix C++ compiler """ cxx = conf.find_program(["xlc++_r", "xlc++"], var="CXX") cxx = conf.cmd_to_list(cxx) conf.env.CXX_NAME = "xlc++" conf.env.CXX = cxx
def find_xlc(conf): """ Detect the Aix C compiler """ cc = conf.find_program(['xlc_r', 'xlc'], var='CC') cc = conf.cmd_to_list(cc) conf.env.CC_NAME = 'xlc' conf.env.CC = cc
def find_gxx(conf): """ Find the program g++, and if present, try to detect its version number """ cxx = conf.find_program(["g++", "c++"], var="CXX") cxx = conf.cmd_to_list(cxx) conf.get_cc_version(cxx, gcc=True) conf.env.CXX_NAME = "gcc" conf.env.CXX = cxx
def find_arm_gcc(conf): """ Find the program gcc, and if present, try to detect its version number """ cc = conf.find_program(['arm-none-eabi-gcc', 'arm-none-linux-gnueabi-gcc'], var='CC') cc = conf.cmd_to_list(cc) conf.get_cc_version(cc, gcc=True) conf.env.CC_NAME = 'arm-gcc' conf.env.CC = cc
def find_gxx(conf): """ Find the program g++, and if present, try to detect its version number """ cxx = conf.find_program(['g++', 'c++'], var='CXX') cxx = conf.cmd_to_list(cxx) conf.get_cc_version(cxx, gcc=True) conf.env.CXX_NAME = 'gcc' conf.env.CXX = cxx
def find_gcc(conf): """ Find the program gcc, and if present, try to detect its version number """ cc = conf.find_program(['gcc', 'cc'], var='CC') cc = conf.cmd_to_list(cc) conf.get_cc_version(cc, gcc=True) conf.env.CC_NAME = 'gcc' conf.env.CC = cc
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)
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)
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')
def find_avr_gxx(conf): """ Find the program g++, and if present, try to detect its version number """ cxx = conf.find_program(['avr-g++'], var='CXX') # Shortcut... cxx = "/Applications/Arduino.app//Contents/Resources/Java/hardware/tools/avr/bin/avr-g++" cxx = conf.cmd_to_list(cxx) conf.get_cc_version(cxx, gcc=True) conf.env.CXX_NAME = 'gcc' conf.env.CXX = cxx
def configure(conf): conf.env.PYTHON=sys.executable # Add expected bin directory to path os.environ['PATH'] = sys.prefix + '/bin:' + os.environ['PATH'] conf.env.PYTHON=conf.cmd_to_list(conf.env.PYTHON) 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 configure(conf): """ Find a F# compiler, set the variable FSC for the compiler and FS_NAME (mono or fsc) """ conf.find_program(['fsc.exe', 'fsharpc'], var='FSC') conf.env.FSC = conf.cmd_to_list(conf.env.FSC) conf.env.ASS_ST = '/r:%s' conf.env.RES_ST = '/resource:%s' conf.env.CS_NAME = 'fsc' if str(conf.env.FSC).lower().find('fsharpc') > -1: conf.env.CS_NAME = 'mono'
def find_icpc(conf): if sys.platform=='cygwin': conf.fatal('The Intel compiler does not work on Cygwin') v=conf.env cxx=None if v['CXX']:cxx=v['CXX'] elif'CXX'in conf.environ:cxx=conf.environ['CXX'] if not cxx:cxx=conf.find_program('icpc',var='CXX') if not cxx:conf.fatal('Intel C++ Compiler (icpc) was not found') cxx=conf.cmd_to_list(cxx) conf.get_cc_version(cxx,icc=True) v['CXX']=cxx v['CXX_NAME']='icc'
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') cc=conf.cmd_to_list(cc) try: conf.cmd_and_log(cc+['-version']) except: conf.fatal('%r -version could not be executed'%cc) v['CC']=cc v['CC_NAME']='irix'
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: conf.fatal('%r is not a Sun compiler'%cc) v['CC']=cc v['CC_NAME']='sun'
def find_icc(conf): if sys.platform=='cygwin': conf.fatal('The Intel compiler does not work on Cygwin') 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('icc',var='CC') if not cc:cc=conf.find_program('ICL',var='CC') if not cc:conf.fatal('Intel C Compiler (icc) was not found') cc=conf.cmd_to_list(cc) conf.get_cc_version(cc,icc=True) v['CC']=cc v['CC_NAME']='icc'
def find_clang(conf): v=conf.env clang=None if v['CLANG']:clang=v['CLANG'] elif'CLANG'in conf.environ:cxx=conf.environ['CLANG'] if not clang:clang=conf.find_program('clang',var='CLANG') if not clang:clang=conf.find_program('clang++',var='CLANG') if not clang:conf.fatal('clang was not found') clang=conf.cmd_to_list(clang) v['CXX_NAME']='clang' v['CXX']=clang v['COMPILER_CXX']=clang v['CC_NAME']='clang' v['CC']=clang v['COMPILER_CC']=clang
def configure(conf): try: conf.find_program("python", var="PYTHON") except conf.errors.ConfigurationError: warn("could not find a python executable, setting to sys.executable '%s'" % sys.executable) conf.env.PYTHON = sys.executable if conf.env.PYTHON != sys.executable: warn("python executable '%s' different from sys.executable '%s'" % (conf.env.PYTHON, sys.executable)) conf.env.PYTHON = conf.cmd_to_list(conf.env.PYTHON) 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 configure(conf): try: conf.find_program('python',var='PYTHON') except conf.errors.ConfigurationError: Logs.warn("could not find a python executable, setting to sys.executable '%s'"%sys.executable) conf.env.PYTHON=sys.executable if conf.env.PYTHON!=sys.executable: Logs.warn("python executable %r differs from system %r"%(conf.env.PYTHON,sys.executable)) conf.env.PYTHON=conf.cmd_to_list(conf.env.PYTHON) 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_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)
def get_msvc_version(conf, compiler, version, target, vcvars): debug('msvc: get_msvc_version: %r %r %r', compiler, version, target) batfile = conf.bldnode.make_node('waf-print-msvc.bat') batfile.write("""@echo off set INCLUDE= set LIB= call "%s" %s echo PATH=%%PATH%% echo INCLUDE=%%INCLUDE%% echo LIB=%%LIB%% """ % (vcvars, target)) sout = conf.cmd_and_log(['cmd', '/E:on', '/V:on', '/C', batfile.abspath()]) lines = sout.splitlines() if not lines[0]: lines.pop(0) if version == '11.0': if lines[0].startswith('Error'): conf.fatal( 'msvc: Could not find a valid architecture for building (get_msvc_version_1)' ) else: for x in ('Setting environment', 'Setting SDK environment', 'Intel(R) C++ Compiler', 'Intel Parallel Studio', 'Intel(R) Parallel Studio', 'Intel(R) Composer', 'Intel Corporation. All rights reserved.'): if lines[0].find(x) > -1: lines.pop(0) break else: debug('msvc: get_msvc_version: %r %r %r -> not found', compiler, version, target) conf.fatal( 'msvc: Could not find a valid architecture for building (get_msvc_version_2)' ) MSVC_PATH = MSVC_INCDIR = MSVC_LIBDIR = None for line in lines: if line.startswith('PATH='): path = line[5:] MSVC_PATH = path.split(';') elif line.startswith('INCLUDE='): MSVC_INCDIR = [i for i in line[8:].split(';') if i] elif line.startswith('LIB='): MSVC_LIBDIR = [i for i in line[4:].split(';') if i] if None in (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR): conf.fatal( 'msvc: Could not find a valid architecture for building (get_msvc_version_3)' ) env = dict(os.environ) env.update(PATH=path) compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler) cxx = conf.find_program(compiler_name, path_list=MSVC_PATH) cxx = conf.cmd_to_list(cxx) if 'CL' in env: del (env['CL']) try: try: conf.cmd_and_log(cxx + ['/help'], env=env) except Exception, e: debug('msvc: get_msvc_version: %r %r %r -> failure' % (compiler, version, target)) debug(str(e)) conf.fatal('msvc: cannot run the compiler (in get_msvc_version)') else:
def find_pgfortran(conf): """Find the PGI fortran compiler (will look in the environment variable 'FC')""" fc = conf.find_program(['pgfortran', 'pgf95', 'pgf90'], var='FC') fc = conf.cmd_to_list(fc) conf.get_pgfortran_version(fc) conf.env.FC_NAME = 'PGFC'
def find_gxx(conf): cxx=conf.find_program(['g++','c++'],var='CXX') cxx=conf.cmd_to_list(cxx) conf.get_cc_version(cxx,gcc=True) conf.env.CXX_NAME='gcc' conf.env.CXX=cxx
def find_emcc(conf): cc = conf.find_program(['emcc'], var='CC') cc = conf.cmd_to_list(cc) conf.env.CC_NAME = 'emcc' conf.env.CC = cc
def find_xlc(conf): cc=conf.find_program(['xlc_r','xlc'],var='CC') cc=conf.cmd_to_list(cc) conf.get_xlc_version(cc) conf.env.CC_NAME='xlc' conf.env.CC=cc
def find_bgxlf(conf): fc = conf.find_program(['bgxlf2003_r', 'bgxlf2003'], var='FC') fc = conf.cmd_to_list(fc) conf.get_xlf_version(fc) conf.env.FC_NAME = 'BGXLF'
def get_msvc_version(conf, compiler, version, target, windows_kit, vcvars): """ Create a bat file to obtain the location of the libraries :param compiler: ? :param version: ? :target: ? :vcvars: ? :return: the location of msvc, the location of include dirs, and the library paths :rtype: tuple of strings """ debug('msvc: get_msvc_version: %r %r %r %r', compiler, version, target, windows_kit) batfile = conf.bldnode.make_node('waf-print-msvc.bat') batfile.write("""@echo off set INCLUDE= set LIB= call "%s" %s %s echo PATH=%%PATH%% echo INCLUDE=%%INCLUDE%% echo LIB=%%LIB%%;%%LIBPATH%% """ % (vcvars, target, windows_kit)) 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 not MSVC_PATH or not MSVC_INCDIR or not MSVC_LIBDIR: conf.fatal( 'msvc: Could not find a valid architecture for building (get_msvc_version_3)' ) # 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 = 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, silent_output=True) 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 %r -> failure' % (compiler, version, target, windows_kit)) debug(str(e)) conf.fatal('msvc: cannot run the compiler (in get_msvc_version)') else: debug('msvc: get_msvc_version: %r %r %r %r -> OK', compiler, version, target, windows_kit) finally: conf.env[compiler_name] = '' # vcvarsall does not always resolve the windows sdk path with VS2015 + Win10, but we know where it is winsdk_path = _get_win_sdk_path(windows_kit, target) if winsdk_path: MSVC_PATH.append(winsdk_path) return (MSVC_PATH, MSVC_INCDIR, MSVC_LIBDIR)
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, silent_output=True) 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[0] v['CC_NAME'] = v['CXX_NAME'] = 'msvc' # Bullseye code coverage if conf.is_option_true('use_bullseye_coverage'): # TODO: Error handling for this is opaque. This will fail the MSVS 2015 tool check, # and not say anything about bullseye being missing. try: covc = conf.find_program('covc', var='BULL_COVC', path_list=path, silent_output=True) covlink = conf.find_program('covlink', var='BULL_COVLINK', path_list=path, silent_output=True) covselect = conf.find_program('covselect', var='BULL_COVSELECT', path_list=path, silent_output=True) v['BULL_COVC'] = covc v['BULL_COVLINK'] = covlink v['BULL_COV_FILE'] = conf.CreateRootRelativePath( conf.options.bullseye_cov_file) # Update the coverage file with the region selections detailed in the settings regions parameters # NOTE: should we clear other settings at this point, or allow them to accumulate? # Maybe we need a flag for that in the setup? regions = conf.options.bullseye_coverage_regions.replace( ' ', '').split(',') conf.cmd_and_log( ([covselect] + ['--file', v['BULL_COV_FILE'], '-a'] + regions)) except: Logs.error( 'Could not find the Bullseye Coverage tools on the path, or coverage tools are not correctly installed. Coverage build disabled.' ) # linker if not v['LINK_CXX']: link = conf.find_program(linker_name, path_list=path, silent_output=True) 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', silent_output=True) 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', silent_output=True) v['MTFLAGS'] = ['/NOLOGO'] # call configure on the waflib winres module to setup the environment for configure # conf.load('winres') caches the environment as part of the module load key, and we just modified # the environment, causing the cache to miss, and extra calls import/load the module # winres is loaded try: module = sys.modules['waflib.Tools.winres'] func = getattr(module, 'configure', None) if func: func(conf) except Error as e: warn( 'Resource compiler not found. Compiling resource file is disabled')
def find_gcc(conf): cc = conf.find_program(['gcc', 'cc'], var='CC') cc = conf.cmd_to_list(cc) conf.get_cc_version(cc, gcc=True) conf.env.CC_NAME = 'gcc' conf.env.CC = cc
def mkspec_clang_configure(conf, major, minor, prefix=None, minimum=False, force_debug=False): """ :param major: The major version number of the compiler, e.g. 3 :param minor: The minor version number of the compiler, e.g. 4 :param prefix: Prefix to compiler name, e.g. 'arm-linux-androideabi' :param minimum: Only check for a minimum compiler version, if true :param force_debug: Always compile with debugging flags, if true """ # Where to look paths = conf.mkspec_get_toolchain_paths() # If the user-defined CXX variable is set, then use that compiler if 'CXX' in os.environ: cxx = waflib.Utils.to_list(os.environ['CXX']) conf.to_log('Using user defined environment variable CXX=%r' % cxx) else: # Find the clang++ compiler clangxx_names = conf.mkspec_get_compiler_binary_name( 'clang++', major, minor, prefix) if minimum: clangxx_names = 'clang++' cxx = conf.find_program(clangxx_names, path_list=paths) cxx = conf.cmd_to_list(cxx) conf.env['CXX'] = cxx conf.env['CXX_NAME'] = os.path.basename(conf.env.get_flat('CXX')) conf.mkspec_check_clang_version(cxx, major, minor, minimum) # If the user-defined CC variable is set, then use that compiler if 'CC' in os.environ: cc = waflib.Utils.to_list(os.environ['CC']) conf.to_log('Using user defined environment variable CC=%r' % cc) else: # Find clang as the C compiler clang_names = conf.mkspec_get_compiler_binary_name( 'clang', major, minor, prefix) if minimum: clang_names = 'clang' cc = conf.find_program(clang_names, path_list=paths) cc = conf.cmd_to_list(cc) conf.env['CC'] = cc conf.env['CC_NAME'] = os.path.basename(conf.env.get_flat('CC')) conf.mkspec_check_clang_version(cc, major, minor, minimum) # Find the archiver ar = conf.mkspec_get_ar_binary_name(prefix) conf.find_program(ar, path_list=paths, var='AR') conf.env.ARFLAGS = 'rcs' # Set up C++ tools and flags conf.gxx_common_flags() conf.gxx_modifier_platform() conf.cxx_load_tools() conf.cxx_add_flags() # Also set up C tools and flags conf.gcc_common_flags() conf.gcc_modifier_platform() conf.cc_load_tools() conf.cc_add_flags() # Add linker flags conf.link_add_flags() # Add our own cxx flags conf.mkspec_set_clang_cxxflags(force_debug) # Add our own cc flags conf.mkspec_set_clang_ccflags(force_debug)
def find_g95(conf): fc = conf.find_program('g95', var='FC') fc = conf.cmd_to_list(fc) conf.get_g95_version(fc) conf.env.FC_NAME = 'G95'