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:
parent
527bb7abfe
commit
4d74784209
@ -1257,69 +1257,81 @@ def _is_valid_os(self, os_string, platform):
|
||||
return True
|
||||
return False
|
||||
|
||||
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
|
||||
|
||||
e.g
|
||||
=linux-ubuntu10-x84_64 -> (linux, ubuntu10, x86_64)
|
||||
|
||||
=cray_xc-SuSE11-haswell -> (cray_xc, SuSE11, haswell)
|
||||
|
||||
=bgq -> (bgq,
|
||||
default_os,
|
||||
default_target)
|
||||
|
||||
=elcapitan -> (darwin, elcapitan, x86_64)
|
||||
|
||||
=x86_64 -> (autodetected platform,
|
||||
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:
|
||||
if self._is_valid_platform(entry, platform_names):
|
||||
# If entry is different from platform name then create it.
|
||||
# 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)
|
||||
def add_target_from_string(self, arch):
|
||||
if arch.target is None:
|
||||
return arch.platform.target('default_target')
|
||||
else:
|
||||
# throw error since entry is unknown
|
||||
raise UnknownArchitectureSpecError(entry)
|
||||
return arch.platform.target(arch.target)
|
||||
|
||||
if target is None:
|
||||
target = platform.target('default')
|
||||
if platform_os is None:
|
||||
platform_os = platform.operating_system('default_os')
|
||||
def add_operating_system_from_string(self, arch):
|
||||
if arch.platform_os is None:
|
||||
return arch.platform.operating_system('default_os')
|
||||
else:
|
||||
return arch.platform.operating_system(arch.platform_os)
|
||||
|
||||
self.architecture = Arch(platform=platform,
|
||||
platform_os=platform_os,
|
||||
target=target)
|
||||
#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
|
||||
|
||||
# e.g
|
||||
# =linux-ubuntu10-x84_64 -> (linux, ubuntu10, x86_64)
|
||||
|
||||
# =cray_xc-SuSE11-haswell -> (cray_xc, SuSE11, haswell)
|
||||
|
||||
# =bgq -> (bgq,
|
||||
# default_os,
|
||||
# default_target)
|
||||
|
||||
# =elcapitan -> (darwin, elcapitan, x86_64)
|
||||
|
||||
# =x86_64 -> (autodetected platform,
|
||||
# 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:
|
||||
# if self._is_valid_platform(entry, platform_names):
|
||||
# # If entry is different from platform name then create it.
|
||||
# # 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)
|
||||
|
||||
# if target is None:
|
||||
# target = platform.target('default')
|
||||
# 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):
|
||||
"""determine if this spec satisfies all constraints of another.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user