FEAT: chuẩn bị thư viện để tạo file exe trên window
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
[package]
|
||||
name = "sonicforge-daw"
|
||||
version = "1.0.0"
|
||||
description = "SonicForge DAW desktop shell (Tauri v2 + Python sidecar)"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "sonicforge_daw_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-shell = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
[profile.release]
|
||||
strip = true
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Default capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": ["core:default"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
; NSIS installer hooks — cai Microsoft Visual C++ Redistributable neu thieu
|
||||
; (MSVCP140.dll missing). Dat vc_redist.x64.exe CANH tauri.conf.json
|
||||
; (build_windows.ps1 tu tai ve neu chua co).
|
||||
!macro customInstall
|
||||
File "/oname=$PLUGINSDIR\vc_redist.x64.exe" "vc_redist.x64.exe"
|
||||
ExecWait '"$PLUGINSDIR\vc_redist.x64.exe" /install /quiet /norestart'
|
||||
!macroend
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1009 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 459 B |
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1,41 @@
|
||||
// SonicForge DAW — desktop shell: spawn/terminate daw_engine.exe sidecar.
|
||||
use tauri_plugin_shell::process::CommandChild;
|
||||
use tauri_plugin_shell::ShellExt;
|
||||
use std::sync::Mutex;
|
||||
|
||||
struct EngineProcess(Mutex<Option<CommandChild>>);
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.setup(|app| {
|
||||
// 1. Spawn sidecar daw_engine.exe (PyInstaller bundle)
|
||||
let sidecar_command = app
|
||||
.shell()
|
||||
.sidecar("daw_engine")
|
||||
.expect("sidecar daw_engine not found — run build_windows.ps1 first");
|
||||
let (_rx, child) = sidecar_command
|
||||
.env("SF_PARENT_PID", std::process::id().to_string())
|
||||
.spawn()
|
||||
.expect("Failed to spawn daw_engine sidecar");
|
||||
|
||||
app.manage(EngineProcess(Mutex::new(Some(child))));
|
||||
println!("Python Background Engine started (localhost:8000, auto-fallback 8000-8010)");
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|window, event| {
|
||||
// 2. Terminate sidecar khi DAW window dong — tranh orphan process
|
||||
if let tauri::WindowEvent::Destroyed = event {
|
||||
let state = window.state::<EngineProcess>();
|
||||
if let Ok(mut lock) = state.0.lock() {
|
||||
if let Some(child) = lock.take() {
|
||||
let _ = child.kill();
|
||||
println!("daw_engine sidecar terminated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
sonicforge_daw_lib::run()
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "SonicForgeDAW",
|
||||
"version": "1.0.0",
|
||||
"identifier": "com.sonicforge.daw",
|
||||
"build": {
|
||||
"frontendDist": "ui",
|
||||
"devUrl": "http://localhost:8000"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Sonic Forge DAW - Professional Desktop Studio",
|
||||
"width": 1440,
|
||||
"height": 900,
|
||||
"resizable": true,
|
||||
"fullscreen": false,
|
||||
"devtools": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": ["msi", "nsis"],
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/daw_engine"
|
||||
],
|
||||
"nsis": {
|
||||
"installerHooks": "hooks.nsh"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<!doctype html>
|
||||
<html lang="vi">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>SonicForge DAW</title>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; background: #12141a; color: #e8eaf0;
|
||||
display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
||||
#msg { text-align: center; max-width: 480px; line-height: 1.6; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="msg">Đang khởi động SonicForge Engine…</div>
|
||||
<script>
|
||||
// Engine (sidecar) có thể cần vài giây để boot (import librosa/pedalboard).
|
||||
// Thử health-check trên dải port 8000-8010, redirect tới port đầu tiên OK.
|
||||
(async function () {
|
||||
var tries = 0;
|
||||
while (tries < 90) { // ~60s tối đa
|
||||
for (var p = 8000; p <= 8010; p++) {
|
||||
try {
|
||||
var r = await fetch('http://127.0.0.1:' + p + '/health', { cache: 'no-store' });
|
||||
if (r.ok) { location.href = 'http://127.0.0.1:' + p + '/'; return; }
|
||||
} catch (e) { /* port chưa mở */ }
|
||||
}
|
||||
tries++;
|
||||
await new Promise(function (res) { setTimeout(res, 700); });
|
||||
}
|
||||
document.getElementById('msg').textContent =
|
||||
'Không tìm thấy SonicForge Engine (port 8000–8010). Hãy đóng và chạy lại ứng dụng. ' +
|
||||
'Nếu lặp lại, xem log: %APPDATA%\\SonicForgeDAW\\logs\\engine.log';
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user