Isolate whisper.cpp dependency build outside the project.

This commit is contained in:
Beingpax 2025-10-29 11:59:49 +05:45
parent 3ed3a7c561
commit 615a0c4fad
2 changed files with 27 additions and 16 deletions

View File

@ -1,3 +1,8 @@
# Define a directory for dependencies in the user's home folder
DEPS_DIR := $(HOME)/VoiceInk-Dependencies
WHISPER_CPP_DIR := $(DEPS_DIR)/whisper.cpp
FRAMEWORK_PATH := $(WHISPER_CPP_DIR)/build-apple/whisper.xcframework
.PHONY: all clean whisper setup build check healthcheck help dev run
# Default target
@ -18,21 +23,24 @@ healthcheck: check
# Build process
whisper:
@if [ ! -d "whisper.cpp/build-apple/whisper.xcframework" ]; then \
echo "Building whisper.xcframework..."; \
git clone https://github.com/ggerganov/whisper.cpp.git || (cd whisper.cpp && git pull); \
cd whisper.cpp && ./build-xcframework.sh; \
@mkdir -p $(DEPS_DIR)
@if [ ! -d "$(FRAMEWORK_PATH)" ]; then \
echo "Building whisper.xcframework in $(DEPS_DIR)..."; \
if [ ! -d "$(WHISPER_CPP_DIR)" ]; then \
git clone https://github.com/ggerganov/whisper.cpp.git $(WHISPER_CPP_DIR); \
else \
(cd $(WHISPER_CPP_DIR) && git pull); \
fi; \
cd $(WHISPER_CPP_DIR) && ./build-xcframework.sh; \
else \
echo "whisper.xcframework already built, skipping build"; \
echo "whisper.xcframework already built in $(DEPS_DIR), skipping build"; \
fi
setup: whisper
@if [ ! -d "VoiceInk/whisper.xcframework" ]; then \
echo "Copying whisper.xcframework to VoiceInk..."; \
cp -r whisper.cpp/build-apple/whisper.xcframework VoiceInk/; \
else \
echo "whisper.xcframework already in VoiceInk, skipping copy"; \
fi
@echo "Whisper framework is ready at $(FRAMEWORK_PATH)"
@echo "Please ensure your Xcode project references the framework from this new location."
@echo "Removing old framework copy from the project directory (if it exists)..."
@rm -rf VoiceInk/whisper.xcframework
build: setup
xcodebuild -project VoiceInk.xcodeproj -scheme VoiceInk -configuration Debug CODE_SIGN_IDENTITY="" build
@ -52,7 +60,8 @@ run:
# Cleanup
clean:
@echo "Cleaning build artifacts..."
@rm -rf whisper.cpp VoiceInk/whisper.xcframework
@rm -rf $(DEPS_DIR)
@rm -rf VoiceInk/whisper.xcframework
@echo "Clean complete"
# Help

View File

@ -8,8 +8,8 @@
/* Begin PBXBuildFile section */
E11BBA4E2E5DC555000AB839 /* FluidAudio in Frameworks */ = {isa = PBXBuildFile; productRef = E11BBA4D2E5DC555000AB839 /* FluidAudio */; };
E17382402E4C7D0E001BAEBE /* whisper.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */; };
E17382412E4C7D0E001BAEBE /* whisper.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E1A0BD062EB1E7B800266859 /* whisper.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1A0BD052EB1E7B800266859 /* whisper.xcframework */; };
E1A0BD072EB1E7B800266859 /* whisper.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E1A0BD052EB1E7B800266859 /* whisper.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E1A261122CC143AC00B233D1 /* KeyboardShortcuts in Frameworks */ = {isa = PBXBuildFile; productRef = E1A261112CC143AC00B233D1 /* KeyboardShortcuts */; };
E1ADD45A2CC5352A00303ECB /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = E1ADD4592CC5352A00303ECB /* LaunchAtLogin */; };
E1ADD45F2CC544F100303ECB /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = E1ADD45E2CC544F100303ECB /* Sparkle */; };
@ -43,7 +43,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
E17382412E4C7D0E001BAEBE /* whisper.xcframework in Embed Frameworks */,
E1A0BD072EB1E7B800266859 /* whisper.xcframework in Embed Frameworks */,
E1D7EF9A2E35E19B00640029 /* MediaRemoteAdapter in Embed Frameworks */,
);
name = "Embed Frameworks";
@ -55,6 +55,7 @@
E11473B02CBE0F0A00318EE4 /* VoiceInk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VoiceInk.app; sourceTree = BUILT_PRODUCTS_DIR; };
E11473C32CBE0F0B00318EE4 /* VoiceInkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E11473CD2CBE0F0B00318EE4 /* VoiceInkUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E1A0BD052EB1E7B800266859 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../VoiceInk-Dependencies/whisper.cpp/build-apple/whisper.xcframework"; sourceTree = "<group>"; };
E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../whisper.cpp/build-apple/whisper.xcframework"; sourceTree = "<group>"; };
E1CE28772E4336150082B758 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../build-apple/whisper.xcframework"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -86,7 +87,7 @@
E1ADD45A2CC5352A00303ECB /* LaunchAtLogin in Frameworks */,
E11BBA4E2E5DC555000AB839 /* FluidAudio in Frameworks */,
E1D7EF992E35E16C00640029 /* MediaRemoteAdapter in Frameworks */,
E17382402E4C7D0E001BAEBE /* whisper.xcframework in Frameworks */,
E1A0BD062EB1E7B800266859 /* whisper.xcframework in Frameworks */,
E1BBBDCC2EB0DF6700C3ABFE /* SelectedTextKit in Frameworks */,
E1ADD45F2CC544F100303ECB /* Sparkle in Frameworks */,
E1A261122CC143AC00B233D1 /* KeyboardShortcuts in Frameworks */,
@ -134,6 +135,7 @@
E114741C2CBE1DE200318EE4 /* Frameworks */ = {
isa = PBXGroup;
children = (
E1A0BD052EB1E7B800266859 /* whisper.xcframework */,
E1CE28772E4336150082B758 /* whisper.xcframework */,
E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */,
);