Changed add_architecture_from_string and split the work done into two methods add_target_from_string and add_operating_system_from_string

This commit is contained in:
Mario Melara 2016-03-02 10:27:00 -08:00
parent 527bb7abfe
commit 4d74784209

View File

@ -1257,69 +1257,81 @@ def _is_valid_os(self, os_string, platform):
return True return True
return False return False
def add_architecture_from_string(self, arch): def add_target_from_string(self, arch):
""" The user is able to provide a architecture string of the form if arch.target is None:
platform-os-target. This string will be parsed by this function return arch.platform.target('default_target')
and turn the architecture string into an architecture tuple of else:
platform, operating system and target processor classes. return arch.platform.target(arch.target)
The platform-os-target triplet can be delimited by a '-'. If any
portion of the architecture triplet is empty, spack will supply
the default. If the entire architecture field is blank then
defaults will be provided based off of the platform.
This happens in the concretize_architecture method in concretize.py
e.g def add_operating_system_from_string(self, arch):
=linux-ubuntu10-x84_64 -> (linux, ubuntu10, x86_64) if arch.platform_os is None:
return arch.platform.operating_system('default_os')
else:
return arch.platform.operating_system(arch.platform_os)
=cray_xc-SuSE11-haswell -> (cray_xc, SuSE11, haswell) #def add_architecture_from_string(self, arch):
# """ The user is able to provide a architecture string of the form
# platform-os-target. This string will be parsed by this function
# and turn the architecture string into an architecture tuple of
# platform, operating system and target processor classes.
# The platform-os-target triplet can be delimited by a '-'. If any
# portion of the architecture triplet is empty, spack will supply
# the default. If the entire architecture field is blank then
# defaults will be provided based off of the platform.
# This happens in the concretize_architecture method in concretize.py
=bgq -> (bgq, # e.g
default_os, # =linux-ubuntu10-x84_64 -> (linux, ubuntu10, x86_64)
default_target)
=elcapitan -> (darwin, elcapitan, x86_64) # =cray_xc-SuSE11-haswell -> (cray_xc, SuSE11, haswell)
=x86_64 -> (autodetected platform, # =bgq -> (bgq,
default_os, # default_os,
x86_64) # default_target)
"""
if arch is None: return
platform_list = spack.architecture.all_platforms() # =elcapitan -> (darwin, elcapitan, x86_64)
platform_names = {plat.__name__.lower():plat for plat in platform_list}
Arch = spack.architecture.Arch
arch_list = arch.split("-")
# Create instance of current platform, gets overwritten if user # =x86_64 -> (autodetected platform,
# provided a platform spec. # default_os,
platform = spack.architecture.sys_type() # x86_64)
target = None # """
platform_os = None # if arch is None: return
#
# platform_list = spack.architecture.all_platforms()
# platform_names = {plat.__name__.lower():plat for plat in platform_list}
# Arch = spack.architecture.Arch
# arch_list = arch.split("-")
#
# # Create instance of current platform, gets overwritten if user
# # provided a platform spec.
# platform = spack.architecture.sys_type()
# target = None
# platform_os = None
for entry in arch_list: # for entry in arch_list:
if self._is_valid_platform(entry, platform_names): # if self._is_valid_platform(entry, platform_names):
# If entry is different from platform name then create it. # # If entry is different from platform name then create it.
# else just keep the already instantiated platform class # # else just keep the already instantiated platform class
if entry != platform.name: # if entry != platform.name:
platform = platform_dict[entry]() # Create instance of platform # platform = platform_dict[entry]() # Create instance of platform
elif self._is_valid_target(entry, platform): # elif self._is_valid_target(entry, platform):
target = platform.target(entry) # target = platform.target(entry)
# check if os is valid by checking platform operating sys dict # # check if os is valid by checking platform operating sys dict
elif self._is_valid_os(entry, platform): # elif self._is_valid_os(entry, platform):
platform_os = platform.operating_system(entry) # platform_os = platform.operating_system(entry)
else: # else:
# throw error since entry is unknown # # throw error since entry is unknown
raise UnknownArchitectureSpecError(entry) # raise UnknownArchitectureSpecError(entry)
if target is None: # if target is None:
target = platform.target('default') # target = platform.target('default')
if platform_os is None: # if platform_os is None:
platform_os = platform.operating_system('default_os') # platform_os = platform.operating_system('default_os')
self.architecture = Arch(platform=platform,
platform_os=platform_os,
target=target)
# self.architecture = Arch(platform=platform,
# platform_os=platform_os,
# target=target)
#
def satisfies(self, other, deps=True, strict=False): def satisfies(self, other, deps=True, strict=False):
"""determine if this spec satisfies all constraints of another. """determine if this spec satisfies all constraints of another.