2017-03-11 00:54:09 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/therecipe/qt/internal/cmd"
|
|
|
|
"github.com/therecipe/qt/internal/cmd/deploy"
|
|
|
|
|
|
|
|
"github.com/therecipe/qt/internal/utils"
|
|
|
|
)
|
|
|
|
|
2017-03-16 22:18:32 +03:00
|
|
|
func main() {
|
2017-03-11 00:54:09 +03:00
|
|
|
flag.Usage = func() {
|
|
|
|
println("Usage: qtdeploy [-docker] [mode] [target] [path/to/project]\n")
|
|
|
|
|
|
|
|
println("Flags:\n")
|
|
|
|
flag.PrintDefaults()
|
2018-07-23 23:18:06 +03:00
|
|
|
println()
|
2017-03-11 00:54:09 +03:00
|
|
|
|
|
|
|
println("Modes:\n")
|
2018-07-23 23:18:06 +03:00
|
|
|
for _, m := range []struct{ name, desc string }{
|
2017-03-11 00:54:09 +03:00
|
|
|
{"build", "compile and bundle"},
|
|
|
|
{"run", "run the binary"},
|
|
|
|
{"test", "build and run"},
|
|
|
|
{"help", "print help"},
|
2018-07-23 23:18:06 +03:00
|
|
|
} {
|
|
|
|
fmt.Printf(" %v%v%v\n", m.name, strings.Repeat(" ", 12-len(m.name)), m.desc)
|
2017-03-11 00:54:09 +03:00
|
|
|
}
|
2018-07-23 23:18:06 +03:00
|
|
|
println()
|
2017-03-11 00:54:09 +03:00
|
|
|
|
2017-03-16 22:18:32 +03:00
|
|
|
println("Targets:\n")
|
|
|
|
//TODO:
|
2018-07-23 23:18:06 +03:00
|
|
|
println()
|
2017-03-16 22:18:32 +03:00
|
|
|
|
2017-03-11 00:54:09 +03:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
var docker bool
|
|
|
|
flag.BoolVar(&docker, "docker", false, "run command inside docker container")
|
|
|
|
|
2017-07-12 00:33:08 +03:00
|
|
|
var vagrant bool
|
|
|
|
flag.BoolVar(&vagrant, "vagrant", false, "run command inside vagrant vm")
|
|
|
|
|
2017-03-11 00:54:09 +03:00
|
|
|
var ldFlags string
|
2017-03-16 22:18:32 +03:00
|
|
|
flag.StringVar(&ldFlags, "ldflags", "", "arguments to pass on each go tool link invocation")
|
|
|
|
|
|
|
|
var fast bool
|
|
|
|
flag.BoolVar(&fast, "fast", false, "use cached moc, minimal and dependencies (works for: windows, darwin, linux)")
|
2017-03-11 00:54:09 +03:00
|
|
|
|
2017-05-03 04:16:05 +03:00
|
|
|
var tags string
|
|
|
|
flag.StringVar(&tags, "tags", "", "a list of build tags to consider satisfied during the build")
|
|
|
|
|
2017-07-01 01:29:11 +03:00
|
|
|
var device string
|
|
|
|
flag.StringVar(&device, "device", "", "a device UUID to be used by the iOS simulator")
|
|
|
|
|
2018-04-07 22:05:41 +03:00
|
|
|
var comply bool
|
|
|
|
flag.BoolVar(&comply, "comply", false, "dump object code to make it easier to comply with LGPL obligations for proprietary developments")
|
|
|
|
|
2017-03-11 00:54:09 +03:00
|
|
|
if cmd.ParseFlags() {
|
|
|
|
flag.Usage()
|
|
|
|
}
|
|
|
|
|
|
|
|
mode := "test"
|
2017-03-16 22:18:32 +03:00
|
|
|
target := runtime.GOOS
|
2017-03-11 00:54:09 +03:00
|
|
|
path, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
utils.Log.WithError(err).Debug("failed to get cwd")
|
|
|
|
}
|
|
|
|
|
|
|
|
switch flag.NArg() {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
mode = flag.Arg(0)
|
|
|
|
case 2:
|
|
|
|
mode = flag.Arg(0)
|
|
|
|
target = flag.Arg(1)
|
|
|
|
case 3:
|
|
|
|
mode = flag.Arg(0)
|
|
|
|
target = flag.Arg(1)
|
|
|
|
path = flag.Arg(2)
|
|
|
|
default:
|
|
|
|
flag.Usage()
|
|
|
|
}
|
|
|
|
|
|
|
|
if mode == "help" {
|
|
|
|
flag.Usage()
|
|
|
|
}
|
|
|
|
|
2018-07-23 23:18:06 +03:00
|
|
|
var vagrant_system string
|
|
|
|
if target_splitted := strings.Split(target, "/"); vagrant && len(target_splitted) == 2 {
|
|
|
|
vagrant_system = target_splitted[0]
|
|
|
|
target = target_splitted[1]
|
2017-07-12 00:33:08 +03:00
|
|
|
}
|
|
|
|
|
2017-03-16 22:18:32 +03:00
|
|
|
if target == "desktop" {
|
|
|
|
target = runtime.GOOS
|
2018-08-18 17:55:15 +03:00
|
|
|
}
|
|
|
|
if target != runtime.GOOS {
|
2018-07-23 23:18:06 +03:00
|
|
|
fast = false
|
2017-03-11 00:54:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2018-07-23 23:18:06 +03:00
|
|
|
deploy.Deploy(mode, target, path, docker, ldFlags, tags, fast && !(docker || vagrant), device, vagrant, vagrant_system, comply)
|
2017-03-11 00:54:09 +03:00
|
|
|
}
|