def _check_c(context, name, autoadd, test_code): # Detect which performance library to use info = None for perflib in get_perflib_names(context.env): _info = get_initialized_perflib_config(context.env, perflib) if name in _info.interfaces() and _check_perflib(context, 0, _info): info = _info break context.Message("Checking for %s ... " % name.upper()) if info is None: context.Result('no') return 0 if not name in info.interfaces(): raise RuntimeError("%s does not support %s interface" % \ (info.__class__, name.upper())) saved = save_and_set(context.env, info._interfaces[name], info._interfaces[name].keys()) ret = context.TryLink(test_code, extension='.c') if not ret or not autoadd: restore(context.env, saved) if not ret: context.Result('no') context.Result('yes - %s' % info.name) return ret
def _check_perflib(context, autoadd, info): context.Message("Checking for %s ... " % info.name) if info.disabled(): context.Result('no - disabled from user environment') return 0 saved = save_and_set(context.env, info._core, info._core.keys()) ret = context.TryLink(info.test_code, extension='.c') if not ret or not autoadd: restore(context.env, saved) context.Result(ret) return ret
def _check_fortran(context, name, autoadd, test_code_tpl, func): # Generate test code using name mangler try: mangler = context.env['F77_NAME_MANGLER'] except KeyError: if not CheckF77Mangling(context): return 0 mangler = context.env['F77_NAME_MANGLER'] test_code = test_code_tpl % {'func': mangler(func)} try: f77_ldflags = context.env['F77_LDFLAGS'] except KeyError: if not CheckF77Clib(context, autoadd=0): return 0 f77_ldflags = context.env['F77_LDFLAGS'] # Detect which performance library to use info = None for perflib in get_perflib_names(context.env): _info = get_initialized_perflib_config(context.env, perflib) if name in _info.interfaces() and _check_perflib(context, 0, _info): info = _info break context.Message("Checking for F77 %s ... " % name) if info is None: context.Result('no') return 0 if not info._interfaces[name].has_key("LINKFLAGSEND"): info._interfaces[name]["LINKFLAGSEND"] = f77_ldflags[:] else: info._interfaces[name]["LINKFLAGSEND"].extend(f77_ldflags[:]) if not name in info.interfaces(): raise RuntimeError("%s does not support %s interface" % \ (info.__class__, name)) saved = save_and_set(context.env, info._interfaces[name], info._interfaces[name].keys()) ret = context.TryLink(test_code, extension='.c') if not ret or not autoadd: restore(context.env, saved) if not ret: context.Result('no') context.Result('yes - %s' % info.name) set_checker_result(context.env, name, info) return ret
def NumpyCheckLibAndHeader(context, libs, symbols=None, headers=None, language=None, section=None, name=None, autoadd=1): from SCons.Util import is_List env = context.env # XXX: handle language if language: raise NotImplementedError("FIXME: language selection not "\ "implemented yet !") # Make sure libs and symbols are lists if libs and not is_List(libs): libs = [libs] if symbols and not is_List(symbols): symbols = [symbols] if headers and not is_List(headers): headers = [headers] if not name: name = libs[0] # Get user customization (numscons.cfg) if any # opts will keep all user cusstomization, and put into config check source # files in comment so that scons will automatically consider sources as # obsolete whenever config change opts = [] build_info = None if section: cfg = _read_section(section, env) if cfg: opts.append(cfg) build_info = BuildDict.from_config_dict(cfg) if build_info is None: build_info = BuildDict() if not build_info['LIBS']: build_info['LIBS'] = libs opts.append(build_info) # Display message if symbols: sbstr = ', '.join(symbols) msg = 'Checking for symbol(s) %s in %s... ' % (sbstr, name) else: msg = 'Checking for %s... ' % name context.Message(msg) # Disable from environment if name=None is in it try: value = os.environ[name] if value == 'None': msg = 'Disabled from env through var %s !' % name return context.Result(msg), {} except KeyError: pass # Check whether the header is available (CheckHeader-like checker) saved = save_and_set(env, build_info) try: src_code = [r'#include <%s>' % h for h in headers] src_code.extend([r'#if 0', str(opts), r'#endif', '\n']) src = '\n'.join(src_code) st = context.TryCompile(src, '.c') finally: restore(env, saved) if not st: context.Result('Failed (could not check header(s) : check config.log '\ 'in %s for more details)' % env['build_dir']) return st # Check whether the library is available (CheckLib-like checker) saved = save_and_set(env, build_info) try: if symbols: for sym in symbols: # Add opts at the end of the source code to force dependency of # check from options. extra = [r'#if 0', str(build_info), r'#endif', '\n'] st = check_symbol(context, None, sym, '\n'.join(extra)) if not st: break finally: if st == 0 or autoadd == 0: restore(env, saved) if not st: context.Result('Failed (could not check symbol %s : check config.log '\ 'in %s for more details))' % (sym, env['build_dir'])) return st context.Result(st) return st