cleanup + split qtdeploy

This commit is contained in:
therecipe 2016-10-29 23:28:13 +02:00
parent 33a17d2e87
commit bac79d8fdd
34 changed files with 528 additions and 389 deletions

View file

@ -62,8 +62,9 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then travis_wait 45 $GOPATH/src/github.com/therecipe/qt/internal/ci/darwin.sh; fi
script:
- if [[ "$DESKTOP" == "true" ]]; then $GOPATH/src/github.com/therecipe/qt/setup.sh; fi
- if [[ "$ANDROID" == "true" ]]; then $GOPATH/src/github.com/therecipe/qt/setup.sh android; fi
- if [[ "$IOS" == "true" ]]; then $GOPATH/src/github.com/therecipe/qt/setup.sh ios; fi
- if [[ "$IOS_SIMULATOR" == "true" ]]; then $GOPATH/src/github.com/therecipe/qt/setup.sh ios-simulator; fi
- if [[ "$QT_WINDOWS_CC" == "true" ]]; then $GOPATH/src/github.com/therecipe/qt/setup.sh windows; fi
- go get github.com/therecipe/qt/cmd/qtsetup
- if [[ "$DESKTOP" == "true" ]]; then $GOPATH/bin/qtsetup; fi
- if [[ "$ANDROID" == "true" ]]; then $GOPATH/bin/qtsetup android; fi
- if [[ "$IOS" == "true" ]]; then $GOPATH/bin/qtsetup ios; fi
- if [[ "$IOS_SIMULATOR" == "true" ]]; then $GOPATH/bin/qtsetup ios-simulator; fi
- if [[ "$QT_WINDOWS_CC" == "true" ]]; then $GOPATH/bin/qtsetup windows; fi

View file

