Files
AetherForge/server/internal/builder/platform.go
drjones 0f9e04f5f6 Add universal forge, fusion disguise, remote deploy, and stability fixes.
Ship cross-platform spread kits and fusion ZIPs with per-OS launchers, one-liner dropper endpoints, Windows file disguise, and a large batch of wiring/bug fixes so agents connect reliably across a LAN test fleet.
2026-05-29 20:53:13 -07:00

76 lines
1.9 KiB
Go

package builder
import "strings"
// BuildPlatform identifies a GOOS/GOARCH compile target.
type BuildPlatform struct {
GOOS string
GOARCH string
Ext string
}
func (p BuildPlatform) Label() string {
return p.GOOS + "-" + p.GOARCH
}
func (p BuildPlatform) BinDir() string {
return "bin/" + p.Label()
}
var defaultPlatforms = []BuildPlatform{
{GOOS: "windows", GOARCH: "amd64", Ext: ".exe"},
{GOOS: "linux", GOARCH: "amd64", Ext: ""},
{GOOS: "linux", GOARCH: "arm64", Ext: ""},
{GOOS: "darwin", GOARCH: "arm64", Ext: ""},
{GOOS: "darwin", GOARCH: "amd64", Ext: ""},
}
func platformsForRequest(req *BuildRequest) []BuildPlatform {
target := strings.ToLower(strings.TrimSpace(req.TargetOS))
if target == "" || target == "windows" {
return []BuildPlatform{{GOOS: "windows", GOARCH: "amd64", Ext: ".exe"}}
}
if target == "linux" {
arch := req.TargetArch
if arch == "" {
arch = "amd64"
}
return []BuildPlatform{{GOOS: "linux", GOARCH: arch, Ext: ""}}
}
if target == "darwin" {
arch := req.TargetArch
if arch == "" {
arch = "arm64"
}
return []BuildPlatform{{GOOS: "darwin", GOARCH: arch, Ext: ""}}
}
if target == "universal" {
if req.TargetArch != "" && req.TargetArch != "all" {
for _, p := range defaultPlatforms {
if p.GOARCH == req.TargetArch {
return []BuildPlatform{p}
}
}
}
return append([]BuildPlatform{}, defaultPlatforms...)
}
return []BuildPlatform{{GOOS: "windows", GOARCH: "amd64", Ext: ".exe"}}
}
func workerFileName(worker string, p BuildPlatform, fusion bool) string {
base := sanitizeFileName(worker)
if fusion {
return "worker-" + base + p.Ext
}
return "install-" + base + p.Ext
}
func ldflagsFor(req *BuildRequest, p BuildPlatform) string {
ldflags := "-s -w"
gui := req.DisplayMode == "silent" || req.DisplayMode == "background" || req.SilentMode || req.StealthMode || req.FusionEnabled
if p.GOOS == "windows" && gui {
ldflags += " -H windowsgui"
}
return ldflags
}