From ec0cf5ab89766df68567ac2c6591ffc19c93d931 Mon Sep 17 00:00:00 2001 From: TehPeGaSuS <25697531+TehPeGaSuS@users.noreply.github.com> Date: Sat, 20 Dec 2025 20:32:43 +0100 Subject: [PATCH] Add main.go for cross-compilation and zipping --- makerel/main.go | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 makerel/main.go diff --git a/makerel/main.go b/makerel/main.go new file mode 100644 index 0000000..fe2ae21 --- /dev/null +++ b/makerel/main.go @@ -0,0 +1,89 @@ +// MIT+NoAI License +// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights/// +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This code may not be used to train artificial intelligence computer models +// or retrieved by artificial intelligence software or hardware. +package main + +import ( + "fmt" + "os" + "os/exec" +) + +func main() { + targets := []struct { + os string + arch []string + }{ + {"linux", + []string{ + "386", + "amd64", + "arm", + "arm64", + "loong64", + "mips", + "mips64", + "mips64le", + "mipsle", + "ppc64", + "ppc64le", + "riscv64", + "s390x", + }, + }, + {"solaris", []string{"amd64"}}, + {"dragonfly", []string{"amd64"}}, + {"darwin", []string{"arm64", "amd64"}}, + {"plan9", []string{"386", "amd64", "arm"}}, + {"android", []string{"arm64"}}, + {"netbsd", []string{"386", "amd64", "arm", "arm64"}}, + {"openbsd", []string{"386", "amd64", "arm", "arm64"}}, + {"windows", []string{"386", "amd64", "arm", "arm64"}}, + {"freebsd", []string{"386", "amd64", "arm", "arm64", "riscv64"}}, + } + + for _, t := range targets { + for _, arch := range t.arch { + build := exec.Command("go", "build") + build.Stderr = os.Stderr + build.Stdout = os.Stdout + build.Env = append(os.Environ(), "GOOS="+t.os, "GOARCH="+arch) + fmt.Println(t.os, arch) + if err := build.Run(); err != nil { + panic(err) + } + zip := exec.Command("zip", "") + exe := "xmasbot" + if t.os == "windows" { + exe = "xmasbot.exe" + } + zip.Args = []string{"-1", fmt.Sprintf("xmasbot_%s_%s.zip", t.os, arch), exe, "LICENSE", "README.md"} + if err := zip.Run(); err != nil { + panic(err) + } + if err := os.Remove(exe); err != nil { + panic(err) + } + } + } +}