@ -19,7 +19,7 @@ The project is pretty much a WIP and **not** recommended to be used in productio
However it should already contain everything you need to build fully featured Qt applications in Go.
[Screenshots of the Line Edits example](internal/screens)
[Screenshots of the Line Edits example](internal/screenshots)
## Installation
@ -27,7 +27,7 @@ However it should already contain everything you need to build fully featured Qt
The full installation requires at least **8gb** free ram and takes 20 min.
The stub installation requires only **1gb** free ram and takes 5 min. (**experimental**)
The stub installation requires only **1gb** free ram and takes 10 min. (**experimental**)
The only differnce between those two version is, that you **won't** be able to use `go run/build` to build your applications if you choose to install the stub version.
You are therefore **limited** to the use of `qtdeploy` to build your application.
@ -36,7 +36,7 @@ To build the stub version export `QT_STUB=true` system wide and procede with the
#### Environmental variables
If you define enviormental variables during the installation export them system wide, as they are needed not only during the installation but also later by `qtdeploy`.
If you define enviormental variables during the installation export them system wide, as they are needed not only during the installation but also later.
Add the enviormental variables into your `$HOME/.bash_profile` or `$HOME/.profile` on macOS or Linux.
@ -87,11 +87,11 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
4. Download the binding
* `go get -d github.com/therecipe/qt`
* `go get github.com/therecipe/qt/cmd/qtsetup`
5. Generate, install and test (20 min)
* `cd %GOPATH%\src\github.com\therecipe\qt && setup.bat`
* `%GOPATH%\bin\qtsetup`
6. Create your first [application](#example)
@ -120,11 +120,11 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
4. Download the binding
* `go get -d github.com/therecipe/qt`
* `go get github.com/therecipe/qt/cmd/qtsetup`
5. Generate, install and test (20 min)
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh`
* `$GOPATH/bin/qtsetup`
6. Create your first [application](#example)
@ -162,11 +162,11 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
4. Download the binding
* `go get -d github.com/therecipe/qt`
* `go get github.com/therecipe/qt/cmd/qtsetup`
5. Generate, install and test (20 min)
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh`
* `$GOPATH/bin/qtsetup`
6. Create your first [application](#example)
@ -190,7 +190,7 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
3. Generate, install and test (20 min)
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh windows`
* `$GOPATH/bin/qtsetup windows`
4. Deploy applications with `$GOPATH/bin/qtdeploy build windows path/to/your/project`
@ -221,11 +221,11 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
6. Install and test (20 min)
* `cd %GOPATH%\src\github.com\therecipe\qt && setup.bat android`
* `%GOPATH%\bin\qtsetup android`
or
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh android`
* `$GOPATH/bin/qtsetup android`
7. Create your first [application](#example)
@ -237,7 +237,7 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
2. Install and test (20 min)
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh ios && ./setup.sh ios-simulator`
* `$GOPATH/bin/qtsetup ios && $GOPATH/bin/qtsetup ios-simulator`
3. Create your first [application](#example)
@ -259,11 +259,11 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
4. Install and test (20 min)
* `cd %GOPATH%\src\github.com\therecipe\qt && setup.bat sailfish && setup.bat sailfish-emulator`
* `%GOPATH%\bin\qtsetup sailfish && %GOPATH%\bin\qtsetup sailfish-emulator`
or
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh sailfish && ./setup.sh sailfish-emulator`
* `$GOPATH/bin/qtsetup sailfish && $GOPATH/bin/qtsetup sailfish-emulator`
5. Create your first [application](#example)
@ -376,13 +376,13 @@ You can export `QT_DEBUG=true` before "qtdeploying" your application to enable p
14. Install and test the binding (20 min)
* Raspberry Pi 1
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh rpi1`
* `$GOPATH/bin/qtsetup rpi1`
* Raspberry Pi 2
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh rpi2`
* `$GOPATH/bin/qtsetup rpi2`
* Raspberry Pi 3
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh rpi3`
* `$GOPATH/bin/qtsetup rpi3`
15. Notes
@ -414,7 +414,7 @@ And make sure your Project folder is in your **GOPATH**.
* **Optional:** Install [Wine](https://www.winehq.org) to test your applications.
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh windows-docker`
* `$GOPATH/bin/qtsetup windows-docker`
* Deploy applications with `$GOPATH/bin/qtdeploy build windows path/to/your/project docker`
@ -422,7 +422,7 @@ And make sure your Project folder is in your **GOPATH**.
* `docker pull therecipe/qt:base`
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh linux-docker`
* `$GOPATH/bin/qtsetup linux-docker`
* Deploy applications with `$GOPATH/bin/qtdeploy build linux path/to/your/project docker`
@ -430,7 +430,7 @@ And make sure your Project folder is in your **GOPATH**.
* `docker pull therecipe/qt:base_android`
* `cd $GOPATH/src/github.com/therecipe/qt && ./setup.sh android-docker`
* `$GOPATH/bin/qtsetup android-docker`
* Deploy applications with `$GOPATH/bin/qtdeploy build android path/to/your/project docker`
@ -474,7 +474,7 @@ func main() {
}
```
3. Open the terminal in `[GOPATH]/src/qtExample` and run `[GOPATH]/bin/qtdeploy build desktop`
3. Open the terminal in `[GOPATH]/src` and run `[GOPATH]/bin/qtdeploy build desktop ./qtExample`
4. You will find the application in `[GOPATH]/src/qtExample/deploy/[GOOS]_minimal/`

View file

@ -42,6 +42,8 @@ install:
DEL %TMP%\%NDK% /Q
build_script:
- cmd: >-
%GOPATH%\src\github.com\therecipe\qt\setup.bat
go get github.com/therecipe/qt/cmd/qtsetup
%GOPATH%\src\github.com\therecipe\qt\setup.bat android
%GOPATH%\bin\qtsetup
%GOPATH%\bin\qtsetup android

View file

@ -12,13 +12,13 @@ machine:
dependencies:
pre:
override:
- go get -d github.com/therecipe/qt
- go get github.com/therecipe/qt/cmd/qtsetup
- if [[ "$OS" == "linux" ]]; then /home/ubuntu/.go_project/src/github.com/therecipe/qt/internal/ci/linux.sh; fi
post:
test:
pre:
override:
- if [[ "$DESKTOP" == "true" ]]; then /home/ubuntu/.go_project/src/github.com/therecipe/qt/setup.sh; fi
- if [[ "$ANDROID" == "true" ]]; then /home/ubuntu/.go_project/src/github.com/therecipe/qt/setup.sh android; fi
- if [[ "$QT_WINDOWS_CC" == "true" ]]; then /home/ubuntu/.go_project/src/github.com/therecipe/qt/setup.sh windows; fi
- if [[ "$DESKTOP" == "true" ]]; then /home/ubuntu/.go_project/bin/qtsetup; fi
- if [[ "$ANDROID" == "true" ]]; then /home/ubuntu/.go_project/bin/qtsetup android; fi
- if [[ "$QT_WINDOWS_CC" == "true" ]]; then /home/ubuntu/.go_project/bin/qtsetup windows; fi
post:

View file

@ -16,7 +16,6 @@ import (
"github.com/therecipe/qt/internal/binding/parser"
"github.com/therecipe/qt/internal/binding/templater"
"github.com/therecipe/qt/internal/minimal"
"github.com/therecipe/qt/internal/utils"
)
@ -25,7 +24,6 @@ var (
depPath string
buildMode, buildTarget string
ending string
buildMinimal bool
buildDocker bool
)
@ -39,12 +37,16 @@ func main() {
if buildDocker {
deployDocker()
} else {
moc()
qrc()
moc()
minimal()
build()
predeploy()
deploy()
pastdeploy()
cleanup()
}
}
@ -103,8 +105,6 @@ func args() {
buildMode = "build"
}
buildMinimal = true
utils.Log.Debugln("mode:", buildMode, "target:", buildTarget, "path:", appPath, "use docker:", buildDocker)
switch buildMode {
@ -180,9 +180,7 @@ func args() {
}
}
if buildMinimal {
depPath += "_minimal"
}
depPath += "_minimal"
switch buildMode {
case "build", "test":
@ -202,144 +200,22 @@ func moc() {
}
func qrc() {
utils.MakeFolder(filepath.Join(appPath, "qml"))
var (
rccPath string
qmlGo = filepath.Join(appPath, "qrc.go")
qmlQrc = filepath.Join(appPath, "qrc.qrc")
qmlCpp = filepath.Join(appPath, "qrc.cpp")
)
switch buildTarget {
case "android":
{
rccPath = filepath.Join(utils.QT_DIR(), "5.7", "android_armv7", "bin", "rcc")
}
case "ios", "ios-simulator":
{
rccPath = filepath.Join(utils.QT_DIR(), "5.7", "ios", "bin", "rcc")
}
case "desktop", "sailfish", "sailfish-emulator", "rpi1", "rpi2", "rpi3", "windows":
{
switch runtime.GOOS {
case "darwin":
{
rccPath = filepath.Join(utils.QT_DARWIN_DIR(), "bin", "rcc")
}
case "linux":
{
if utils.UsePkgConfig() {
rccPath = filepath.Join(strings.TrimSpace(utils.RunCmd(exec.Command("pkg-config", "--variable=host_bins", "Qt5Core"), fmt.Sprintf("find rccPath for %v on %v", buildTarget, runtime.GOOS))), "rcc")
} else {
rccPath = filepath.Join(utils.QT_DIR(), "5.7", "gcc_64", "bin", "rcc")
}
}
case "windows":
{
rccPath = filepath.Join(utils.QT_DIR(), "5.7", "mingw53_32", "bin", "rcc")
}
}
}
}
utils.Save(qmlGo, qmlHeader())
var rcc = exec.Command(rccPath, "-project", "-o", qmlQrc)
rcc.Dir = filepath.Join(appPath, "qml")
utils.RunCmd(rcc, fmt.Sprintf("execute rcc.1 for %v on %v", buildTarget, runtime.GOOS))
utils.Save(qmlQrc, strings.Replace(utils.Load(qmlQrc), "<file>./", "<file>qml/", -1))
if utils.Exists(filepath.Join(appPath, "qtquickcontrols2.conf")) {
utils.Save(qmlQrc, strings.Replace(utils.Load(qmlQrc), "<qresource>", "<qresource>\n<file>qtquickcontrols2.conf</file>", -1))
}
rcc = exec.Command(rccPath, "-name", appName, "-o", qmlCpp, qmlQrc)
utils.RunCmd(rcc, fmt.Sprintf("execute rcc.2 for %v on %v", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command(filepath.Join(utils.MustGoPath(), "bin", "qtrcc"), appPath), fmt.Sprintf("execute qtrcc for %v on %v", buildTarget, runtime.GOOS))
}
func qmlHeader() string {
return strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(`package main
/*
#cgo +build windows,386 LDFLAGS: -L${QT_WINDOWS_DIR} -lQt5Core
#cgo +build !ios,darwin,amd64 LDFLAGS: -F${QT_DARWIN_DIR}/lib -framework QtCore
#cgo +build linux,amd64 LDFLAGS: -Wl,-rpath,${QT_LINUX_DIR} -L${QT_LINUX_DIR} -lQt5Core
#cgo +build android,linux,arm LDFLAGS: -L${QT_DIR}/5.7/android_armv7/lib -lQt5Core
#cgo +build ios,darwin,amd64 LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/${IPHONESIMULATOR_SDK_DIR} -mios-simulator-version-min=7.0 -arch x86_64
#cgo +build ios,darwin,amd64 LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios_iphonesimulator -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype_iphonesimulator -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds_iphonesimulator -lqicns_iphonesimulator -lqico_iphonesimulator -lqtga_iphonesimulator -lqtiff_iphonesimulator -lqwbmp_iphonesimulator -lqwebp_iphonesimulator -lqtharfbuzzng_iphonesimulator -lz -lqtpcre_iphonesimulator -lm -lQt5Core_iphonesimulator -lQt5Widgets_iphonesimulator -lQt5Gui_iphonesimulator -lQt5PlatformSupport_iphonesimulator
#cgo +build ios,darwin,386 LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/${IPHONESIMULATOR_SDK_DIR} -mios-simulator-version-min=7.0 -arch i386
#cgo +build ios,darwin,386 LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios_iphonesimulator -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype_iphonesimulator -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds_iphonesimulator -lqicns_iphonesimulator -lqico_iphonesimulator -lqtga_iphonesimulator -lqtiff_iphonesimulator -lqwbmp_iphonesimulator -lqwebp_iphonesimulator -lqtharfbuzzng_iphonesimulator -lz -lqtpcre_iphonesimulator -lm -lQt5Core_iphonesimulator -lQt5Widgets_iphonesimulator -lQt5Gui_iphonesimulator -lQt5PlatformSupport_iphonesimulator
#cgo +build ios,darwin,arm64 LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${IPHONEOS_SDK_DIR} -miphoneos-version-min=7.0 -arch arm64
#cgo +build ios,darwin,arm64 LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds -lqicns -lqico -lqtga -lqtiff -lqwbmp -lqwebp -lqtharfbuzzng -lz -lqtpcre -lm -lQt5Core -lQt5Widgets -lQt5Gui -lQt5PlatformSupport
#cgo +build ios,darwin,arm LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${IPHONEOS_SDK_DIR} -miphoneos-version-min=7.0 -arch armv7
#cgo +build ios,darwin,arm LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds -lqicns -lqico -lqtga -lqtiff -lqwbmp -lqwebp -lqtharfbuzzng -lz -lqtpcre -lm -lQt5Core -lQt5Widgets -lQt5Gui -lQt5PlatformSupport
#cgo +build sailfish_emulator,linux,386 LDFLAGS: -Wl,-rpath,/usr/share/harbour-${APPNAME}/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-i486/usr/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-i486/lib -L/srv/mer/targets/SailfishOS-i486/usr/lib -L/srv/mer/targets/SailfishOS-i486/lib -lQt5Core
#cgo +build sailfish,linux,arm LDFLAGS: -Wl,-rpath,/usr/share/harbour-${APPNAME}/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-armv7hl/usr/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-armv7hl/lib -L/srv/mer/targets/SailfishOS-armv7hl/usr/lib -L/srv/mer/targets/SailfishOS-armv7hl/lib -lQt5Core
#cgo +build rpi1,linux,arm LDFLAGS: -Wl,-rpath-link,${RPI1_SYSROOT_DIR}/opt/vc/lib -Wl,-rpath-link,${RPI1_SYSROOT_DIR}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${RPI1_SYSROOT_DIR}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${QT_DIR}/5.7/rpi1/lib -mfloat-abi=hard --sysroot=${RPI1_SYSROOT_DIR} -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -L${RPI1_SYSROOT_DIR}/opt/vc/lib -L${QT_DIR}/5.7/rpi1/lib -lQt5Core
#cgo +build rpi2,linux,arm LDFLAGS: -Wl,-rpath-link,${RPI2_SYSROOT_DIR}/opt/vc/lib -Wl,-rpath-link,${RPI2_SYSROOT_DIR}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${RPI2_SYSROOT_DIR}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${QT_DIR}/5.7/rpi2/lib -mfloat-abi=hard --sysroot=${RPI2_SYSROOT_DIR} -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -L${RPI2_SYSROOT_DIR}/opt/vc/lib -L${QT_DIR}/5.7/rpi2/lib -lQt5Core
#cgo +build rpi3,linux,arm LDFLAGS: -Wl,-rpath-link,${RPI3_SYSROOT_DIR}/opt/vc/lib -Wl,-rpath-link,${RPI3_SYSROOT_DIR}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${RPI3_SYSROOT_DIR}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${QT_DIR}/5.7/rpi3/lib -mfloat-abi=hard --sysroot=${RPI3_SYSROOT_DIR} -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -L${RPI3_SYSROOT_DIR}/opt/vc/lib -L${QT_DIR}/5.7/rpi3/lib -lQt5Core
*/
import "C"`,
"${QT_WINDOWS_DIR}", func() string {
if runtime.GOOS == "linux" {
return "/usr/lib/mxe/usr/i686-w64-mingw32.shared/qt5/lib"
}
return "${QT_DIR}/5.7/mingw53_32/lib"
}(), -1),
"${QT_DARWIN_DIR}", utils.QT_DARWIN_DIR(), -1),
"${QT_LINUX_DIR}", func() string {
if utils.UsePkgConfig() {
return strings.TrimSpace(utils.RunCmd(exec.Command("pkg-config", "--variable=libdir", "Qt5Core"), fmt.Sprintf("find linux pkg-config lib dir for %v on %v", buildTarget, runtime.GOOS)))
}
return "${QT_DIR}/5.7/gcc_64/lib"
}(), -1),
"${QT_DIR}", utils.QT_DIR(), -1),
"${RPI1_SYSROOT_DIR}", utils.RPI1_SYSROOT_DIR(), -1),
"${RPI2_SYSROOT_DIR}", utils.RPI2_SYSROOT_DIR(), -1),
"${RPI3_SYSROOT_DIR}", utils.RPI3_SYSROOT_DIR(), -1),
"${XCODE_DIR}", utils.XCODE_DIR(), -1),
"${IPHONEOS_SDK_DIR}", utils.IPHONEOS_SDK_DIR(), -1),
"${IPHONESIMULATOR_SDK_DIR}", utils.IPHONESIMULATOR_SDK_DIR(), -1),
"${APPNAME}", appName, -1),
"\\", "/", -1)
func minimal() {
utils.RunCmd(exec.Command(filepath.Join(utils.MustGoPath(), "bin", "qtminimal"), buildTarget, appPath), fmt.Sprintf("execute qtminimal for %v on %v", buildTarget, runtime.GOOS))
}
func build() {
var (
ldFlags = "-ldflags="
tagFlags = "-tags="
tagFlags = "-tags=\"minimal\""
outputFile string
env map[string]string
)
if buildMinimal {
minimal.BuildTarget = buildTarget
minimal.Minimal(appPath)
tagFlags += "\"minimal\""
}
switch buildTarget {
case "android":
{
@ -589,7 +465,7 @@ func build() {
}
//armv7
if buildTarget == "ios" && (strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel") || buildMinimal) {
if buildTarget == "ios" && (strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel")) {
var cmdiOS = exec.Command("go", "build", ldFlags, "-o", strings.Replace(outputFile, "libgo.a", "libgo_armv7.a", -1))
cmdiOS.Dir = appPath
if tagFlags != "" {
@ -693,7 +569,7 @@ func predeploy() {
//add c_main_wrappers
utils.Save(filepath.Join(depPath, "c_main_wrapper.cpp"), "#include \"libgo.h\"\nint main(int argc, char *argv[]) { go_main_wrapper(); }")
if buildTarget == "ios" && (strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel") || buildMinimal) {
if buildTarget == "ios" && (strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel")) {
utils.Save(filepath.Join(depPath, "c_main_wrapper_armv7.cpp"), "#include \"libgo_armv7.h\"\nint main(int argc, char *argv[]) { go_main_wrapper(); }")
}
@ -712,7 +588,7 @@ func predeploy() {
strip.Dir = filepath.Join(depPath, "build")
utils.RunCmd(strip, fmt.Sprintf("strip binary for %v on %v", buildTarget, runtime.GOOS))
if buildTarget == "ios" && (strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel") || buildMinimal) {
if buildTarget == "ios" && (strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel")) {
//build armv7
cmd = exec.Command("xcrun", "clang++", "c_main_wrapper_armv7.cpp", "gallery_plugin_import.cpp", "gallery_qml_plugin_import.cpp", "-o", "build/main_armv7", "-u", "_qt_registerPlatformPlugin", "-Wl,-e,_qt_main_wrapper", "-I../..", "-L.", "-lgo_armv7")
cmd.Args = append(cmd.Args, templater.GetiOSClang(buildTarget, "armv7")...)
@ -1029,17 +905,17 @@ func pastdeploy() {
}
func cleanup() {
utils.RemoveAll(filepath.Join(appPath, "qrc.go"))
utils.RemoveAll(filepath.Join(appPath, "qrc.qrc"))
utils.RemoveAll(filepath.Join(appPath, "qrc.cpp"))
utils.RemoveAll(filepath.Join(appPath, "rrc.go"))
utils.RemoveAll(filepath.Join(appPath, "rrc.qrc"))
utils.RemoveAll(filepath.Join(appPath, "rrc.cpp"))
utils.RemoveAll(filepath.Join(appPath, "cgo_main_wrapper.go"))
var tmpMocFiles []string
json.Unmarshal([]byte(utils.Load(filepath.Join(appPath, "cleanup.json"))), &tmpMocFiles)
json.Unmarshal([]byte(utils.Load(filepath.Join(appPath, "moc_cleanup.json"))), &tmpMocFiles)
for _, mf := range tmpMocFiles {
utils.RemoveAll(mf)
}
utils.RemoveAll(filepath.Join(appPath, "cleanup.json"))
utils.RemoveAll(filepath.Join(appPath, "moc_cleanup.json"))
}
func deployDocker() {
@ -1097,7 +973,7 @@ func deployDocker() {
utils.Log.Panicln("Project needs to be inside GOPATH", appPath, utils.MustGoPath())
}
utils.RunCmd(exec.Command("docker", "run", "--rm", "-v", fmt.Sprintf("%v:/media/sf_GOPATH", utils.MustGoPath()), "-i", fmt.Sprintf("therecipe/qt:%v", dockerImage), "qtdeploy", "build", buildTarget, strings.Replace(strings.Replace(appPath, utils.MustGoPath(), "/media/sf_GOPATH", -1), "\\", "/", -1)), fmt.Sprintf("deploy binary for %v on %v with docker", buildTarget, runtime.GOOS))
utils.RunCmd(exec.Command("docker", "run", "--rm", "-v", fmt.Sprintf("%v:/media/sf_GOPATH", utils.MustGoPath()), "-i", fmt.Sprintf("therecipe/qt:%v", dockerImage), "$GOPATH/bin/qtdeploy", "build", buildTarget, strings.Replace(strings.Replace(appPath, utils.MustGoPath(), "/media/sf_GOPATH", -1), "\\", "/", -1)), fmt.Sprintf("deploy binary for %v on %v with docker", buildTarget, runtime.GOOS))
}
func run() {
@ -1310,7 +1186,7 @@ func iosPLIST() string {
</dict>
</plist>
`, appName, appName, func() string {
if strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel") || buildMinimal {
if strings.HasPrefix(runtime.Version(), "go1.7") || strings.HasPrefix(runtime.Version(), "devel") {
return ""
}
return `

View file

@ -1,4 +1,4 @@
package minimal
package main
import (
goparser "go/parser"
@ -14,27 +14,45 @@ import (
"github.com/therecipe/qt/internal/utils"
)
var BuildTarget string
func main() {
var (
buildTarget = "desktop"
appPath, _ = os.Getwd()
)
func Minimal(path string) error {
switch len(os.Args) {
case 2:
{
buildTarget = os.Args[1]
}
case 3:
{
buildTarget = os.Args[1]
appPath = os.Args[2]
}
}
if !filepath.IsAbs(appPath) {
appPath = utils.GetAbsPath(appPath)
}
var (
imported []string
cached []string
)
var walkFuncImports = func(path string, info os.FileInfo, err error) error {
var walkFuncImports = func(appPath string, info os.FileInfo, err error) error {
if err == nil && !strings.HasPrefix(info.Name(), "moc") && strings.HasSuffix(info.Name(), ".go") && !info.IsDir() {
var pFile, errParse = goparser.ParseFile(token.NewFileSet(), path, nil, 0)
var pFile, errParse = goparser.ParseFile(token.NewFileSet(), appPath, nil, 0)
if errParse != nil {
utils.Log.WithError(errParse).Panicf("failed to parser file %v", path)
utils.Log.WithError(errParse).Panicf("failed to parser file %v", appPath)
} else {
for _, i := range pFile.Imports {
if !strings.Contains(i.Path.Value, "github.com/therecipe/qt") {
var path = filepath.Join(utils.MustGoPath(), "src", strings.Replace(i.Path.Value, "\"", "", -1))
if _, err := ioutil.ReadDir(path); err == nil {
if !isImported(imported, path) {
imported = append(imported, path)
var appPath = filepath.Join(utils.MustGoPath(), "src", strings.Replace(i.Path.Value, "\"", "", -1))
if _, err := ioutil.ReadDir(appPath); err == nil {
if !isImported(imported, appPath) {
imported = append(imported, appPath)
}
}
}
@ -44,10 +62,10 @@ func Minimal(path string) error {
return nil
}
var walkFunc = func(path string, info os.FileInfo, err error) error {
var walkFunc = func(appPath string, info os.FileInfo, err error) error {
if err == nil && strings.HasSuffix(info.Name(), ".go") && !info.IsDir() {
if file := utils.Load(path); strings.Contains(file, "github.com/therecipe/qt/") &&
if file := utils.Load(appPath); strings.Contains(file, "github.com/therecipe/qt/") &&
!(strings.Contains(file, "github.com/therecipe/qt/androidextras") &&
strings.Count(file, "github.com/therecipe/qt/") == 1) {
cached = append(cached, file)
@ -57,20 +75,19 @@ func Minimal(path string) error {
return nil
}
filepath.Walk(path, walkFuncImports)
filepath.Walk(appPath, walkFuncImports)
for _, imp := range imported {
filepath.Walk(imp, walkFuncImports)
}
filepath.Walk(path, walkFunc)
filepath.Walk(appPath, walkFunc)
for _, imp := range imported {
filepath.Walk(imp, walkFunc)
}
for _, module := range templater.GetLibs() {
if _, err := parser.GetModule(module); err != nil {
utils.Log.Errorf("failed to load qt/%v", strings.ToLower(module))
return err
utils.Log.WithError(err).Errorf("failed to load qt/%v", strings.ToLower(module))
}
}
@ -129,11 +146,11 @@ func Minimal(path string) error {
}
}
if BuildTarget == "sailfish" || BuildTarget == "sailfish-emulator" {
if buildTarget == "sailfish" || buildTarget == "sailfish-emulator" {
parser.ClassMap["QQuickWidget"].Export = false
}
if BuildTarget == "ios" || BuildTarget == "ios-simulator" {
if buildTarget == "ios" || buildTarget == "ios-simulator" {
parser.ClassMap["QProcess"].Export = false
parser.ClassMap["QProcessEnvironment"].Export = false
}
@ -142,7 +159,6 @@ func Minimal(path string) error {
for _, module := range templater.GetLibs() {
templater.GenModule(module)
}
return nil
}
func exportFunction(class *parser.Class, function *parser.Function) {
@ -187,9 +203,9 @@ func hasPureVirtualFunctions(className string) bool {
return false
}
func isImported(imported []string, path string) bool {
func isImported(imported []string, appPath string) bool {
for _, i := range imported {
if i == path {
if i == appPath {
return true
}
}

View file

@ -69,7 +69,7 @@ func main() {
if cleanup {
var b, err = json.Marshal(tmpFiles)
if err == nil {
utils.SaveBytes(filepath.Join(appPath, "cleanup.json"), b)
utils.SaveBytes(filepath.Join(appPath, "moc_cleanup.json"), b)
}
}
}
@ -87,7 +87,7 @@ func moc(appPath string) {
}
tmpFiles = append(tmpFiles, filepath.Join(appPath, name))
}
utils.RemoveAll(filepath.Join(appPath, "cleanup.json"))
utils.RemoveAll(filepath.Join(appPath, "moc_cleanup.json"))
var module = &parser.Module{Project: parser.MOC, Namespace: &parser.Namespace{Classes: make([]*parser.Class, 0)}}
@ -154,7 +154,7 @@ func moc(appPath string) {
if meta != "" {
var (
name = strings.Split(tag, ":")[1]
name = strings.Replace(strings.Split(tag, ":")[1], "\"", "", -1)
f = &parser.Function{Access: "public", Fullname: class.Name + "::" + name, Meta: meta, Name: name, Output: "void", Status: "public", Virtual: "non", Signature: "()"}
)
f.Parameters = getParameters(_type)

139
cmd/qtrcc/rcc.go Executable file
View file

@ -0,0 +1,139 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/therecipe/qt/internal/utils"
)
func main() {
var appPath string
switch len(os.Args) {
case 1:
{
appPath, _ = os.Getwd()
}
case 2:
{
appPath = os.Args[1]
}
}
if !filepath.IsAbs(appPath) {
appPath = utils.GetAbsPath(appPath)
}
var appName = filepath.Base(appPath)
utils.MakeFolder(filepath.Join(appPath, "qml"))
var (
rccPath string
qmlGo = filepath.Join(appPath, "rrc.go")
qmlQrc = filepath.Join(appPath, "rrc.qrc")
qmlCpp = filepath.Join(appPath, "rrc.cpp")
)
switch runtime.GOOS {
case "darwin":
{
rccPath = filepath.Join(utils.QT_DARWIN_DIR(), "bin", "rcc")
}
case "linux":
{
if utils.UsePkgConfig() {
rccPath = filepath.Join(strings.TrimSpace(utils.RunCmd(exec.Command("pkg-config", "--variable=host_bins", "Qt5Core"), fmt.Sprintf("find rccPath with pkg-config on %v", runtime.GOOS))), "rcc")
} else {
rccPath = filepath.Join(utils.QT_DIR(), "5.7", "gcc_64", "bin", "rcc")
}
}
case "windows":
{
rccPath = filepath.Join(utils.QT_DIR(), "5.7", "mingw53_32", "bin", "rcc")
}
}
utils.Save(qmlGo, qmlHeader(appName))
var rcc = exec.Command(rccPath, "-project", "-o", qmlQrc)
rcc.Dir = filepath.Join(appPath, "qml")
utils.RunCmd(rcc, fmt.Sprintf("execute rcc.1 on %v", runtime.GOOS))
utils.Save(qmlQrc, strings.Replace(utils.Load(qmlQrc), "<file>./", "<file>qml/", -1))
if utils.Exists(filepath.Join(appPath, "qtquickcontrols2.conf")) {
utils.Save(qmlQrc, strings.Replace(utils.Load(qmlQrc), "<qresource>", "<qresource>\n<file>qtquickcontrols2.conf</file>", -1))
}
rcc = exec.Command(rccPath, "-name", appName, "-o", qmlCpp, qmlQrc)
utils.RunCmd(rcc, fmt.Sprintf("execute rcc.2 on %v", runtime.GOOS))
}
func qmlHeader(appName string) string {
return strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(strings.Replace(`package main
/*
#cgo +build windows,386 LDFLAGS: -L${QT_WINDOWS_DIR} -lQt5Core
#cgo +build !ios,darwin,amd64 LDFLAGS: -F${QT_DARWIN_DIR}/lib -framework QtCore
#cgo +build linux,amd64 LDFLAGS: -Wl,-rpath,${QT_LINUX_DIR} -L${QT_LINUX_DIR} -lQt5Core
#cgo +build android,linux,arm LDFLAGS: -L${QT_DIR}/5.7/android_armv7/lib -lQt5Core
#cgo +build ios,darwin,amd64 LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/${IPHONESIMULATOR_SDK_DIR} -mios-simulator-version-min=7.0 -arch x86_64
#cgo +build ios,darwin,amd64 LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios_iphonesimulator -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype_iphonesimulator -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds_iphonesimulator -lqicns_iphonesimulator -lqico_iphonesimulator -lqtga_iphonesimulator -lqtiff_iphonesimulator -lqwbmp_iphonesimulator -lqwebp_iphonesimulator -lqtharfbuzzng_iphonesimulator -lz -lqtpcre_iphonesimulator -lm -lQt5Core_iphonesimulator -lQt5Widgets_iphonesimulator -lQt5Gui_iphonesimulator -lQt5PlatformSupport_iphonesimulator
#cgo +build ios,darwin,386 LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/${IPHONESIMULATOR_SDK_DIR} -mios-simulator-version-min=7.0 -arch i386
#cgo +build ios,darwin,386 LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios_iphonesimulator -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype_iphonesimulator -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds_iphonesimulator -lqicns_iphonesimulator -lqico_iphonesimulator -lqtga_iphonesimulator -lqtiff_iphonesimulator -lqwbmp_iphonesimulator -lqwebp_iphonesimulator -lqtharfbuzzng_iphonesimulator -lz -lqtpcre_iphonesimulator -lm -lQt5Core_iphonesimulator -lQt5Widgets_iphonesimulator -lQt5Gui_iphonesimulator -lQt5PlatformSupport_iphonesimulator
#cgo +build ios,darwin,arm64 LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${IPHONEOS_SDK_DIR} -miphoneos-version-min=7.0 -arch arm64
#cgo +build ios,darwin,arm64 LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds -lqicns -lqico -lqtga -lqtiff -lqwbmp -lqwebp -lqtharfbuzzng -lz -lqtpcre -lm -lQt5Core -lQt5Widgets -lQt5Gui -lQt5PlatformSupport
#cgo +build ios,darwin,arm LDFLAGS: -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,${XCODE_DIR}/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${IPHONEOS_SDK_DIR} -miphoneos-version-min=7.0 -arch armv7
#cgo +build ios,darwin,arm LDFLAGS: -L${QT_DIR}/5.7/ios/plugins/platforms -lqios -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -L${QT_DIR}/5.7/ios/lib -framework MobileCoreServices -framework CoreFoundation -framework CoreText -framework CoreGraphics -framework OpenGLES -lqtfreetype -framework Security -framework SystemConfiguration -framework CoreBluetooth -L${QT_DIR}/5.7/ios/plugins/imageformats -lqdds -lqicns -lqico -lqtga -lqtiff -lqwbmp -lqwebp -lqtharfbuzzng -lz -lqtpcre -lm -lQt5Core -lQt5Widgets -lQt5Gui -lQt5PlatformSupport
#cgo +build sailfish_emulator,linux,386 LDFLAGS: -Wl,-rpath,/usr/share/harbour-${APPNAME}/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-i486/usr/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-i486/lib -L/srv/mer/targets/SailfishOS-i486/usr/lib -L/srv/mer/targets/SailfishOS-i486/lib -lQt5Core
#cgo +build sailfish,linux,arm LDFLAGS: -Wl,-rpath,/usr/share/harbour-${APPNAME}/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-armv7hl/usr/lib -Wl,-rpath-link,/srv/mer/targets/SailfishOS-armv7hl/lib -L/srv/mer/targets/SailfishOS-armv7hl/usr/lib -L/srv/mer/targets/SailfishOS-armv7hl/lib -lQt5Core
#cgo +build rpi1,linux,arm LDFLAGS: -Wl,-rpath-link,${RPI1_SYSROOT_DIR}/opt/vc/lib -Wl,-rpath-link,${RPI1_SYSROOT_DIR}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${RPI1_SYSROOT_DIR}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${QT_DIR}/5.7/rpi1/lib -mfloat-abi=hard --sysroot=${RPI1_SYSROOT_DIR} -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -L${RPI1_SYSROOT_DIR}/opt/vc/lib -L${QT_DIR}/5.7/rpi1/lib -lQt5Core
#cgo +build rpi2,linux,arm LDFLAGS: -Wl,-rpath-link,${RPI2_SYSROOT_DIR}/opt/vc/lib -Wl,-rpath-link,${RPI2_SYSROOT_DIR}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${RPI2_SYSROOT_DIR}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${QT_DIR}/5.7/rpi2/lib -mfloat-abi=hard --sysroot=${RPI2_SYSROOT_DIR} -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -L${RPI2_SYSROOT_DIR}/opt/vc/lib -L${QT_DIR}/5.7/rpi2/lib -lQt5Core
#cgo +build rpi3,linux,arm LDFLAGS: -Wl,-rpath-link,${RPI3_SYSROOT_DIR}/opt/vc/lib -Wl,-rpath-link,${RPI3_SYSROOT_DIR}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${RPI3_SYSROOT_DIR}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${QT_DIR}/5.7/rpi3/lib -mfloat-abi=hard --sysroot=${RPI3_SYSROOT_DIR} -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -L${RPI3_SYSROOT_DIR}/opt/vc/lib -L${QT_DIR}/5.7/rpi3/lib -lQt5Core
*/
import "C"`,
"${QT_WINDOWS_DIR}", func() string {
if runtime.GOOS == "linux" {
return "/usr/lib/mxe/usr/i686-w64-mingw32.shared/qt5/lib"
}
return "${QT_DIR}/5.7/mingw53_32/lib"
}(), -1),
"${QT_DARWIN_DIR}", utils.QT_DARWIN_DIR(), -1),
"${QT_LINUX_DIR}", func() string {
if utils.UsePkgConfig() {
return strings.TrimSpace(utils.RunCmd(exec.Command("pkg-config", "--variable=libdir", "Qt5Core"), fmt.Sprintf("find linux pkg-config lib dir on %v", runtime.GOOS)))
}
return "${QT_DIR}/5.7/gcc_64/lib"
}(), -1),
"${QT_DIR}", utils.QT_DIR(), -1),
"${RPI1_SYSROOT_DIR}", utils.RPI1_SYSROOT_DIR(), -1),
"${RPI2_SYSROOT_DIR}", utils.RPI2_SYSROOT_DIR(), -1),
"${RPI3_SYSROOT_DIR}", utils.RPI3_SYSROOT_DIR(), -1),
"${XCODE_DIR}", utils.XCODE_DIR(), -1),
"${IPHONEOS_SDK_DIR}", utils.IPHONEOS_SDK_DIR(), -1),
"${IPHONESIMULATOR_SDK_DIR}", utils.IPHONESIMULATOR_SDK_DIR(), -1),
"${APPNAME}", appName, -1),
"\\", "/", -1)
}

View file

@ -1,7 +1,6 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
@ -11,38 +10,42 @@ import (
"github.com/therecipe/qt/internal/utils"
)
func main() {
var (
buildTarget = func() string {
if len(os.Args) > 1 {
return os.Args[1]
}
return "desktop"
}()
)
utils.Log.Infof("running setup/check.go %v", buildTarget)
func check(buildTarget string) {
utils.Log.Infof("running setup/check %v", buildTarget)
switch buildTarget {
case "all":
{
for _, target := range []string{"desktop", "android", "ios", "ios-simulator",
"sailfish", "sailfish-emulator", "rpi1", "rpi2", "rpi3", "windows",
"linux-docker", "windows-docker", "android-docker"} {
utils.RunCmd(exec.Command(utils.GoQtPkgPath(func() string {
if runtime.GOOS == "windows" {
return "setup.bat"
}
return "setup.sh"
}()), target), fmt.Sprintf("run setup %v", target))
}
os.Exit(0)
}
case "desktop", "android", "ios", "ios-simulator",
"sailfish", "sailfish-emulator", "rpi1", "rpi2", "rpi3", "windows",
"sailfish", "sailfish-emulator", "rpi1", "rpi2", "rpi3", "windows", "darwin", "linux",
"linux-docker", "windows-docker", "android-docker":
{
var buildDocker = strings.HasSuffix(buildTarget, "-docker")
switch buildTarget {
case "windows":
{
if runtime.GOOS == "windows" && !buildDocker {
} else if runtime.GOOS == "linux" || buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v", buildTarget, runtime.GOOS)
}
}
case "darwin", "ios", "ios-simulator":
{
if runtime.GOOS == "darwin" && !buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v (not even with docker)", buildTarget, runtime.GOOS)
}
}
case "linux":
{
if runtime.GOOS == "linux" && !buildDocker {
} else if buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v", buildTarget, runtime.GOOS)
}
}
}
}
default:

View file

@ -8,8 +8,8 @@ import (
"github.com/therecipe/qt/internal/utils"
)
func main() {
utils.Log.Info("running setup/generate.go")
func generate() {
utils.Log.Info("running setup/generate")
if testFile := utils.GoQtPkgPath("core", "cgo_desktop_darwin_amd64.go"); utils.Exists(testFile) && strings.Contains(utils.Load(testFile), utils.QT_DIR()) {
if utils.QT_STUB() &&

View file

@ -13,23 +13,16 @@ import (
"github.com/therecipe/qt/internal/utils"
)
func main() {
var (
buildTarget = func() string {
if len(os.Args) > 1 {
return os.Args[1]
}
return "desktop"
}()
env, tagFlags = getEnvAndTagflags(buildTarget)
)
utils.Log.Infof("running setup/install.go %v", buildTarget)
func install(buildTarget string) {
utils.Log.Infof("running setup/install %v", buildTarget)
if strings.HasSuffix(buildTarget, "-docker") {
utils.Log.Debugf("build target is %v -> skipping installation", buildTarget)
return
}
var env, tagFlags = getEnvAndTagflags(buildTarget)
if buildTarget != "desktop" || (runtime.GOOS == "windows" && buildTarget == "desktop") {
if buildTarget == "sailfish" {
var _, err = ioutil.ReadDir(filepath.Join(runtime.GOROOT(), "bin", "linux_386"))
@ -115,6 +108,47 @@ func installPkgCmd(buildTarget, tagFlags, pkg string, env map[string]string) *ex
}
func getEnvAndTagflags(buildTarget string) (env map[string]string, tagFlags string) {
switch buildTarget {
case "desktop", "android", "ios", "ios-simulator",
"sailfish", "sailfish-emulator", "rpi1", "rpi2", "rpi3", "windows", "darwin", "linux",
"linux-docker", "windows-docker", "android-docker":
{
var buildDocker = strings.HasSuffix(buildTarget, "-docker")
switch buildTarget {
case "windows":
{
if runtime.GOOS == "windows" && !buildDocker {
} else if runtime.GOOS == "linux" || buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v", buildTarget, runtime.GOOS)
}
}
case "darwin", "ios", "ios-simulator":
{
if runtime.GOOS == "darwin" && !buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v (not even with docker)", buildTarget, runtime.GOOS)
}
}
case "linux":
{
if runtime.GOOS == "linux" && !buildDocker {
} else if buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v", buildTarget, runtime.GOOS)
}
}
}
}
default:
{
utils.Log.Panicf("failed to recognize build target %v", buildTarget)
}
}
switch buildTarget {
case
"android":

43
cmd/qtsetup/prep.go Executable file
View file

@ -0,0 +1,43 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"github.com/therecipe/qt/internal/utils"
)
func prep() {
utils.Log.Info("running setup/prep")
utils.RunCmd(exec.Command("go", "get", "golang.org/x/crypto/ssh"), "install ssh pkg")
utils.RunCmd(exec.Command("go", "get", "github.com/emirpasic/gods/lists/arraylist"), "install arraylist pkg")
utils.RunCmd(exec.Command("go", "get", "github.com/Sirupsen/logrus"), "install logrus pkg")
utils.RunCmd(exec.Command("go", "install", "github.com/therecipe/qt/cmd/..."), "install cmd pkgs")
for _, app := range []string{"qtdeploy", "qtmoc", "qtrcc", "qtminimal"} {
switch runtime.GOOS {
case "darwin", "linux":
{
if os.Geteuid() == 0 || runtime.GOOS == "darwin" {
utils.RemoveAll(fmt.Sprintf("/usr/local/bin/%v", app))
var err = os.Symlink(filepath.Join(utils.MustGoPath(), "bin", app), fmt.Sprintf("/usr/local/bin/%v", app))
if err != nil {
utils.Log.WithError(err).Warnf("failed to create %v symlink in your PATH (/usr/local/bin) -> use %v instead", app, filepath.Join(utils.MustGoPath(), "bin", app))
}
} else {
utils.Log.Warnf("(not root) failed to create %v symlink in your PATH (/usr/local/bin) -> use %v instead", app, filepath.Join(utils.MustGoPath(), "bin", app))
}
}
case "windows":
{
utils.RemoveAll(filepath.Join(runtime.GOROOT(), "bin", fmt.Sprintf("%v.exe", app)))
utils.RunCmdOptional(exec.Command("cmd", "/C", "mklink", "/H", filepath.Join(runtime.GOROOT(), "bin", fmt.Sprintf("%v.exe", app)), filepath.Join(utils.MustGoPath(), "bin", fmt.Sprintf("%v.exe", app))), fmt.Sprintf("create %v symlink in your PATH (GOROOT/bin) -> use %v instead", app, filepath.Join(utils.MustGoPath(), "bin", fmt.Sprintf("%v.exe", app))))
}
}
}
}

110
cmd/qtsetup/setup.go Executable file
View file

@ -0,0 +1,110 @@
package main
import (
"os"
"runtime"
"strings"
"github.com/therecipe/qt/internal/utils"
)
func main() {
var (
buildMode = "full"
buildTarget = "desktop"
)
switch len(os.Args) {
case 2:
{
switch os.Args[1] {
case "desktop", "android", "ios", "ios-simulator",
"sailfish", "sailfish-emulator", "rpi1", "rpi2", "rpi3", "windows", "darwin", "linux",
"linux-docker", "windows-docker", "android-docker":
{
buildTarget = os.Args[1]
var buildDocker = strings.HasSuffix(buildTarget, "-docker")
switch buildTarget {
case "windows":
{
if runtime.GOOS == "windows" && !buildDocker {
} else if runtime.GOOS == "linux" || buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v", buildTarget, runtime.GOOS)
}
}
case "darwin", "ios", "ios-simulator":
{
if runtime.GOOS == "darwin" && !buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v (not even with docker)", buildTarget, runtime.GOOS)
}
}
case "linux":
{
if runtime.GOOS == "linux" && !buildDocker {
} else if buildDocker {
} else {
utils.Log.Fatalf("%v is currently not supported as a deploy target on %v", buildTarget, runtime.GOOS)
}
}
}
}
case "prep", "check", "generate", "install", "test", "full":
{
buildMode = os.Args[1]
}
default:
{
utils.Log.Fatalln("usage:", "qtsetup", "[ prep | check | generate | install | test | full ]", "[ desktop | android | ios | ios-simulator | sailfish | sailfish-emulator | rpi1 | rpi2 | rpi3 | windows | linux-docker | windows-docker | android-docker ]")
}
}
}
case 3:
{
buildMode = os.Args[1]
buildTarget = os.Args[2]
}
}
switch buildMode {
case "full":
{
prep()
check(buildTarget)
generate()
install(buildTarget)
test(buildTarget)
}
case "prep":
{
prep()
}
case "check":
{
check(buildTarget)
}
case "generate":
{
generate()
}
case "install":
{
install(buildTarget)
}
case "test":
{
test(buildTarget)
}
}
}

45
cmd/qtsetup/test.go Executable file
View file

@ -0,0 +1,45 @@
package main
import (
"fmt"
"os/exec"
"path/filepath"
"strings"
"github.com/therecipe/qt/internal/utils"
)
func test(buildTarget string) {
utils.Log.Infof("running setup/test %v (~10min)", buildTarget)
//TODO: cleanup
for _, example := range []string{filepath.Join("widgets", "line_edits"), filepath.Join("widgets", "video_player"), filepath.Join("widgets", "graphicsscene"), filepath.Join("widgets", "dropsite"), filepath.Join("widgets", "table"),
filepath.Join("quick", "bridge"), filepath.Join("quick", "bridge2"), filepath.Join("quick", "calc"), filepath.Join("quick", "dialog"), filepath.Join("quick", "sailfish"), filepath.Join("quick", "translate"), filepath.Join("quick", "view"),
filepath.Join("qml", "application"), filepath.Join("qml", "material"), filepath.Join("qml", "prop"),
filepath.Join("uitools", "calculator")} {
if (buildTarget == "sailfish" || buildTarget == "sailfish-emulator") && (!strings.Contains(example, "quick") || (example == filepath.Join("quick", "bridge") || example == filepath.Join("quick", "dialog"))) {
} else if !(buildTarget == "sailfish" || buildTarget == "sailfish-emulator") && example == filepath.Join("quick", "sailfish") {
} else {
utils.Log.Infoln("testing", example)
utils.RunCmd(exec.Command(filepath.Join(utils.MustGoPath(), "bin", "qtdeploy"),
"test",
strings.TrimSuffix(buildTarget, "-docker"),
filepath.Join(utils.GoQtPkgPath("internal", "examples"), example),
func() string {
if strings.HasSuffix(buildTarget, "-docker") {
return "docker"
}
return ""
}()),
fmt.Sprintf("test.%v", example))
}
}
}

View file

@ -28,14 +28,10 @@ ENV PATH $PATH:/usr/local/go/bin
ENV GOPATH $HOME/work
RUN go get github.com/therecipe/qt
RUN go get golang.org/x/crypto/ssh
RUN go get github.com/emirpasic/gods/lists/arraylist
RUN go get github.com/Sirupsen/logrus
RUN go build -o $HOME/work/bin/qtdeploy $GOPATH/src/github.com/therecipe/qt/internal/deploy/deploy.go && ln -s $HOME/work/bin/qtdeploy /usr/local/bin/qtdeploy
RUN go build -o $HOME/work/bin/qtmoc $GOPATH/src/github.com/therecipe/qt/internal/moc/moc.go && ln -s $HOME/work/bin/qtmoc /usr/local/bin/qtmoc
RUN go get github.com/therecipe/qt/cmd/qtsetup
ENV QT_DIR /opt/Qt5.7.0
RUN go run $GOPATH/src/github.com/therecipe/qt/internal/setup/check.go
RUN go run $GOPATH/src/github.com/therecipe/qt/internal/setup/generate.go
RUN $GOPATH/bin/qtsetup prep
RUN $GOPATH/bin/qtsetup check
RUN $GOPATH/bin/qtsetup generate

View file

@ -13,5 +13,5 @@ ENV NDK android-ndk-r12b-linux-x86_64.zip
RUN curl -sL --retry 10 --retry-delay 10 -o /tmp/$NDK https://dl.google.com/android/repository/$NDK && unzip -qq /tmp/$NDK -d $HOME && rm -f /tmp/$NDK
RUN go run $GOPATH/src/github.com/therecipe/qt/internal/setup/check.go android
RUN go run $GOPATH/src/github.com/therecipe/qt/internal/setup/generate.go
RUN $GOPATH/bin/qtsetup check android
RUN $GOPATH/bin/qtsetup generate

View file

@ -4,5 +4,5 @@ FROM therecipe/qt:base
RUN echo "deb http://pkg.mxe.cc/repos/apt/debian wheezy main" | tee --append /etc/apt/sources.list.d/mxeapt.list > /dev/null && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D43A795B73B16ABE9643FE1AFD8FFF16DB45C6AB && apt-get -qq update && apt-get -y -qq install mxe-i686-w64-mingw32.shared-qt3d mxe-i686-w64-mingw32.shared-qtactiveqt mxe-i686-w64-mingw32.shared-qtbase mxe-i686-w64-mingw32.shared-qtcanvas3d mxe-i686-w64-mingw32.shared-qtcharts mxe-i686-w64-mingw32.shared-qtconnectivity mxe-i686-w64-mingw32.shared-qtdatavis3d mxe-i686-w64-mingw32.shared-qtdeclarative mxe-i686-w64-mingw32.shared-qtdeclarative-render2d mxe-i686-w64-mingw32.shared-qtgamepad mxe-i686-w64-mingw32.shared-qtgraphicaleffects mxe-i686-w64-mingw32.shared-qtimageformats mxe-i686-w64-mingw32.shared-qtlocation mxe-i686-w64-mingw32.shared-qtmultimedia mxe-i686-w64-mingw32.shared-qtofficeopenxml mxe-i686-w64-mingw32.shared-qtpurchasing mxe-i686-w64-mingw32.shared-qtquickcontrols mxe-i686-w64-mingw32.shared-qtquickcontrols2 mxe-i686-w64-mingw32.shared-qtscript mxe-i686-w64-mingw32.shared-qtscxml mxe-i686-w64-mingw32.shared-qtsensors mxe-i686-w64-mingw32.shared-qtserialbus mxe-i686-w64-mingw32.shared-qtserialport mxe-i686-w64-mingw32.shared-qtservice mxe-i686-w64-mingw32.shared-qtsvg mxe-i686-w64-mingw32.shared-qtsystems mxe-i686-w64-mingw32.shared-qttools mxe-i686-w64-mingw32.shared-qttranslations mxe-i686-w64-mingw32.shared-qtvirtualkeyboard mxe-i686-w64-mingw32.shared-qtwebchannel mxe-i686-w64-mingw32.shared-qtwebkit mxe-i686-w64-mingw32.shared-qtwebsockets mxe-i686-w64-mingw32.shared-qtwinextras mxe-i686-w64-mingw32.shared-qtxlsxwriter mxe-i686-w64-mingw32.shared-qtxmlpatterns && apt-get -qq clean
RUN go run $GOPATH/src/github.com/therecipe/qt/internal/setup/check.go windows
RUN go run $GOPATH/src/github.com/therecipe/qt/internal/setup/generate.go
RUN $GOPATH/bin/qtsetup check windows
RUN $GOPATH/bin/qtsetup generate

View file

@ -99,11 +99,11 @@ func initQmlContext(quickWidget *quick.QQuickWidget) {
type QmlBridge struct {
core.QObject
_ func(source, action, data string) `signal:sendToQml`
_ func(source, action, data string) `slot:sendToGo`
_ func(source, action, data string) `signal:"sendToQml"`
_ func(source, action, data string) `slot:"sendToGo"`
_ func(object *core.QObject) `slot:registerToGo`
_ func(objectName string) `slot:deregisterToGo`
_ func(object *core.QObject) `slot:"registerToGo"`
_ func(objectName string) `slot:"deregisterToGo"`
}
func initQmlBridge(quickWidget *quick.QQuickWidget) {

View file

@ -16,8 +16,8 @@ import (
type QmlBridge struct {
core.QObject
_ func(data string) `signal:sendToQml`
_ func(data string) string `slot:sendToGo`
_ func(data string) `signal:"sendToQml"`
_ func(data string) string `slot:"sendToGo"`
}
func main() {

View file

@ -11,10 +11,11 @@ import (
"github.com/therecipe/qt/widgets"
)
//go:generate qtmoc
type DropSiteWindow struct {
widgets.QWidget
_ func(mimeData *core.QMimeData) `slot:updateFormatsTable`
_ func(mimeData *core.QMimeData) `slot:"updateFormatsTable"`
}
func main() {
@ -117,7 +118,7 @@ func main() {
type DropArea struct {
widgets.QLabel
_ func(mimeData *core.QMimeData) `signal:changed`
_ func(mimeData *core.QMimeData) `signal:"changed"`
}
func initDropArea() *DropArea {

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 187 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -1,104 +0,0 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/therecipe/qt/internal/utils"
)
func main() {
var (
buildTarget = func() string {
if len(os.Args) > 1 {
return os.Args[1]
}
return "desktop"
}()
ending = func() string {
if runtime.GOOS == "windows" {
return ".exe"
}
return ""
}()
)
utils.Log.Infof("running setup/test.go %v", buildTarget)
utils.MakeFolder(filepath.Join(utils.MustGoPath(), "bin"))
utils.RemoveAll(filepath.Join(utils.MustGoPath(), "bin", fmt.Sprintf("qtdeploy%v", ending)))
utils.RemoveAll(filepath.Join(utils.MustGoPath(), "bin", fmt.Sprintf("qtmoc%v", ending)))
utils.RunCmd(exec.Command("go", "build", "-o", filepath.Join(utils.MustGoPath(), "bin", fmt.Sprintf("qtdeploy%v", ending)), utils.GoQtPkgPath("internal", "deploy", "deploy.go")), "qtdeploy")
utils.RunCmd(exec.Command("go", "build", "-o", filepath.Join(utils.MustGoPath(), "bin", fmt.Sprintf("qtmoc%v", ending)), utils.GoQtPkgPath("internal", "moc", "moc.go")), "qtmoc")
switch runtime.GOOS {
case "darwin", "linux":
{
if os.Geteuid() == 0 || runtime.GOOS == "darwin" {
utils.RemoveAll("/usr/local/bin/qtdeploy")
utils.RemoveAll("/usr/local/bin/qtmoc")
var err = os.Symlink(filepath.Join(utils.MustGoPath(), "bin/qtdeploy"), "/usr/local/bin/qtdeploy")
if err != nil {
utils.Log.WithError(err).Errorf("failed to create qtdeploy symlink in your PATH -> use %v instead", filepath.Join(utils.MustGoPath(), "bin/qtdeploy"))
}
err = os.Symlink(filepath.Join(utils.MustGoPath(), "bin/qtmoc"), "/usr/local/bin/qtmoc")
if err != nil {
utils.Log.WithError(err).Errorf("failed to create qtmoc symlink in your PATH -> use %v instead", filepath.Join(utils.MustGoPath(), "bin/qtmoc"))
}
} else {
utils.Log.Errorf("failed to create qtdeploy and qtmoc symlinks in your PATH (not root) -> use %v and %v instead", filepath.Join(utils.MustGoPath(), "bin/qtdeploy"), filepath.Join(utils.MustGoPath(), "bin/qtmoc"))
}
}
case "windows":
{
utils.RemoveAll(filepath.Join(runtime.GOROOT(), "bin\\qtdeploy.exe"))
utils.RemoveAll(filepath.Join(runtime.GOROOT(), "bin\\qtmoc.exe"))
utils.RunCmdOptional(exec.Command("cmd", "/C", "mklink", "/H", filepath.Join(runtime.GOROOT(), "bin\\qtdeploy.exe"), filepath.Join(utils.MustGoPath(), "bin\\qtdeploy.exe")), "symlink.qtdeploy")
utils.RunCmdOptional(exec.Command("cmd", "/C", "mklink", "/H", filepath.Join(runtime.GOROOT(), "bin\\qtmoc.exe"), filepath.Join(utils.MustGoPath(), "bin\\qtmoc.exe")), "symlink.qtmoc")
}
}
utils.Log.Info("starting to test examples (~10min)")
//TODO: cleanup
for _, example := range []string{filepath.Join("widgets", "line_edits"), filepath.Join("widgets", "video_player"), filepath.Join("widgets", "graphicsscene"), filepath.Join("widgets", "dropsite"), filepath.Join("widgets", "table"),
filepath.Join("quick", "bridge"), filepath.Join("quick", "bridge2"), filepath.Join("quick", "calc"), filepath.Join("quick", "dialog"), filepath.Join("quick", "sailfish"), filepath.Join("quick", "translate"), filepath.Join("quick", "view"),
filepath.Join("qml", "application"), filepath.Join("qml", "prop"),
filepath.Join("uitools", "calculator")} {
if (buildTarget == "sailfish" || buildTarget == "sailfish-emulator") && (!strings.Contains(example, "quick") || (example == filepath.Join("quick", "bridge") || example == filepath.Join("quick", "dialog"))) {
} else if !(buildTarget == "sailfish" || buildTarget == "sailfish-emulator") && example == filepath.Join("quick", "sailfish") {
} else {
utils.Log.Infoln("testing", example)
utils.RunCmd(exec.Command(filepath.Join(utils.MustGoPath(), "bin", "qtdeploy"),
"test",
strings.TrimSuffix(buildTarget, "-docker"),
filepath.Join(utils.GoQtPkgPath("internal", "examples"), example),
func() string {
if strings.HasSuffix(buildTarget, "-docker") {
return "docker"
}
return ""
}()),
fmt.Sprintf("test.%v", example))
}
}
}

2
qt.go
View file

@ -9,7 +9,7 @@ import (
"strings"
"sync"
_ "github.com/therecipe/qt/internal/android"
_ "github.com/therecipe/qt/internal/android/cgo"
)
var (

View file

@ -1,13 +0,0 @@
go get golang.org/x/crypto/ssh
@ if %errorlevel% neq 0 exit /b %errorlevel%
go get github.com/emirpasic/gods/lists/arraylist
@ if %errorlevel% neq 0 exit /b %errorlevel%
go get github.com/Sirupsen/logrus
@ if %errorlevel% neq 0 exit /b %errorlevel%
go run %GOPATH%/src/github.com/therecipe/qt/internal/setup/check.go %*
@ if %errorlevel% neq 0 exit /b %errorlevel%
go run %GOPATH%/src/github.com/therecipe/qt/internal/setup/generate.go %*
@ if %errorlevel% neq 0 exit /b %errorlevel%
go run %GOPATH%/src/github.com/therecipe/qt/internal/setup/install.go %*
@ if %errorlevel% neq 0 exit /b %errorlevel%
go run %GOPATH%/src/github.com/therecipe/qt/internal/setup/test.go %*

View file

@ -1,10 +0,0 @@
#!/bin/bash
set -ev
go get golang.org/x/crypto/ssh
go get github.com/emirpasic/gods/lists/arraylist
go get github.com/Sirupsen/logrus
go run $GOPATH/src/github.com/therecipe/qt/internal/setup/check.go "$@"
go run $GOPATH/src/github.com/therecipe/qt/internal/setup/generate.go "$@"
go run $GOPATH/src/github.com/therecipe/qt/internal/setup/install.go "$@"
go run $GOPATH/src/github.com/therecipe/qt/internal/setup/test.go "$@"