diff --git a/.gitignore b/.gitignore index 7ce5928..cdae156 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ src-tauri/binaries/ src-tauri/resources/daw_engine/ src-tauri/resources/native_host/* !src-tauri/resources/native_host/.gitkeep +!src-tauri/resources/native_host/*.dll src-tauri/vc_redist.x64.exe app/storage/plugin_dirs.json app/storage/sf_scan_state.json.bak-root diff --git a/build_windows.ps1 b/build_windows.ps1 index 070af68..d4e4684 100644 --- a/build_windows.ps1 +++ b/build_windows.ps1 @@ -69,28 +69,45 @@ Write-Host "== [4b/6] Native host bridges (CMake/MSVC) + FluidSynth runtime ==" # trong resources/native_host/ de exe tim thay luc runtime (Rust: resource_dir/ # native_host; Python: SF_RESOURCE_DIR/native_host). Thieu -> native audio / # VST GUI khong chay tren may cai sach. -if (-not (Test-Path "native_host\build\CMakeCache.txt")) { - if (-not $env:VST3_SDK_ROOT) { - Write-Host "ERROR: can VST3_SDK_ROOT env (duong dan VST3 SDK) khi chua co native_host\build" -ForegroundColor Red - exit 1 +# +# Prebuilt: 3 bridge DLL (~175KB) DUOC COMMIT vao src-tauri/resources/native_host/ +# (.gitignore cho phep *.dll) de nguoi dung clone moi KHONG can VST3 SDK +# (Steinberg SDK ban quyen) + khong can MSVC/cmake. Chi build tu source khi +# ca 3 DLL deu thieu (may dev tu build bridge moi). +$bridgeDlls = @("sf_host_bridge.dll","vst2_host_bridge.dll","vst3_host_bridge.dll") +$havePrebuilt = $true +foreach ($dllName in $bridgeDlls) { + if (-not (Test-Path "src-tauri\resources\native_host\$dllName")) { $havePrebuilt = $false } +} +if ($havePrebuilt) { + Write-Host "Dung prebuilt bridge DLL (resources/native_host) - skip cmake build, khong can VST3 SDK." +} else { + if (-not (Test-Path "native_host\build\CMakeCache.txt")) { + if (-not $env:VST3_SDK_ROOT) { + Write-Host "ERROR: thieu prebuilt bridge DLL + khong co native_host\build + VST3_SDK_ROOT chua set." -ForegroundColor Red + Write-Host " Cach 1 (khuyen nghi): git pull lai de co src-tauri/resources/native_host/*.dll (prebuilt)." -ForegroundColor Yellow + Write-Host " Cach 2 (dev): set env VST3_SDK_ROOT tro den VST3 SDK roi build lai native_host." -ForegroundColor Yellow + exit 1 + } + & cmake -S native_host -B native_host\build -A x64 -DVST3_SDK_ROOT="$env:VST3_SDK_ROOT" + if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: cmake configure native_host that bai" -ForegroundColor Red; exit 1 } } - & cmake -S native_host -B native_host\build -A x64 -DVST3_SDK_ROOT="$env:VST3_SDK_ROOT" - if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: cmake configure native_host that bai" -ForegroundColor Red; exit 1 } -} -& cmake --build native_host\build --config Release -if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: cmake build native_host that bai" -ForegroundColor Red; exit 1 } - -if (-not (Test-Path "native_host\fluidsynth_runtime\libfluidsynth-3.dll")) { - python native_host\scripts\dl_fluidsynth_runtime.py - if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: dl_fluidsynth_runtime that bai" -ForegroundColor Red; exit 1 } + & cmake --build native_host\build --config Release + if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: cmake build native_host that bai" -ForegroundColor Red; exit 1 } + Copy-Item "native_host\build\Release\vst2_host_bridge.dll","native_host\build\Release\vst3_host_bridge.dll","native_host\build\Release\sf_host_bridge.dll" "src-tauri\resources\native_host\" } -if (Test-Path "src-tauri\resources\native_host") { - Remove-Item -Recurse -Force "src-tauri\resources\native_host" +# fluidsynth_runtime (14.8MB, gitignore) - khong commit; tu dong tai neu thieu. +if (-not (Test-Path "src-tauri\resources\native_host\fluidsynth_runtime\libfluidsynth-3.dll")) { + if (-not (Test-Path "native_host\fluidsynth_runtime\libfluidsynth-3.dll")) { + python native_host\scripts\dl_fluidsynth_runtime.py + if ($LASTEXITCODE -ne 0) { Write-Host "ERROR: dl_fluidsynth_runtime that bai" -ForegroundColor Red; exit 1 } + } + New-Item -ItemType Directory -Force "src-tauri\resources\native_host\fluidsynth_runtime" | Out-Null + Copy-Item "native_host\fluidsynth_runtime\*" "src-tauri\resources\native_host\fluidsynth_runtime\" -Recurse -Force +} else { + Write-Host "Da co fluidsynth_runtime trong resources/native_host." } -New-Item -ItemType Directory -Force "src-tauri\resources\native_host" | Out-Null -Copy-Item "native_host\build\Release\vst2_host_bridge.dll","native_host\build\Release\vst3_host_bridge.dll","native_host\build\Release\sf_host_bridge.dll" "src-tauri\resources\native_host\" -Copy-Item "native_host\fluidsynth_runtime" "src-tauri\resources\native_host\fluidsynth_runtime" -Recurse -Force Write-Host "== [5/6] VC++ Redistributable cho hooks.nsh ==" if (-not (Test-Path src-tauri\vc_redist.x64.exe)) { diff --git a/src-tauri/resources/native_host/sf_host_bridge.dll b/src-tauri/resources/native_host/sf_host_bridge.dll new file mode 100644 index 0000000..5a38864 Binary files /dev/null and b/src-tauri/resources/native_host/sf_host_bridge.dll differ diff --git a/src-tauri/resources/native_host/vst2_host_bridge.dll b/src-tauri/resources/native_host/vst2_host_bridge.dll new file mode 100644 index 0000000..8b3da5b Binary files /dev/null and b/src-tauri/resources/native_host/vst2_host_bridge.dll differ diff --git a/src-tauri/resources/native_host/vst3_host_bridge.dll b/src-tauri/resources/native_host/vst3_host_bridge.dll new file mode 100644 index 0000000..96ba5a3 Binary files /dev/null and b/src-tauri/resources/native_host/vst3_host_bridge.dll differ