summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-09-22 23:36:06 +0800
committerruki <[email protected]>2020-09-22 23:36:06 +0800
commitd052576f2e101a0b0cdf299d0264400e13b3faf2 (patch)
treede8d7444b7391dbc6a002d85044c031b37e569f3
parent0d0ed671f7ac74fb385854adf630deff55ad7aa5 (diff)
improve qt/wasm
-rw-r--r--xmake/modules/detect/sdks/find_qt.lua3
-rw-r--r--xmake/rules/qt/xmake.lua56
2 files changed, 32 insertions, 27 deletions
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua
index c6c8be700..9f5f65000 100644
--- a/xmake/modules/detect/sdks/find_qt.lua
+++ b/xmake/modules/detect/sdks/find_qt.lua
@@ -169,9 +169,10 @@ function _find_qt(sdkdir, sdkver)
local bindir = qtenvs.QT_INSTALL_BINS
local qmldir = qtenvs.QT_INSTALL_QML
local libdir = qtenvs.QT_INSTALL_LIBS
+ local pluginsdir = qtenvs.QT_INSTALL_PLUGINS
local includedir = qtenvs.QT_INSTALL_HEADERS
local mkspecsdir = path.join(qtenvs.QT_INSTALL_ARCHDATA, "mkspecs")
- return {sdkdir = sdkdir, bindir = bindir, libdir = libdir, includedir = includedir, qmldir = qmldir, mkspecsdir = mkspecsdir, sdkver = sdkver}
+ return {sdkdir = sdkdir, bindir = bindir, libdir = libdir, includedir = includedir, qmldir = qmldir, pluginsdir = pluginsdir, mkspecsdir = mkspecsdir, sdkver = sdkver}
end
-- find qt sdk toolchains
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index 06a800dd6..52524da47 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -18,10 +18,29 @@
-- @file xmake.lua
--
+-- define rule: qt/wasm application
+rule("qt._wasm_app")
+ add_deps("qt.env")
+ before_load(function (target)
+ if is_plat("wasm") then
+ target:set("filename", target:basename() .. ".js")
+ end
+ end)
+ after_build(function (target)
+ local qt = target:data("qt")
+ local pluginsdir = qt and qt.pluginsdir
+ if pluginsdir then
+ local targetdir = target:targetdir()
+ local htmlfile = path.join(targetdir, target:basename() .. ".html")
+ os.vcp(path.join(pluginsdir, "platforms/wasm_shell.html"), htmlfile)
+ io.gsub(htmlfile, "@APPNAME@", target:name())
+ os.vcp(path.join(pluginsdir, "platforms/qtloader.js"), targetdir)
+ os.vcp(path.join(pluginsdir, "platforms/qtlogo.svg"), targetdir)
+ end
+ end)
+
-- define rule: qt static library
rule("qt.static")
-
- -- add rules
add_deps("qt.qrc", "qt.ui", "qt.moc")
-- we must set kind before target.on_load(), may we will use target in on_load()
@@ -29,15 +48,12 @@ rule("qt.static")
target:set("kind", "static")
end)
- -- after load
after_load(function (target)
import("load")(target, {frameworks = {"QtCore"}})
end)
-- define rule: qt shared library
rule("qt.shared")
-
- -- add rules
add_deps("qt.qrc", "qt.ui", "qt.moc")
-- we must set kind before target.on_load(), may we will use target in on_load()
@@ -45,15 +61,12 @@ rule("qt.shared")
target:set("kind", "shared")
end)
- -- after load
after_load(function (target)
import("load")(target, {frameworks = {"QtCore"}})
end)
-- define rule: qt console
rule("qt.console")
-
- -- add rules
add_deps("qt.qrc", "qt.ui", "qt.moc")
-- we must set kind before target.on_load(), may we will use target in on_load()
@@ -61,23 +74,19 @@ rule("qt.console")
target:set("kind", "binary")
end)
- -- after load
after_load(function (target)
import("load")(target, {frameworks = {"QtCore"}})
end)
-- define rule: qt widgetapp
rule("qt.widgetapp")
-
- -- add rules
- add_deps("qt.ui", "qt.moc")
+ add_deps("qt.ui", "qt.moc", "qt._wasm_app")
-- we must set kind before target.on_load(), may we will use target in on_load()
before_load(function (target)
target:set("kind", is_plat("android") and "shared" or "binary")
end)
- -- after load
after_load(function (target)
import("load")(target, {gui = true, frameworks = {"QtGui", "QtWidgets", "QtCore"}})
end)
@@ -91,22 +100,21 @@ rule("qt.widgetapp")
-- define rule: qt static widgetapp
rule("qt.widgetapp_static")
-
- -- add rules
- add_deps("qt.ui", "qt.moc")
+ add_deps("qt.ui", "qt.moc", "qt._wasm_app")
-- we must set kind before target.on_load(), may we will use target in on_load()
before_load(function (target)
target:set("kind", is_plat("android") and "shared" or "binary")
end)
- -- after load
after_load(function (target)
local plugins = {}
if is_plat("macosx") then
plugins.QCocoaIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qcocoa", "Qt5PrintSupport", "Qt5PlatformSupport", "cups"}}
elseif is_plat("windows") then
plugins.QWindowsIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"Qt5PrintSupport", "Qt5PlatformSupport", "qwindows"}}
+ elseif is_plat("wasm") then
+ plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"Qt5EventDispatcherSupport", "Qt5FontDatabaseSupport", "Qt5EglSupport", "qwasm"}}
end
import("load")(target, {gui = true, plugins = plugins, frameworks = {"QtGui", "QtWidgets", "QtCore"}})
end)
@@ -120,16 +128,13 @@ rule("qt.widgetapp_static")
-- define rule: qt quickapp
rule("qt.quickapp")
-
- -- add rules
- add_deps("qt.qrc", "qt.moc")
+ add_deps("qt.qrc", "qt.moc", "qt._wasm_app")
-- we must set kind before target.on_load(), may we will use target in on_load()
before_load(function (target)
target:set("kind", is_plat("android") and "shared" or "binary")
end)
- -- after load
after_load(function (target)
import("load")(target, {gui = true, frameworks = {"QtGui", "QtQuick", "QtQml", "QtCore", "QtNetwork"}})
end)
@@ -143,24 +148,23 @@ rule("qt.quickapp")
-- define rule: qt static quickapp
rule("qt.quickapp_static")
-
- -- add rules
- add_deps("qt.qrc", "qt.moc")
+ add_deps("qt.qrc", "qt.moc", "qt._wasm_app")
-- we must set kind before target.on_load(), may we will use target in on_load()
before_load(function (target)
target:set("kind", is_plat("android") and "shared" or "binary")
end)
- -- after load
after_load(function (target)
local plugins = {}
if is_plat("macosx") then
plugins.QCocoaIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"qcocoa", "Qt5PrintSupport", "Qt5PlatformSupport", "Qt5Widgets", "cups"}}
elseif is_plat("windows") then
plugins.QWindowsIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"Qt5PrintSupport", "Qt5PlatformSupport", "Qt5Widgets", "qwindows"}}
+ elseif is_plat("wasm") then
+ plugins.QWasmIntegrationPlugin = {linkdirs = "plugins/platforms", links = {"Qt5EventDispatcherSupport", "Qt5FontDatabaseSupport", "Qt5EglSupport", "qwasm"}}
end
- import("load")(target, {gui = true, plugins = plugins, frameworks = {"QtGui", "QtQuick", "QtQml", "QtCore"}})
+ import("load")(target, {gui = true, plugins = plugins, frameworks = {"QtGui", "QtQuick", "QtQml", "QtQmlModels", "QtCore", "QtNetwork"}})
end)
-- deploy application