summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-04-03 11:36:52 +0800
committerGitHub <[email protected]>2023-04-03 11:36:52 +0800
commit85207603a511fbd168f53bad60318b8cbf1c145a (patch)
tree1f83094788d135b8d06455f40e0e13413d9fa30a
parent5da0d5ed555cb4236add90c900b475a4faf073b5 (diff)
parent5542436f97281afa290654170032534de3c9f4a0 (diff)
Merge pull request #3588 from jingkaimori/jingkaimori/qt-wasm-linking
fix missing frameworks in wasm
-rw-r--r--xmake/rules/qt/config_static.lua70
-rw-r--r--xmake/rules/qt/xmake.lua99
2 files changed, 77 insertions, 92 deletions
diff --git a/xmake/rules/qt/config_static.lua b/xmake/rules/qt/config_static.lua
new file mode 100644
index 000000000..21297d8b8
--- /dev/null
+++ b/xmake/rules/qt/config_static.lua
@@ -0,0 +1,70 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki, jingkaimori
+-- @file config_static.lua
+--
+
+-- imports
+import("core.base.semver")
+
+function main(target)
+ -- get qt sdk version
+ local qt = target:data("qt")
+ local qt_sdkver = nil
+ if qt.sdkver then
+ qt_sdkver = semver.new(qt.sdkver)
+ else
+ raise("Qt SDK version not found, please run `xmake f --qt_sdkver=xxx` to set it.")
+ end
+
+ -- @see
+ -- https://github.com/xmake-io/xmake/issues/1047
+ -- https://github.com/xmake-io/xmake/issues/2791
+ local QtPlatformSupport
+ if qt_sdkver:ge("6.0") then
+ QtPlatformSupport = nil
+ elseif qt_sdkver:ge("5.9") then
+ QtPlatformSupport = "QtPlatformCompositorSupport"
+ else
+ QtPlatformSupport = "QtPlatformSupport"
+ end
+
+ -- load some basic plugins and frameworks
+ local plugins = {}
+ local frameworks = {}
+ if target:is_plat("macosx") then
+ plugins.QCocoaIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qcocoa", "cups"}}
+ table.insert(frameworks, "QtWidgets")
+ if QtPlatformSupport then
+ table.insert(frameworks, QtPlatformSupport)
+ end
+ elseif target:is_plat("windows") then
+ plugins.QWindowsIntegrationPlugin = {linkdirs = "plugins/platforms", links = {is_mode("debug") and "qwindowsd" or "qwindows"}}
+ table.join2(frameworks, "QtPrintSupport", "QtWidgets")
+ if QtPlatformSupport then
+ table.insert(frameworks, QtPlatformSupport)
+ end
+ elseif target:is_plat("wasm") then
+ plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qwasm"}}
+ if qt_sdkver:ge("6.0") then
+ table.join2(frameworks, "QtOpenGL")
+ else
+ table.join2(frameworks, "QtEventDispatcherSupport", "QtFontDatabaseSupport", "QtEglSupport")
+ end
+ end
+ return frameworks, plugins, qt_sdkver
+end \ No newline at end of file
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index 08e8265c2..c06ee4b3b 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -121,50 +121,11 @@ rule("qt.widgetapp_static")
end)
on_config(function (target)
-
- -- get qt sdk version
- local qt = target:data("qt")
- local qt_sdkver = nil
- if qt.sdkver then
- import("core.base.semver")
- qt_sdkver = semver.new(qt.sdkver)
- end
-
- -- @see
- -- https://github.com/xmake-io/xmake/issues/1047
- -- https://github.com/xmake-io/xmake/issues/2791
- local QtPlatformSupport
- if qt_sdkver then
- if qt_sdkver:ge("6.0") then
- QtPlatformSupport = nil
- elseif qt_sdkver:ge("5.9") then
- QtPlatformSupport = "QtPlatformCompositorSupport"
- else
- QtPlatformSupport = "QtPlatformSupport"
- end
- end
-
- -- load some basic plugins and frameworks
- local plugins = {}
- local frameworks = {"QtGui", "QtWidgets", "QtCore"}
- if qt_sdkver and qt_sdkver:lt("5.0") then
- frameworks = {"QtGui", "QtCore"} -- qt4.x has not QtWidgets, it is in QtGui
- end
- if target:is_plat("macosx") then
- plugins.QCocoaIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qcocoa", "cups"}}
- table.insert(frameworks, "QtWidgets")
- if QtPlatformSupport then
- table.insert(frameworks, QtPlatformSupport)
- end
- elseif target:is_plat("windows") then
- plugins.QWindowsIntegrationPlugin = {linkdirs = "plugins/platforms", links = {is_mode("debug") and "qwindowsd" or "qwindows"}}
- table.join2(frameworks, "QtPrintSupport", "QtWidgets")
- if QtPlatformSupport then
- table.insert(frameworks, QtPlatformSupport)
- end
- elseif target:is_plat("wasm") then
- plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qwasm"}}
- table.join2(frameworks, "QtEventDispatcherSupport", "QtFontDatabaseSupport", "QtEglSupport")
+ local frameworks, plugins, qt_sdkver = import("config_static")(target)
+ if qt_sdkver:ge("5.0") then
+ table.join2(frameworks, {"QtGui", "QtWidgets", "QtCore"})
+ else
+ table.join2(frameworks, {"QtGui", "QtCore"})-- qt4.x has not QtWidgets, it is in QtGui
end
import("load")(target, {gui = true, plugins = plugins, frameworks = frameworks})
end)
@@ -208,54 +169,8 @@ rule("qt.quickapp_static")
end)
on_config(function (target)
-
- -- get qt sdk version
- local qt = target:data("qt")
- local qt_sdkver = nil
- if qt.sdkver then
- import("core.base.semver")
- qt_sdkver = semver.new(qt.sdkver)
- end
-
- -- @see
- -- https://github.com/xmake-io/xmake/issues/1047
- -- https://github.com/xmake-io/xmake/issues/2791
- local QtPlatformSupport
- if qt_sdkver then
- if qt_sdkver:ge("6.0") then
- QtPlatformSupport = nil
- elseif qt_sdkver:ge("5.9") then
- QtPlatformSupport = "QtPlatformCompositorSupport"
- else
- QtPlatformSupport = "QtPlatformSupport"
- end
- end
-
- -- load some basic plugins and frameworks
- local plugins = {}
- local frameworks = {"QtGui", "QtQuick", "QtQml", "QtQmlModels", "QtCore", "QtNetwork"}
- if target:is_plat("macosx") then
- plugins.QCocoaIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qcocoa", "cups"}}
- table.insert(frameworks, "QtWidgets")
- if QtPlatformSupport then
- table.insert(frameworks, QtPlatformSupport)
- end
- elseif target:is_plat("windows") then
- plugins.QWindowsIntegrationPlugin = {linkdirs = "plugins/platforms", links = {is_mode("debug") and "qwindowsd" or "qwindows"}}
- table.join2(frameworks, "QtPrintSupport", "QtWidgets")
- if QtPlatformSupport then
- table.insert(frameworks, QtPlatformSupport)
- end
- elseif target:is_plat("wasm") then
- plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qwasm"}}
- if qt_sdkver then
- if qt_sdkver:lt("6.0") then
- table.join2(frameworks, "QtEventDispatcherSupport", "QtFontDatabaseSupport", "QtEglSupport")
- else
- table.join2(frameworks, "QtOpenGL")
- end
- end
- end
+ local frameworks, plugins = import("config_static")(target)
+ table.join2(frameworks, {"QtGui", "QtQuick", "QtQml", "QtQmlModels", "QtCore", "QtNetwork"})
import("load")(target, {gui = true, plugins = plugins, frameworks = frameworks})
end)