- Add build.ps1: one-shot PowerShell build with version from git tag - winamp_path config is now optional; roadamp works with any running Winamp instance regardless of install location (FindWindow does the discovery). Path is only needed if roadamp should launch Winamp itself. - Remove hardcoded C:\Program Files\Winamp default Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>master
| @@ -0,0 +1,51 @@ | |||||
| #Requires -Version 5.1 | |||||
| <# | |||||
| .SYNOPSIS | |||||
| Build roadamp.exe | |||||
| .PARAMETER OutDir | |||||
| Output directory. Defaults to the project root (where this script lives). | |||||
| .PARAMETER Version | |||||
| Version string embedded via -ldflags. Defaults to the current git tag/commit. | |||||
| .EXAMPLE | |||||
| .\build.ps1 | |||||
| .\build.ps1 -OutDir C:\Deploy\roadamp | |||||
| #> | |||||
| param( | |||||
| [string]$OutDir = $PSScriptRoot, | |||||
| [string]$Version = "" | |||||
| ) | |||||
| Set-StrictMode -Version Latest | |||||
| $ErrorActionPreference = 'Stop' | |||||
| Push-Location $PSScriptRoot | |||||
| try { | |||||
| # Resolve version from git if not supplied | |||||
| if (-not $Version) { | |||||
| $tag = git describe --tags --always --dirty 2>$null | |||||
| $Version = if ($tag) { $tag } else { "dev" } | |||||
| } | |||||
| $out = Join-Path $OutDir "roadamp.exe" | |||||
| Write-Host "Building roadamp $Version → $out" -ForegroundColor Cyan | |||||
| $env:GOOS = "windows" | |||||
| $env:GOARCH = "amd64" | |||||
| $env:CGO_ENABLED = "0" | |||||
| go build ` | |||||
| -trimpath ` | |||||
| -ldflags "-s -w -X main.Version=$Version" ` | |||||
| -o $out ` | |||||
| ./cmd/roadamp | |||||
| $size = [math]::Round((Get-Item $out).Length / 1MB, 2) | |||||
| Write-Host "Done $out (${size} MB)" -ForegroundColor Green | |||||
| } | |||||
| finally { | |||||
| Pop-Location | |||||
| } | |||||
| @@ -1,4 +1,8 @@ | |||||
| port: 8080 | port: 8080 | ||||
| winamp_path: "C:\\Program Files\\Winamp\\Winamp.exe" | |||||
| # Optional: full path to winamp.exe — only needed if you want roadamp to | |||||
| # launch Winamp for you. Leave empty (or omit) if you start Winamp yourself. | |||||
| # winamp_path: "C:\\Program Files\\Winamp\\Winamp.exe" | |||||
| killist_file: "killist.dat" | killist_file: "killist.dat" | ||||
| resume_file: "resume.dat" | |||||
| resume_file: "resume.dat" | |||||
| @@ -37,7 +37,6 @@ type Config struct { | |||||
| func loadConfig(path string) (Config, error) { | func loadConfig(path string) (Config, error) { | ||||
| cfg := Config{ | cfg := Config{ | ||||
| Port: 8080, | Port: 8080, | ||||
| WinampPath: `C:\Program Files\Winamp\Winamp.exe`, | |||||
| KillListFile: "killist.dat", | KillListFile: "killist.dat", | ||||
| ResumeFile: "resume.dat", | ResumeFile: "resume.dat", | ||||
| } | } | ||||
| @@ -228,7 +227,9 @@ func (s *Server) handleCommand(raw []byte) { | |||||
| _ = s.kl.Remove(cmd.Title) | _ = s.kl.Remove(cmd.Title) | ||||
| case "winamp_start": | case "winamp_start": | ||||
| if !s.wa.IsRunning() { | if !s.wa.IsRunning() { | ||||
| _ = exec.Command(s.cfg.WinampPath).Start() | |||||
| if s.cfg.WinampPath != "" { | |||||
| _ = exec.Command(s.cfg.WinampPath).Start() | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| // Push a fresh status after any command. | // Push a fresh status after any command. | ||||
| @@ -417,6 +418,10 @@ func (s *Server) handleWinampStart(w http.ResponseWriter, r *http.Request) { | |||||
| jsonOK(w, map[string]string{"status": "already_running"}) | jsonOK(w, map[string]string{"status": "already_running"}) | ||||
| return | return | ||||
| } | } | ||||
| if s.cfg.WinampPath == "" { | |||||
| http.Error(w, "winamp_path not configured", http.StatusServiceUnavailable) | |||||
| return | |||||
| } | |||||
| if err := exec.Command(s.cfg.WinampPath).Start(); err != nil { | if err := exec.Command(s.cfg.WinampPath).Start(); err != nil { | ||||
| http.Error(w, err.Error(), 500) | http.Error(w, err.Error(), 500) | ||||
| return | return | ||||