Ensure variant defaults are parsable from CLI. (#18661)

- Add a unit test to check if there are unparsable defaults
- Fix 'rust' and 'nsimd' variants
This commit is contained in:
Massimiliano Culpo
2020-09-19 07:54:26 +02:00
committed by GitHub
parent fff2f34de8
commit fcb4dfc307
3 changed files with 33 additions and 21 deletions

View File

@@ -2,10 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Nsimd(CMakePackage):
"""NSIMD is a vectorization library that abstracts SIMD programming.
It was designed to exploit the maximum power of processors
@@ -28,11 +24,8 @@ class Nsimd(CMakePackage):
'NEON128', 'AARCH64', 'SVE',
),
multi=False)
variant('optionals',
default=(),
description='Optional SIMD features',
values=('FMA', 'FP16'),
multi=True)
variant('optionals', values=any_combination_of('FMA', 'FP16'),
description='Optional SIMD features',)
conflicts('simd=none', msg="SIMD instruction set not defined")
@@ -56,10 +49,14 @@ def generate_code(self, spec, prefix):
python(*options)
def cmake_args(self):
# Required SIMD argument
simd = self.spec.variants['simd'].value
optionals = ';'.join(self.spec.variants['optionals'].value)
cmake_args = [
"-DSIMD={0}".format(simd),
"-DSIMD_OPTIONALS={0}".format(optionals),
]
cmake_args = ["-DSIMD={0}".format(simd)]
# Optional SIMD instructions to be turned on explicitly
optionals_value = self.spec.variants['optionals'].value
if optionals_value != 'none':
optionals_arg = ';'.join(optionals_value)
cmake_args.append("-DSIMD_OPTIONALS={0}".format(optionals_arg))
return cmake_args

View File

@@ -2,8 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
from six import iteritems
@@ -56,9 +54,7 @@ class Rust(Package):
description='Install Rust source files'
)
variant(
'extra_targets',
default=(),
multi=True,
'extra_targets', default='none', multi=True,
description='Triples for extra targets to enable. For supported targets, see: https://doc.rust-lang.org/nightly/rustc/platform-support.html'
)
@@ -502,7 +498,10 @@ def configure(self, spec, prefix):
ar = which('ar', required=True)
extra_targets = list(self.spec.variants['extra_targets'].value)
extra_targets = []
if self.spec.variants['extra_targets'].value != 'none':
extra_targets = list(self.spec.variants['extra_targets'].value)
targets = [self.get_rust_target()] + extra_targets
target_spec = 'target=[' + \
','.join('"{0}"'.format(target) for target in targets) + ']'