Skip to content

Commit

Permalink
experimental support for the msvc builds to get the webengine/webview…
Browse files Browse the repository at this point in the history
… modules working on windows

* Go 1.13 related fixes for js/wasm
* fix windows docker deployment issue
* new 3rdparty/UGlobalHotkey example
* fix webengine module on arch linux
* support for the prebuilt Qt wasm builds
* make use of -trimpath if available
* bump Go version in docker images to 1.12.9
  • Loading branch information
therecipe committed Sep 10, 2019
1 parent d6c64b2 commit 33ee7b2
Show file tree
Hide file tree
Showing 49 changed files with 747 additions and 64 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
github.com/golang/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
github.com/golang/sys v0.0.0-20190419153524-e8e3143a4f4a h1:5bYuhgnDII4NSAAw1wRU+pCovYhB/AqYVmsK2JDnK2k=
github.com/golang/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
github.com/golang/text v0.3.1-0.20190410012825-f4905fbd45b6/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
github.com/golang/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
12 changes: 6 additions & 6 deletions internal/binding/converter/body_input_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func GoInputParametersForJS(function *parser.Function) string {
}
} else {
alloc := GoInputJS(parameter.Name, parameter.Value, function, parameter.PureGoType)
if gType := GoType(function, parameter.Value, parameter.PureGoType); (parser.UseWasm() && strings.Contains(alloc, "js.TypedArrayOf(")) || gType == "*bool" || gType == "*int" {
if gType := GoType(function, parameter.Value, parameter.PureGoType); (parser.UseWasm() && strings.Contains(alloc, ".TypedArrayOf(")) || gType == "*bool" || gType == "*int" {
input = append(input, fmt.Sprintf("%vC", parser.CleanName(parameter.Name, parameter.Value)))
} else {
input = append(input, alloc)
Expand Down Expand Up @@ -113,7 +113,7 @@ func GoInputParametersForJSAlloc(function *parser.Function) []string {
continue
}
//TODO: make it possible to pass nil strings; fix this on C side instead
input = append(input, fmt.Sprintf("var %v js.Value\nif %v != \"\" || true {\n%v = %v\ndefer (*js.TypedArray)(unsafe.Pointer(uintptr(%v.Get(\"data_ptr\").Int()))).Release()\n}\n", name, parser.CleanName(parameter.Name, parameter.Value), name, alloc, name))
input = append(input, fmt.Sprintf("var %v js.Value\nif %v != \"\" || true {\n%v = %v\ndefer qt.ReleaseTypedArray(unsafe.Pointer(uintptr(%v.Get(\"data_ptr\").Int())))\n}\n", name, parser.CleanName(parameter.Name, parameter.Value), name, alloc, name))
}

case "[]byte":
Expand All @@ -122,20 +122,20 @@ func GoInputParametersForJSAlloc(function *parser.Function) []string {
continue
}
//TODO: make it possible to pass nil []bytes; fix this on C side instead
input = append(input, fmt.Sprintf("var %v js.Value\nif len(%v) != 0 || true {\n%v = %v\ndefer (*js.TypedArray)(unsafe.Pointer(uintptr(%v.Get(\"data_ptr\").Int()))).Release()\n}\n", name, parser.CleanName(parameter.Name, parameter.Value), name, alloc, name))
input = append(input, fmt.Sprintf("var %v js.Value\nif len(%v) != 0 || true {\n%v = %v\ndefer qt.ReleaseTypedArray(unsafe.Pointer(uintptr(%v.Get(\"data_ptr\").Int())))\n}\n", name, parser.CleanName(parameter.Name, parameter.Value), name, alloc, name))
}

case "*string", "[]string", "error":
{
if !parser.UseWasm() {
continue
}
input = append(input, fmt.Sprintf("%v := %v\ndefer (*js.TypedArray)(unsafe.Pointer(uintptr(%v.Get(\"data_ptr\").Int()))).Release()\n", name, alloc, name))
input = append(input, fmt.Sprintf("%v := %v\ndefer qt.ReleaseTypedArray(unsafe.Pointer(uintptr(%v.Get(\"data_ptr\").Int())))\n", name, alloc, name))
}

case "*bool":
{
input = append(input, fmt.Sprintf("var %v %v\nif %v != nil {\n%v = qt.WASM.Call(\"_malloc\", 1)\nqt.WASM.Call(\"setValue\", %v, qt.GoBoolToInt(*%v), \"i8\")\ndefer func(){*%v = int8(qt.WASM.Call(\"getValue\", %v, \"i8\").Int()) != 0\nqt.WASM.Call(\"_free\", %v)\n}()\n}\n", name, func() string {
input = append(input, fmt.Sprintf("var %v %v\nif %v != nil {\n%v = qt.Module.Call(\"_malloc\", 1)\nqt.Module.Call(\"setValue\", %v, qt.GoBoolToInt(*%v), \"i8\")\ndefer func(){*%v = int8(qt.Module.Call(\"getValue\", %v, \"i8\").Int()) != 0\nqt.Module.Call(\"_free\", %v)\n}()\n}\n", name, func() string {
if parser.UseWasm() {
return "js.Value"
}
Expand All @@ -145,7 +145,7 @@ func GoInputParametersForJSAlloc(function *parser.Function) []string {

case "*int":
{
input = append(input, fmt.Sprintf("var %v %v\nif %v != nil {\n%v = qt.WASM.Call(\"_malloc\", 4)\nqt.WASM.Call(\"setValue\", %v, *%v, \"i32\")\ndefer func(){*%v = int(int32(qt.WASM.Call(\"getValue\", %v, \"i32\").Int()))\nqt.WASM.Call(\"_free\", %v)\n}()\n}\n", name,
input = append(input, fmt.Sprintf("var %v %v\nif %v != nil {\n%v = qt.Module.Call(\"_malloc\", 4)\nqt.Module.Call(\"setValue\", %v, *%v, \"i32\")\ndefer func(){*%v = int(int32(qt.Module.Call(\"getValue\", %v, \"i32\").Int()))\nqt.Module.Call(\"_free\", %v)\n}()\n}\n", name,
func() string {
if parser.UseWasm() {
return "js.Value"
Expand Down
4 changes: 2 additions & 2 deletions internal/binding/converter/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func GoEnum(n string, v string, e *parser.Enum) string {
e.NoConst = true
if parser.UseJs() {
if parser.UseWasm() {
return fmt.Sprintf("int64(qt.WASM.Call(\"_%v_%v_Type\").Int())", strings.Split(e.Fullname, "::")[0], n)
return fmt.Sprintf("int64(qt.Module.Call(\"_%v_%v_Type\").Int())", strings.Split(e.Fullname, "::")[0], n)
}
return fmt.Sprintf("qt.WASM.Call(\"_%v_%v_Type\").Int64()", strings.Split(e.Fullname, "::")[0], n)
return fmt.Sprintf("qt.Module.Call(\"_%v_%v_Type\").Int64()", strings.Split(e.Fullname, "::")[0], n)
}
return fmt.Sprintf("C.%v_%v_Type()", strings.Split(e.Fullname, "::")[0], n)
}
Expand Down
11 changes: 11 additions & 0 deletions internal/binding/converter/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,14 @@ func variantWrapper(f *parser.Function, value string, p string) (string, string,

return p, "", fmt.Sprintf(".ToInterface().(%v)", strings.TrimSpace(vs[1]))
}

func lambda(i string) string {
if !utils.QT_MSVC() || !strings.HasPrefix(i, "({") {
return i
}
i = strings.TrimSuffix(strings.TrimPrefix(i, "("), ")")
i = "[&]" + i + "()"
is := strings.Split(i, ";")
is[len(is)-2] = "return " + is[len(is)-2]
return strings.Join(is, ";")
}
10 changes: 5 additions & 5 deletions internal/binding/converter/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func CppInput(name, value string, f *parser.Function) string {
}
return fmt.Sprintf("({ emscripten::val tempVal = %v; %v ret = %v; ret; })", name, parser.CleanValue(value), cppInput("tempVal", value, f))
}
return fmt.Sprintf("({ %v_PackedString tempVal = %v; %v ret = %v; free(tempVal.data); ret; })", strings.Title(parser.State.ClassMap[f.ClassName()].Module), name, parser.CleanValue(value), cppInput("tempVal", value, f))
return lambda(fmt.Sprintf("({ %v_PackedString tempVal = %v; %v ret = %v; free(tempVal.data); ret; })", strings.Title(parser.State.ClassMap[f.ClassName()].Module), name, parser.CleanValue(value), cppInput("tempVal", value, f)))
}

out := cppInput(name, value, f)
Expand Down Expand Up @@ -506,7 +506,7 @@ func cppInput(name, value string, f *parser.Function) string {
return fmt.Sprintf("*static_cast<%v*>(%v)", value, name)
}

return fmt.Sprintf("({ %v* tmpP = static_cast<%v*>(%v); %v tmpV = *tmpP; tmpP->~%v(); free(tmpP); tmpV; })", parser.CleanValue(value), value, name, parser.CleanValue(value), strings.Split(parser.CleanValue(value), "<")[0])
return lambda(fmt.Sprintf("({ %v* tmpP = static_cast<%v*>(%v); %v tmpV = *tmpP; tmpP->~%v(); free(tmpP); tmpV; })", parser.CleanValue(value), value, name, parser.CleanValue(value), strings.Split(parser.CleanValue(value), "<")[0]))
}
}

Expand All @@ -529,7 +529,7 @@ func GoInputJS(name, value string, f *parser.Function, p string) string {

if strings.Contains(vOld, "**") {
if parser.UseWasm() {
return fmt.Sprintf("func() js.Value {\ntmp := js.TypedArrayOf([]byte(strings.Join(%v, \"|\")))\nreturn js.ValueOf(map[string]interface{}{\"data\": tmp, \"data_ptr\": unsafe.Pointer(&tmp)})\n}()", name)
return fmt.Sprintf("func() js.Value {\ntmp := qt.TypedArrayOf([]byte(strings.Join(%v, \"|\")))\nreturn js.ValueOf(map[string]interface{}{\"data\": tmp, \"data_ptr\": unsafe.Pointer(&tmp)})\n}()", name)
}
if f.SignalMode != parser.CALLBACK {
return fmt.Sprintf("func() *js.Object {\ntmp := new(js.Object)\nif js.InternalObject(%v).Get(\"$val\") == js.Undefined {\ntmp.Set(\"data\", []byte(js.InternalObject(%v).Call(\"join\", \"|\").String()))\n} else {\ntmp.Set(\"data\", []byte(strings.Join(%v, \"|\")))\n}\nreturn tmp\n}()", name, name, name) //needed for indirect exported pure js call -> can be ommited if build without js support
Expand All @@ -540,15 +540,15 @@ func GoInputJS(name, value string, f *parser.Function, p string) string {
/* TODO: if value == "char" && strings.Count(vOld, "*") == 1 && f.Name == "readData" {} */

if parser.UseWasm() {
return fmt.Sprintf("func() js.Value {\ntmp := js.TypedArrayOf([]byte(%v))\nreturn js.ValueOf(map[string]interface{}{\"data\": tmp, \"data_ptr\": unsafe.Pointer(&tmp)})\n}()", name)
return fmt.Sprintf("func() js.Value {\ntmp := qt.TypedArrayOf([]byte(%v))\nreturn js.ValueOf(map[string]interface{}{\"data\": tmp, \"data_ptr\": unsafe.Pointer(&tmp)})\n}()", name)
}
return fmt.Sprintf("func() *js.Object {\ntmp := new(js.Object)\ntmp.Set(\"data\", []byte(%v))\nreturn tmp\n}()", name)
}

case "QStringList":
{
if parser.UseWasm() {
return fmt.Sprintf("func() js.Value {\ntmp := js.TypedArrayOf([]byte(strings.Join(%v, \"¡¦!\")))\nreturn js.ValueOf(map[string]interface{}{\"data\": tmp, \"data_ptr\": unsafe.Pointer(&tmp)})\n}()", name)
return fmt.Sprintf("func() js.Value {\ntmp := qt.TypedArrayOf([]byte(strings.Join(%v, \"¡¦!\")))\nreturn js.ValueOf(map[string]interface{}{\"data\": tmp, \"data_ptr\": unsafe.Pointer(&tmp)})\n}()", name)
}
if f.SignalMode != parser.CALLBACK {
return fmt.Sprintf("func() *js.Object {\ntmp := new(js.Object)\nif js.InternalObject(%v).Get(\"$val\") == js.Undefined {\ntmp.Set(\"data\", []byte(js.InternalObject(%v).Call(\"join\", \"¡¦!\").String()))\n} else {\ntmp.Set(\"data\", []byte(strings.Join(%v, \"¡¦!\")))\n}\nreturn tmp\n}()", name, name, name) //needed for indirect exported pure js call -> can be ommited if build without js support
Expand Down
9 changes: 7 additions & 2 deletions internal/binding/converter/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/therecipe/qt/internal/binding/parser"
"github.com/therecipe/qt/internal/utils"
)

func GoOutput(name, value string, f *parser.Function, p string) string {
Expand Down Expand Up @@ -587,7 +588,7 @@ func cppOutputPack(name, value string, f *parser.Function) string {
out = strings.Replace(out, "ret.", fmt.Sprintf("%vPacked.", parser.CleanName(name, value)), -1)
return out
}
} else {
} else if !utils.QT_MSVC() {
if strings.Contains(out, "_PackedString") {
out = strings.Replace(out, "({ ", "", -1)
out = strings.Replace(out, " })", "", -1)
Expand All @@ -611,7 +612,7 @@ func cppOutputPacked(name, value string, f *parser.Function) string {
}
return "reinterpret_cast<uintptr_t>(" + out + ")"
}
} else {
} else if !utils.QT_MSVC() {
if strings.Contains(out, "_PackedString") {
return fmt.Sprintf("%vPacked", parser.CleanName(name, value))
}
Expand All @@ -637,6 +638,10 @@ func cppOutputPackingListForJs(hash string) string {
}

func cppOutput(name, value string, f *parser.Function) string {
return lambda(_cppOutput(lambda(name), value, f))
}

func _cppOutput(name, value string, f *parser.Function) string {
var vOld = value

var tHash = sha1.New()
Expand Down
2 changes: 1 addition & 1 deletion internal/binding/parser/class_fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (c *Class) fixGeneral_Version() {
}
}

case "QWebEnginePage", "QWebEngineView":
case "QWebEnginePage", "QWebEngineView", "QWebEngineClientCertificateSelection":
{
for _, f := range c.Functions {
if !((f.Name == "QWebEnginePage" && f.OverloadNumber == "3") ||
Expand Down
2 changes: 1 addition & 1 deletion internal/binding/parser/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func GetLibs() []string {

for i := len(libs) - 1; i >= 0; i-- {
switch {
case !(runtime.GOOS == "darwin" || runtime.GOOS == "linux" || runtime.GOOS == "freebsd") && (libs[i] == "WebEngine" || libs[i] == "WebView"),
case !(runtime.GOOS == "darwin" || runtime.GOOS == "linux" || runtime.GOOS == "freebsd" || (runtime.GOOS == "windows" && utils.QT_MSVC())) && (libs[i] == "WebEngine" || libs[i] == "WebView"),
runtime.GOOS != "windows" && libs[i] == "WinExtras",
runtime.GOOS != "darwin" && libs[i] == "MacExtras",
!(runtime.GOOS == "linux" || runtime.GOOS == "freebsd") && libs[i] == "X11Extras":
Expand Down
6 changes: 3 additions & 3 deletions internal/binding/templater/function_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func goFunctionBody(function *parser.Function) string {

var body string
if UseJs() {
body = converter.GoJSOutputParametersFromC(function, fmt.Sprintf("qt.WASM.Call(\"_%v\", %v)", converter.CppHeaderName(function), converter.GoInputParametersForJS(function)))
body = converter.GoJSOutputParametersFromC(function, fmt.Sprintf("qt.Module.Call(\"_%v\", %v)", converter.CppHeaderName(function), converter.GoInputParametersForJS(function)))
} else {
body = converter.GoOutputParametersFromC(function, fmt.Sprintf("C.%v(%v)", converter.CppHeaderName(function), converter.GoInputParametersForC(function)))
}
Expand Down Expand Up @@ -328,9 +328,9 @@ func goFunctionBody(function *parser.Function) string {
if pType := converter.GoType(function, p.Value, p.PureGoType); pType == "*bool" || pType == "*int" {
if UseJs() {
if pType == "*int" {
fmt.Fprintf(bb, "var %[1]vR int\nif %[1]v != 0 {\n%[1]vR = int(int32(qt.WASM.Call(\"getValue\", %[1]v, \"i32\").Int()))\ndefer func(){qt.WASM.Call(\"setValue\", %[1]v, %[1]vR, \"i32\")}()\n}\n", parser.CleanName(p.Name, p.Value))
fmt.Fprintf(bb, "var %[1]vR int\nif %[1]v != 0 {\n%[1]vR = int(int32(qt.Module.Call(\"getValue\", %[1]v, \"i32\").Int()))\ndefer func(){qt.Module.Call(\"setValue\", %[1]v, %[1]vR, \"i32\")}()\n}\n", parser.CleanName(p.Name, p.Value))
} else { //TODO: make empty *bool callbacks safe?
fmt.Fprintf(bb, "%[1]vR := int8(qt.WASM.Call(\"getValue\", %[1]v, \"i8\").Int()) != 0\ndefer func(){qt.WASM.Call(\"setValue\", %[1]v, qt.GoBoolToInt(%[1]vR), \"i8\")}()\n", parser.CleanName(p.Name, p.Value))
fmt.Fprintf(bb, "%[1]vR := int8(qt.Module.Call(\"getValue\", %[1]v, \"i8\").Int()) != 0\ndefer func(){qt.Module.Call(\"setValue\", %[1]v, qt.GoBoolToInt(%[1]vR), \"i8\")}()\n", parser.CleanName(p.Name, p.Value))
}
} else {
if pType == "*int" {
Expand Down
31 changes: 25 additions & 6 deletions internal/binding/templater/template_cgo_qmake.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ func isAlreadyCached(module, path, target string, mode int, libs []string) bool
switch target {
case "windows":
if utils.QT_DEBUG_CONSOLE() {
if strings.Contains(file, "subsystem,windows") {
if strings.Contains(file, "subsystem,windows") || strings.Contains(file, "/SUBSYSTEM:WINDOWS") {
utils.Log.Debugln("wrong subsystem: have windows and want console, re-creating ...")
return false
}
} else {
if strings.Contains(file, "subsystem,console") {
if strings.Contains(file, "subsystem,console") || strings.Contains(file, "/SUBSYSTEM:CONSOLE") {
utils.Log.Debugln("wrong subsystem: have console and want windows, re-creating ...")
return false
}
Expand Down Expand Up @@ -290,7 +290,11 @@ func createMakefile(module, path, target string, mode int) {
if utils.QT_DEBUG_CONSOLE() {
subsystem = "console"
}
cmd.Args = append(cmd.Args, []string{"-spec", "win32-g++", "CONFIG+=" + subsystem}...)
spec := "win32-g++"
if utils.QT_MSVC() {
spec = "win32-msvc"
}
cmd.Args = append(cmd.Args, []string{"-spec", spec, "CONFIG+=" + subsystem}...)
case "linux":
cmd.Args = append(cmd.Args, []string{"-spec", "linux-g++"}...)
case "freebsd":
Expand Down Expand Up @@ -544,7 +548,9 @@ func createCgo(module, path, target string, mode int, ipkg, tags string) string
case "android", "android-emulator":
fmt.Fprint(bb, "#cgo LDFLAGS: -Wl,--allow-shlib-undefined\n")
case "windows":
fmt.Fprint(bb, "#cgo LDFLAGS: -Wl,--allow-multiple-definition\n")
if !utils.QT_MSVC() {
fmt.Fprint(bb, "#cgo LDFLAGS: -Wl,--allow-multiple-definition\n")
}
case "ios":
fmt.Fprintf(bb, "#cgo CXXFLAGS: -isysroot %v/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/%v -miphoneos-version-min=11.0\n", utils.XCODE_DIR(), utils.IPHONEOS_SDK_DIR())
fmt.Fprintf(bb, "#cgo LDFLAGS: -Wl,-syslibroot,%v/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/%v -miphoneos-version-min=11.0\n", utils.XCODE_DIR(), utils.IPHONEOS_SDK_DIR())
Expand All @@ -555,8 +561,10 @@ func createCgo(module, path, target string, mode int, ipkg, tags string) string
fmt.Fprint(bb, "#cgo CFLAGS: -s EXTRA_EXPORTED_RUNTIME_METHODS=['getValue','setValue']\n")
}

fmt.Fprint(bb, "#cgo CFLAGS: -Wno-unused-parameter -Wno-unused-variable -Wno-return-type\n")
fmt.Fprint(bb, "#cgo CXXFLAGS: -Wno-unused-parameter -Wno-unused-variable -Wno-return-type\n")
if !utils.QT_MSVC() {
fmt.Fprint(bb, "#cgo CFLAGS: -Wno-unused-parameter -Wno-unused-variable -Wno-return-type\n")
fmt.Fprint(bb, "#cgo CXXFLAGS: -Wno-unused-parameter -Wno-unused-variable -Wno-return-type\n")
}

fmt.Fprint(bb, "*/\nimport \"C\"\n")

Expand Down Expand Up @@ -621,6 +629,15 @@ func createCgo(module, path, target string, mode int, ipkg, tags string) string
tmp = strings.Replace(tmp, "-fdata-sections", "", -1)
tmp = strings.Replace(tmp, "-Wl,-dead_strip", "", -1)
case "windows":
if utils.QT_MSVC() {
tmp = strings.Replace(tmp, "-DUNICODE", "-D_ALLOW_KEYWORD_MACROS -DUNICODE", -1)
tmp = strings.Replace(tmp, "-wd4467", "-wd4467 -wd4716", -1)
tmp = strings.Replace(tmp, `"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'"`, "", -1) //TODO:

tmp = strings.Replace(tmp, " CFLAGS:", " MSCFLAGS:", -1)
tmp = strings.Replace(tmp, " CXXFLAGS:", " MSCXXFLAGS:", -1)
tmp = strings.Replace(tmp, " LDFLAGS:", " MSLDFLAGS:", -1)
}
if utils.QT_MSYS2() {
tmp = strings.Replace(tmp, ",--relax,--gc-sections", "", -1)
if utils.QT_MSYS2_STATIC() {
Expand All @@ -640,8 +657,10 @@ func createCgo(module, path, target string, mode int, ipkg, tags string) string
}
if utils.QT_DEBUG_CONSOLE() { //TODO: necessary at all?
tmp = strings.Replace(tmp, "subsystem,windows", "subsystem,console", -1)
tmp = strings.Replace(tmp, "/SUBSYSTEM:WINDOWS", "/SUBSYSTEM:CONSOLE", -1)
} else {
tmp = strings.Replace(tmp, "subsystem,console", "subsystem,windows", -1)
tmp = strings.Replace(tmp, "/SUBSYSTEM:CONSOLE", "/SUBSYSTEM:WINDOWS", -1)
}
if utils.QT_MXE() {
if li := fmt.Sprintf("-L %v", filepath.Join(utils.QT_MXE_DIR(), "usr", utils.QT_MXE_TRIPLET(), "qt5", "lib")); !strings.Contains(tmp, li) {
Expand Down
4 changes: 2 additions & 2 deletions internal/binding/templater/template_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,9 @@ func (ptr *%[1]v) Destroy%[1]v() {
for _, l := range strings.Split(bb.String(), "\n") {
if strings.HasPrefix(l, "//export") {
if parser.UseWasm() {
fmt.Fprintf(bb, "qt.WASM.Set(\"_%[1]v\", js.FuncOf(%[1]v))\n", strings.TrimPrefix(l, "//export "))
fmt.Fprintf(bb, "qt.Module.Set(\"_%[1]v\", js.FuncOf(%[1]v))\n", strings.TrimPrefix(l, "//export "))
} else {
fmt.Fprintf(bb, "qt.WASM.Set(\"_%[1]v\", %[1]v)\n", strings.TrimPrefix(l, "//export "))
fmt.Fprintf(bb, "qt.Module.Set(\"_%[1]v\", %[1]v)\n", strings.TrimPrefix(l, "//export "))
}
}
}
Expand Down
Loading

0 comments on commit 33ee7b2

Please sign in to comment.