summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-05 12:51:56 +0800
committerruki <[email protected]>2020-04-05 12:51:56 +0800
commit7e23b2f6e8920f1f95c48908db5f88161d2c4d01 (patch)
treecbb86b79b84e9ec32f228eb5011eebdf1f5a95b1
parent73caf845b1e4813d7fbb6779b9c3b1022177966e (diff)
deploy qt app
-rw-r--r--xmake/rules/qt/deploy/android.lua4
-rw-r--r--xmake/rules/qt/deploy/macosx.lua81
-rw-r--r--xmake/rules/qt/xmake.lua12
3 files changed, 91 insertions, 6 deletions
diff --git a/xmake/rules/qt/deploy/android.lua b/xmake/rules/qt/deploy/android.lua
index 9f53ecc84..2f4cc40de 100644
--- a/xmake/rules/qt/deploy/android.lua
+++ b/xmake/rules/qt/deploy/android.lua
@@ -27,10 +27,10 @@ import("core.project.config")
function main(target, opt)
-- get target apk path
- local target_apk = path.join(path.directory(target:targetfile()), target:basename() .. ".apk")
+ local target_apk = path.join(target:targetdir(), target:basename() .. ".apk")
-- trace progress info
- cprintf("${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} ", opt.progress.stop)
+ cprintf("${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} ", opt.progress)
if option.get("verbose") then
cprint("${dim color.build.target}generating.qt.app %s.apk", target:basename())
else
diff --git a/xmake/rules/qt/deploy/macosx.lua b/xmake/rules/qt/deploy/macosx.lua
new file mode 100644
index 000000000..868b10ecb
--- /dev/null
+++ b/xmake/rules/qt/deploy/macosx.lua
@@ -0,0 +1,81 @@
+--!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.theme.theme")
+import("core.base.option")
+import("core.project.config")
+import("lib.detect.find_path")
+
+-- deploy application package for macosx
+function main(target, opt)
+
+ -- trace progress info
+ cprintf("${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} ", opt.progress)
+ if option.get("verbose") then
+ cprint("${dim color.build.target}generating.qt.app %s.app", target:basename())
+ else
+ cprint("${color.build.target}generating.qt.app %s.app", target:basename())
+ end
+
+ -- get qt sdk
+ local qt = target:data("qt")
+
+ -- get macdeployqt
+ local macdeployqt = path.join(qt.bindir, "macdeployqt")
+ assert(os.isexec(macdeployqt), "macdeployqt not found!")
+
+ -- generate target app
+ local target_app = path.join(target:targetdir(), target:basename() .. ".app")
+ local target_contents = path.join(target_app, "Contents")
+ os.tryrm(target_app)
+ os.cp(target:targetfile(), path.join(target_contents, "MacOS", target:basename()))
+ os.cp(path.join(os.programdir(), "scripts", "PkgInfo"), target_contents)
+
+ -- TODO generate Info.plist and codesign
+
+ -- 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
+
+ -- do deploy
+ local argv = {target_app, "-always-overwrite"}
+ if option.get("diagnosis") then
+ table.insert(argv, "-verbose=3")
+ 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
+ os.vrunv(macdeployqt, argv)
+end
+
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index 60b0e40bb..addb2b961 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -82,8 +82,9 @@ rule("qt.widgetapp")
import("load")(target, {gui = true, frameworks = {"QtGui", "QtWidgets", "QtCore"}})
end)
- -- deploy application for android after build
+ -- deploy application
after_build("android", "deploy.android")
+ after_build("macosx", "deploy.macosx")
-- install application for android
on_install("android", "install.android")
@@ -110,8 +111,9 @@ rule("qt.widgetapp_static")
import("load")(target, {gui = true, plugins = plugins, frameworks = {"QtGui", "QtWidgets", "QtCore"}})
end)
- -- deploy application for android after build
+ -- deploy application
after_build("android", "deploy.android")
+ after_build("macosx", "deploy.macosx")
-- install application for android
on_install("android", "install.android")
@@ -132,8 +134,9 @@ rule("qt.quickapp")
import("load")(target, {gui = true, frameworks = {"QtGui", "QtQuick", "QtQml", "QtCore"}})
end)
- -- deploy application for android after build
+ -- deploy application
after_build("android", "deploy.android")
+ after_build("macosx", "deploy.macosx")
-- install application for android
on_install("android", "install.android")
@@ -160,8 +163,9 @@ rule("qt.quickapp_static")
import("load")(target, {gui = true, plugins = plugins, frameworks = {"QtGui", "QtQuick", "QtQml", "QtCore"}})
end)
- -- deploy application for android after build
+ -- deploy application
after_build("android", "deploy.android")
+ after_build("macosx", "deploy.macosx")
-- install application for android
on_install("android", "install.android")