summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-20 22:53:03 +0800
committerGitHub <[email protected]>2023-09-20 22:53:03 +0800
commit5c619b17b5847b18d284323830dedaeff9d5d6ed (patch)
treef07d818478934cd5e8d343abc7897e830b07642a
parent1ca0b3dc0d00d10ecc1d82aaa22c4b17d7285917 (diff)
parenta80914a07b5a13981198aebfd46961f24ebde721 (diff)
Merge pull request #4223 from jingkaimori/jingkaimori/mingw-windeploy
run windeploy on mingw
-rw-r--r--xmake/rules/qt/install/mingw.lua103
-rw-r--r--xmake/rules/qt/xmake.lua5
2 files changed, 108 insertions, 0 deletions
diff --git a/xmake/rules/qt/install/mingw.lua b/xmake/rules/qt/install/mingw.lua
new file mode 100644
index 000000000..663551090
--- /dev/null
+++ b/xmake/rules/qt/install/mingw.lua
@@ -0,0 +1,103 @@
+--!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 jingkaimori
+-- @file mingw.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("core.tool.toolchain")
+import("lib.detect.find_path")
+import("detect.sdks.find_qt")
+
+-- get install directory
+function _get_installdir(target)
+ local installdir = assert(target:installdir(), "please use `xmake install -o installdir` or `set_installdir` to set install directory on windows.")
+ return installdir
+end
+
+-- install application package for windows
+function main(target, opt)
+
+ local targetfile = target:targetfile()
+ local installdir = _get_installdir(target)
+ local installfile = path.join(installdir, "bin", path.filename(targetfile))
+
+ -- get qt sdk
+ local qt = assert(find_qt(), "Qt SDK not found!")
+
+ -- get windeployqt
+ local windeployqt = path.join(qt.bindir, "windeployqt.exe")
+ assert(os.isexec(windeployqt), "windeployqt.exe not found!")
+
+ -- find qml directory
+ local qmldir = target:values("qt.deploy.qmldir")
+ if not qmldir then
+ for _, sourcebatch in pairs(target:sourcebatches()) do
+ if sourcebatch.rulename == "qt.qrc" then
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ qmldir = find_path("*.qml", path.directory(sourcefile))
+ if qmldir then
+ break
+ end
+ end
+ end
+ end
+ else
+ qmldir = path.join(target:scriptdir(), qmldir)
+ end
+
+ -- add mingw dlls to PATH
+ local envs = nil
+ local mingw = toolchain.load("mingw", {plat = target:plat(), arch = target:arch()})
+ if msvc then
+ local bindir = mingw:bindir()
+ if bindir then
+ envs = {PATH = bindir}
+ end
+ end
+
+ local argv = {"--force"}
+ if option.get("diagnosis") then
+ table.insert(argv, "--verbose=2")
+ elseif option.get("verbose") then
+ table.insert(argv, "--verbose=1")
+ else
+ table.insert(argv, "--verbose=0")
+ end
+
+ if is_mode("debug") then
+ table.insert(argv, "--debug")
+ else
+ table.insert(argv, "--release")
+ end
+
+ if qmldir then
+ table.insert(argv, "--qmldir=" .. qmldir)
+ end
+
+ -- add user flags
+ local user_flags = target:values("qt.deploy.flags") or {}
+ if user_flags then
+ argv = table.join(argv, user_flags)
+ end
+
+ table.insert(argv, installfile)
+
+ os.vrunv(windeployqt, argv, {envs = envs})
+end
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index c06ee4b3b..598a67343 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -76,6 +76,7 @@ rule("qt.console")
end)
after_install("windows", "install.windows")
+ after_install("mingw", "install.mingw")
-- define rule: qt widgetapp
rule("qt.widgetapp")
@@ -110,6 +111,7 @@ rule("qt.widgetapp")
-- install application for android
on_install("android", "install.android")
after_install("windows", "install.windows")
+ after_install("mingw", "install.mingw")
-- define rule: qt static widgetapp
rule("qt.widgetapp_static")
@@ -137,6 +139,7 @@ rule("qt.widgetapp_static")
-- install application for android
on_install("android", "install.android")
after_install("windows", "install.windows")
+ after_install("mingw", "install.mingw")
-- define rule: qt quickapp
rule("qt.quickapp")
@@ -158,6 +161,7 @@ rule("qt.quickapp")
-- install application for android
on_install("android", "install.android")
after_install("windows", "install.windows")
+ after_install("mingw", "install.mingw")
-- define rule: qt static quickapp
rule("qt.quickapp_static")
@@ -181,6 +185,7 @@ rule("qt.quickapp_static")
-- install application for android
on_install("android", "install.android")
after_install("windows", "install.windows")
+ after_install("mingw", "install.mingw")
-- define rule: qt qmlplugin
rule("qt.qmlplugin")