diff options
| author | jingkaimori <[email protected]> | 2023-04-03 00:17:44 +0800 |
|---|---|---|
| committer | jingkaimori <[email protected]> | 2023-04-03 00:17:44 +0800 |
| commit | e0f0066e8bfe0aee40f152a51fcb917f1b5ee924 (patch) | |
| tree | af4702f95d7f4c91f7281b7c3f8f923772c32686 | |
| parent | abd463ca2191769b6ee6012f4b823ce4c3c8623f (diff) | |
refactor static linking of qt
extract these codes as separate function.
| -rw-r--r-- | xmake/rules/qt/config_static.lua | 70 | ||||
| -rw-r--r-- | xmake/rules/qt/xmake.lua | 105 |
2 files changed, 77 insertions, 98 deletions
diff --git a/xmake/rules/qt/config_static.lua b/xmake/rules/qt/config_static.lua new file mode 100644 index 000000000..441fa519b --- /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 +-- + +function main(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 = {} + 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:ge("6.0") then + table.join2(frameworks, "QtOpenGL") + else + table.join2(frameworks, "QtEventDispatcherSupport", "QtFontDatabaseSupport", "QtEglSupport") + end + 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 0a73817c4..530bd72a0 100644 --- a/xmake/rules/qt/xmake.lua +++ b/xmake/rules/qt/xmake.lua @@ -121,56 +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"}} - if qt_sdkver then - if qt_sdkver:ge("6.0") then - table.join2(frameworks, "QtOpenGL") - else - table.join2(frameworks, "QtEventDispatcherSupport", "QtFontDatabaseSupport", "QtEglSupport") - end - end + local frameworks, plugins, qt_sdkver = import("load")(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) @@ -214,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:ge("6.0") then - table.join2(frameworks, "QtOpenGL") - else - table.join2(frameworks, "QtEventDispatcherSupport", "QtFontDatabaseSupport", "QtEglSupport") - end - end - end + local frameworks, plugins = import("load")(target); + table.join2(frameworks, {"QtGui", "QtQuick", "QtQml", "QtQmlModels", "QtCore", "QtNetwork"}) import("load")(target, {gui = true, plugins = plugins, frameworks = frameworks}) end) |
