Beispiel #1
0
func IsPrivateSignal(f *parser.Function) bool {

	var fData string

	switch runtime.GOOS {
	case "darwin":
		fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/clang_64/lib/%v.framework/Versions/5/Headers/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))

	case "windows":
		fData = utils.Load(fmt.Sprintf("C:\\Qt\\Qt5.5.1\\5.5\\mingw492_32\\include\\%v\\%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))

	case "linux":
		switch runtime.GOARCH {
		case "amd64":
			{
				fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/gcc_64/include/%v/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))
			}
		case "386":
			{
				fData = utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/5.5/gcc/include/%v/%v", strings.Title(parser.ClassMap[f.Class()].DocModule), filepath.Base(f.Filepath)))
			}
		}
	}

	if fData != "" {
		return strings.Contains(strings.Split(strings.Split(fData, f.Name+"(")[1], ")")[0], "QPrivateSignal")
	} else {
		fmt.Println("converter.IsPrivateSignal", f.Class())
	}

	return false
}
Beispiel #2
0
func GetModule(s string) (m *Module) {

	switch runtime.GOOS {
	case "darwin", "linux":
		xml.Unmarshal([]byte(utils.Load(fmt.Sprintf("/usr/local/Qt5.5.1/Docs/Qt-5.5/qt%v/qt%v.index", s, s))), &m)

	case "windows":
		xml.Unmarshal([]byte(utils.Load(fmt.Sprintf("C:\\Qt\\Qt5.5.1\\Docs\\Qt-5.5\\qt%v\\qt%v.index", s, s))), &m)
	}

	m.prepare()

	return m
}
Beispiel #3
0
func pastdeploy() {

	switch buildTarget {
	case "android":
		{
			var (
				copyCmd   string
				apkEnding string
			)

			switch runtime.GOOS {
			case "darwin", "linux":
				{
					copyCmd = "cp"
					apkEnding = "apk"
				}
			case "windows":
				{
					copyCmd = "xcopy"
					apkEnding = "apk*"
				}
			}

			if ks := utils.Load(filepath.Join(appPath, "android", appName+".keystore")); ks != "" {
				runCmd(exec.Command(copyCmd, filepath.Join(depPath, "build", "bin", "QtApp-release-signed.apk"), filepath.Join(depPath, fmt.Sprintf("%v.%v", appName, apkEnding))), "pastdeploy.release")
			} else {
				runCmd(exec.Command(copyCmd, filepath.Join(depPath, "build", "bin", "QtApp-debug.apk"), filepath.Join(depPath, fmt.Sprintf("%v.%v", appName, apkEnding))), "pastdeploy.debug")
			}

			//TODO: copy manifest to android folder and change mindSdkVersion >= 16

		}
	case "desktop":
		{
			switch runtime.GOOS {
			case "darwin":
				{
					runCmd(exec.Command("mv", filepath.Join(depPath, fmt.Sprintf("%v.app/Contents/MacOS/%v", appName, appName)), filepath.Join(depPath, fmt.Sprintf("%v.app/Contents/MacOS/%v_app", appName, appName))), "pastdeploy.moveApp")
					runCmd(exec.Command("mv", filepath.Join(depPath, fmt.Sprintf("%v.app/Contents/MacOS/%v_sh", appName, appName)), filepath.Join(depPath, fmt.Sprintf("%v.app/Contents/MacOS/%v", appName, appName))), "pastdeploy.moveSh")
				}
			}
		}
	}
}
Beispiel #4
0
func GenModule(name string) {
	if ShouldBuild(name) {

		var (
			pkgName = strings.ToLower(name)
			suffix  string
		)

		if name == "AndroidExtras" {
			suffix = "_android"
		}

		//cleanup
		utils.RemoveAll(utils.GetQtPkgPath(pkgName))
		utils.RemoveAll(utils.GetQtPkgPath("internal", "binding", "dump", name))

		//prepare
		utils.MakeFolder(utils.GetQtPkgPath(pkgName))
		CopyCgo(name)
		if name == "AndroidExtras" {
			utils.Save(utils.GetQtPkgPath(pkgName, "utils-androidextras_android.go"), utils.Load(utils.GetQtPkgPath("internal", "binding", "files", "utils-androidextras_android.go")))
		}

		//dry run
		for _, c := range parser.ClassMap {
			if strings.TrimPrefix(c.Module, "Qt") == name {
				AddObjectNameFunctionIfNeeded(c)
				ManualWeakLink(c)
			}
		}
		CppTemplate("Qt" + name)
		HTemplate("Qt" + name)
		GoTemplate("Qt"+name, false)

		//generate
		utils.Save(utils.GetQtPkgPath(pkgName, pkgName+suffix+".cpp"), CppTemplate("Qt"+name))
		utils.Save(utils.GetQtPkgPath(pkgName, pkgName+suffix+".h"), HTemplate("Qt"+name))

		if name == "AndroidExtras" {
			utils.Save(utils.GetQtPkgPath(pkgName, pkgName+suffix+".go"), GoTemplate("Qt"+name, false))
		}
		utils.Save(utils.GetQtPkgPath(pkgName, pkgName+".go"), GoTemplate("Qt"+name, name == "AndroidExtras"))
	}
}
Beispiel #5
0
func deploy() {

	switch buildTarget {
	case "android":
		{

			var (
				jdkLib        string
				qtPrefix      string
				androidPrefix string
				ending        string
			)

			switch runtime.GOOS {
			case "darwin", "linux":
				{

					if runtime.GOOS == "darwin" {
						var version = strings.Split(runCmd(exec.Command("java", "-version"), "deploy.jdk"), "\"")[1]
						jdkLib = fmt.Sprintf("/Library/Java/JavaVirtualMachines/jdk%v.jdk/Contents/Home", version)
					} else {
						jdkLib = "/opt/jdk"
					}

					qtPrefix = "/usr/local"
					androidPrefix = "/opt"
				}
			case "windows":
				{
					var version = strings.Split(runCmd(exec.Command("java", "-version"), "deploy.jdk"), "\"")[1]
					jdkLib = fmt.Sprintf("C:\\Program Files\\Java\\jdk%v", version)

					qtPrefix = "C:\\Qt"
					androidPrefix = "C:\\android"
					ending = ".exe"
				}
			}

			var deploy = exec.Command(filepath.Join(qtPrefix, "Qt5.5.1", "5.5", "android_armv7", "bin", "androiddeployqt"+ending))
			deploy.Args = append(deploy.Args,
				"--input", filepath.Join(depPath, "android-libgo.so-deployment-settings.json"),
				"--output", filepath.Join(depPath, "build"),
				"--deployment", "bundled",
				"--android-platform", "android-22",
				"--jdk", jdkLib,
				"--ant", filepath.Join(androidPrefix, "apache-ant", "bin", "ant"),
			)

			if ks := utils.Load(filepath.Join(appPath, "android", appName+".keystore")); ks != "" {
				deploy.Args = append(deploy.Args,
					"--sign", filepath.Join(appPath, "android", appName+".keystore"),
					strings.TrimSpace(utils.Load(filepath.Join(appPath, "android", "alias.txt"))),
					"--storepass", strings.TrimSpace(utils.Load(filepath.Join(appPath, "android", "password.txt"))),
				)
			}

			deploy.Dir = filepath.Join(qtPrefix, "Qt5.5.1", "5.5", "android_armv7", "bin")
			deploy.Env = append(deploy.Env, "JAVA_HOME="+jdkLib)

			if runtime.GOOS == "windows" {
				utils.Save(filepath.Join(depPath, "build.bat"), fmt.Sprintf("set JAVA_HOME=%v\r\n%v", jdkLib, strings.Join(deploy.Args, " ")))
				runCmd(exec.Command(filepath.Join(depPath, "build.bat")), "deploy")
				utils.RemoveAll(filepath.Join(depPath, "build.bat"))
			} else {
				runCmd(deploy, "deploy")
			}
		}
	case "desktop":
		{
			switch runtime.GOOS {
			case "darwin":
				{
					var deploy = exec.Command("/usr/local/Qt5.5.1/5.5/clang_64/bin/macdeployqt")
					deploy.Args = append(deploy.Args,
						filepath.Join(depPath, fmt.Sprintf("%v.app/", appName)),
						fmt.Sprintf("-qmldir=%v", filepath.Join(appPath, "qml")),
						"-always-overwrite")
					deploy.Dir = "/usr/local/Qt5.5.1/5.5/clang_64/bin/"
					runCmd(deploy, "deploy")
				}

			case "linux":
				{
					var libraryPath string

					for _, dep := range strings.Split(runCmd(exec.Command("ldd", filepath.Join(depPath, appName)), "deploy.ldd"), "\n") {
						if strings.Contains(dep, "libQt5") || strings.Contains(dep, "libicu") {
							var libraryP, libName = filepath.Split(strings.Split(dep, " ")[2])
							libraryPath = libraryP
							runCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, libName), filepath.Join(depPath, libName)), fmt.Sprintf("deploy.%v", libName))
						}
					}

					for _, libName := range []string{"DBus", "XcbQpa", "Quick", "Widgets"} {
						runCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, fmt.Sprintf("libQt5%v.so.5", libName)), filepath.Join(depPath, fmt.Sprintf("libQt5%v.so.5", libName))), fmt.Sprintf("deploy.%v", libName))
					}

					libraryPath = strings.TrimSuffix(libraryPath, "lib/")

					for _, libDir := range []string{"platforms", "platformthemes", "xcbglintegrations"} {
						utils.MakeFolder(filepath.Join(depPath, libDir))
					}

					runCmd(exec.Command("cp", "-R", filepath.Join(libraryPath, "qml/"), depPath), "deploy.qml")
					runCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, "plugins", "platforms", "libqxcb.so"), filepath.Join(depPath, "platforms", "libqxcb.so")), "deploy.qxcb")
					runCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, "plugins", "platformthemes", "libqgtk2.so"), filepath.Join(depPath, "platformthemes", "libqgtk2.so")), "deploy.qgtk2")
					runCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, "plugins", "xcbglintegrations", "libqxcb-glx-integration.so"), filepath.Join(depPath, "xcbglintegrations", "libqxcb-glx-integration.so")), "deploy.qxcb-glx-integration")
				}

			case "windows":
				{
					var deploy = exec.Command("C:\\Qt\\Qt5.5.1\\5.5\\mingw492_32\\bin\\windeployqt.exe")
					deploy.Args = append(deploy.Args,
						filepath.Join(depPath, appName+ending),
						fmt.Sprintf("-qmldir=%v", filepath.Join(appPath, "qml")),
						"-force")
					runCmd(deploy, "deploy")
				}
			}
		}
	}
}
Beispiel #6
0
func qrc() {

	utils.MakeFolder(filepath.Join(appPath, "qml"))

	var (
		rccPath string
		qmlGo   = filepath.Join(appPath, "qtQrc.go")
		qmlQrc  = filepath.Join(appPath, "qtQrc.qrc")
		qmlCpp  = filepath.Join(appPath, "qtQrc.cpp")
	)

	switch buildTarget {
	case "android":
		{
			switch runtime.GOOS {
			case "darwin":
				{
					rccPath = "/usr/local/Qt5.5.1/5.5/android_armv7/bin/rcc"
				}

			case "linux":
				{

					switch runtime.GOARCH {
					case "amd64":
						{
							rccPath = "/usr/local/Qt5.5.1/5.5/android_armv7/bin/rcc"
						}

					case "386":
						{
							rccPath = "/usr/local/Qt5.5.1/5.5/android_armv7/bin/rcc"
						}
					}
				}

			case "windows":
				{
					rccPath = "C:\\Qt\\Qt5.5.1\\5.5\\android_armv7\\bin\\rcc.exe"
				}
			}
		}

	case "desktop":
		{
			switch runtime.GOOS {
			case "darwin":
				{
					rccPath = "/usr/local/Qt5.5.1/5.5/clang_64/bin/rcc"
				}

			case "linux":
				{

					switch runtime.GOARCH {
					case "amd64":
						{
							rccPath = "/usr/local/Qt5.5.1/5.5/gcc_64/bin/rcc"
						}

					case "386":
						{
							rccPath = "/usr/local/Qt5.5.1/5.5/gcc/bin/rcc"
						}
					}
				}

			case "windows":
				{
					rccPath = "C:\\Qt\\Qt5.5.1\\5.5\\mingw492_32\\bin\\rcc.exe"
				}
			}
		}
	}

	utils.Save(qmlGo, qmlHeader())

	var rcc = exec.Command(rccPath)
	rcc.Args = append(rcc.Args,
		"-project",
		"-o", qmlQrc)
	rcc.Dir = filepath.Join(appPath, "qml")
	runCmd(rcc, "qrc.qrc")

	utils.Save(qmlQrc, strings.Replace(utils.Load(qmlQrc), "<file>./", "<file>qml/", -1))

	rcc = exec.Command(rccPath)
	rcc.Args = append(rcc.Args,
		"-name", appName,
		"-o", qmlCpp,
		qmlQrc)
	runCmd(rcc, "qrc.cpp")
}