From cc4cad2e2393ef2830c940909ca12d99e4668599 Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Mon, 25 May 2026 21:15:32 +0200 Subject: [PATCH] build script + winamp_path optional - 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 --- build.ps1 | 51 +++++++++++++++++++++++++++++++++++++++ config.yaml.example | 8 ++++-- internal/server/server.go | 9 +++++-- 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..738d357 --- /dev/null +++ b/build.ps1 @@ -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 +} diff --git a/config.yaml.example b/config.yaml.example index 86883af..89a8599 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -1,4 +1,8 @@ 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" -resume_file: "resume.dat" +resume_file: "resume.dat" diff --git a/internal/server/server.go b/internal/server/server.go index e62e360..a5b689e 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -37,7 +37,6 @@ type Config struct { func loadConfig(path string) (Config, error) { cfg := Config{ Port: 8080, - WinampPath: `C:\Program Files\Winamp\Winamp.exe`, KillListFile: "killist.dat", ResumeFile: "resume.dat", } @@ -228,7 +227,9 @@ func (s *Server) handleCommand(raw []byte) { _ = s.kl.Remove(cmd.Title) case "winamp_start": 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. @@ -417,6 +418,10 @@ func (s *Server) handleWinampStart(w http.ResponseWriter, r *http.Request) { jsonOK(w, map[string]string{"status": "already_running"}) 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 { http.Error(w, err.Error(), 500) return