// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "debug/buildinfo" "embed" "os" "os/exec" "path/filepath" "plugin" "unicode" "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/gui/prep" "go.wit.com/log" ) // sent via -ldflags var VERSION string var BUILDTIME string // used for shell auto completion var ARGNAME string = "fixup" // todo: get this from $0 ? //go:embed resources/* var resources embed.FS func main() { me = new(autoType) prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: this line should be: prep.Bash(argv) me.myGui = prep.Gui() // prepares the GUI package for go-args me.pp = arg.MustParse(&argv) me.pb = NewBlocks() /* if argv.Drives != nil { doDrives() doDrives2() } */ go listenForBlockEvents() me.myGui.Start() // loads the GUI toolkit doGui() // start making our forge GUI debug() // sits here forever okExit("everything compiled") } func doFixup() { okExit("list drives") } // this is dumb. sync this with go-deb func trimNonNumericFromStart(s string) string { for i, r := range s { if unicode.IsDigit(r) { return s[i:] } } return "" } func okExit(thing string) { if thing != "" { log.Info(thing, "ok") } // log.Info("Finished go-clean on", check.GetGoPath(), "ok") os.Exit(0) } func badExit(err error) { log.Info("go-clean failed: ", err) os.Exit(-1) } func dumpDebug() { // Get absolute path of the currently running binary exePath, err := os.Executable() if err != nil { log.Println("Error getting executable path:", err) return } // Resolve symlinks if necessary exePath, err = filepath.EvalSymlinks(exePath) if err != nil { log.Println("Error resolving symlink:", err) return } // Read build info bi, err := buildinfo.ReadFile(exePath) if err != nil { log.Println("Error reading build info:", err) return } log.Println("Go Version:", bi.GoVersion) for _, dep := range bi.Deps { log.Printf("Dependency: %s %s\n", dep.Path, dep.Version) } } func checkPlug(pluginPath string) *plugin.Plugin { if err := checkPluginViaSubprocess(pluginPath); err != nil { log.Printf("Plugin check failed: %v\n", err) return nil } p, err := plugin.Open(pluginPath) if err != nil { log.Fatalf("plugin.Open failed: %v", err) } log.Println("Plugin loaded successfully.") return p } func checkPluginViaSubprocess(path string) error { exe, err := os.Executable() if err != nil { return log.Errorf("failed to get executable path: %w", err) } resolved, err := filepath.EvalSymlinks(exe) if err != nil { return log.Errorf("failed to resolve executable symlink: %w", err) } cmd := exec.Command(resolved, "--gui-check-plugin", path) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr return cmd.Run() }