Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whisper-cpp: make compatible with --HEAD install #202270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions Formula/w/whisper-cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WhisperCpp < Formula

def install
args = %W[
-DBUILD_SHARED_LIBS=OFF
-DBUILD_SHARED_LIBS=#{build.head? ? "ON" : "OFF"}
-DGGML_METAL=#{(OS.mac? && !Hardware::CPU.intel?) ? "ON" : "OFF"}
-DGGML_METAL_EMBED_LIBRARY=#{OS.mac? ? "ON" : "OFF"}
-DGGML_NATIVE=#{build.bottle? ? "OFF" : "ON"}
Expand All @@ -33,11 +33,29 @@ def install
-DWHISPER_BUILD_SERVER=OFF
]
args << "-DLLAMA_METAL_MACOSX_VERSION_MIN=#{MacOS.version}" if OS.mac?
args << "-DCMAKE_INSTALL_RPATH=#{rpath(target: prefix/"libinternal")}" if build.head?

system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
# the "main" target is our whisper-cpp binary
system "cmake", "--build", "build", "--target", "main"
bin.install "build/bin/main" => "whisper-cpp"
# avoid installing libggml libraries to "lib" since they would conflict with llama.cpp
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "libinternal")
Copy link
Member

@carlocab carlocab Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "libinternal")
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args(install_libdir: "lib/ggml")

Maybe? You'll need to adjust the argument to #rpath from my suggestion above if you apply this. (to rpath(target: lib/"ggml")).

Though, ideally we should be using libggml from llama.cpp instead (or vice-versa).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, ideally we should be using libggml from llama.cpp instead (or vice-versa).

I've suggested this with maintainers of libggml/llama.cpp/whisper.cpp and they said that could be an eventual goal but that the codebases aren't ready for that at this moment since libggml seems to be such a fast-moving target.

if build.head?
system "cmake", "--build", "build"
system "cmake", "--install", "build"
# avoid publishing header files since they will conflict with llama.cpp
rm_r include
else
# the "main" target is our whisper-cli binary
system "cmake", "--build", "build", "--target", "main"
bin.install "build/bin/main" => "whisper-cli"
end

# for backward compatibility with existing installs
(bin/"whisper-cpp").write <<~EOS
#!/bin/bash
here="${BASH_SOURCE[0]}"
echo "${BASH_SOURCE[0]}: warning: whisper-cpp is deprecated. Use whisper-cli instead." >&2
exec "$(dirname "$here")/whisper-cli" "$@"
EOS
(bin/"whisper-cpp").chmod 0755

pkgshare.install "models/for-tests-ggml-tiny.bin", "samples/jfk.wav"
end
Expand Down
Loading