openradioss: add DEXEC_NAME to cmake variable and change style of cmake_args (#43365)

This commit is contained in:
kjrstory 2024-03-29 18:45:54 +09:00 committed by GitHub
parent 3bdebeba3c
commit 5932ee901c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 58 deletions

View File

@ -54,59 +54,52 @@ class OpenradiossEngine(CMakePackage):
@property @property
def compiler_name(self): def compiler_name(self):
compiler_mapping = { compiler_mapping = {
"aocc": "64_AOCC", "aocc": "linux64_AOCC",
"intel": "64_intel", "intel": "linux64_intel",
"oneapi": "64_intel", "oneapi": "linux64_intel",
"gcc": "64_gf", "gcc": "linux64_gf",
"arm": "a64_gf", "arm": "linuxa64",
} }
compiler_name = compiler_mapping[self.spec.compiler.name] compiler_name = compiler_mapping[self.spec.compiler.name]
return compiler_name return compiler_name
def cmake_args(self): def cmake_args(self):
args = [ args = [
"-Dmpi_os=0", self.define("mpi_os", False),
"-DCMAKE_Fortran_COMPILER={0}".format(spack_fc), self.define("CMAKE_Fortran_COMPILER", spack_fc),
"-DCMAKE_C_COMPILER={0}".format(spack_cc), self.define("CMAKE_C_COMPILER", spack_cc),
"-DCMAKE_CPP_COMPILER={0}".format(spack_cxx), self.define("CMAKE_CPP_COMPILER", spack_cxx),
"-DCMAKE_CXX_COMPILER={0}".format(spack_cxx), self.define("CMAKE_CXX_COMPILER", spack_cxx),
"-Dsanitize=0", self.define("sanitize", False),
self.define("arch", self.compiler_name),
self.define_from_variant("debug", "debug"),
self.define_from_variant("static_link", "static_link"),
] ]
args.append("-Drach=linux" + self.compiler_name)
if "+sp" in self.spec: if "+sp" in self.spec:
args.append("-Dprecision=sp") args.append(self.define("precision", "sp"))
else: else:
args.append("-Dprecision=dp") args.append(self.define("precision", "dp"))
if "+mpi" in self.spec: if "+mpi" in self.spec:
args.append("-DMPI=ompi") args.append(self.define("MPI", "ompi"))
args.append("-Dmpi_root=" + self.spec["mpi"].prefix) args.append(self.define("mpi_root", self.spec["mpi"].prefix))
args.append("-Dmpi_incdir=" + self.spec["mpi"].prefix.include) args.append(self.define("mpi_incdir", self.spec["mpi"].prefix.include))
args.append("-Dmpi_libdir=" + self.spec["mpi"].prefix.lib) args.append(self.define("mpi_libdir", self.spec["mpi"].prefix.lib))
else: else:
args.append("-DMPI=smp") args.append(self.define("MPI", "smp"))
if "+debug" in self.spec: exec_file = f"engine_{self.compiler_name}"
args.append("-Ddebug=1") exec_file += "_ompi" if "+mpi" in self.spec else ""
else: args.append(self.define("EXEC_NAME", exec_file))
args.append("-Ddebug=0")
if "+static_link" in self.spec:
args.append("-Dstatic_link=1")
else:
args.append("-Dstatic_link=0")
return args return args
def install(self, spec, prefix): def install(self, spec, prefix):
mkdirp(join_path(prefix, "exec")) mkdirp(join_path(prefix, "exec"))
if "+mpi" in spec: exec_file = f"engine_{self.compiler_name}"
exec_file = "engine_linux" + self.compiler_name + "_ompi" exec_file += "_ompi" if "+mpi" in self.spec else ""
else:
exec_file = "engine_linux" + self.compiler_name
install( install(
join_path(self.stage.source_path, "engine", exec_file), join_path(self.stage.source_path, "engine", exec_file),

View File

@ -53,47 +53,39 @@ class OpenradiossStarter(CMakePackage):
@property @property
def compiler_name(self): def compiler_name(self):
compiler_mapping = { compiler_mapping = {
"aocc": "64_AOCC", "aocc": "linux64_AOCC",
"intel": "64_intel", "intel": "linux64_intel",
"oneapi": "64_intel", "oneapi": "linux64_intel",
"gcc": "64_gf", "gcc": "linux64_gf",
"arm": "a64_gf", "arm": "linuxa64",
} }
compiler_name = compiler_mapping[self.spec.compiler.name] compiler_name = compiler_mapping[self.spec.compiler.name]
return compiler_name return compiler_name
def cmake_args(self): def cmake_args(self):
args = [ args = [
"-DCMAKE_Fortran_COMPILER={0}".format(spack_fc), self.define("CMAKE_Fortran_COMPILER", spack_fc),
"-DCMAKE_C_COMPILER={0}".format(spack_cc), self.define("CMAKE_C_COMPILER", spack_cc),
"-DCMAKE_CPP_COMPILER={0}".format(spack_cxx), self.define("CMAKE_CPP_COMPILER", spack_cxx),
"-DCMAKE_CXX_COMPILER={0}".format(spack_cxx), self.define("CMAKE_CXX_COMPILER", spack_cxx),
"-Dsanitize=0", self.define("santize", False),
self.define("arch", self.compiler_name),
self.define("EXEC_NAME", f"starter_{self.compiler_name}"),
self.define_from_variant("debug", "debug"),
self.define_from_variant("static_link", "static_link"),
] ]
args.append("-Darch=linux" + self.compiler_name)
if "+sp" in self.spec: if "+sp" in self.spec:
args.append("-Dprecision=sp") args.append(self.define("precision", "sp"))
else: else:
args.append("-Dprecision=dp") args.append(self.define("precision", "dp"))
if "+debug" in self.spec:
args.append("-Ddebug=1")
else:
args.append("-Ddebug=0")
if "+static_link" in self.spec:
args.append("-Dstatic_link=1")
else:
args.append("-Dstatic_link=0")
return args return args
def install(self, spec, prefix): def install(self, spec, prefix):
mkdirp(join_path(prefix, "exec")) mkdirp(join_path(prefix, "exec"))
exec_file = "starter_linux" + self.compiler_name exec_file = f"starter_{self.compiler_name}"
install( install(
join_path(self.stage.source_path, "starter", exec_file), join_path(self.stage.source_path, "starter", exec_file),