gllvm/gowllvm.go

41 lines
835 B
Go
Raw Normal View History

2017-06-22 01:34:56 +02:00
package main
import(
"os"
"os/exec"
2017-06-22 21:14:00 +02:00
"log"
2017-06-22 01:34:56 +02:00
)
func main() {
// Parse command line
var args = os.Args
if len(args) < 2 {
2017-06-22 21:14:00 +02:00
log.Fatal("Not enough arguments.")
2017-06-22 01:34:56 +02:00
}
var modeFlag = args[1]
args = args[2:]
switch modeFlag {
case "compile":
// Call main compiling function with args
2017-06-22 01:34:56 +02:00
compile(args)
case "extract":
// Call main extracting function with args
extract(args)
2017-06-22 01:34:56 +02:00
default:
2017-06-22 21:14:00 +02:00
log.Fatal("You should call gowllvm with a valid mode.")
2017-06-22 01:34:56 +02:00
}
}
// Executes a command then returns true if there was an error
func execCmd(cmdExecName string, args []string) bool {
cmd := exec.Command(cmdExecName, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if cmd.Run() == nil {
return false
} else {
return true
}
}