summaryrefslogtreecommitdiff
path: root/xmake/rules/qt/install/windows.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/rules/qt/install/windows.lua')
-rw-r--r--xmake/rules/qt/install/windows.lua100
1 files changed, 6 insertions, 94 deletions
diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua
index 5a60de706..3ae05be35 100644
--- a/xmake/rules/qt/install/windows.lua
+++ b/xmake/rules/qt/install/windows.lua
@@ -19,12 +19,7 @@
--
-- imports
-import("core.base.option")
-import("core.project.config")
-import("core.tool.toolchain")
-import("lib.detect.find_file")
-import("lib.detect.find_path")
-import("detect.sdks.find_qt")
+import("rules.qt.install.windeployqt", {rootdir = os.programdir()})
-- get bin directory, if set_prefixdir changed bindir, we should use bindir
function _get_bindir(target)
@@ -39,96 +34,13 @@ function main(target, opt)
local targetfile = path.join(bindir, path.filename(target:targetfile()))
local installfiles = {}
table.insert(installfiles, targetfile)
- for _, t in ipairs(target:orderdeps()) do
- if t:rules()["qt.shared"] then -- qt.shared deps
- local installfile = path.join(bindir, path.filename(t:targetfile()))
+ for _, dep in ipairs(target:orderdeps()) do
+ if dep:rule("qt.shared") then -- qt.shared deps
+ local installfile = path.join(bindir, path.filename(dep:targetfile()))
table.insert(installfiles, installfile)
end
end
- -- get qt sdk
- local qt = assert(find_qt(), "Qt SDK not found!")
-
- -- get windeployqt
- local search_dirs = {}
- if qt.bindir_host then table.insert(search_dirs, qt.bindir_host) end
- if qt.bindir then table.insert(search_dirs, qt.bindir) end
- local windeployqt = find_file("windeployqt" .. (is_host("windows") and ".exe" or ""), search_dirs)
- 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
-
- -- 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.VCInstallDir then
- envs = {VCINSTALLDIR = vcvars.VCInstallDir}
- end
- end
- -- bind qt bin path
- -- https://github.com/xmake-io/xmake/issues/4297
- if qt.bindir_host or qt.bindir then
- envs = envs or {}
- envs.PATH = {}
- if qt.bindir_host then
- table.insert(envs.PATH, qt.bindir_host)
- end
- if qt.bindir then
- table.insert(envs.PATH, qt.bindir)
- end
- local curpath = os.getenv("PATH")
- if curpath then
- table.join2(envs.PATH, path.splitenv(curpath))
- 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
-
- -- make sure user flags have priority over default
- local user_flags = table.wrap(target:values("qt.deploy.flags"))
- if table.contains(user_flags, "--debug", "--release") then
- if is_mode("debug") then
- table.insert(argv, "--debug")
- else
- table.insert(argv, "--release")
- end
- end
-
- if qmldir then
- table.insert(argv, "--qmldir=" .. qmldir)
- end
-
- -- add user flags
- if user_flags then
- argv = table.join(argv, user_flags)
- end
-
- -- windeployqt for both target and its deps
- table.join2(argv, installfiles)
-
- os.vrunv(windeployqt, argv, {envs = envs})
+ -- run windeployqt to deploy Qt dependencies
+ windeployqt.run_deploy(target, bindir, installfiles)
end