Skip to content

Commit

Permalink
Merge pull request #492 from climbfuji/feature/find_ext_grep
Browse files Browse the repository at this point in the history
Configure 'spack external find grep'
  • Loading branch information
climbfuji authored Dec 19, 2024
2 parents fedfdb1 + bd8c5ea commit 033e700
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions var/spack/repos/builtin/packages/grep/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ class Grep(AutotoolsPackage):
depends_on("pcre2", when="@3.8:+pcre")
depends_on("pcre", when="@:3.7+pcre")

# For spack external find
executables = ["^grep$"]

@classmethod
def determine_version(cls, exe):
version_string = Executable(exe)("--version", output=str, error=str).split("\n")[0]
# Linux
if "GNU grep" in version_string:
return version_string.lstrip("grep (GNU grep)").strip()
# macOS
elif "BSD grep, GNU compatible" in version_string:
return (
version_string.lstrip("grep (BSD grep, GNU compatible)").rstrip("-FreeBSD").strip()
)
# Don't know how to handle this version of grep, don't add it
else:
return None

def configure_args(self):
args = []

Expand Down

0 comments on commit 033e700

Please sign in to comment.