parser: parse compilers as direct build deps
This commit is contained in:
parent
8e7489bc17
commit
78744b11ae
@ -280,12 +280,11 @@ def all_specs(self) -> List["spack.spec.Spec"]:
|
|||||||
class SpecNodeParser:
|
class SpecNodeParser:
|
||||||
"""Parse a single spec node from a stream of tokens"""
|
"""Parse a single spec node from a stream of tokens"""
|
||||||
|
|
||||||
__slots__ = "ctx", "has_compiler", "has_version", "literal_str"
|
__slots__ = "ctx", "has_version", "literal_str"
|
||||||
|
|
||||||
def __init__(self, ctx, literal_str):
|
def __init__(self, ctx, literal_str):
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.literal_str = literal_str
|
self.literal_str = literal_str
|
||||||
self.has_compiler = False
|
|
||||||
self.has_version = False
|
self.has_version = False
|
||||||
|
|
||||||
def parse(
|
def parse(
|
||||||
@ -332,23 +331,13 @@ def add_flag(name: str, value: str, propagate: bool):
|
|||||||
raise_parsing_error(str(e), e)
|
raise_parsing_error(str(e), e)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if self.ctx.accept(SpecTokens.COMPILER):
|
if self.ctx.accept(SpecTokens.COMPILER) or self.ctx.accept(
|
||||||
if self.has_compiler:
|
SpecTokens.COMPILER_AND_VERSION
|
||||||
raise_parsing_error("Spec cannot have multiple compilers")
|
):
|
||||||
|
build_dependency = spack.spec.Spec(self.ctx.current_token.value[1:])
|
||||||
compiler_name = self.ctx.current_token.value[1:]
|
initial_spec._add_dependency(
|
||||||
initial_spec.compiler = spack.spec.CompilerSpec(compiler_name.strip(), ":")
|
build_dependency, depflag=spack.deptypes.BUILD, virtuals=()
|
||||||
self.has_compiler = True
|
|
||||||
|
|
||||||
elif self.ctx.accept(SpecTokens.COMPILER_AND_VERSION):
|
|
||||||
if self.has_compiler:
|
|
||||||
raise_parsing_error("Spec cannot have multiple compilers")
|
|
||||||
|
|
||||||
compiler_name, compiler_version = self.ctx.current_token.value[1:].split("@")
|
|
||||||
initial_spec.compiler = spack.spec.CompilerSpec(
|
|
||||||
compiler_name.strip(), compiler_version
|
|
||||||
)
|
)
|
||||||
self.has_compiler = True
|
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.ctx.accept(SpecTokens.VERSION_HASH_PAIR)
|
self.ctx.accept(SpecTokens.VERSION_HASH_PAIR)
|
||||||
|
Loading…
Reference in New Issue
Block a user