diff --git a/.github/workflows/linux_special.yaml b/.github/workflows/linux_special.yaml deleted file mode 100644 index 5c0dba09..00000000 --- a/.github/workflows/linux_special.yaml +++ /dev/null @@ -1,181 +0,0 @@ -name: Linux with OpenCL and Cuda - -on: - push: - tags: - - "v*" - pull_request: - workflow_dispatch: - inputs: - build_only: - description: 'Build without publishing' - required: false - default: 'false' -jobs: - publish-tauri: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - - platform: "ubuntu-22.04" - platform_version: "22.04" - - platform: "ubuntu-24.04" - platform_version: "24.04" - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - - - name: setup Bun - uses: oven-sh/setup-bun@v1 - - - name: Rust cache - uses: swatinem/rust-cache@v2 - - - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable - - - name: Install frontend dependencies - run: bun install - working-directory: ./desktop - - - name: Cache Pre Build - id: cache-pre-build - uses: actions/cache@v4 - with: - path: | - desktop/src-tauri/openblas - key: ${{ matrix.platform }}-pre-build - - # Run pre build - - name: Run pre_build.js - run: bun scripts/pre_build.js --opencl - - - name: Build - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - with: - projectPath: "./desktop" - tauriScript: bunx tauri - - - name: Rename installer - run: | - - # Rename .deb files - for file in target/release/bundle/deb/*.deb; do - name=$(basename "$file" .deb) - new_name="${name}_${{ matrix.platform }}_opencl.deb" - mv "$file" "target/release/bundle/deb/$new_name" - echo "Renamed '$file' to '$new_name'" - done - - # Rename .rpm files - for file in target/release/bundle/rpm/*.rpm; do - name=$(basename "$file" .rpm) - new_name="${name}_${{ matrix.platform_version }}_opencl.rpm" - mv "$file" "target/release/bundle/rpm/$new_name" - echo "Renamed '$file' to '$new_name'" - done - shell: bash - - - name: Upload installer - if: github.event.inputs.build_only != 'true' - run: | - bun scripts/publish.js target/release/bundle/deb/*.deb - bun scripts/publish.js target/release/bundle/rpm/*.rpm - shell: pwsh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish-tauri-linux-cuda: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - - platform: "ubuntu-22.04" - cuda-version: "12.4.1" - platform_version: "22.04" - - platform: "ubuntu-24.04" - cuda-version: "12.4.1" - platform_version: "24.04" - - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - - - uses: Jimver/cuda-toolkit@v0.2.15 - id: cuda-toolkit - with: - cuda: ${{ matrix.cuda-version }} - - - name: setup Bun - uses: oven-sh/setup-bun@v1 - - - name: Rust cache - uses: swatinem/rust-cache@v2 - - - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable - - - name: Install frontend dependencies - run: bun install - working-directory: ./desktop - - - name: Cache Pre Build - id: cache-pre-build - uses: actions/cache@v4 - with: - path: | - desktop/src-tauri/openblas - key: ${{ matrix.platform }}-pre-build - - # Run pre build - - name: Run pre_build.js - run: bun scripts/pre_build.js --nvidia - env: - INPUT_CUDA_VERSION: ${{ matrix.cuda-version }} - - - name: Build - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - INPUT_CUDA_VERSION: ${{ matrix.cuda-version }} - with: - projectPath: "./desktop" - tauriScript: bunx tauri - - - name: Rename installer - run: | - - # Rename .deb files - for file in target/release/bundle/deb/*.deb; do - name=$(basename "$file" .deb) - new_name="${name}_${{ matrix.platform }}_nvidia_${{ matrix.cuda-version }}.deb" - mv "$file" "target/release/bundle/deb/$new_name" - echo "Renamed '$file' to '$new_name'" - done - - # Rename .rpm files - for file in target/release/bundle/rpm/*.rpm; do - name=$(basename "$file" .rpm) - new_name="${name}_${{ matrix.platform_version }}_nvidia_${{ matrix.cuda-version }}.rpm" - mv "$file" "target/release/bundle/rpm/$new_name" - echo "Renamed '$file' to '$new_name'" - done - shell: bash - - - name: Upload installer - if: github.event.inputs.build_only != 'true' - run: | - bun scripts/publish.js target/release/bundle/deb/*.deb - bun scripts/publish.js target/release/bundle/rpm/*.rpm - shell: pwsh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/linux_special.yml b/.github/workflows/linux_special.yml new file mode 100644 index 00000000..e72bdfc9 --- /dev/null +++ b/.github/workflows/linux_special.yml @@ -0,0 +1,129 @@ +name: Linux with OpenCL and Cuda + +on: + workflow_dispatch: + inputs: + skip-publish: + description: 'Skip publish' + required: false + default: '0' +jobs: + publish-tauri: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + include: + # Ubuntu 22.04 + - platform: "ubuntu-22.04" + args: "" + pre-build-args: "" + rust-version: "stable" + name: "ubuntu-22.04" + + # Ubuntu 24.04 + - platform: "ubuntu-24.04" + args: "" + pre-build-args: "" + rust-version: "stable" + name: "ubuntu-24.04" + + + # Ubuntu 22.04 cuda + - platform: "ubuntu-22.04" + args: '--features "cuda"' + pre-build-args: "--cuda" + rust-version: "stable" + cuda-version: "12.4.1" + name: "ubuntu-22.04-cuda-12" + + # Ubuntu 24.04 cuda + - platform: "ubuntu-24.04" + args: '--features "cuda"' + pre-build-args: "--cuda" + rust-version: "stable" + cuda-version: "12.4.1" + name: "ubuntu-24.04-cuda-12" + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - uses: Jimver/cuda-toolkit@v0.2.15 + if: contains(matrix.args, 'cuda') + id: cuda-toolkit + with: + cuda: ${{ matrix.cuda-version }} + method: 'network' + + - name: setup Bun + uses: oven-sh/setup-bun@v1 + + - name: Rust cache + uses: swatinem/rust-cache@v2 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Install frontend dependencies + run: bun install + working-directory: ./desktop + + + - name: Cache Pre Build + id: cache-pre-build + uses: actions/cache@v4 + with: + path: | + desktop/src-tauri/openblas + desktop/src-tauri/clblast + desktop/src-tauri/ffmpeg + key: ${{ runner.os }}-pre-build + + # Run pre build + - name: Run pre_build.js + run: bun scripts/pre_build.js ${{ matrix.pre-build-args }} + + + - name: Build + uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} + INPUT_CUDA_VERSION: ${{ matrix.cuda-version }} + with: + projectPath: "./desktop" + tauriScript: bunx tauri + args: ${{ matrix.args }} + + + - name: Rename installer + run: | + + # Rename .deb files + for file in target/release/bundle/deb/*.deb; do + name=$(basename "$file" .deb) + new_name="${name}_${{ matrix.name }}.deb" + mv "$file" "target/release/bundle/deb/$new_name" + echo "Renamed '$file' to '$new_name'" + done + + # Rename .rpm files + for file in target/release/bundle/rpm/*.rpm; do + name=$(basename "$file" .rpm) + new_name="${name}_${{ matrix.name }}.rpm" + mv "$file" "target/release/bundle/rpm/$new_name" + echo "Renamed '$file' to '$new_name'" + done + shell: bash + + + - name: Upload installer + if: github.event.inputs.skip-publish != '1' + run: | + bun scripts/publish.js target/release/bundle/deb/*.deb + bun scripts/publish.js target/release/bundle/rpm/*.rpm + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3dd0f94d..b1d98103 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,10 +18,11 @@ jobs: args: "--target aarch64-apple-darwin" - platform: "macos-latest" # for Intel based macs. args: "--target x86_64-apple-darwin" - - platform: "ubuntu-22.04" # Ubuntu x86_64 + - platform: "ubuntu-24.04" # Ubuntu x86_64 args: "" - platform: "windows-latest" # Windows x86_64 - args: "--target x86_64-pc-windows-msvc" + args: '--target x86_64-pc-windows-msvc --features "openblas"' + pre-build-args: "--openblas" runs-on: ${{ matrix.platform }} steps: @@ -55,7 +56,7 @@ jobs: # Run pre build - name: Run pre_build.js on ${{ matrix.platform }} - run: bun scripts/pre_build.js + run: bun scripts/pre_build.js ${{ matrix.pre-build-args }} - name: Build uses: tauri-apps/tauri-action@v0 diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml index b2294691..1256a1a0 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/test_core.yml @@ -2,25 +2,58 @@ name: Test Core on: workflow_dispatch: - + pull_request: + paths: + - '.github/workflows/lint.yml' + - 'desktop/src-tauri/**' + - 'cli/src/**' + - 'core/src/**' jobs: - publish-tauri: + test: permissions: contents: write strategy: fail-fast: false matrix: - include: - - platform: "macos-latest" # for Arm based macs (M1 and above). - args: "--target aarch64-apple-darwin" - - platform: "macos-latest" # for Intel based macs. - args: "--target x86_64-apple-darwin" - - platform: "ubuntu-22.04" # Ubuntu x86_64 - args: "" - - platform: "windows-latest" # Windows x86_64 - args: "--target x86_64-pc-windows-msvc" + include: + - platform: "macos-latest" # for Arm based macs (M1 and above). + args: "--target aarch64-apple-darwin" + pre-build-args: "" + name: "MacOS (Arm) - aarch64" + action: "test" + + - platform: "macos-13" # for Intel based macs. + args: "--target x86_64-apple-darwin" + pre-build-args: "" + name: "MacOS (Intel) - x86_64" + action: "test" + + - platform: "ubuntu-22.04" # Ubuntu x86_64 + args: "" + pre-build-args: "" + name: "Ubuntu 22.04 - x86_64" + action: "test" + + - platform: "windows-latest" # Windows x86_64 + args: "--target x86_64-pc-windows-msvc" + pre-build-args: "" + name: "Windows - x86_64" + action: "test" + + - platform: "windows-latest" # Windows x86_64 with openblas + args: '--target x86_64-pc-windows-msvc --features "openblas"' + pre-build-args: "--openblas" + name: "Windows - x86_64 with OpenBLAS" + action: "test" + + - platform: "windows-latest" # Windows x86_64 with opencl + args: '--target x86_64-pc-windows-msvc --features "opencl"' + pre-build-args: "--opencl" + name: "Windows - x86_64 with OpenCL" + action: "test" runs-on: ${{ matrix.platform }} + name: ${{ matrix.name }} steps: - uses: actions/checkout@v4 @@ -44,11 +77,11 @@ jobs: desktop/src-tauri/openblas desktop/src-tauri/clblast desktop/src-tauri/ffmpeg - key: ${{ matrix.platform }}-${{ matrix.args }}-pre-build + key: ${{ matrix.platform }}-pre-build # Run pre build - name: Run pre_build.js on ${{ matrix.platform }} - run: bun scripts/pre_build.js + run: bun scripts/pre_build.js ${{ matrix.pre-build-args }} - name: Download tiny model on Windows if: contains(matrix.platform, 'windows') @@ -64,6 +97,20 @@ jobs: run: echo "$PWD/desktop/src-tauri/ffmpeg/bin" >> $GITHUB_PATH if: contains(matrix.platform, 'windows') == false + - name: Add openblas and opencl DLLs to path + if: contains(matrix.pre-build-args, 'openblas') || contains(matrix.pre-build-args, 'opencl') + run: | + echo "$PWD/desktop/src-tauri/clblast/bin" >> $env:GITHUB_PATH + echo "$PWD/desktop/src-tauri/openblas/bin" >> $env:GITHUB_PATH + echo "C:/vcpkg/packages/opencl_x64-windows/bin" >> $env:GITHUB_PATH + + + - name: Build + if: matrix.action == 'build' + run: | + cargo build ${{ matrix.args }} -p vibe_core --release + - name: Test + if: matrix.action == 'test' run: | - cargo test -p vibe_core --release -- --nocapture \ No newline at end of file + cargo test ${{ matrix.args }} -p vibe_core --release -- --nocapture \ No newline at end of file diff --git a/.github/workflows/windows_special.yml b/.github/workflows/windows_special.yml index 73bf03d6..ceecbf1d 100644 --- a/.github/workflows/windows_special.yml +++ b/.github/workflows/windows_special.yml @@ -1,221 +1,77 @@ -name: Non avx2, cuda, portable +name: Windows Non avx2, cuda, portable on: - push: - tags: - - "v*" workflow_dispatch: - + inputs: + skip-publish: + description: 'Skip publish' + required: false + default: '0' jobs: - older-cpu: - permissions: - contents: write - - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v2 - - - name: setup Bun - uses: oven-sh/setup-bun@v1 - - - name: Rust cache - uses: swatinem/rust-cache@v2 - - - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable - - - name: Install frontend dependencies - run: bun install - working-directory: ./desktop - - - name: Cache Pre Build - id: cache-pre-build - uses: actions/cache@v4 - with: - path: | - desktop/src-tauri/openblas - desktop/src-tauri/clblast - desktop/src-tauri/ffmpeg - key: ${{ runner.os }}-pre-build - - # Run pre build - - name: Run pre_build.js - run: bun scripts/pre_build.js --older-cpu - - - name: Build - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - with: - projectPath: "./desktop" - tauriScript: bunx tauri - - - name: Rename installer - run: | - # Get the list of exe files in the directory - $exe_files = Get-ChildItem -Path "target\release\bundle\nsis\*.exe" - - # Rename each exe file - foreach ($file in $exe_files) { - # Split the file name and extension - $name = $file.BaseName - $ext = $file.Extension - - # New file name - $suffix = "older_cpu" - $new_name = "{0}_{1}{2}" -f $name, $suffix, $ext - - # Rename the file - Rename-Item -Path $file.FullName -NewName $new_name - Write-Output "Renamed '$($file.FullName)' to '$new_name'" - } - shell: pwsh - - - name: Upload installer - run: | - bun scripts/publish.js target/release/bundle/nsis/*.exe - shell: pwsh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - portable: + publish-tauri: permissions: contents: write strategy: fail-fast: false matrix: include: - - rust_version: "stable" # https://github.com/rustdesk/rustdesk/discussions/7503, also 1.78 has ABI change which causes our sciter version not working, https://blog.rust-lang.org/2024/03/30/i128-layout-update.html + # Windows no AVX2 + - platform: "windows-latest" + args: '--features="openblas"' + pre-build-args: "--older-cpu --openblas" + rust-version: "stable" + + # Windows cuda 12.5.0 + - platform: "windows-latest" + args: '--features="cuda,openblas"' + pre-build-args: "--cuda --openblas" + name: 'cuda-12.5.0' + cuda-verison: '12.5.0' + rust-version: "stable" + + # Windows cuda 11.8.0 + - platform: "windows-latest" + args: '--features="cuda,openblas"' + pre-build-args: "--cuda --openblas" + name: 'cuda-11.8.0' + cuda-verison: '11.8.0' + rust-version: "stable" + + # Windows portable + - platform: "windows-latest" # Windows x86_64 + args: '--features="openblas"' + pre-build-args: "--portable --openblas" name: portable - - rust_version: "1.75" - name: portable-win7 - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v2 + rust-version: "stable" - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2 - - - name: setup Bun - uses: oven-sh/setup-bun@v1 - - - name: Rust cache - uses: swatinem/rust-cache@v2 - - - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ matrix.rust_version }} - components: "rustfmt" - - - name: Install frontend dependencies - run: bun install - working-directory: ./desktop - - - name: Cache Pre Build - id: cache-pre-build - uses: actions/cache@v4 - with: - path: | - desktop/src-tauri/openblas - desktop/src-tauri/clblast - desktop/src-tauri/ffmpeg - key: ${{ runner.os }}-pre-build - - # Run pre build - - name: Run pre_build.js - run: bun scripts/pre_build.js - - - name: Build - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} - TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - WINDOWS_PORTABLE: 1 - with: - projectPath: "./desktop" - tauriScript: bunx tauri - - - name: Prepare Portable zip - run: | - # Get all EXE files in the specified directory - $exe_files = Get-ChildItem -Path "target\release\bundle\nsis\*.exe" - - # Unzip each EXE file and zip the contents - foreach ($file in $exe_files) { - $name = $file.BaseName - $ext = "_${{ matrix.name }}.zip" - - # Create a new directory for extraction in the same folder - $extract_dir = New-Item -ItemType Directory -Path "$($file.DirectoryName)\$name" - echo $extract_dir.FullName - - try { - # Unzip the EXE file into the new directory - & 7z x $file.FullName -o"$extract_dir" - - # Zip the contents into a new zip file - $zip_name = "{0}{1}" -f $name, $ext - & 7z a "$($file.DirectoryName)\$zip_name" "$extract_dir\*" - - Write-Output "Zipped contents of '$($file.FullName)' to '$zip_name'" - } finally { - # Remove the extraction directory - Remove-Item -Recurse -Force $extract_dir - } - } - shell: pwsh - - - name: Upload installer - run: | - bun scripts/publish.js target/release/bundle/nsis/*.zip - shell: pwsh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - nvidia: - permissions: - contents: write - strategy: - matrix: - cuda-version: [12.5.0, 11.8.0] + # Windows7 portable + - platform: "windows-latest" # Windows x86_64 + args: '--features="openblas"' + pre-build-args: "--portable --openblas" + name: portable-win7 + rust-version: "1.75" - runs-on: windows-latest + runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 - # - name: Cache cuda installer - # id: cache-cuda-installer - # uses: actions/cache@v4 - # with: - # path: | - # cuda.exe - # key: ${{ runner.os }}-cuda-installer - name: Setup CUDA Toolkit + if: contains(matrix.args, 'cuda') id: cuda-toolkit shell: pwsh run: scripts/setup_cuda.ps1 env: - INPUT_CUDA_VERSION: ${{ matrix.cuda-version }} + INPUT_CUDA_VERSION: ${{ matrix.cuda-verison }} - name: setup Bun uses: oven-sh/setup-bun@v1 - name: Rust cache uses: swatinem/rust-cache@v2 - with: - key: ${{ matrix.cuda-version }} - name: Install Rust stable uses: dtolnay/rust-toolchain@stable @@ -224,20 +80,21 @@ jobs: run: bun install working-directory: ./desktop + - name: Cache Pre Build id: cache-pre-build uses: actions/cache@v4 with: path: | desktop/src-tauri/openblas + desktop/src-tauri/clblast desktop/src-tauri/ffmpeg key: ${{ runner.os }}-pre-build # Run pre build - name: Run pre_build.js - run: bun scripts/pre_build.js --nvidia - env: - INPUT_CUDA_VERSION: ${{ matrix.cuda-version }} + run: bun scripts/pre_build.js ${{ matrix.pre-build-args }} + - name: Build uses: tauri-apps/tauri-action@v0 @@ -245,37 +102,38 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} - INPUT_CUDA_VERSION: ${{ matrix.cuda-version }} with: projectPath: "./desktop" tauriScript: bunx tauri + args: ${{ matrix.args }} - - name: Rename installer - run: | - $cudaPath = (Get-Item env:CUDA_PATH).Value - $cudaVersion = (Split-Path $cudaPath -Leaf) - # Get the list of exe files in the directory - $exe_files = Get-ChildItem -Path "target\release\bundle\nsis\*.exe" - - # Rename each exe file - foreach ($file in $exe_files) { - # Split the file name and extension - $name = $file.BaseName - $ext = $file.Extension - - # New file name - $suffix = $cudaVersion - $new_name = "{0}_nvidia_{1}{2}" -f $name, $suffix, $ext - # Rename the file - Rename-Item -Path $file.FullName -NewName $new_name - Write-Output "Renamed '$($file.FullName)' to '$new_name'" - } + - name: Rename Installer + run: | + # Get the list of exe files in the directory + $exe_files = Get-ChildItem -Path "target\release\bundle\nsis\*.exe" + + # Rename each exe file + foreach ($file in $exe_files) { + # Split the file name and extension + $name = $file.BaseName + $ext = $file.Extension + + # New file name + $suffix = "${{ matrix.name }}" + $new_name = "{0}_{1}{2}" -f $name, $suffix, $ext + + # Rename the file + Rename-Item -Path $file.FullName -NewName $new_name + Write-Output "Renamed '$($file.FullName)' to '$new_name'" + } shell: pwsh + - name: Upload installer + if: github.event.inputs.skip-publish != '1' run: | - bun scripts/publish.js target/release/bundle/nsis/*.exe + bun scripts/publish.js target/release/bundle/nsis/*.exe shell: pwsh env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/BUILDING.md b/BUILDING.md index 64dff0f1..72bf2e5e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -206,3 +206,14 @@ cargo +nightly -Zunstable-options update --breaking "rust-analyzer.runnables.extraArgs": ["--release"] } ``` + +## Test core + +```console +bun run scripts/pre_build.js +# Export env +$env:PATH += ";$pwddesktop\src-tauri\clblast\bin" +$env:PATH += ";$pwd\desktop\src-tauri\openblas\bin" +$env:PATH += ";C:\vcpkg\packages\opencl_x64-windows\bin" +cargo test --target x86_64-pc-windows-msvc --features "opencl,openblas" -p vibe_core --release -- --nocapture +``` diff --git a/core/build.rs b/core/build.rs index daba942c..463ecfbe 100644 --- a/core/build.rs +++ b/core/build.rs @@ -52,6 +52,7 @@ fn main() { if cfg!(feature = "opencl") { println!("cargo:rustc-link-search={}", clblast_dir.join("..\\..\\").display()); + println!("cargo:rustc-link-search={}", clblast_dir.join("..\\lib").display()); println!("cargo:rustc-link-search=C:\\vcpkg\\packages\\opencl_x64-windows\\lib"); } diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index f7089a54..17ad77ce 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -48,18 +48,21 @@ crash-handler = "0.6.2" urlencoding = "2.1.3" +# Linux [target.'cfg(target_os = "linux")'.dependencies] -vibe_core = { path = "../../core", features = ["openblas"] } +vibe_core = { path = "../../core", features = [] } openssl = { version = "0.10.63", features = ["vendored"] } +# Windows [target.'cfg(windows)'.dependencies] -vibe_core = { path = "../../core", features = ["opencl", "openblas"] } +vibe_core = { path = "../../core", features = [] } windows = { version = "0.56.0", features = [ "Win32_System_Console", "Win32_Foundation", ] } winreg = "0.52.0" +# macOS [target.'cfg(target_os = "macos")'.dependencies] vibe_core = { path = "../../core", features = ["coreml", "metal"] } cocoa = "0.25.0" @@ -70,6 +73,12 @@ objc_id = "0.1" [features] default = ["custom-protocol"] diarize = ["vibe_core/diarize"] +cuda = ["vibe_core/cuda"] +coreml = ["vibe_core/coreml"] +metal = ["vibe_core/metal"] +openblas = ["vibe_core/openblas"] +opencl = ["vibe_core/opencl"] + # this feature is used for production builds or when `devPath` points to the filesystem # DO NOT REMOVE!! custom-protocol = ["tauri/custom-protocol"] diff --git a/desktop/src-tauri/tauri.windows.conf.json b/desktop/src-tauri/tauri.windows.conf.json index 17830935..9bf567f4 100644 --- a/desktop/src-tauri/tauri.windows.conf.json +++ b/desktop/src-tauri/tauri.windows.conf.json @@ -1,10 +1,7 @@ { "bundle": { "resources": { - "ffmpeg\\bin\\x64\\*": "./", - "openblas\\bin\\*.dll": "./", - "clblast\\bin\\*.dll": "./", - "C:\\vcpkg\\packages\\opencl_x64-windows\\bin\\*.dll": "./" + "ffmpeg\\bin\\x64\\*": "./" } } -} +} \ No newline at end of file diff --git a/scripts/pre_build.js b/scripts/pre_build.js index d9120559..faa4b1af 100755 --- a/scripts/pre_build.js +++ b/scripts/pre_build.js @@ -12,7 +12,10 @@ const platform = { linux: 'linux', }[os.platform()] const cwd = process.cwd() -const buildForOldCPU = process.argv.includes('--older-cpu') + +function hasFeature(name) { + return process.argv.includes(`--${name}`) || process.argv.includes(name) +} const config = { ffmpegRealname: 'ffmpeg', @@ -46,7 +49,7 @@ const config = { 'libavfilter-dev', 'libavdevice-dev', // FFMPEG 'libasound2-dev', // cpal - 'libomp-dev' // OpenMP in ggml.ai + 'libomp-dev', // OpenMP in ggml.ai ], }, macos: { @@ -68,7 +71,7 @@ const exports = { if (platform == 'linux') { // Install APT packages await $`sudo apt-get update` - if (process.argv.includes('--opencl')) { + if (hasFeature('opencl')) { config.linux.aptPackages.push('libclblast-dev') } for (const name of config.linux.aptPackages) { @@ -88,7 +91,7 @@ if (platform == 'windows') { } // Setup OpenBlas - if (!(await fs.exists(config.openblasRealname))) { + if (!(await fs.exists(config.openblasRealname)) && hasFeature('openblas')) { await $`C:\\msys64\\usr\\bin\\wget.exe -nc --show-progress ${config.windows.openBlasUrl} -O ${config.windows.openBlasName}.zip` await $`"C:\\Program Files\\7-Zip\\7z.exe" x ${config.windows.openBlasName}.zip -o${config.openblasRealname}` await $`rm ${config.windows.openBlasName}.zip` @@ -98,7 +101,7 @@ if (platform == 'windows') { } // Setup CLBlast - if (!(await fs.exists(config.clblastRealname)) && !process.argv.includes('--nvidia')) { + if (!(await fs.exists(config.clblastRealname)) && !hasFeature('cuda')) { await $`C:\\msys64\\usr\\bin\\wget.exe -nc --show-progress ${config.windows.clblastUrl} -O ${config.windows.clblastName}.zip` await $`"C:\\Program Files\\7-Zip\\7z.exe" x ${config.windows.clblastName}.zip` // 7z file inside await $`"C:\\Program Files\\7-Zip\\7z.exe" x ${config.windows.clblastName}.7z` // Inner folder @@ -124,7 +127,7 @@ if (platform == 'macos') { // Nvidia let cudaPath -if (process.argv.includes('--nvidia')) { +if (hasFeature('cuda')) { if (process.env['CUDA_PATH']) { cudaPath = process.env['CUDA_PATH'] } else if (platform === 'windows') { @@ -155,21 +158,8 @@ if (process.argv.includes('--nvidia')) { }, } await fs.writeFile('tauri.windows.conf.json', JSON.stringify(windowsConfig, null, 4)) - - // modify features in cargo.toml - let content = await fs.readFile('Cargo.toml', { encoding: 'utf-8' }) - content = content.replace('opencl', 'cuda') - await fs.writeFile('Cargo.toml', content) } if (platform === 'linux') { - // modify features in cargo.toml - let content = await fs.readFile('Cargo.toml', { encoding: 'utf-8' }) - content = content.replace( - 'vibe_core = { path = "../../core", features = ["openblas"] }', - 'vibe_core = { path = "../../core", features = ["openblas", "cuda"] }' - ) - await fs.writeFile('Cargo.toml', content) - // Add cuda toolkit depends package const tauriConfigContent = await fs.readFile('tauri.linux.conf.json', { encoding: 'utf-8' }) const tauriConfig = JSON.parse(tauriConfigContent) @@ -178,14 +168,24 @@ if (process.argv.includes('--nvidia')) { } } -// Linux OpenCL -if (platform === 'linux' && process.argv.includes('--opencl')) { - let content = await fs.readFile('Cargo.toml', { encoding: 'utf-8' }) - content = content.replace( - 'vibe_core = { path = "../../core", features = ["openblas"] }', - 'vibe_core = { path = "../../core", features = ["openblas", "opencl"] }' - ) - await fs.writeFile('Cargo.toml', content) +if (hasFeature('opencl')) { + if (platform === 'windows') { + const tauriConfigContent = await fs.readFile('tauri.windows.conf.json', { encoding: 'utf-8' }) + const tauriConfig = JSON.parse(tauriConfigContent) + tauriConfig.bundle.resources['clblast\\bin\\*.dll'] = './' + tauriConfig.bundle.resources['C:\\vcpkg\\packages\\opencl_x64-windows\\bin\\*.dll'] = './' + await fs.writeFile('tauri.windows.conf.json', JSON.stringify(tauriConfig, null, 4)) + } +} + +// OpenBlas +if (hasFeature('openblas')) { + if (platform === 'windows') { + const tauriConfigContent = await fs.readFile('tauri.windows.conf.json', { encoding: 'utf-8' }) + const tauriConfig = JSON.parse(tauriConfigContent) + tauriConfig.bundle.resources['openblas\\bin\\*.dll'] = './' + await fs.writeFile('tauri.windows.conf.json', JSON.stringify(tauriConfig, null, 4)) + } } // Development hints @@ -200,18 +200,20 @@ if (!process.env.GITHUB_ENV) { if (platform == 'windows') { console.log(`$env:FFMPEG_DIR = "${exports.ffmpeg}"`) console.log(`$env:OPENBLAS_PATH = "${exports.openBlas}"`) - console.log(`$env:CLBlast_DIR = "${exports.clblast}"`) console.log(`$env:LIBCLANG_PATH = "${exports.libClang}"`) console.log(`$env:PATH += "${exports.cmake}"`) - if (buildForOldCPU) { + if (hasFeature('older-cpu')) { console.log(`$env:WHISPER_NO_AVX = "ON"`) console.log(`$env:WHISPER_NO_AVX2 = "ON"`) console.log(`$env:WHISPER_NO_FMA = "ON"`) console.log(`$env:WHISPER_NO_F16C = "ON"`) } - if (process.argv.includes('--nvidia')) { + if (hasFeature('cuda')) { console.log(`$env:CUDA_PATH = "${cudaPath}"`) } + if (hasFeature('opencl')) { + console.log(`$env:CLBlast_DIR = "${exports.clblast}"`) + } } if (platform == 'macos') { console.log(`export FFMPEG_DIR="${exports.ffmpeg}"`) @@ -238,11 +240,14 @@ if (process.env.GITHUB_ENV) { const openblas = `OPENBLAS_PATH=${exports.openBlas}\n` console.log('Adding ENV', openblas) await fs.appendFile(process.env.GITHUB_ENV, openblas) - const clblast = `CLBlast_DIR=${exports.clblast}\n` - console.log('Adding ENV', clblast) - await fs.appendFile(process.env.GITHUB_ENV, clblast) - if (buildForOldCPU) { + if (hasFeature('opencl')) { + const clblast = `CLBlast_DIR=${exports.clblast}\n` + console.log('Adding ENV', clblast) + await fs.appendFile(process.env.GITHUB_ENV, clblast) + } + + if (hasFeature('older-cpu')) { await fs.appendFile(process.env.GITHUB_ENV, `WHISPER_NO_AVX=ON\n`) await fs.appendFile(process.env.GITHUB_ENV, `WHISPER_NO_AVX2=ON\n`) await fs.appendFile(process.env.GITHUB_ENV, `WHISPER_NO_FMA=ON\n`)