buzz/Makefile

177 lines
5.3 KiB
Makefile
Raw Normal View History

2022-10-11 22:25:08 +02:00
version := $$(poetry version -s)
2022-11-21 20:12:13 +01:00
version_escaped := $$(echo ${version} | sed -e 's/\./\\./g')
2022-10-11 22:25:08 +02:00
mac_app_path := ./dist/Buzz.app
2022-10-11 22:25:08 +02:00
mac_zip_path := ./dist/Buzz-${version}-mac.zip
mac_dmg_path := ./dist/Buzz-${version}-mac.dmg
2022-12-10 12:48:27 +01:00
bundle_windows: dist/Buzz
2022-10-29 12:16:06 +02:00
iscc //DAppVersion=${version} installer.iss
2022-12-30 22:58:57 +01:00
bundle_mac: dist/Buzz.app codesign_all_mac zip_mac notarize_zip staple_app_mac dmg_mac
2022-11-10 11:49:28 +01:00
UNAME_S := $(shell uname -s)
LIBWHISPER :=
ifeq ($(OS), Windows_NT)
LIBWHISPER=whisper.dll
else
ifeq ($(UNAME_S), Darwin)
LIBWHISPER=libwhisper.dylib
else
LIBWHISPER=libwhisper.so
endif
endif
2022-10-29 12:16:06 +02:00
clean:
rm -f buzz/$(LIBWHISPER)
2022-11-28 14:59:15 +01:00
rm -f buzz/whisper_cpp.py
2022-10-29 12:16:06 +02:00
rm -rf dist/* || true
2024-03-24 22:05:01 +01:00
COVERAGE_THRESHOLD := 80
ifeq ($(UNAME_S),Linux)
2024-03-24 22:05:01 +01:00
COVERAGE_THRESHOLD := 74
endif
2023-01-05 01:30:30 +01:00
test: buzz/whisper_cpp.py translation_mo
pytest -s -vv --cov=buzz --cov-report=xml --cov-report=html --benchmark-skip --cov-fail-under=${COVERAGE_THRESHOLD}
2023-04-25 20:27:40 +02:00
benchmarks: buzz/whisper_cpp.py translation_mo
pytest -s -vv --benchmark-only --benchmark-json benchmarks.json
2022-10-29 12:16:06 +02:00
2023-01-05 01:30:30 +01:00
dist/Buzz dist/Buzz.app: buzz/whisper_cpp.py translation_mo
2022-10-29 12:16:06 +02:00
pyinstaller --noconfirm Buzz.spec
./dist/Buzz/Buzz --version
2022-10-29 12:16:06 +02:00
version:
poetry version ${version}
2022-11-28 14:59:15 +01:00
echo "VERSION = \"${version}\"" > buzz/__version__.py
2022-10-29 12:16:06 +02:00
2022-11-10 11:49:28 +01:00
CMAKE_FLAGS=
ifeq ($(UNAME_S),Darwin)
AVX1_M := $(shell sysctl machdep.cpu.features)
ifeq (,$(findstring AVX1.0,$(AVX1_M)))
CMAKE_FLAGS += -DWHISPER_NO_AVX=ON
endif
2023-01-08 17:49:33 +01:00
ifeq (,$(findstring FMA,$(AVX1_M)))
CMAKE_FLAGS += -DWHISPER_NO_FMA=ON
endif
2022-11-10 11:49:28 +01:00
AVX2_M := $(shell sysctl machdep.cpu.leaf7_features)
ifeq (,$(findstring AVX2,$(AVX2_M)))
CMAKE_FLAGS += -DWHISPER_NO_AVX2=ON
endif
else
ifeq ($(OS), Windows_NT)
CMAKE_FLAGS += -DBUILD_SHARED_LIBS=ON
endif
2022-11-10 11:49:28 +01:00
endif
2023-10-28 19:32:31 +02:00
buzz/$(LIBWHISPER):
cmake -S whisper.cpp -B whisper.cpp/build/ $(CMAKE_FLAGS)
2022-11-10 11:49:28 +01:00
cmake --build whisper.cpp/build --verbose
2023-10-28 19:32:31 +02:00
cp whisper.cpp/build/bin/Debug/$(LIBWHISPER) buzz || true
cp whisper.cpp/build/$(LIBWHISPER) buzz || true
2022-11-10 11:49:28 +01:00
2023-10-28 19:32:31 +02:00
buzz/whisper_cpp.py: buzz/$(LIBWHISPER)
cd buzz && ctypesgen ../whisper.cpp/whisper.h -lwhisper -o whisper_cpp.py
2022-10-29 12:16:06 +02:00
# Prints all the Mac developer identities used for code signing
print_identities_mac:
security find-identity -p basic -v
dmg_mac:
ditto -x -k "${mac_zip_path}" dist/dmg
2022-09-28 00:00:21 +02:00
create-dmg \
--volname "Buzz" \
2022-10-11 09:49:42 +02:00
--volicon "./assets/buzz.icns" \
2022-09-28 00:00:21 +02:00
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
2023-10-28 19:32:31 +02:00
--icon "Buzz.app" 175 120 \
2022-09-28 00:00:21 +02:00
--hide-extension "Buzz.app" \
--app-drop-link 425 120 \
--codesign "$$BUZZ_CODESIGN_IDENTITY" \
--notarize "$$BUZZ_KEYCHAIN_NOTARY_PROFILE" \
"${mac_dmg_path}" \
2022-09-28 00:00:21 +02:00
"dist/dmg/"
2023-01-03 15:26:50 +01:00
staple_app_mac:
xcrun stapler staple ${mac_app_path}
notarize_zip:
xcrun notarytool submit ${mac_zip_path} --keychain-profile "$$BUZZ_KEYCHAIN_NOTARY_PROFILE" --wait
zip_mac:
ditto -c -k --keepParent "${mac_app_path}" "${mac_zip_path}"
codesign_all_mac: dist/Buzz.app
for i in $$(find dist/Buzz.app/Contents/Resources/torch/bin -name "*" -type f); \
do \
codesign --force --options=runtime --sign "$$BUZZ_CODESIGN_IDENTITY" --timestamp "$$i"; \
done
for i in $$(find dist/Buzz.app/Contents/Resources -name "*.dylib" -o -name "*.so" -type f); \
do \
codesign --force --options=runtime --sign "$$BUZZ_CODESIGN_IDENTITY" --timestamp "$$i"; \
done
for i in $$(find dist/Buzz.app/Contents/MacOS -name "*.dylib" -o -name "*.so" -o -name "Qt*" -o -name "Python" -type f); \
do \
codesign --force --options=runtime --sign "$$BUZZ_CODESIGN_IDENTITY" --timestamp "$$i"; \
done
codesign --force --options=runtime --sign "$$BUZZ_CODESIGN_IDENTITY" --timestamp dist/Buzz.app/Contents/MacOS/Buzz
codesign --force --options=runtime --sign "$$BUZZ_CODESIGN_IDENTITY" --entitlements ./entitlements.plist --timestamp dist/Buzz.app
codesign --verify --deep --strict --verbose=2 dist/Buzz.app
# HELPERS
2022-10-04 22:54:16 +02:00
# Get the build logs for a notary upload
notarize_log:
xcrun notarytool log ${id} --keychain-profile "$$BUZZ_KEYCHAIN_NOTARY_PROFILE"
2022-10-04 22:54:16 +02:00
VENV_PATH := $(shell poetry env info -p)
# Make GGML model from whisper. Example: make ggml model_path=/Users/chidiwilliams/.cache/whisper/medium.pt
ggml:
python3 ./whisper.cpp/models/convert-pt-to-ggml.py ${model_path} $(VENV_PATH)/src/whisper dist
2022-12-08 14:13:11 +01:00
upload_brew:
2023-01-03 15:26:50 +01:00
brew bump-cask-pr --version ${version} --verbose buzz
2022-12-09 09:14:02 +01:00
2023-01-05 01:30:30 +01:00
UPGRADE_VERSION_BRANCH := upgrade-to-${version}
2022-12-09 09:14:02 +01:00
gh_upgrade_pr:
git checkout main && git pull
2023-01-05 01:30:30 +01:00
git checkout -B ${UPGRADE_VERSION_BRANCH}
2022-12-09 09:14:02 +01:00
make version version=${version}
git commit -am "Upgrade to ${version}"
2023-01-05 01:30:30 +01:00
git push --set-upstream origin ${UPGRADE_VERSION_BRANCH}
2022-12-09 09:14:02 +01:00
gh pr create --fill
2023-01-05 01:30:30 +01:00
gh pr merge ${UPGRADE_VERSION_BRANCH} --auto --squash
# Internationalization
translation_po_all:
$(MAKE) translation_po locale=ca_ES
2023-08-03 00:15:59 +02:00
$(MAKE) translation_po locale=es_ES
$(MAKE) translation_po locale=pl_PL
$(MAKE) translation_po locale=zh_CN
$(MAKE) translation_po locale=zh_TW
$(MAKE) translation_po locale=it_IT
2023-01-05 01:30:30 +01:00
TMP_POT_FILE_PATH := $(shell mktemp)
2024-03-14 12:26:20 +01:00
PO_FILE_PATH := buzz/locale/${locale}/LC_MESSAGES/buzz.po
2023-01-05 01:30:30 +01:00
translation_po:
2023-09-02 15:30:23 +02:00
xgettext --from-code=UTF-8 -o "${TMP_POT_FILE_PATH}" -l python $(shell find buzz/widgets -name '*.py')
sed -i.bak 's/CHARSET/UTF-8/' ${TMP_POT_FILE_PATH} && rm ${TMP_POT_FILE_PATH}.bak
msgmerge -U ${PO_FILE_PATH} ${TMP_POT_FILE_PATH}
2023-01-03 23:07:54 +01:00
2023-01-05 01:30:30 +01:00
translation_mo:
2024-03-14 12:26:20 +01:00
for dir in buzz/locale/*/ ; do \
2024-03-14 12:56:31 +01:00
python msgfmt.py -o $$dir/LC_MESSAGES/buzz.mo $$dir/LC_MESSAGES/buzz.po; \
2023-01-03 23:07:54 +01:00
done
2023-11-09 10:20:38 +01:00
lint:
ruff check . --fix
ruff format .