diff options
| author | ruki <[email protected]> | 2025-11-28 00:57:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-28 00:57:14 +0800 |
| commit | 90a7323d1b7d910c8e1f7817932ec20a38839888 (patch) | |
| tree | dac73a477fcd9799a3b27694241cd43d5db620d1 | |
| parent | 214ad0573c9a3466ce9c7a2abaa3a8cde2c4e342 (diff) | |
fix windeployqt
| -rw-r--r-- | xmake/rules/qt/install/mingw.lua | 8 | ||||
| -rw-r--r-- | xmake/rules/qt/install/windeployqt.lua | 11 | ||||
| -rw-r--r-- | xmake/rules/qt/install/windows.lua | 8 | ||||
| -rw-r--r-- | xmake/rules/qt/installcmd.lua | 27 |
4 files changed, 25 insertions, 29 deletions
diff --git a/xmake/rules/qt/install/mingw.lua b/xmake/rules/qt/install/mingw.lua index f9ac70488..1dc244c58 100644 --- a/xmake/rules/qt/install/mingw.lua +++ b/xmake/rules/qt/install/mingw.lua @@ -41,10 +41,6 @@ function main(target, opt) end end - -- prepare windeployqt arguments - local program, argv, envs = windeployqt.prepare(target, bindir, installfiles) - assert(program, "windeployqt.exe not found!") - - -- deploy Qt dependencies - os.vrunv(program, argv, {envs = envs}) + -- run windeployqt to deploy Qt dependencies + windeployqt.run_deploy(target, bindir, installfiles) end diff --git a/xmake/rules/qt/install/windeployqt.lua b/xmake/rules/qt/install/windeployqt.lua index b1340fc6c..d0404b8f6 100644 --- a/xmake/rules/qt/install/windeployqt.lua +++ b/xmake/rules/qt/install/windeployqt.lua @@ -26,12 +26,12 @@ import("lib.detect.find_file") import("lib.detect.find_path") import("detect.sdks.find_qt") --- prepare windeployqt arguments and environment -function prepare(target, bindir, installfiles) +-- run windeployqt to deploy Qt dependencies +function run_deploy(target, bindir, installfiles) -- get qt sdk local qt = find_qt() if not qt then - return nil, nil, nil + return end -- get windeployqt @@ -40,7 +40,7 @@ function prepare(target, bindir, installfiles) if qt.bindir then table.insert(search_dirs, qt.bindir) end local program = find_file("windeployqt" .. (is_host("windows") and ".exe" or ""), search_dirs) if not program or not os.isexec(program) then - return nil, nil, nil + return end -- find qml directory @@ -135,6 +135,7 @@ function prepare(target, bindir, installfiles) -- windeployqt for both target and its deps table.join2(argv, installfiles) - return program, argv, envs + -- run windeployqt + os.vrunv(program, argv, {envs = envs}) end diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua index 4b1c87b44..3ae05be35 100644 --- a/xmake/rules/qt/install/windows.lua +++ b/xmake/rules/qt/install/windows.lua @@ -41,10 +41,6 @@ function main(target, opt) end end - -- prepare windeployqt arguments - local program, argv, envs = windeployqt.prepare(target, bindir, installfiles) - assert(program, "windeployqt.exe not found!") - - -- deploy Qt dependencies - os.vrunv(program, argv, {envs = envs}) + -- run windeployqt to deploy Qt dependencies + windeployqt.run_deploy(target, bindir, installfiles) end diff --git a/xmake/rules/qt/installcmd.lua b/xmake/rules/qt/installcmd.lua index cf70d813c..5fc0a3cf4 100644 --- a/xmake/rules/qt/installcmd.lua +++ b/xmake/rules/qt/installcmd.lua @@ -47,29 +47,32 @@ function main(target, batchcmds, opt) end elseif target:is_plat("windows", "mingw") then -- Windows/Mingw: need to run windeployqt to deploy Qt dependencies - -- First, copy binary to package bindir (windeployqt needs it there) - local package_bindir = package:installdir("bin") - batchcmds:mkdir(package_bindir) + -- First, deploy to target bindir, then copy all files to package bindir + + -- get target bindir for deployment + local bindir = assert(target:bindir(), "please use `xmake install -o installdir` or `set_installdir` to set install directory on windows.") -- copy target binary to bindir first - local targetfile = path.join(package_bindir, target:filename()) - batchcmds:cp(target:targetfile(), targetfile) + local targetfile = path.join(bindir, path.filename(target:targetfile())) + os.cp(target:targetfile(), targetfile) -- copy qt.shared deps local installfiles = {targetfile} for _, dep in ipairs(target:orderdeps()) do if dep:rule("qt.shared") then - local depfile = path.join(package_bindir, path.filename(dep:targetfile())) - batchcmds:cp(dep:targetfile(), depfile) + local depfile = path.join(bindir, path.filename(dep:targetfile())) + os.cp(dep:targetfile(), depfile) table.insert(installfiles, depfile) end end - -- reuse existing logic to prepare windeployqt arguments - local program, argv, envs = windeployqt.prepare(target, package_bindir, installfiles) - if program and argv and envs then - batchcmds:vrunv(program, argv, {envs = envs}) - end + -- run windeployqt to deploy Qt dependencies to bindir + windeployqt.run_deploy(target, bindir, installfiles) + + -- copy all deployed files from bindir to package bindir + local package_bindir = package:installdir("bin") + batchcmds:mkdir(package_bindir) + batchcmds:cp(path.join(bindir, "*"), package_bindir, {rootdir = bindir}) else -- Linux: copy all files from bindir (plugins, translations, etc. should be handled separately) local bindir = target:bindir() |
