def __init__(self, uid, **kwargs): self.uid = uid self.members = {} all_roles = CompilerRole.keys() for key, val in kwargs.iteritems(): if key not in all_roles: raise InternalError("Invalid role: %s" % key) role = CompilerRole.find(key) self.members[role] = val
def parse_compiler_flags(self, args): """Parses host compiler flags out of the command line arguments. Args: args: Argument namespace containing command line arguments Returns: Dictionary of installed compilers by role keyword string. Raises: ConfigurationError: Invalid command line arguments specified """ for family_attr, family_cls in [('host_family', CompilerFamily), ('mpi_family', MpiCompilerFamily)]: try: family_arg = getattr(args, family_attr) except AttributeError as err: # User didn't specify that argument, but that's OK self.logger.debug(err) continue else: delattr(args, family_attr) try: family_comps = InstalledCompilerFamily(family_cls(family_arg)) except KeyError: self.parser.error("Invalid compiler family: %s" % family_arg) for comp in family_comps: self.logger.debug("args.%s=%r", comp.info.role.keyword, comp.absolute_path) setattr(args, comp.info.role.keyword, comp.absolute_path) compiler_keys = set(CompilerRole.keys()) all_keys = set(args.__dict__.keys()) given_keys = compiler_keys & all_keys missing_keys = compiler_keys - given_keys self.logger.debug("Given compilers: %s", given_keys) self.logger.debug("Missing compilers: %s", missing_keys) compilers = dict([(key, InstalledCompiler(getattr(args, key))) for key in given_keys]) for key in missing_keys: try: compilers[key] = host.default_compiler(CompilerRole.find(key)) except ConfigurationError as err: self.logger.debug(err) # Check that all required compilers were found for role in CompilerRole.tau_required(): if role.keyword not in compilers: raise ConfigurationError("%s compiler could not be found" % role.language, "See 'compiler arguments' under `%s --help`" % COMMAND) # Probe MPI compilers to discover wrapper flags for args_attr, wrapped_attr in [('mpi_include_path', 'include_path'), ('mpi_library_path', 'library_path'), ('mpi_libraries', 'libraries')]: if not hasattr(args, args_attr): probed = set() for role in MPI_CC_ROLE, MPI_CXX_ROLE, MPI_FC_ROLE: try: comp = compilers[role.keyword] except KeyError: self.logger.debug("Not probing %s: not found", role) else: probed.update(getattr(comp.wrapped, wrapped_attr)) setattr(args, args_attr, list(probed)) return compilers