Skip to content

Latest commit

 

History

History
244 lines (171 loc) · 5.48 KB

BUILDING.md

File metadata and controls

244 lines (171 loc) · 5.48 KB

Building

Prerequisites

Bun | Cargo | Clang | Cmake

Windows:

Note Install Clang into C:\Program Files\LLVM or set LIBCLANG_PATH env.

Winget packages

winget install -e --id JernejSimoncic.Wget
winget install -e --id 7zip.7zip

Linux:

Based on tauri/prerequisites/#setting-up-linux

sudo apt-get update
sudo apt-get install -y ffmpeg libopenblas-dev # runtime
sudo apt-get install -y pkg-config build-essential libglib2.0-dev libgtk-3-dev libwebkit2gtk-4.1-dev clang cmake libssl-dev # tauri
sudo apt-get install -y libavutil-dev libavformat-dev libavfilter-dev libavdevice-dev # ffmpeg

Vulkan (Linux)

sudo apt-get install -y mesa-vulkan-drivers

Build

Install dependencies from desktop folder

bun install

Execute pre build scripts and follow the instructions it provide

bun scripts/pre_build.js

Build with Nvidia support

See whisper.cpp#nvidia-support

  1. Enable cuda feature in Cargo.toml

  2. Install cuda

  3. Add to tauri.windows.conf.json

tauri.windows.conf.json
{
	"bundle": {
		"resources": {
			"ffmpeg\\bin\\x64\\*.dll": "./",
			"openblas\\bin\\*.dll": "./",
			"clblast\\bin\\*.dll": "./",
			"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\bin\\cudart64_*": "./",
			"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\bin\\cublas64_*": "./",
			"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\bin\\cublasLt64_*": "./"
		}
	}
}
  1. Build in Powershell
$env:CUDA_PATH = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5"
$env:CudaToolkitDir = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5"
bun run scripts/pre_build.js --openblas --build

Build with AMD support

AMD support is only available under linux environment

  1. Install rocm toolkit

  2. Run bun scripts/pre_build.js --amd

  3. Run

export ROCM_VERSION="your rocm version"
cd desktop
bunx tauri build

Gotchas

On Windows when run pre_build with --vulkan you may need to run it with admin rights first time thanks to vulkan recent changes...

On Ubuntu you may need to copy some libraries for ffmpeg_next library

sudo cp -rf /usr/include/x86_64-linux-gnu/libsw* /usr/include/
sudo cp -rf /usr/include/x86_64-linux-gnu/libav* /usr/include/

If the CPU failed to execute an instruction, then build with the following environment variable

WHISPER_NO_AVX = "ON"
WHISPER_NO_AVX2 = "ON"
WHISPER_NO_FMA = "ON"
WHISPER_NO_F16C = "ON"

Rust analyzer failed to run on windows

  1. Execute cargo clean
  2. Add to settings.json:
"rust-analyzer.cargo.extraEnv": {
	"FFMPEG_DIR": "${workspaceFolder}\\desktop\\src-tauri\\ffmpeg",
	"OPENBLAS_PATH": "${workspaceFolder}\\desktop\\src-tauri\\openblas",
	"CLBlast_DIR": "${workspaceFolder}\\desktop\\src-tauri\\clblast",
	"LIBCLANG_PATH": "C:\\Program Files\\LLVM\\bin"
}
  1. Relaunch VSCode

Otherwise you will get error such as ggml_gallocr_needs_realloc: graph has different number of nodes and it will transcribe slower.

Test

export RUST_LOG=trace
cargo test -- --nocapture

Test core in release mode

cargo test -p vibe_core --release -- --nocapture

Lint

cargo fmt
cargo clippy

Create new release

  1. Increment verison in tauri.conf.json and commit
  2. Create new git tag and push
git tag -a v<version> -m "v<version>" && git push --tags

It will create releases for Windows, Linux, and macOS

Along with latest.json file (used for auto updater).

When Release action finish, it will run Deploy landing action

and update downloads links in landing page.

Landing

Compress images

bunx tinypng-go static/*.png

Convert markdown to PDF

go install github.com/mandolyte/mdtopdf/cmd/md2pdf@latest
md2pdf -i docs/PRIVACY_POLICY.md -o docs/PRIVACY_POLICY.pdf

Normalize wav file for tests

ffmpeg -i file.wav -ar 16000 -ac 1 -c:a pcm_s16le normal.wav

Edit PR before merge

  1. Install gh cli
gh pr checkout <url>
git push <fork url>

Update packages

bunx ncu -u -t newest
cd src-tauri
cargo install cargo-edit
rm -rf ../Cargo.lock
CARGO_NET_GIT_FETCH_WITH_CLI=true
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo upgrade
# OR
cargo +nightly -Zunstable-options update --breaking

Debug in release mode in VSCode

{
	"rust-analyzer.runnables.extraEnv": {
		"FFMPEG_DIR": "${workspaceFolder}\\desktop\\src-tauri\\ffmpeg",
		"OPENBLAS_PATH": "${workspaceFolder}\\desktop\\src-tauri\\openblas",
		"CLBlast_DIR": "${workspaceFolder}\\desktop\\src-tauri\\clblast",
		"LIBCLANG_PATH": "C:\\Program Files\\LLVM\\bin"
	},
	"rust-analyzer.runnables.extraArgs": ["--release"]
}

Test core

bun run scripts/pre_build.js
# Export env
$env:PATH += ";$pwddesktop\src-tauri\clblast\bin"
$env:PATH += ";$pwd\desktop\src-tauri\openblas\bin"
cargo test --target x86_64-pc-windows-msvc --features "vulkan" -p vibe_core --release -- --nocapture