Exemplo n.º 1
0
Arquivo: binding.go Projeto: xland/qt
func GenModule(name string) {
	var (
		moduleT = name
		cppTmp  string
	)

	name = strings.ToLower(name)

	parser.GetModule(name)

	if ShouldBuild(moduleT) {

		utils.RemoveAll(utils.GetQtPkgPath(name))
		utils.RemoveAll(utils.GetQtPkgPath("internal", "binding", "dump", moduleT))

		var fcount = 0
		for _, c := range parser.ClassMap {

			if moduleT == strings.TrimPrefix(c.Module, "Qt") {

				//Dry run to catch all unsupported
				for _, f := range map[string]func(*parser.Class) string{"cpp": CppTemplate, "h": HTemplate, "go": GoTemplate} {
					f(c)
				}

				for e, f := range map[string]func(*parser.Class) string{"cpp": CppTemplate, "h": HTemplate, "go": GoTemplate} {
					utils.MakeFolder(utils.GetQtPkgPath(name))
					CopyCgo(moduleT)
					if moduleT == "AndroidExtras" {
						utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v_android.%v", strings.ToLower(c.Name), e)), f(c))
						if e == "go" {
							c.Stub = true
							utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v.%v", strings.ToLower(c.Name), e)), f(c))
							c.Stub = false
						}
					} else {
						if e == "cpp" {
							cppTmp += f(c)
						} else {
							utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v.%v", strings.ToLower(c.Name), e)), f(c))
						}
					}
				}

				c.Dump()

				fcount += len(c.Functions)
			}

		}
		utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v.cpp", strings.ToLower(moduleT))), cppTmp)
		fmt.Printf("%v%v\tfunctions:%v", name, terminalSeperator(name), fcount)
	}
}
Exemplo n.º 2
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"))
	}
}
Exemplo n.º 3
0
Arquivo: cgo.go Projeto: mouse225/qt
func createCgoLinux(module string) {
	var tmp string

	tmp += fmt.Sprintf("package %v\n", strings.ToLower(module))
	tmp += "/*\n"

	tmp += "#cgo CPPFLAGS: -pipe -O2 -Wall -W -D_REENTRANT\n"

	tmp += "#cgo CPPFLAGS: -DQT_NO_DEBUG"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -DQT_%v_LIB", strings.ToUpper(m))
	}
	tmp += "\n"

	tmp += "#cgo CPPFLAGS: -I/usr/local/Qt5.5.1/5.5/gcc/include -I/usr/local/Qt5.5.1/5.5/gcc/mkspecs/linux-g++\n"

	tmp += "#cgo CPPFLAGS:"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -I/usr/local/Qt5.5.1/5.5/gcc/include/Qt%v", m)
	}
	tmp += "\n\n"

	tmp += "#cgo LDFLAGS: -Wl,-O1 -Wl,-rpath,/usr/local/Qt5.5.1/5.5/gcc -Wl,-rpath,/usr/local/Qt5.5.1/5.5/gcc/lib\n"

	tmp += "#cgo LDFLAGS: -L/usr/local/Qt5.5.1/5.5/gcc/lib -L/usr/lib64"
	for _, m := range append(LibDeps[module], module) {
		if m == "UiTools" {
			tmp += fmt.Sprintf(" -lQt5%v", m)
		}
	}
	for _, m := range append(LibDeps[module], module) {
		if m != "UiTools" {
			tmp += fmt.Sprintf(" -lQt5%v", m)
		}
	}

	tmp += " -lpthread\n"
	tmp += "*/\n"

	tmp += fmt.Sprintf("import \"C\"\n")

	utils.Save(utils.GetQtPkgPath(strings.ToLower(module), "cgo_linux_386.go"), strings.Replace(tmp, "lib64", "lib", -1))
	utils.Save(utils.GetQtPkgPath(strings.ToLower(module), "cgo_linux_amd64.go"), strings.Replace(tmp, "gcc", "gcc_64", -1))
}
Exemplo n.º 4
0
Arquivo: cgo.go Projeto: mouse225/qt
func createCgoDarwin(module string) {
	var tmp string

	tmp += fmt.Sprintf("package %v\n", strings.ToLower(module))
	tmp += "/*\n"

	tmp += "#cgo CPPFLAGS: -pipe -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7 -Wall -W\n"

	tmp += "#cgo CPPFLAGS: -DQT_NO_DEBUG"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -DQT_%v_LIB", strings.ToUpper(m))
	}
	tmp += "\n"

	tmp += "#cgo CPPFLAGS: -I/usr/local/Qt5.5.1/5.5/clang_64/mkspecs/macx-clang -F/usr/local/Qt5.5.1/5.5/clang_64/lib\n"

	tmp += "#cgo CPPFLAGS:"
	for _, m := range append(LibDeps[module], module) {
		if m == "UiTools" {
			tmp += fmt.Sprintf(" -I/usr/local/Qt5.5.1/5.5/clang_64/include/Qt%v", m)
		} else {
			tmp += fmt.Sprintf(" -I/usr/local/Qt5.5.1/5.5/clang_64/lib/Qt%v.framework/Headers", m)
		}
	}
	tmp += "\n"

	tmp += "#cgo CPPFLAGS: -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AGL.framework/Headers\n"
	tmp += "\n"

	tmp += "#cgo LDFLAGS: -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.7\n"

	tmp += "#cgo LDFLAGS: -F/usr/local/Qt5.5.1/5.5/clang_64/lib"
	for _, m := range append(LibDeps[module], module) {
		if m == "UiTools" {
			tmp += fmt.Sprintf(" -L/usr/local/Qt5.5.1/5.5/clang_64/lib -lQt5%v", m)
		}
	}
	for _, m := range append(LibDeps[module], module) {
		if m != "UiTools" {
			tmp += fmt.Sprintf(" -framework Qt%v", m)
		}
	}

	tmp += " -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL\n"
	tmp += "*/\n"

	tmp += fmt.Sprintf("import \"C\"\n")

	utils.Save(utils.GetQtPkgPath(strings.ToLower(module), "cgo_darwin_amd64.go"), tmp)
}
Exemplo n.º 5
0
Arquivo: class.go Projeto: mouse225/qt
func (c *Class) Dump() {

	var tmp = fmt.Sprintln("########################################\t\t\tFUNCTIONS\t\t\t########################################")

	for _, f := range c.Functions {
		tmp += fmt.Sprintln(f)
	}

	tmp += fmt.Sprintln("########################################\t\t\tENUMS\t\t\t########################################")

	for _, e := range c.Enums {
		tmp += fmt.Sprintln(e)
	}

	utils.MakeFolder(utils.GetQtPkgPath("internal", "binding", "dump", c.Module))
	utils.Save(utils.GetQtPkgPath("internal", "binding", "dump", c.Module, fmt.Sprintf("%v.txt", c.Name)), tmp)
}
Exemplo n.º 6
0
Arquivo: cgo.go Projeto: mouse225/qt
func createCgoWindows(module string) {
	var tmp string

	tmp += fmt.Sprintf("package %v\n", strings.ToLower(module))
	tmp += "/*\n"

	tmp += "#cgo CPPFLAGS: -pipe -fno-keep-inline-dllexport -O2 -Wall -Wextra\n"

	tmp += "#cgo CPPFLAGS: -DUNICODE -DQT_NO_DEBUG"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -DQT_%v_LIB", strings.ToUpper(m))
	}
	tmp += "\n"

	tmp += "#cgo CPPFLAGS: -IC:/Qt/Qt5.5.1/5.5/mingw492_32/include -IC:/Qt/Qt5.5.1/5.5/mingw492_32/mkspecs/win32-g++\n"

	tmp += "#cgo CPPFLAGS:"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -IC:/Qt/Qt5.5.1/5.5/mingw492_32/include/Qt%v", m)
	}
	tmp += "\n\n"

	tmp += "#cgo LDFLAGS: -Wl,-s -Wl,-subsystem,windows -mthreads -Wl,--allow-multiple-definition\n"

	tmp += "#cgo LDFLAGS: -LC:/Qt/Qt5.5.1/5.5/mingw492_32/lib"
	for _, m := range append(LibDeps[module], module) {
		if m == "UiTools" {
			tmp += fmt.Sprintf(" -lQt5%v", m)
		}
	}
	for _, m := range append(LibDeps[module], module) {
		if m != "UiTools" {
			tmp += fmt.Sprintf(" -lQt5%v", m)
		}
	}

	tmp += " -lmingw32 -lqtmain -lshell32\n"
	tmp += "*/\n"

	tmp += fmt.Sprintf("import \"C\"\n")

	utils.Save(utils.GetQtPkgPath(strings.ToLower(module), "cgo_windows_386.go"), tmp)
}
Exemplo n.º 7
0
Arquivo: cgo.go Projeto: mouse225/qt
func createCgoandroidWindows(module string) {
	var tmp string

	tmp += fmt.Sprintf("package %v\n", strings.ToLower(module))
	tmp += "/*\n"

	tmp += "#cgo CPPFLAGS: -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT\n"

	tmp += "#cgo CPPFLAGS: -DQT_NO_DEBUG"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -DQT_%v_LIB", strings.ToUpper(m))
	}
	tmp += "\n"

	tmp += "#cgo CPPFLAGS: -IC:/Qt/Qt5.5.1/5.5/android_armv7/include -isystem C:/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem C:/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem C:/android/android-ndk/platforms/android-9/arch-arm/usr/include -IC:/Qt/Qt5.5.1/5.5/android_armv7/mkspecs/android-g++\n"

	tmp += "#cgo CPPFLAGS:"
	for _, m := range append(LibDeps[module], module) {
		tmp += fmt.Sprintf(" -IC:/Qt/Qt5.5.1/5.5/android_armv7/include/Qt%v", m)
	}
	tmp += "\n\n"

	tmp += "#cgo LDFLAGS: --sysroot=C:/android/android-ndk/platforms/android-9/arch-arm/ -Wl,-rpath=C:/Qt/Qt5.5.1/5.5/android_armv7/lib -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--allow-multiple-definition\n"

	tmp += "#cgo LDFLAGS: -LC:/android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a -LC:/android/android-ndk/platforms/android-9/arch-arm//usr/lib -LC:/Qt/Qt5.5.1/5.5/android_armv7/lib -LC:/android/android/ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a -LC:/android/android/ndk/platforms/android-9/arch-arm//usr/lib"
	for _, m := range append(LibDeps[module], module) {
		if m == "UiTools" {
			tmp += fmt.Sprintf(" -lQt5%v", m)
		}
	}
	for _, m := range append(LibDeps[module], module) {
		if m != "UiTools" {
			tmp += fmt.Sprintf(" -lQt5%v", m)
		}
	}

	tmp += " -lGLESv2 -lgnustl_shared -llog -lz -lm -ldl -lc -lgcc\n"
	tmp += "*/\n"

	tmp += fmt.Sprintf("import \"C\"\n")

	utils.Save(utils.GetQtPkgPath(strings.ToLower(module), "cgo_android_arm.go"), tmp)
}
Exemplo n.º 8
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")
				}
			}
		}
	}
}
Exemplo n.º 9
0
func predeploy() {

	var copyCmd string

	switch runtime.GOOS {
	case "windows":
		copyCmd = "xcopy"
	default:
		copyCmd = "cp"
	}

	switch buildTarget {
	case "android":
		{
			utils.MakeFolder(filepath.Join(appPath, "android"))

			for _, dir := range []string{"drawable-hdpi", "drawable-ldpi", "drawable-mdpi"} {
				utils.MakeFolder(filepath.Join(depPath, "build", "res", dir))
				runCmdOptional(exec.Command(copyCmd, filepath.Join(appPath, "android", "icon.png"), filepath.Join(depPath, "build", "res", dir, "icon.png")), "predeploy.cpicon")
			}

			var libPath = filepath.Join(depPath, "build", "libs", "armeabi-v7a")
			utils.MakeFolder(libPath)
			runCmd(exec.Command(copyCmd, filepath.Join(depPath, "libgo.so"), libPath), "predeploy.cplib")

			var (
				qtPrefix      string
				androidPrefix string
				ndkhost       string
			)

			switch runtime.GOOS {
			case "darwin", "linux":
				{
					qtPrefix = "/usr/local"
					androidPrefix = "/opt"
					ndkhost = runtime.GOOS + "-x86_64"

					runCmd(exec.Command("cp", "/usr/local/Qt5.5.1/5.5/android_armv7/jar/QtAndroid-bundled.jar", filepath.Join(depPath, "build", "libs")), "predeploy.cpqtandroid")

					runCmd(exec.Command("zip", "-d", filepath.Join(depPath, "build", "libs", "QtAndroid-bundled.jar"), "org/qtproject/qt5/android/QtNative.class"), "predeploy.patchqtandroid_main")
					for i := 1; i < 19; i++ {
						runCmd(exec.Command("zip", "-d", filepath.Join(depPath, "build", "libs", "QtAndroid-bundled.jar"), fmt.Sprintf("org/qtproject/qt5/android/QtNative$%v.class", i)), fmt.Sprintf("predeploy.patchqtandroid_%v", i))
					}
				}

			case "windows":
				{
					qtPrefix = "C:\\Qt"
					androidPrefix = "C:\\android"
					ndkhost = runtime.GOOS

					var (
						jdkVersion = strings.Split(runCmd(exec.Command("java", "-version"), "predeploy.jdk"), "\"")[1]
						jarPath    = fmt.Sprintf("C:\\Program Files\\Java\\jdk%v\\bin\\jar.exe", jdkVersion)
					)

					runCmd(exec.Command("xcopy", "C:\\Qt\\Qt5.5.1\\5.5\\android_armv7\\jar\\QtAndroid-bundled.jar", filepath.Join(depPath, "build", "libs")), "predeploy.cpqtandroid")

					var jarUnzip = exec.Command(jarPath, "-xf", filepath.Join(depPath, "build", "libs", "QtAndroid-bundled.jar"))
					jarUnzip.Dir = filepath.Join(depPath, "build", "libs")
					runCmd(jarUnzip, "predeploy.unzipqtandroid")

					utils.RemoveAll(filepath.Join(depPath, "build", "libs", "QtAndroid-bundled.jar"))
					utils.RemoveAll(filepath.Join(depPath, "build", "libs", "org", "qtproject", "qt5", "android", "QtNative.class"))
					for i := 1; i < 19; i++ {
						utils.RemoveAll(filepath.Join(depPath, "build", "libs", "org", "qtproject", "qt5", "android", fmt.Sprintf("QtNative$%v.class", i)))
					}

					var zipQtAndroid = exec.Command(jarPath, "-cmf", filepath.Join(depPath, "build", "libs", "META-INF", "MANIFEST.MF"), filepath.Join(depPath, "build", "libs", "QtAndroid-bundled.jar"), "org")
					zipQtAndroid.Dir = filepath.Join(depPath, "build", "libs")
					runCmd(zipQtAndroid, "predeploy.zipqtandroid")

					utils.RemoveAll(filepath.Join(depPath, "build", "libs", "org"))
					utils.RemoveAll(filepath.Join(depPath, "build", "libs", "META-INF"))
				}
			}

			utils.MakeFolder(filepath.Join(depPath, "build", "src", "org", "qtproject", "qt5", "android"))
			runCmd(exec.Command(copyCmd, utils.GetQtPkgPath("internal", "android", "patch", "QtNative.java"), filepath.Join(depPath, "build", "src", "org", "qtproject", "qt5", "android")), "predeploy.cpqtandroidpatched")

			var out, err = json.Marshal(&struct {
				Qt                            string `json:"qt"`
				Sdk                           string `json:"sdk"`
				SdkBuildToolsRevision         string `json:"sdkBuildToolsRevision"`
				Ndk                           string `json:"ndk"`
				Toolchainprefix               string `json:"toolchain-prefix"`
				Toolprefix                    string `json:"tool-prefix"`
				Toolchainversion              string `json:"toolchain-version"`
				Ndkhost                       string `json:"ndk-host"`
				Targetarchitecture            string `json:"target-architecture"`
				AndroidPackageSourceDirectory string `json:"android-package-source-directory"`
				Qmlrootpath                   string `json:"qml-root-path"`
				Applicationbinary             string `json:"application-binary"`
			}{
				Qt:  filepath.Join(qtPrefix, "Qt5.5.1", "5.5", "android_armv7"),
				Sdk: filepath.Join(androidPrefix, "android-sdk"),
				SdkBuildToolsRevision: "23.0.2",
				Ndk:                           filepath.Join(androidPrefix, "android-ndk"),
				Toolchainprefix:               "arm-linux-androideabi",
				Toolprefix:                    "arm-linux-androideabi",
				Toolchainversion:              "4.9",
				Ndkhost:                       ndkhost,
				Targetarchitecture:            "armeabi-v7a",
				AndroidPackageSourceDirectory: filepath.Join(appPath, "android"),
				Qmlrootpath:                   filepath.Join(appPath, "qml"),
				Applicationbinary:             filepath.Join(depPath, "libgo.so"),
			})
			if err != nil {
				fmt.Println("predeploy.json", string(out), err)
				os.Exit(1)
			}

			utils.Save(filepath.Join(depPath, "android-libgo.so-deployment-settings.json"), string(out))
		}

	case "desktop":
		{
			switch runtime.GOOS {
			case "darwin":
				{
					utils.Save(filepath.Join(depPath, fmt.Sprintf("%v.app/Contents/MacOS/%v_sh", appName, appName)), darwinSH())
					utils.Save(filepath.Join(depPath, fmt.Sprintf("%v.app/Contents/MacOS/Info.plist", appName)), darwinPLIST())
					//TODO: icon + plist
				}

			case "linux":
				{
					utils.Save(filepath.Join(depPath, fmt.Sprintf("%v.sh", appName)), linuxSH())
				}

			case "windows":
				{
					//TODO: icon windres
				}
			}
		}
	}
}
Exemplo n.º 10
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")
}