mirror of
https://github.com/bluszcz/cutego.git
synced 2024-09-28 13:15:17 +03:00
fix for msys2 setup + fix static linux build issues + various minor fixes
This commit is contained in:
parent
20875b0327
commit
18d257176d
9 changed files with 59 additions and 24 deletions
|
@ -69,39 +69,39 @@ func LoadModule(m string) *Module {
|
|||
var err error
|
||||
switch {
|
||||
case utils.QT_WEBKIT() && m == "WebKit":
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/5.8.0"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/5.8.0", "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_MXE():
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.12.0")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.12.0"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_HOMEBREW():
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.12.0")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.12.0"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_MACPORTS(), utils.QT_NIX():
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.11.1")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.11.1"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_MSYS2():
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.12.0")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.12.0"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_UBPORTS_VERSION() == "xenial":
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.9.0")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.9.0"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_SAILFISH():
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.6.3")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.6.3"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_RPI():
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.7.0")), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API("5.7.0"), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
|
||||
case utils.QT_PKG_CONFIG():
|
||||
if utils.QT_API("") != "" {
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API(utils.QT_VERSION())), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API(utils.QT_VERSION()), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
} else {
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.QT_DOC_DIR(), fmt.Sprintf("qt%v", strings.ToLower(m)), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
}
|
||||
|
||||
default:
|
||||
if utils.QT_API("") != "" {
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API(utils.QT_VERSION())), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+utils.QT_API(utils.QT_VERSION()), "get doc dir")), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
|
||||
} else {
|
||||
path := filepath.Join(utils.QT_DIR(), "Docs", fmt.Sprintf("Qt-%v", utils.QT_VERSION_MAJOR()), fmt.Sprintf("qt%v", strings.ToLower(m)), fmt.Sprintf("qt%v.index", strings.ToLower(m)))
|
||||
if !utils.ExistsDir(filepath.Join(utils.QT_DIR(), "Docs", fmt.Sprintf("Qt-%v", utils.QT_VERSION_MAJOR()))) {
|
||||
|
|
|
@ -350,7 +350,7 @@ func createMakefile(module, path, target string, mode int) {
|
|||
utils.Save(pPath, "// +build windows\r\n"+content)
|
||||
}
|
||||
}
|
||||
if mode == MOC || mode == RCC || !(utils.QT_MXE_STATIC() || utils.QT_MSYS2_STATIC()) || (!strings.HasPrefix(module, "Q") && strings.Contains(pPath, "_qml_")) {
|
||||
if mode == MOC || mode == RCC || !(utils.QT_MXE_STATIC() || utils.QT_MSYS2_STATIC()) || (module != "Qml" && strings.Contains(pPath, "_qml_")) {
|
||||
utils.RemoveAll(pPath)
|
||||
}
|
||||
}
|
||||
|
@ -358,6 +358,17 @@ func createMakefile(module, path, target string, mode int) {
|
|||
utils.RemoveAll(filepath.Join(path, n))
|
||||
}
|
||||
case "linux":
|
||||
for _, suf := range []string{"_plugin_import", "_qml_plugin_import"} {
|
||||
pPath := filepath.Join(path, fmt.Sprintf("%v%v.cpp", filepath.Base(path), suf))
|
||||
if (utils.QT_STATIC()) && utils.ExistsFile(pPath) {
|
||||
if content := utils.Load(pPath); !strings.Contains(content, "+build linux") {
|
||||
utils.Save(pPath, "// +build linux\r\n"+content)
|
||||
}
|
||||
}
|
||||
if mode == MOC || mode == RCC || !utils.QT_STATIC() || (module != "Qml" && strings.Contains(pPath, "_qml_")) {
|
||||
utils.RemoveAll(pPath)
|
||||
}
|
||||
}
|
||||
case "ios", "ios-simulator":
|
||||
for _, suf := range []string{"_plugin_import", "_qml_plugin_import"} {
|
||||
pPath := filepath.Join(path, fmt.Sprintf("%v%v.cpp", filepath.Base(path), suf))
|
||||
|
@ -368,7 +379,7 @@ func createMakefile(module, path, target string, mode int) {
|
|||
}
|
||||
}
|
||||
*/
|
||||
if module != "build_static" /*TODO when shared builds are available: utils.QT_VERSION_MAJOR() != "5.9"*/ || mode == MOC || mode == RCC {
|
||||
if module != "build_static" || mode == MOC || mode == RCC /*TODO when shared builds are available: utils.QT_VERSION_MAJOR() != "5.9"*/ {
|
||||
utils.RemoveAll(pPath)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func GenModule(m, target string, mode int) {
|
|||
}
|
||||
|
||||
if m == "AndroidExtras" {
|
||||
utils.Save(utils.GoQtPkgPath(strings.ToLower(m), "utils-androidextras_android.go"), utils.Load(filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal"), "get files dir")), "/binding/files/utils-androidextras_android.go")))
|
||||
utils.Save(utils.GoQtPkgPath(strings.ToLower(m), "utils-androidextras_android.go"), utils.Load(filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal", "get files dir")), "/binding/files/utils-androidextras_android.go")))
|
||||
}
|
||||
|
||||
if !UseStub(false, "Qt"+m, mode) {
|
||||
|
|
|
@ -44,10 +44,10 @@ func ParseFlags() bool {
|
|||
}
|
||||
|
||||
if api := utils.QT_API(""); api != "" {
|
||||
if utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+api), "get doc dir") == "" {
|
||||
if utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/binding/files/docs/"+api, "get doc dir") == "" {
|
||||
utils.Log.Errorf("invalid api version provided: '%v'", api)
|
||||
fmt.Println("valid api versions are:")
|
||||
if o := utils.RunCmdOptional(utils.GoList("'{{ join .Imports \"|\" }}'", "github.com/therecipe/qt/internal/binding/files/docs"), "get doc dir"); o != "" {
|
||||
if o := utils.GoListOptional("'{{ join .Imports \"|\" }}'", "github.com/therecipe/qt/internal/binding/files/docs", "get doc dir"); o != "" {
|
||||
for _, v := range strings.Split(o, "|") {
|
||||
fmt.Println(strings.TrimPrefix(strings.TrimSpace(strings.Replace(v, "'", "", -1)), "github.com/therecipe/qt/internal/binding/files/docs/"))
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ func BuildEnv(target, name, depPath string) (map[string]string, []string, []stri
|
|||
}
|
||||
}
|
||||
|
||||
if target == "linux" {
|
||||
if target == "linux" && !utils.QT_STATIC() {
|
||||
env["CGO_LDFLAGS"] = "-Wl,-rpath,$ORIGIN/lib -Wl,--disable-new-dtags"
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,11 @@ func Check(target string, docker, vagrant bool) {
|
|||
{"GOROOT", runtime.GOROOT()},
|
||||
{"GOPATH", utils.MustGoPath()},
|
||||
{"GOBIN", utils.GOBIN()},
|
||||
{"GOMOD", utils.GOMOD("")},
|
||||
{"QT_HASH", hash},
|
||||
{"QT_API", utils.QT_API("")},
|
||||
{"QT_VERSION", utils.QT_VERSION()},
|
||||
{"QT_VERSION_MAJOR", utils.QT_VERSION_MAJOR()},
|
||||
//{"QT_VERSION_MAJOR", utils.QT_VERSION_MAJOR()},
|
||||
{"QT_DIR", utils.QT_DIR()},
|
||||
{"QT_STUB", fmt.Sprint(utils.QT_STUB())},
|
||||
{"QT_DEBUG", fmt.Sprint(utils.QT_DEBUG())},
|
||||
|
@ -92,6 +93,7 @@ func Check(target string, docker, vagrant bool) {
|
|||
case "windows":
|
||||
if runtime.GOOS == target {
|
||||
vars = append(vars, [][]string{
|
||||
{"QT_DEBUG_CONSOLE", fmt.Sprint(utils.QT_DEBUG_CONSOLE())},
|
||||
{"QT_MSYS2", fmt.Sprint(utils.QT_MSYS2())},
|
||||
}...)
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ func Test(target string, docker, vagrant bool, vagrantsystem string) {
|
|||
|
||||
example := filepath.Join(cat, example)
|
||||
|
||||
path := filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/examples"), "get doc dir")), example)
|
||||
path := filepath.Join(strings.TrimSpace(utils.GoListOptional("{{.Dir}}", "github.com/therecipe/qt/internal/examples", "get doc dir")), example)
|
||||
utils.Log.Infof("testing %v", example)
|
||||
deploy.Deploy(
|
||||
mode,
|
||||
|
|
|
@ -10,7 +10,7 @@ RUN apt-get -qq update && apt-get --no-install-recommends -qq -y install libfont
|
|||
RUN apt-get -qq update && apt-get --no-install-recommends -qq -y install libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxkbcommon-dev
|
||||
|
||||
RUN git clone -q --depth 1 -b 5.12 --recursive https://code.qt.io/qt/qt5.git /opt/qt5
|
||||
RUN cd /opt/qt5 && ./configure -prefix /opt/Qt/5.12.0/gcc_64 -confirm-license -opensource -static -qt-zlib -qt-libpng -qt-libjpeg -xcb -dbus-runtime -openssl-runtime -opengl -optimize-size -skip qtwebengine -skip qtfeedback -nomake tests -nomake examples && make && make install
|
||||
RUN cd /opt/qt5 && ./configure -prefix /opt/Qt/5.12.0/gcc_64 -confirm-license -opensource -static -qt-zlib -qt-libpng -qt-libjpeg -qpa xcb -dbus-runtime -openssl-runtime -opengl -optimize-size -skip qtwebengine -skip qtfeedback -nomake tests -nomake examples && make && make install
|
||||
|
||||
|
||||
FROM ubuntu:16.04
|
||||
|
|
|
@ -272,16 +272,20 @@ func GOMOD(path string) string {
|
|||
}
|
||||
|
||||
var (
|
||||
useGOMOD bool
|
||||
useGOMOD int
|
||||
useGOMODMutex = new(sync.Mutex)
|
||||
)
|
||||
|
||||
func UseGOMOD(path string) (r bool) {
|
||||
useGOMODMutex.Lock()
|
||||
if !useGOMOD && len(GOMOD(path)) != 0 {
|
||||
useGOMOD = true
|
||||
if useGOMOD == 0 {
|
||||
if len(GOMOD(path)) != 0 {
|
||||
useGOMOD = 1
|
||||
} else {
|
||||
useGOMOD = -1
|
||||
}
|
||||
}
|
||||
r = useGOMOD
|
||||
r = useGOMOD == 1
|
||||
useGOMODMutex.Unlock()
|
||||
return
|
||||
}
|
||||
|
@ -306,6 +310,21 @@ func GoList(args ...string) *exec.Cmd {
|
|||
return cmd
|
||||
}
|
||||
|
||||
var (
|
||||
goListCache = make(map[string]string)
|
||||
goListCacheMutex = new(sync.Mutex)
|
||||
)
|
||||
|
||||
func GoListOptional(args ...string) (r string) {
|
||||
goListCacheMutex.Lock()
|
||||
if _, ok := goListCache[strings.Join(args, "|")]; !ok {
|
||||
goListCache[strings.Join(args, "|")] = RunCmdOptional(GoList(args[:2]...), args[2])
|
||||
}
|
||||
r = goListCache[strings.Join(args, "|")]
|
||||
goListCacheMutex.Unlock()
|
||||
return r
|
||||
}
|
||||
|
||||
func QT_STATIC() bool {
|
||||
return os.Getenv("QT_STATIC") == "true"
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package utils
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -26,7 +27,9 @@ func GOBIN() string {
|
|||
func MustGoPath() string {
|
||||
mustGoPathMutex.Lock()
|
||||
if len(mustGoPath) == 0 {
|
||||
mustGoPath = strings.TrimSpace(RunCmd(GoList("{{.Root}}", "github.com/therecipe/qt"), "get list gopath"))
|
||||
if _, err := exec.LookPath("go"); err == nil {
|
||||
mustGoPath = strings.TrimSpace(RunCmd(GoList("{{.Root}}", "github.com/therecipe/qt"), "get list gopath"))
|
||||
}
|
||||
if len(mustGoPath) == 0 {
|
||||
mustGoPath = GOPATH()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue