forked from therecipe/qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.go
86 lines (70 loc) · 3.56 KB
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package deploy
import (
"fmt"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/ilius/qt/internal/utils"
)
func run(target, name, depPath, device string) {
switch target {
case "android", "android-emulator":
if utils.ExistsFile(filepath.Join(depPath, "build-debug.apk")) {
exec.Command(filepath.Join(utils.ANDROID_SDK_DIR(), "platform-tools", "adb"), "install", "-r", filepath.Join(depPath, "build-debug.apk")).Start()
} else {
exec.Command(filepath.Join(utils.ANDROID_SDK_DIR(), "platform-tools", "adb"), "install", "-r", filepath.Join(depPath, "build-release-signed.apk")).Start()
}
//TODO: parse manifest for ident and start app (+ logcat)
case "ios-simulator":
if device == "" {
out, _ := exec.Command("xcrun", "instruments", "-s").Output()
lines := strings.Split(string(out), "iPhone")
device = strings.Split(strings.Split(string(out), "iPhone 11 ("+strings.Split(strings.Split(lines[len(lines)-1], "(")[1], ")")[0]+") [")[1], "]")[0]
}
go utils.RunCmdOptional(exec.Command("xcrun", "instruments", "-w", device), "start simulator")
time.Sleep(3 * time.Second)
utils.RunCmdOptional(exec.Command("xcrun", "simctl", "uninstall", "booted", filepath.Join(depPath, "main.app")), "uninstall old app")
utils.RunCmdOptional(exec.Command("xcrun", "simctl", "install", "booted", filepath.Join(depPath, "main.app")), "install new app")
utils.RunCmdOptional(exec.Command("xcrun", "simctl", "launch", "booted", strings.Replace(name, "_", "", -1)), "start app") //TODO: parse ident from plist
case "darwin":
exec.Command("open", filepath.Join(depPath, fmt.Sprintf("%v.app", name))).Start()
case "linux", "freebsd":
exec.Command(filepath.Join(depPath, name)).Start()
case "windows":
if runtime.GOOS == target {
exec.Command(filepath.Join(depPath, name+".exe")).Start()
} else {
exec.Command("wine", filepath.Join(depPath, name+".exe")).Start()
}
case "sailfish-emulator":
if utils.QT_SAILFISH() {
return
}
emulator := "Sailfish OS Emulator"
if strings.HasPrefix(utils.QT_SAILFISH_VERSION(), "3.") {
emulator = fmt.Sprintf("Sailfish OS Emulator %v", utils.QT_SAILFISH_VERSION())
}
utils.RunCmdOptional(exec.Command(filepath.Join(utils.VIRTUALBOX_DIR(), "vboxmanage"), "registervm", filepath.Join(utils.SAILFISH_DIR(), "emulator", emulator, emulator+".vbox")), "register vm")
utils.RunCmdOptional(exec.Command(filepath.Join(utils.VIRTUALBOX_DIR(), "vboxmanage"), "sharedfolder", "add", emulator, "--name", "GOPATH", "--hostpath", utils.MustGoPath(), "--automount"), "mount GOPATH")
if runtime.GOOS == "windows" {
utils.RunCmdOptional(exec.Command(filepath.Join(utils.VIRTUALBOX_DIR(), "vboxmanage"), "startvm", emulator), "start emulator")
} else {
utils.RunCmdOptional(exec.Command("nohup", filepath.Join(utils.VIRTUALBOX_DIR(), "vboxmanage"), "startvm", emulator), "start emulator")
}
time.Sleep(10 * time.Second)
err := sailfish_ssh("2223", "nemo", "sudo", "rpm", "-i", "--force", strings.Replace(strings.Replace(depPath, utils.MustGoPath(), "/media/sf_GOPATH/", -1)+"/*.rpm", "\\", "/", -1))
if err != nil {
utils.Log.WithError(err).Errorf("failed to install %v for %v", name, target)
}
err = sailfish_ssh("2223", "nemo", "nohup", "/usr/bin/harbour-"+name, ">", "/dev/null", "2>&1", "&")
if err != nil {
utils.Log.WithError(err).Errorf("failed to run %v for %v", name, target)
}
case "js", "wasm": //TODO: REVIEW and use emscripten wrapper instead
if runtime.GOOS == "darwin" {
exec.Command("/Applications/Firefox.app/Contents/MacOS/firefox", filepath.Join(depPath, "index.html")).Start()
}
}
}