-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first iteration of plugin enabled spackage
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,25 @@ | |
|
||
import os | ||
|
||
from spack.error import SpackError | ||
from spack.package import * | ||
from spack.directives import directive | ||
|
||
|
||
@directive("singularity_eos_plugins") | ||
def singularity_eos_plugin(name, path): | ||
def _execute_register(pkg): | ||
pkg.plugins[name] = path | ||
|
||
return _execute_register | ||
|
||
|
||
def plugin_validator(pkg_name, variant_name, values): | ||
if values == ("none",): | ||
return | ||
for v in values: | ||
if v not in SingularityEos.plugins: | ||
raise SpackError(f"Unknown Singularity-EOS plugin '{v}'") | ||
|
||
|
||
class SingularityEos(CMakePackage, CudaPackage): | ||
|
@@ -63,6 +81,19 @@ class SingularityEos(CMakePackage, CudaPackage): | |
|
||
variant("closure", default=True, description="Build closure module") | ||
|
||
plugins = {} | ||
|
||
singularity_eos_plugin("dust", "example/plugin") | ||
|
||
variant( | ||
"plugins", | ||
multi=True, | ||
default="none", | ||
validator=plugin_validator, | ||
description="list of plugins to build", | ||
) | ||
variant("variant", default="default", description="include path used for variant header") | ||
|
||
# building/testing/docs | ||
depends_on("[email protected]:") | ||
depends_on("[email protected]:", when="@main +tests") | ||
|
@@ -183,6 +214,15 @@ def cmake_args(self): | |
self.define("SINGULARITY_USE_EOSPAC", "^eospac" in self.spec), | ||
] | ||
|
||
if "none" not in self.spec.variants["plugins"].value: | ||
pdirs = [] | ||
for p in self.spec.variants["plugins"].value: | ||
pdirs.append(join_path(self.stage.source_path, self.plugins[p])) | ||
args.append(self.define("SINGULARITY_PLUGINS", ";".join(pdirs))) | ||
|
||
if self.spec.variants["variant"].value != "default": | ||
args.append(self.define_from_variant("SINGULARITY_VARIANT", "variant")) | ||
|
||
#TODO: do we need this? | ||
if "+kokkos+cuda" in self.spec: | ||
args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx)) | ||
|