Commit b5359a9e authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Slight rework of mpcdf_enable_repositories

Do not filter Compiler for CUDA repositories, they have a fixed
relationship, change macro semantic somewhat, add have_* macros
parent b8939ecf
from __future__ import print_function
__all__ = ["valid_mpi", "valid_cuda", "project_meta", "get_attribute", "get_attribute_values", "set_attribute", "mpcdf_enable_repositories", "mpcdf_setup_repositories"]
import osc
import osc.conf
import osc.core
......@@ -124,6 +122,7 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False):
build.remove(enable)
compilers = get_attribute_values(api_url, project, package, "MPCDF:compiler_modules", with_project=True)
all_compilers = get_attribute_values(api_url, project, None, "MPCDF:compiler_modules")
mpis = get_attribute_values(api_url, project, package, "MPCDF:mpi_modules", with_project=True)
cudas = get_attribute_values(api_url, project, package, "MPCDF:cuda_modules", with_project=True)
......@@ -159,13 +158,13 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False):
if flag == "cuda":
for cuda in cudas:
for compiler in compilers:
for compiler in all_compilers:
if valid_cuda(cuda, compiler):
enable(cuda + "_" + compiler)
if flag == "cuda_mpi":
for cuda in cudas:
for compiler in compilers:
for compiler in all_compilers:
if valid_cuda(cuda, compiler):
for mpi in mpis:
if valid_mpi(compiler, mpi):
......@@ -192,8 +191,12 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
if distribution is None:
# Get existing value from project meta
distribution = project_meta(api_url, project if parent is None else parent).find(
"./repository[@name='System']/path[@project='distributions']").get("repository")
dist_repo = project_meta(api_url, project if parent is None else parent).find(
"./repository[@name='System']/path[@project='distributions']")
if dist_repo is not None:
distribution = dist_repo.get("repository")
else:
raise osc.oscerr.WrongArgs("ERROR: Specify distribution or parent project")
print("Using '{0}' as base distribution".format(distribution))
distributions = project_meta(api_url, "distributions")
......@@ -220,12 +223,19 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
prjconf = [start_marker]
# Remove existing repositories
for repo in root.findall("./repository"):
root.remove(repo)
for oldrepo in root.findall("./repository"):
root.remove(oldrepo)
def repo(name, *dependencies, **kwargs):
is_compiler = kwargs.pop("compiler", False)
is_mpi = kwargs.pop("mpi", False)
is_cuda = kwargs.pop("cuda", False)
is_cuda_mpi = kwargs.pop("cuda_mpi", False)
have_compiler = is_compiler or is_mpi or is_cuda or is_cuda_mpi
have_mpi = is_mpi or is_cuda_mpi
have_cuda = is_cuda or is_cuda_mpi
if kwargs:
raise Exception("Invalid argument")
r = ElementTree.SubElement(root, "repository")
......@@ -252,8 +262,16 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
prjconf.append("%if %_repository == {0}".format(name))
prjconf.append("Macros:")
prjconf.append("%is_compiler_repository {0}".format(1 if is_compiler else 0))
prjconf.append("%is_mpi_repository {0}".format(1 if is_mpi else 0))
prjconf.append("%is_cuda_repository {0}".format(1 if is_cuda else 0))
prjconf.append("%is_cuda_mpi_repository {0}".format(1 if is_cuda_mpi else 0))
prjconf.append("%have_mpcdf_compiler {0}".format(1 if have_compiler else 0))
prjconf.append("%have_mpcdf_mpi {0}".format(1 if have_mpi else 0))
prjconf.append("%have_mpcdf_cuda {0}".format(1 if have_cuda else 0))
prjconf.append(":Macros")
prjconf.append("%endif")
prjconf.append("")
......@@ -264,7 +282,7 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
repo("System", ("distributions", distribution))
for compiler in compilers:
repo(compiler, (project, "System"))
repo(compiler, (project, "System"), compiler=True)
for mpi in filter(partial(valid_mpi, compiler), mpis):
repo(mpi + "_" + compiler, (project, compiler), mpi=True)
......@@ -276,7 +294,7 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
repo(cuda + "_" + mpi + "_" + compiler,
(project, cuda + "_" + compiler),
(project, mpi + "_" + compiler),
mpi=True, cuda=True)
cuda_mpi=True)
# Remove build configuration
build = root.find("./build")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment