diff options
| author | ruki <[email protected]> | 2020-12-17 22:02:55 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-17 22:02:55 +0800 |
| commit | 4560dba670ee153a00f6d7c1cdf65b7c7232ac4d (patch) | |
| tree | a5a306cf90bc8c71da9b1f0bd224de170805ae67 | |
| parent | e95f99d7d99daf3c065dd04d457b2a8a81545380 (diff) | |
| parent | 4392ac36fa097bba6a9493c1f90a0d1ff0954699 (diff) | |
Merge pull request #1145 from SirLynix/qt-deploy
Qt deploy for Windows
| -rw-r--r-- | xmake/rules/qt/install/windows.lua | 77 | ||||
| -rw-r--r-- | xmake/rules/qt/xmake.lua | 6 |
2 files changed, 83 insertions, 0 deletions
diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua new file mode 100644 index 000000000..03bd84f8f --- /dev/null +++ b/xmake/rules/qt/install/windows.lua @@ -0,0 +1,77 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file macosx.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("core.tool.toolchain") +import("lib.detect.find_path") + +-- install application package for windows +function main(target, opt) + + local targetfile = target:targetfile() + local installfile = path.join(target:installdir(), "bin", path.filename(targetfile)) + + -- get qt sdk + local qt = target:data("qt") + + -- get windeployqt + local windeployqt = path.join(qt.bindir, "windeployqt.exe") + assert(os.isexec(windeployqt), "windeployqt.exe not found!") + + -- find qml directory + local qmldir = nil + 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 + + -- find msvc to set VCINSTALLDIR env + local envs = nil + local msvc = toolchain.load("msvc", {plat = target:plat(), arch = target:arch()}) + if msvc then + local vcvars = msvc:config("vcvars") + if vcvars and vcvars.VSInstallDir then + envs = {VCINSTALLDIR = path.join(vcvars.VSInstallDir, "VC")} + 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 qmldir then + table.insert(argv, "--qmldir=" .. qmldir) + 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 afcaa7e83..07d59b31b 100644 --- a/xmake/rules/qt/xmake.lua +++ b/xmake/rules/qt/xmake.lua @@ -75,6 +75,8 @@ rule("qt.console") import("load")(target, {frameworks = {"QtCore"}}) end) + after_install("windows", "install.windows") + -- define rule: qt widgetapp rule("qt.widgetapp") add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc") @@ -94,6 +96,7 @@ rule("qt.widgetapp") -- install application for android on_install("android", "install.android") + after_install("windows", "install.windows") -- define rule: qt static widgetapp rule("qt.widgetapp_static") @@ -143,6 +146,7 @@ rule("qt.widgetapp_static") -- install application for android on_install("android", "install.android") + after_install("windows", "install.windows") -- define rule: qt quickapp rule("qt.quickapp") @@ -163,6 +167,7 @@ rule("qt.quickapp") -- install application for android on_install("android", "install.android") + after_install("windows", "install.windows") -- define rule: qt static quickapp rule("qt.quickapp_static") @@ -212,6 +217,7 @@ rule("qt.quickapp_static") -- install application for android on_install("android", "install.android") + after_install("windows", "install.windows") -- define rule: qt application (deprecated) rule("qt.application") |
