Compare commits

..

1 Commits

Author SHA1 Message Date
Gregory Becker
17c3d6ab19 colima wip 2023-05-30 16:11:36 -07:00
3 changed files with 68 additions and 54 deletions

View File

@@ -233,25 +233,38 @@ def find_compilers(path_hints=None):
path_hints = get_path("PATH")
default_paths = fs.search_paths_for_executables(*path_hints)
pkg_cls_to_check = [spack.repo.path.get_pkg_class(pkg) for pkg in ["apple-clang"]]
detected_compilers = spack.detection.by_executable(pkg_cls_to_check, path_hints=default_paths)
# To detect the version of the compilers, we dispatch a certain number
# of function calls to different workers. Here we construct the list
# of arguments for each call.
arguments = []
for o in all_os_classes():
search_paths = getattr(o, "compiler_search_paths", default_paths)
arguments.extend(arguments_to_detect_version_fn(o, search_paths))
platform = spack.platforms.host()
operating_system = platform.operating_system("default_os")
target = platform.target("default_target")
# Here we map the function arguments to the corresponding calls
tp = multiprocessing.pool.ThreadPool()
try:
detected_versions = tp.map(detect_version, arguments)
finally:
tp.close()
compilers = []
for name, detected in detected_compilers.items():
for entry in detected:
compiler_cls = spack.compilers.class_for_compiler_name(name)
spec = spack.spec.CompilerSpec(entry.spec.name, f"={entry.spec.versions}")
paths = [
entry.spec.extra_attributes["compilers"].get(x, None)
for x in ("c", "cxx", "f77", "fc")
]
compilers.append(compiler_cls(spec, str(operating_system), str(target), paths))
def valid_version(item):
value, error = item
if error is None:
return True
try:
# This will fail on Python 2.6 if a non ascii
# character is in the error
tty.debug(error)
except UnicodeEncodeError:
pass
return False
return compilers
def remove_errors(item):
value, _ = item
return value
return make_compiler_list(map(remove_errors, filter(valid_version, detected_versions)))
def find_new_compilers(path_hints=None, scope=None):

View File

@@ -1,38 +0,0 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from spack.package import *
import spack.compilers.apple_clang
class AppleClang(Package):
def install(self, spec, prefix):
raise NotImplementedError
executables = [r"^clang\+\+", r"^clang"]
@classmethod
def determine_version(cls, exe):
try:
output = spack.compiler.get_compiler_version_output(exe, "--version")
except Exception:
output = ""
version = spack.compilers.apple_clang.AppleClang.extract_version_from_output(output)
if version == "unknown":
return None
return version
@classmethod
def determine_variants(cls, exes, version_str):
compilers = {}
for exe in exes:
basename = os.path.basename(exe)
if basename == "clang":
compilers["c"] = exe
elif basename == "clang++":
compilers["cxx"] = exe
return "", {"compilers": compilers}

View File

@@ -0,0 +1,39 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# ----------------------------------------------------------------------------
# If you submit this package back to Spack as a pull request,
# please first remove this boilerplate and all FIXME comments.
#
# This is a template package file for Spack. We've put "FIXME"
# next to all the things you'll want to change. Once you've handled
# them, you can save this file and test your package like this:
#
# spack install colima
#
# You can edit this file again by typing:
#
# spack edit colima
#
# See the Spack documentation for more information on packaging.
# ----------------------------------------------------------------------------
from spack.package import *
class Colima(MakefilePackage):
"""FIXME: Put a proper description of your package here."""
# FIXME: Add a proper url for your package's homepage here.
homepage = "https://www.example.com"
url = "https://github.com/abiosoft/colima/archive/refs/tags/v0.5.4.tar.gz"
# FIXME: Add a list of GitHub accounts to
# notify when the package is updated.
# maintainers("github_user1", "github_user2")
version("0.5.4", sha256="9dc25fee68c02a79493d61ecf563832ce483955db102fbca64d112957ae2e6e8")
depends_on("go")