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

@ -1256,70 +1256,82 @@ def _is_valid_os(self, os_string, platform):
if os_string in platform.operating_sys: if os_string in platform.operating_sys:
return True return True
return False return False
def add_target_from_string(self, arch):
if arch.target is None:
return arch.platform.target('default_target')
else:
return arch.platform.target(arch.target)
def add_architecture_from_string(self, arch): def add_operating_system_from_string(self, arch):
""" The user is able to provide a architecture string of the form if arch.platform_os is None:
platform-os-target. This string will be parsed by this function return arch.platform.operating_system('default_os')
and turn the architecture string into an architecture tuple of else:
platform, operating system and target processor classes. return arch.platform.operating_system(arch.platform_os)
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_architecture_from_string(self, arch):
=linux-ubuntu10-x84_64 -> (linux, ubuntu10, x86_64) # """ 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
=cray_xc-SuSE11-haswell -> (cray_xc, SuSE11, haswell) # e.g
# =linux-ubuntu10-x84_64 -> (linux, ubuntu10, x86_64)
=bgq -> (bgq, # =cray_xc-SuSE11-haswell -> (cray_xc, SuSE11, haswell)
default_os,
default_target)
=elcapitan -> (darwin, elcapitan, x86_64) # =bgq -> (bgq,
# default_os,
# default_target)
=x86_64 -> (autodetected platform, # =elcapitan -> (darwin, elcapitan, x86_64)
default_os,
x86_64)
"""
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: # =x86_64 -> (autodetected platform,
if self._is_valid_platform(entry, platform_names): # default_os,
# If entry is different from platform name then create it. # x86_64)
# else just keep the already instantiated platform class # """
if entry != platform.name: # if arch is None: return
platform = platform_dict[entry]() # Create instance of platform #
elif self._is_valid_target(entry, platform): # platform_list = spack.architecture.all_platforms()
target = platform.target(entry) # platform_names = {plat.__name__.lower():plat for plat in platform_list}
# check if os is valid by checking platform operating sys dict # Arch = spack.architecture.Arch
elif self._is_valid_os(entry, platform): # arch_list = arch.split("-")
platform_os = platform.operating_system(entry) #
else: # # Create instance of current platform, gets overwritten if user
# throw error since entry is unknown # # provided a platform spec.
raise UnknownArchitectureSpecError(entry) # platform = spack.architecture.sys_type()
# target = None
# platform_os = None
if target is None: # for entry in arch_list:
target = platform.target('default') # if self._is_valid_platform(entry, platform_names):
if platform_os is None: # # If entry is different from platform name then create it.
platform_os = platform.operating_system('default_os') # # else just keep the already instantiated platform class
# if entry != platform.name:
# platform = platform_dict[entry]() # Create instance of platform
# elif self._is_valid_target(entry, platform):
# target = platform.target(entry)
# # check if os is valid by checking platform operating sys dict
# elif self._is_valid_os(entry, platform):
# platform_os = platform.operating_system(entry)
# else:
# # throw error since entry is unknown
# raise UnknownArchitectureSpecError(entry)
self.architecture = Arch(platform=platform, # if target is None:
platform_os=platform_os, # target = platform.target('default')
target=target) # if platform_os is None:
# platform_os = platform.operating_system('default_os')
# 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.