cutego/cmd/qtmoc/main.go

78 lines
1.4 KiB
Go

package main
import (
"flag"
"os"
"path/filepath"
"runtime"
"github.com/therecipe/qt/internal/cmd"
"github.com/therecipe/qt/internal/cmd/moc"
"github.com/therecipe/qt/internal/utils"
)
func main() {
flag.Usage = func() {
println("Usage: qtmoc [-docker] [target] [path/to/project]\n")
println("Flags:\n")
flag.PrintDefaults()
print("\n")
println("Targets:\n")
//TODO:
print("\n")
os.Exit(0)
}
var docker bool
flag.BoolVar(&docker, "docker", false, "run command inside docker container")
var fast bool
flag.BoolVar(&fast, "fast", false, "don't run qtmoc for dependencies")
var tags string
flag.StringVar(&tags, "tags", "", "a list of build tags to consider satisfied during the build")
if cmd.ParseFlags() {
flag.Usage()
}
target := runtime.GOOS
path, err := os.Getwd()
if err != nil {
utils.Log.WithError(err).Debug("failed to get cwd")
}
switch flag.NArg() {
case 0:
case 1:
target = flag.Arg(0)
case 2:
target = flag.Arg(0)
path = flag.Arg(1)
default:
flag.Usage()
}
if target == "desktop" {
target = runtime.GOOS
}
if !filepath.IsAbs(path) {
path, err = filepath.Abs(path)
if err != nil {
utils.Log.WithError(err).WithField("path", path).Fatal("can't resolve absolute path")
}
}
utils.CheckBuildTarget(target)
if docker {
cmd.Docker([]string{"qtmoc", "-debug", "-tags=" + tags}, target, path, false)
} else {
moc.Moc(path, target, tags, fast)
}
}