Skip to content

Commit

Permalink
more fixes for go modules
Browse files Browse the repository at this point in the history
  • Loading branch information
therecipe committed Jan 21, 2019
1 parent df49a97 commit be468a4
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 37 deletions.
2 changes: 1 addition & 1 deletion cmd/qtdeploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func main() {
if err != nil || !utils.ExistsDir(path) {
utils.Log.WithError(err).WithField("path", path).Debug("can't resolve absolute path")
dirFunc := func() (string, error) {
out, err := utils.RunCmdOptionalError(exec.Command("go", "list", "-f", "{{.Dir}}", oPath), "get pkg dir")
out, err := utils.RunCmdOptionalError(utils.GoList("{{.Dir}}", oPath), "get pkg dir")
return strings.TrimSpace(out), err
}
if dir, err := dirFunc(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/qtminimal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func main() {
if err != nil || !utils.ExistsDir(path) {
utils.Log.WithError(err).WithField("path", path).Debug("can't resolve absolute path")
dirFunc := func() (string, error) {
out, err := utils.RunCmdOptionalError(exec.Command("go", "list", "-f", "{{.Dir}}", oPath), "get pkg dir")
out, err := utils.RunCmdOptionalError(utils.GoList("{{.Dir}}", oPath), "get pkg dir")
return strings.TrimSpace(out), err
}
if dir, err := dirFunc(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/qtmoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func main() {
if err != nil || !utils.ExistsDir(path) {
utils.Log.WithError(err).WithField("path", path).Debug("can't resolve absolute path")
dirFunc := func() (string, error) {
out, err := utils.RunCmdOptionalError(exec.Command("go", "list", "-f", "{{.Dir}}", oPath), "get pkg dir")
out, err := utils.RunCmdOptionalError(utils.GoList("{{.Dir}}", oPath), "get pkg dir")
return strings.TrimSpace(out), err
}
if dir, err := dirFunc(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/qtrcc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func main() {
if err != nil || !utils.ExistsDir(path) {
utils.Log.WithError(err).WithField("path", path).Debug("can't resolve absolute path")
dirFunc := func() (string, error) {
out, err := utils.RunCmdOptionalError(exec.Command("go", "list", "-f", "{{.Dir}}", oPath), "get pkg dir")
out, err := utils.RunCmdOptionalError(utils.GoList("{{.Dir}}", oPath), "get pkg dir")
return strings.TrimSpace(out), err
}
if dir, err := dirFunc(); err != nil {
Expand Down
5 changes: 4 additions & 1 deletion internal/binding/converter/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ func IsPrivateSignal(f *parser.Function) bool {
}
}
} else {
fData = utils.Load(filepath.Join(utils.QT_DARWIN_DIR(), "lib", fmt.Sprintf("%v.framework", strings.Title(parser.State.ClassMap[f.ClassName()].DocModule)), "Versions", "5", "Headers", fPath))
fData = utils.LoadOptional(filepath.Join(utils.QT_DARWIN_DIR(), "lib", fmt.Sprintf("%v.framework", strings.Title(parser.State.ClassMap[f.ClassName()].DocModule)), "Versions", "5", "Headers", fPath))
if len(fData) == 0 {
fData = utils.LoadOptional(filepath.Join(utils.QT_DARWIN_DIR(), "lib", fmt.Sprintf("%v.framework", strings.Title(parser.State.ClassMap[f.ClassName()].DocModule)), "Headers", fPath))
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions internal/binding/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", "5.8.0", fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_MXE():
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.12.0"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_HOMEBREW():
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.12.0"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_MACPORTS(), utils.QT_NIX():
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.11.1"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_MSYS2():
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.12.0"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_UBPORTS_VERSION() == "xenial":
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.9.0"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_SAILFISH():
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.6.3"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_RPI():
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API("5.7.0"), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)

case utils.QT_PKG_CONFIG():
if utils.QT_API("") != "" {
err = xml.Unmarshal([]byte(utils.LoadOptional(filepath.Join(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API(utils.QT_VERSION()), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)
} 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(utils.MustGoPath(), "src", "github.com", "therecipe", "qt", "internal", "binding", "files", "docs", utils.QT_API(utils.QT_VERSION()), fmt.Sprintf("qt%v.index", strings.ToLower(m))))), &module)
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)
} 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()))) {
Expand Down
3 changes: 2 additions & 1 deletion internal/binding/templater/templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package templater
import (
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/therecipe/qt/internal/binding/parser"
Expand Down Expand Up @@ -47,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(utils.GoQtPkgPath("internal", "binding", "files", "utils-androidextras_android.go")))
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")))
}

if !UseStub(false, "Qt"+m, mode) {
Expand Down
6 changes: 6 additions & 0 deletions internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ func InitEnv(target string) {
link = filepath.Join("C:\\", "Users", "Public", "env_windows_amd64")
utils.RemoveAll(link)
_, err = utils.RunCmdOptionalError(exec.Command("cmd", "/C", "mklink", "/J", link, qt_dir), "create symlink for env")

if err == nil {
link = filepath.Join("C:\\", "Users", "Public", "env_windows_amd64_Tools")
utils.RemoveAll(link)
_, err = utils.RunCmdOptionalError(exec.Command("cmd", "/C", "mklink", "/J", link, strings.TrimSpace(utils.RunCmd(utils.GoList("{{.Dir}}", "github.com/therecipe/env_"+runtime.GOOS+"_amd64_"+strconv.Itoa(utils.QT_VERSION_NUM())[:3]+"/Tools"), "get env dir"))), "create symlink for env")
}
}
if err != nil {
if !(utils.ExistsFile(link) || utils.ExistsDir(link)) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/deploy/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func build(mode, target, path, ldFlagsCustom, tagsCustom, name, depPath string,
case "wasm":
ending = ".wasm"
case "linux":
if fast {
if fast || utils.QT_PKG_CONFIG() {
delete(env, "CGO_LDFLAGS")
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/deploy/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func bundle(mode, target, path, name, depPath string, tagsCustom string, fast bo
}

if utils.ExistsFile(filepath.Join(libraryPath, libName)) {
utils.RunCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, libName), filepath.Join(depPath, libDir, libName)), fmt.Sprintf("copy %v for %v on %v", libName, target, runtime.GOOS))
utils.RunCmd(exec.Command("cp", "-L", strings.TrimSuffix(filepath.Join(libraryPath, libName), ".5"), filepath.Join(depPath, libDir, libName)), fmt.Sprintf("copy %v for %v on %v", libName, target, runtime.GOOS))
}

if strings.Contains(dep, "WebEngine") || strings.Contains(dep, "WebView") {
Expand All @@ -177,8 +177,8 @@ func bundle(mode, target, path, name, depPath string, tagsCustom string, fast bo
libs = append(libs, []string{"WebEngine", "WebEngineCore", "WebChannel", "Positioning"}...)
}
for _, libName := range libs {
if utils.ExistsFile(filepath.Join(libraryPath, fmt.Sprintf("libQt5%v.so.5", libName))) {
utils.RunCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, fmt.Sprintf("libQt5%v.so.5", libName)), filepath.Join(depPath, libDir, fmt.Sprintf("libQt5%v.so.5", libName))), fmt.Sprintf("copy %v for %v on %v", libName, target, runtime.GOOS))
if utils.ExistsFile(filepath.Join(libraryPath, fmt.Sprintf("libQt5%v.so", libName))) {
utils.RunCmd(exec.Command("cp", "-L", filepath.Join(libraryPath, fmt.Sprintf("libQt5%v.so", libName)), filepath.Join(depPath, libDir, fmt.Sprintf("libQt5%v.so.5", libName))), fmt.Sprintf("copy %v for %v on %v", libName, target, runtime.GOOS))
}
}
if utils.ExistsFile(filepath.Join(libraryPath, "libqgsttools_p.so.1.0.0")) {
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/setup/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func Test(target string, docker, vagrant bool, vagrantsystem string) {
}

example := filepath.Join(cat, example)
path := utils.GoQtPkgPath("internal", "examples", example)

path := filepath.Join(strings.TrimSpace(utils.RunCmdOptional(utils.GoList("{{.Dir}}", "github.com/therecipe/qt/internal/examples"), "get doc dir")), example)
utils.Log.Infof("testing %v", example)
deploy.Deploy(
mode,
Expand Down
4 changes: 1 addition & 3 deletions internal/cmd/tools.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// +build tools

package cmd

import (
//only needed for module support ->
_ "github.com/gopherjs/gopherjs"
_ "github.com/gopherjs/gopherjs/js"
_ "github.com/therecipe/qt/internal/binding/files/docs"
//<-
)
24 changes: 12 additions & 12 deletions internal/docker/docker_pipelines_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ jobs:
file: windows_32_static/Dockerfile
tag: windows_32_static
dep:
- windows_32_static_base
# - windows_32_static_base
- linux
-
template: docker_job_template.yml
parameters:
file: windows_32_static/Dockerfile.base
tag: windows_32_static_base
# -
# template: docker_job_template.yml
# parameters:
# file: windows_32_static/Dockerfile.base
# tag: windows_32_static_base
-
template: docker_job_template.yml
parameters:
Expand All @@ -130,13 +130,13 @@ jobs:
file: windows_64_static/Dockerfile
tag: windows_64_static
dep:
- windows_64_static_base
# - windows_64_static_base
- linux
-
template: docker_job_template.yml
parameters:
file: windows_64_static/Dockerfile.base
tag: windows_64_static_base
# -
# template: docker_job_template.yml
# parameters:
# file: windows_64_static/Dockerfile.base
# tag: windows_64_static_base
# -
# template: docker_job_template.yml
# parameters:
Expand Down
1 change: 1 addition & 0 deletions internal/examples/mod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package examples
1 change: 1 addition & 0 deletions internal/mod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package internal
6 changes: 5 additions & 1 deletion internal/utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,15 @@ func QT_GEN_OPENGL() bool {
func GoList(args ...string) *exec.Cmd {
cmd := exec.Command("go", "list")
if UseGOMOD("") {
if !strings.Contains(strings.Join(args, "|"), "github.com/therecipe/env_"+runtime.GOOS+"_amd64") {
if /*strings.Contains(strings.Join(args, "|"), "github.com/therecipe/env_"+runtime.GOOS+"_amd64") ||*/ strings.Contains(strings.Join(args, "|"), "github.com/therecipe/qt/internal") {
//TODO: make env readonly if it can't be found inside ./vendor ...
cmd.Args = append(cmd.Args, "-mod=readonly")
} else {
cmd.Args = append(cmd.Args, GOFLAGS())
}
}
cmd.Args = append(cmd.Args, "-e", "-f")
cmd.Args = append(cmd.Args, args...)
cmd.Env = append(os.Environ(), []string{"CGO_ENABLED=0", "GOPROXY=disallow"}...)
return cmd
}

0 comments on commit be468a4

Please sign in to comment.