def modify(self, **kwargs): """Build a modified copy of this object.""" # pylint: disable=protected-access uid_parts = [self.uid, str(sorted(kwargs))] compilers = {role.keyword: comp for role, comp in self.members.iteritems()} modified = InstalledCompilerSet(util.calculate_uid(uid_parts), **compilers) modified._add_members(**kwargs) return modified
def uid(self): if self._uid is None: self._uid = util.calculate_uid(self.uid_items()) return self._uid
def __init__(self, absolute_path, info, uid=None, wrapped=None, include_path=None, library_path=None, compiler_flags=None, libraries=None): """Initializes the InstalledCompiler instance. Any information not provided on the argument list may be probed from the system. This can be **VERY** expensive and may involve invoking the compiler, checking PATH, file permissions, or other conditions in the system to determine if a compiler command is present and executable. If this compiler command wraps another command, that command is also probed. The probes recurse to the "root" compiler that doesn't wrap any other command. :any:`uid` uniquely identifies this compiler as installed in the system. If the compiler's installation changes substantially (e.g. significant version upgrades or changes in the compiler wrapper) then the UID will change as well. These probes are necessary because TAU is highly dependent on the compiler used to install TAU. If that compiler changes, or the user tries to "fake out" TAU Commander by renaming compiler commands, then the user should be warned that the compiler has changed. If the change is severe then the operation should halt before an invalid operation. Args: absolute_path (str): Absolute path to the compiler command. info (_CompilerInfo): Information about the compiler invoked by the compiler command. uid (str): A unique identifier for the installed compiler. wrapped (InstalledCompiler): Information about the wrapped compiler or None. If this is None then all wrapper path arguments (i.e. `include_path`) are ignored. include_path (list): Paths to search for include files when compiling with the wrapped compiler. Ignored if :any:`wrapped` is None. library_path (list): Paths to search for libraries when linking with the wrapped compiler. Ignored if :any:`wrapped` is None. compiler_flags (list): Additional flags used when compiling with the wrapped compiler. Ignored if :any:`wrapped` is None. libraries (list): Additional libraries to link when linking with the wrapped compiler. Ignored if :any:`wrapped` is None. """ self._version_string = None self.absolute_path = absolute_path self.info = info self.command = os.path.basename(absolute_path) self.path = os.path.dirname(absolute_path) if wrapped: assert isinstance(wrapped, InstalledCompiler) self.include_path = include_path or [] self.library_path = library_path or [] self.compiler_flags = compiler_flags or [] self.libraries = libraries or [] self.wrapped = wrapped else: self.include_path = [] self.library_path = [] self.compiler_flags = [] self.libraries = [] self.wrapped = self._probe_wrapper() if uid: self.uid = uid else: uid_parts = [self.absolute_path, self.info.family.name, self.info.role.keyword] if self.wrapped: uid_parts.append(self.wrapped.uid) for attr in 'include_path', 'library_path', 'compiler_flags', 'libraries': uid_parts.extend(sorted(getattr(self, attr))) self.uid = util.calculate_uid(uid_parts) # Check that the compiler is executable and of the expected family/role. # Prevents compilers with the same command (e.g. Cray cc and GNU cc) from crossing. # Don't need to check the compiler family of compiler wrappers since the compiler # the wrapper wraps has already been checked. if not self.wrapped and info.family.family_regex: if not re.search(info.family.family_regex, self.version_string, re.MULTILINE): probed_family = _CompilerFamily.probe(absolute_path) raise ConfigurationError("Compiler '%s' is a %s compiler, not a %s compiler." % (absolute_path, probed_family.name, info.family.name))
def __init__(self, absolute_path, info, uid=None, wrapped=None, include_path=None, library_path=None, compiler_flags=None, libraries=None): """Initializes the InstalledCompiler instance. Any information not provided on the argument list may be probed from the system. This can be **VERY** expensive and may involve invoking the compiler, checking PATH, file permissions, or other conditions in the system to determine if a compiler command is present and executable. If this compiler command wraps another command, that command is also probed. The probes recurse to the "root" compiler that doesn't wrap any other command. :any:`uid` uniquely identifies this compiler as installed in the system. If the compiler's installation changes substantially (e.g. significant version upgrades or changes in the compiler wrapper) then the UID will change as well. These probes are necessary because TAU is highly dependent on the compiler used to install TAU. If that compiler changes, or the user tries to "fake out" TAU Commander by renaming compiler commands, then the user should be warned that the compiler has changed. If the change is severe then the operation should halt before an invalid operation. Args: absolute_path (str): Absolute path to the compiler command. info (_CompilerInfo): Information about the compiler invoked by the compiler command. uid (str): A unique identifier for the installed compiler. wrapped (InstalledCompiler): Information about the wrapped compiler or None. If this is None then all wrapper path arguments (i.e. `include_path`) are ignored. include_path (list): Paths to search for include files when compiling with the wrapped compiler. Ignored if :any:`wrapped` is None. library_path (list): Paths to search for libraries when linking with the wrapped compiler. Ignored if :any:`wrapped` is None. compiler_flags (list): Additional flags used when compiling with the wrapped compiler. Ignored if :any:`wrapped` is None. libraries (list): Additional libraries to link when linking with the wrapped compiler. Ignored if :any:`wrapped` is None. """ self._version_string = None self.absolute_path = absolute_path self.info = info self.command = os.path.basename(absolute_path) self.path = os.path.dirname(absolute_path) if wrapped: assert isinstance(wrapped, InstalledCompiler) self.include_path = include_path or [] self.library_path = library_path or [] self.compiler_flags = compiler_flags or [] self.libraries = libraries or [] self.wrapped = wrapped else: self.include_path = [] self.library_path = [] self.compiler_flags = [] self.libraries = [] self.wrapped = self._probe_wrapper() if uid: self.uid = uid else: uid_parts = [self.absolute_path, self.info.family.name, self.info.role.keyword] if self.wrapped: uid_parts.append(self.wrapped.uid) for attr in 'include_path', 'library_path', 'compiler_flags', 'libraries': uid_parts.extend(sorted(getattr(self, attr))) self.uid = util.calculate_uid(uid_parts) # Check that the compiler is executable and of the expected family/role. # Prevents compilers with the same command (e.g. Cray cc and GNU cc) from crossing. # Don't need to check the compiler family of compiler wrappers since the compiler # the wrapper wraps has already been checked. if not self.wrapped and info.family.family_regex: if not re.search(info.family.family_regex, self.version_string): probed_family = _CompilerFamily.probe(absolute_path) raise ConfigurationError("Compiler '%s' is a %s compiler, not a %s compiler." % (absolute_path, probed_family.name, info.family.name))