diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum new file mode 100755 index 0000000..7456fbf --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= +github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum new file mode 100755 index 0000000..7456fbf --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= +github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= diff --git a/multiCompile-linux-386 b/multiCompile-linux-386 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-386 Binary files differ diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum new file mode 100755 index 0000000..7456fbf --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= +github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= diff --git a/multiCompile-linux-386 b/multiCompile-linux-386 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-386 Binary files differ diff --git a/multiCompile-linux-amd64 b/multiCompile-linux-amd64 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-amd64 Binary files differ diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum new file mode 100755 index 0000000..7456fbf --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= +github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= diff --git a/multiCompile-linux-386 b/multiCompile-linux-386 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-386 Binary files differ diff --git a/multiCompile-linux-amd64 b/multiCompile-linux-amd64 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-amd64 Binary files differ diff --git a/multiCompile-windows-386.exe b/multiCompile-windows-386.exe new file mode 100755 index 0000000..e1dd532 --- /dev/null +++ b/multiCompile-windows-386.exe Binary files differ diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum new file mode 100755 index 0000000..7456fbf --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= +github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= diff --git a/multiCompile-linux-386 b/multiCompile-linux-386 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-386 Binary files differ diff --git a/multiCompile-linux-amd64 b/multiCompile-linux-amd64 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-amd64 Binary files differ diff --git a/multiCompile-windows-386.exe b/multiCompile-windows-386.exe new file mode 100755 index 0000000..e1dd532 --- /dev/null +++ b/multiCompile-windows-386.exe Binary files differ diff --git a/multiCompile-windows-amd64.exe b/multiCompile-windows-amd64.exe new file mode 100755 index 0000000..e1dd532 --- /dev/null +++ b/multiCompile-windows-amd64.exe Binary files differ diff --git a/README.md b/README.md index c5b6672..e1ec066 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,30 @@ multiCompile =============== -A small program to quickly compile golang scripts for multiple OS's \ No newline at end of file +A small program to quickly compile golang scripts for multiple OS's from either windows or linux. + +Running on linux: + +``` +$> ./multiCompile-linux-amd64 -p ./multiCompile.go +Dir: ./ +File: multiCompile.go +1) Compiling windows-386 - (linux compiler)... Built ./multiCompile-windows-386.exe +2) Compiling windows-amd64 - (linux compiler)... Built ./multiCompile-windows-amd64.exe +3) Compiling linux-386 - (linux compiler)... Built ./multiCompile-linux-386 +4) Compiling linux-amd64 - (linux compiler)... Built ./multiCompile-linux-amd64 + +``` + +Running on windows: + +``` +C:\>multiCompile-windows-amd64.exe -p .\multiCompile.go +Dir: .\ +File: multiCompile.go +1) Compiling windows-386 - (windows compiler) Built .\multiCompile-windows-386.exe +2) Compiling windows-amd64 - (windows compiler) Built .\multiCompile-windows-amd64.exe +3) Compiling linux-386 - (windows compiler) Built .\multiCompile-linux-386 +4) Compiling linux-amd64 - (windows compiler) Built .\multiCompile-linux-amd64 + +``` \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100755 index 0000000..5f8629f --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module multiCompile + +go 1.16 + +require github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum new file mode 100755 index 0000000..7456fbf --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= +github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= diff --git a/multiCompile-linux-386 b/multiCompile-linux-386 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-386 Binary files differ diff --git a/multiCompile-linux-amd64 b/multiCompile-linux-amd64 new file mode 100755 index 0000000..e63b4ea --- /dev/null +++ b/multiCompile-linux-amd64 Binary files differ diff --git a/multiCompile-windows-386.exe b/multiCompile-windows-386.exe new file mode 100755 index 0000000..e1dd532 --- /dev/null +++ b/multiCompile-windows-386.exe Binary files differ diff --git a/multiCompile-windows-amd64.exe b/multiCompile-windows-amd64.exe new file mode 100755 index 0000000..e1dd532 --- /dev/null +++ b/multiCompile-windows-amd64.exe Binary files differ diff --git a/multiCompile.go b/multiCompile.go new file mode 100755 index 0000000..3f313c4 --- /dev/null +++ b/multiCompile.go @@ -0,0 +1,57 @@ +package main + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + + "github.com/akamensky/argparse" +) + +func main() { + parser := argparse.NewParser("print", "Multi-OS Golang compiler ("+runtime.GOOS+")") + p := parser.String("p", "path", &argparse.Options{Required: true, Help: "path/to/program.go t compile"}) + err := parser.Parse(os.Args) + if err != nil { + fmt.Print(parser.Usage(err)) + os.Exit(1) + } + // convert CRLF to LF + fullPath := strings.Replace(*p, "\n", "", -1) + dir, file := filepath.Split(fullPath) + fmt.Println("Dir: " + dir) + fmt.Println("File: " + file) + + if _, err := os.Stat(fullPath); os.IsNotExist(err) { + fmt.Println("[-] file does not exist!") + os.Exit(1) + } + + osASM := [4]string{"windows-386", "windows-amd64", "linux-386", "linux-amd64"} + for index, element := range osASM { + fmt.Printf("%v) Compiling %v - ", index+1, element) + elemSplit := strings.Split(element, "-") + + fileNoExt := strings.TrimSuffix(file, filepath.Ext(file)) + var ext string + if elemSplit[0] == "windows" { + ext = ".exe" + } else { + ext = "" + } + if runtime.GOOS == "windows" { + fmt.Print("(windows compiler)... ") + exec.Command("go", "env", "-w", "GOOS="+elemSplit[0]).Output() // windows + exec.Command("go", "env", "-w", "GOARCH="+elemSplit[1]).Output() // windows + exec.Command("go", "build", "-o", dir+fileNoExt+"-"+element+ext, fullPath).Output() + } + if runtime.GOOS == "linux" { + fmt.Print("(linux compiler)... ") + exec.Command("env", "GOOS="+elemSplit[0], "GOARC="+elemSplit[1], "go", "build", "-o", dir+fileNoExt+"-"+element+ext, fullPath).Output() // linux + } + fmt.Printf("Built %v\n", dir+fileNoExt+"-"+element+ext) + } +}