cmake build system: make "generator" a variant#35552
Conversation
| allowed_values = ("make", "ninja") | ||
| if any(x not in allowed_values for x in names): | ||
| msg = "only 'make' and 'ninja' are allowed for CMake's 'generator' directive" | ||
| raise ValueError(msg) | ||
|
|
||
| default = default or names[0] | ||
| not_used = [x for x in allowed_values if x not in names] | ||
|
|
||
| def _values(x): | ||
| return x in allowed_values | ||
|
|
||
| _values.__doc__ = f"{','.join(names)}" | ||
|
|
||
| variant( | ||
| "generator", | ||
| default=default, | ||
| values=_values, | ||
| description="the build system generator to use", | ||
| ) | ||
| for x in not_used: | ||
| conflicts(f"generator={x}") |
There was a problem hiding this comment.
This works fine, but can probably cleaned a bit once we have the drop directive from #35045
|
The only reason we didn't do this originally was because the thing getting installed (shouldn't) change, so we didn't want to include it in the hash. But with concretizer reuse the default, maybe this doesn't matter as much. However, the current implementation is more "make generator a directive" than "make generator a variant". The packages that set |
If we have packages that only work with The issue are the checks we do on conditional dependencies like: depends_on("gmake", when="generator=make")that would raise when only Also forgot to mention that a added benefit is that now the dependency on |
|
Oh, so you're saying if the base class contains: variant("generator", values=["make", "ninja"])
depends_on("ninja", when="generator=ninja")and a subclass contains: variant("generator", values=["make"])the subclass will raise audit issues because |
Actually it won't concretize too, because we do consistency checks also during concretization 😅 |
88bdc67 to
7415f59
Compare
|
This is much improved over the current model! Thanks! |
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
7415f59 to
e4b7561
Compare
|
In order to avoid the aforementioned concretizer/audit check issue, could we instead use: variant("generator", values=["make", "ninja"])
depends_on("ninja", when="generator=ninja")in the base class and: conflicts("generator=ninja")in subclasses that only support make? Then we don't need to add a whole new directive just for this. |
|
@adamjstewart For reasons related to |
This doesn't tell me a lot, but I trust you. Just trying to avoid adding more and more hyper-specific directives if we don't need them. |
If we don't make |
3c9e0e2 to
4cd497f
Compare
4cd497f to
679859c
Compare
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
| with pytest.raises(spack.package_base.InstallError): | ||
| s.package.builder.std_cmake_args | ||
| spack.build_systems.cmake.CMakeBuilder.std_args( | ||
| s.package, generator="Yellow Sticky Notes" |
|
|
||
| depends_on("cmake", type="build") | ||
| depends_on("ninja", type="build", when="platform=windows") | ||
| depends_on("gmake", type="build", when="generator=make") |
There was a problem hiding this comment.
I approve of this!
$ spack spec gmake +guile | grep cmake
has nothing on current develop, so it shouldn't break "advanced" gmake builds. gmake ~guile doesn't have deps.
haampie
left a comment
There was a problem hiding this comment.
I grepped for gmake build deps among packages of which there's only two cmake packages that specify a bound on it, so that looks fine. Ninja I think you got right too
This PR make
generatora variant inCMakePackage. This allows us to declare proper dependencies onninjaandgmake, and to select generators at concretization time where it makes sense.Modifications:
variantsandconflictsCMakePackages to use that directive