build: bundle native_host bridges + fluidsynth runtime vao installer (build_windows.ps1 [4b/6], SF_RESOURCE_DIR fallback, tauri resources native_host)
This commit is contained in:
@@ -33,6 +33,8 @@ node_modules
|
||||
src-tauri/target/
|
||||
src-tauri/binaries/
|
||||
src-tauri/resources/daw_engine/
|
||||
src-tauri/resources/native_host/*
|
||||
!src-tauri/resources/native_host/.gitkeep
|
||||
src-tauri/vc_redist.x64.exe
|
||||
app/storage/plugin_dirs.json
|
||||
app/storage/sf_scan_state.json.bak-root
|
||||
|
||||
@@ -23,8 +23,12 @@ import numpy as np
|
||||
|
||||
from app.config import settings
|
||||
|
||||
_NATIVE_DIR = os.getenv("SONICFORGE_NATIVE_DIR") or os.path.join(
|
||||
settings.BASE_DIR, "native_host", "build", "Release")
|
||||
_RES_DIR = os.getenv("SF_RESOURCE_DIR")
|
||||
_NATIVE_DIR = (
|
||||
os.getenv("SONICFORGE_NATIVE_DIR")
|
||||
or (os.path.join(_RES_DIR, "native_host") if _RES_DIR else None)
|
||||
or os.path.join(settings.BASE_DIR, "native_host", "build", "Release")
|
||||
)
|
||||
|
||||
_ERR = None
|
||||
_LOCK = threading.Lock()
|
||||
|
||||
@@ -11,7 +11,11 @@ def _ensure_fluidsynth_runtime() -> None:
|
||||
if os.name != "nt":
|
||||
return
|
||||
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
candidates = [
|
||||
candidates = []
|
||||
res_dir = os.getenv("SF_RESOURCE_DIR")
|
||||
if res_dir:
|
||||
candidates.append(os.path.join(res_dir, "native_host", "fluidsynth_runtime"))
|
||||
candidates += [
|
||||
os.path.join(root, "native_host", "build", "Release", "fluidsynth_runtime"),
|
||||
os.path.join(root, "native_host", "fluidsynth_runtime"),
|
||||
]
|
||||
|
||||
@@ -64,6 +64,34 @@ New-Item -ItemType Directory -Force "src-tauri\resources\daw_engine" | Out-Null
|
||||
Copy-Item "dist\daw_engine\*" "src-tauri\resources\daw_engine\" -Recurse -Force
|
||||
Write-Host "Copied onedir engine -> src-tauri\resources\daw_engine"
|
||||
|
||||
Write-Host "== [4b/6] Native host bridges (CMake/MSVC) + FluidSynth runtime =="
|
||||
# T8-T16: vst2/vst3/sf_host_bridge DLL + fluidsynth_runtime (22 DLL) phai nam
|
||||
# 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
|
||||
}
|
||||
& 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 }
|
||||
}
|
||||
|
||||
if (Test-Path "src-tauri\resources\native_host") {
|
||||
Remove-Item -Recurse -Force "src-tauri\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)) {
|
||||
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile src-tauri\vc_redist.x64.exe
|
||||
|
||||
@@ -138,6 +138,7 @@ pub fn run() {
|
||||
.shell()
|
||||
.command(&engine_exe)
|
||||
.env("SF_PARENT_PID", std::process::id().to_string())
|
||||
.env("SF_RESOURCE_DIR", res_dir.to_string_lossy().to_string())
|
||||
.spawn()
|
||||
{
|
||||
Ok((_rx, child)) => {
|
||||
|
||||
@@ -93,6 +93,7 @@ mod native {
|
||||
if let Ok(res) = app.path().resource_dir() {
|
||||
candidates.push(res.join(name));
|
||||
candidates.push(res.join("native").join(name));
|
||||
candidates.push(res.join("native_host").join(name));
|
||||
}
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
if let Some(dir) = exe.parent() {
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
"icons/favicon.ico"
|
||||
],
|
||||
"resources": {
|
||||
"resources/daw_engine": "daw_engine/"
|
||||
"resources/daw_engine": "daw_engine/",
|
||||
"resources/native_host": "native_host/"
|
||||
},
|
||||
"externalBin": [],
|
||||
"windows": {
|
||||
|
||||
Reference in New Issue
Block a user