partial work on bug hunting

This commit is contained in:
Gregory Becker 2016-03-02 10:56:46 -08:00
parent f27f2f8e49
commit 45887dec8e
3 changed files with 37 additions and 38 deletions

View file

@ -203,8 +203,8 @@ class Arch(namedtuple("Arch", "platform platform_os target")):
__slots__ = () __slots__ = ()
def __str__(self): def __str__(self):
return (self.platform.name +"-"+ return (str(self.platform) +"-"+
self.platform_os.name + "-" + self.target.name) str(self.platform_os) + "-" + str(self.target) )
def _cmp_key(self): def _cmp_key(self):
return (self.platform, self.platform_os, self.target) return (self.platform, self.platform_os, self.target)
@ -246,14 +246,14 @@ def to_dict(arch):
return d return d
def _platform_from_dict(platform): #def _platform_from_dict(platform):
"""Creates all the platform class module names into a dictionary of # """Creates all the platform class module names into a dictionary of
name : <class_mod> key-value pairs. From there we can construct the # name : <class_mod> key-value pairs. From there we can construct the
platform subclass # platform subclass
""" # """
platform_list = all_platforms() # platform_list = all_platforms()
platform_names = {plat.__name__.lower():plat for plat in platform_list} # platform_names = {plat.__name__.lower():plat for plat in platform_list}
return platform_names[platform['name']]() # return platform_names[platform['name']]()
def _target_from_dict(target_dict): def _target_from_dict(target_dict):
@ -288,7 +288,7 @@ def arch_from_dict(d):
platform_os_dict = d['platform_os'] platform_os_dict = d['platform_os']
target_dict = d['target'] target_dict = d['target']
platform = _platform_from_dict(platform_dict) platform = d['platform']
platform_os = _operating_system_from_dict(platform_os_dict, platform) platform_os = _operating_system_from_dict(platform_os_dict, platform)
target = _target_from_dict(target_dict) target = _target_from_dict(target_dict)

View file

@ -217,14 +217,14 @@ def _concretize_platform(self, arch, platform):
arch.platform = platform arch.platform = platform
return True return True
def _concretize_operating_system(self, arch, platform): def _concretize_operating_system(self, spec, platform):
if spec.architecture.platform_os is not None: if spec.architecture.platform_os is not None:
if isinstance(spec.architecture.platform_os,spack.architecture.OperatingSystem): if isinstance(spec.architecture.platform_os,spack.architecture.OperatingSystem):
return False return False
else: else:
spec.add_operating_system_from_string(spec.architecture.platform_os) spec.add_operating_system_from_string(spec.architecture.platform_os)
return True #changed return True #changed
if spec.root.architecture.platform_os: if spec.root.architecture and spec.root.architecture.platform_os:
if isinstance(spec.root.architecture.platform_os,spack.architecture.OperatingSystem): if isinstance(spec.root.architecture.platform_os,spack.architecture.OperatingSystem):
spec.architecture.platform_os = spec.root.architecture.platform_os spec.architecture.platform_os = spec.root.architecture.platform_os
else: else:
@ -243,22 +243,22 @@ def _concretize_operating_system(self, arch, platform):
# return True # return True
def _concretize_target(self, arch, platform): def _concretize_target(self, spec, platform):
if spec.target is not None: if spec.architecture.target is not None:
if isinstance(spec.target,spack.architecture.Target): if isinstance(spec.architecture.target,spack.architecture.Target):
return False return False
else: else:
spec.add_target_from_string(spec.target) spec.add_target_from_string(spec.architecture.target)
return True #changed return True #changed
if spec.root.target: if spec.root.architecture and spec.root.architecture.target:
if isinstance(spec.root.target,spack.architecture.Target): if isinstance(spec.root.architecture.target,spack.architecture.Target):
spec.target = spec.root.target spec.architecture.target = spec.root.architecture.target
else: else:
spec.add_target_from_string(spec.root.target) spec.add_target_from_string(spec.root.architecture.target)
else: else:
platform = spack.architecture.sys_type() platform = spack.architecture.sys_type()
spec.target = platform.target('default') spec.architecture.target = platform.target('default')
return True #changed return True #changed
@ -283,22 +283,20 @@ def concretize_architecture(self, spec):
platform = spack.architecture.sys_type() platform = spack.architecture.sys_type()
if spec.architecture is None: if spec.architecture is None:
# Create an empty tuple
Arch = spack.architecture.Arch
# Set the architecture to all defaults # Set the architecture to all defaults
spec.architecture = Arch(platform=platform, platform_os=None, spec.architecture = spack.architecture.Arch(platform=platform, platform_os=None,
target=None) target=None)
return True return True
#If there is a target and it is a tuple and has both filled return #If there is a target and it is a tuple and has both filled return
#False #False
# if isinstance(spec.architecture, basestring): # if isinstance(spec.architecture, basestring):
# spec.split_architecture_string(spec.architecture) # spec.split_architecture_string(spec.architecture)
print spec.architecture
ret = any(( ret = any((
self._concretize_platform(spec.architecture, platform), self._concretize_platform(spec.architecture, platform),
self._concretize_operating_system(spec.architecture, platform), self._concretize_operating_system(spec, platform),
self._concretize_target(spec.architecture, platform))) self._concretize_target(spec, platform)))
# Does not look pretty at all!!! # Does not look pretty at all!!!

View file

@ -462,11 +462,12 @@ def _set_architecture(self, architecture):
if self.architecture: raise DuplicateArchitectureError( if self.architecture: raise DuplicateArchitectureError(
"Spec for '%s' cannot have two architectures." % self.name) "Spec for '%s' cannot have two architectures." % self.name)
platform = spack.architecture.sys_type() platform = spack.architecture.sys_type()
print architecture
if '-' in architecture: if '-' in architecture:
os, target = architecture.split('-') os, target = architecture.split('-')
else: else:
os = architecture os = None
target = None target = architecture
self.architecture = spack.architecture.Arch(platform, os, target) self.architecture = spack.architecture.Arch(platform, os, target)
@ -1257,17 +1258,17 @@ def _is_valid_os(self, os_string, platform):
return True return True
return False return False
def add_target_from_string(self, arch): def add_target_from_string(self, target):
if arch.target is None: if target is None:
return arch.platform.target('default_target') self.architecture.target = self.architecture.platform.target('default_target')
else: else:
return arch.platform.target(arch.target) self.architecture.target = self.architecture.platform.target(target)
def add_operating_system_from_string(self, arch): def add_operating_system_from_string(self, os):
if arch.platform_os is None: if os is None:
return arch.platform.operating_system('default_os') self.architecture.platform_os = self.architecture.platform.operating_system('default_os')
else: else:
return arch.platform.operating_system(arch.platform_os) self.architecture.platform_os = self.architecture.platform.operating_system(os)
#def add_architecture_from_string(self, arch): #def add_architecture_from_string(self, arch):
# """ The user is able to provide a architecture string of the form # """ The user is able to provide a architecture string of the form