Skip to content

Commit

Permalink
Configure 'spack external find grep'
Browse files Browse the repository at this point in the history
  • Loading branch information
climbfuji committed Dec 16, 2024
1 parent fb5aa53 commit 4665c25
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 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,20 @@ 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]
if "GNU grep" in version_string:
return version_string.lstrip("grep (GNU grep)").strip()
elif "BSD grep, GNU compatible" in version_string:
return version_string.lstrip("grep (BSD grep, GNU compatible)").rstrip("-FreeBSD").strip()
else:
# Don't know how to handle this version of grep, don't add it
return None

def configure_args(self):
args = []

Expand Down

0 comments on commit 4665c25

Please sign in to comment.