diff --git a/ChangeLog.md b/ChangeLog.md index c6e16311..4513e999 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,7 +2,7 @@ ## Next version -*tbd* +- Add `which?` utility method, that checks if a executable is available. ## Current and previous versions diff --git a/build-cfg.yaml b/build-cfg.yaml index 383112e2..5e17b42b 100644 --- a/build-cfg.yaml +++ b/build-cfg.yaml @@ -7,6 +7,7 @@ sources: - exts/string - exts/hash - exts/pathname + - exts/mkmf - exts/thor - core/io - grammars/base_lexer diff --git a/build/fizzy b/build/fizzy index 30417e9a..5f4ff52d 100755 --- a/build/fizzy +++ b/build/fizzy @@ -55,6 +55,7 @@ require "shellwords" require "strscan" require "uri" require "yaml" +require "mkmf" # Try to require `thor` or raise an exception. begin @@ -174,6 +175,13 @@ class Pathname end +# ☞ Exts → Mkmf ──────────────────────────────────────────────────────────────── + +module MakeMakefile::Logging + # Turn off output on `mkmf` methods. + @quiet = true +end + # ☞ Exts → Thor ──────────────────────────────────────────────────────────────── class Thor @@ -633,6 +641,10 @@ module Fizzy::Environment include Fizzy::IO + def which?(name) + find_executable(name.to_s) + end + # Return the environment variable matching the provided `name`. # def get_env(name, default: nil) diff --git a/mkmf.log b/mkmf.log new file mode 100644 index 00000000..d00e02c4 --- /dev/null +++ b/mkmf.log @@ -0,0 +1,4 @@ +find_executable: checking for clang... -------------------- yes + +-------------------- + diff --git a/src/core/environment.rb b/src/core/environment.rb index 56c39988..78e25edc 100644 --- a/src/core/environment.rb +++ b/src/core/environment.rb @@ -4,6 +4,10 @@ module Fizzy::Environment include Fizzy::IO + def which?(name) + find_executable(name.to_s) + end + # Return the environment variable matching the provided `name`. # def get_env(name, default: nil) diff --git a/src/exts/mkmf.rb b/src/exts/mkmf.rb new file mode 100644 index 00000000..50fc30a5 --- /dev/null +++ b/src/exts/mkmf.rb @@ -0,0 +1,4 @@ +module MakeMakefile::Logging + # Turn off output on `mkmf` methods. + @quiet = true +end diff --git a/src/requires.rb b/src/requires.rb index 14b9089e..fe1bfc8b 100644 --- a/src/requires.rb +++ b/src/requires.rb @@ -11,6 +11,7 @@ require "strscan" require "uri" require "yaml" +require "mkmf" # Try to require `thor` or raise an exception. begin