From f7b608aa64f4af3e26a1d48673e5f45e00fe4170 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 10 Jan 2023 00:33:28 +0800 Subject: improve install dir on windows --- xmake/modules/target/action/install/windows.lua | 18 ++++++++++++++---- xmake/rules/qt/install/windows.lua | 9 ++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua index d508623be..84ed75a7d 100644 --- a/xmake/modules/target/action/install/windows.lua +++ b/xmake/modules/target/action/install/windows.lua @@ -21,9 +21,16 @@ -- imports import("lib.detect.find_file") +-- 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 headers function _install_headers(target, opt) - local includedir = path.join(target:installdir(), opt and opt.includedir or "include") + local installdir = _get_installdir(target) + local includedir = path.join(installdir, opt and opt.includedir or "include") os.mkdir(includedir) local srcheaders, dstheaders = target:headerfiles(includedir, {installonly = true}) if srcheaders and dstheaders then @@ -73,7 +80,8 @@ end function install_binary(target, opt) -- install binary - local binarydir = path.join(target:installdir(), opt and opt.bindir or "bin") + local installdir = _get_installdir(target) + local binarydir = path.join(installdir, opt and opt.bindir or "bin") os.mkdir(binarydir) os.vcp(target:targetfile(), binarydir) os.trycp(target:symbolfile(), binarydir) @@ -103,7 +111,8 @@ end function install_shared(target, opt) -- install dll library to the binary directory - local binarydir = path.join(target:installdir(), opt and opt.bindir or "bin") + local installdir = _get_installdir(target) + local binarydir = path.join(installdir, opt and opt.bindir or "bin") os.mkdir(binarydir) os.vcp(target:targetfile(), binarydir) os.trycp(target:symbolfile(), binarydir) @@ -129,7 +138,8 @@ end function install_static(target, opt) -- install library - local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib") + local installdir = _get_installdir(target) + local librarydir = path.join(installdir, opt and opt.libdir or "lib") os.mkdir(librarydir) os.vcp(target:targetfile(), librarydir) os.trycp(target:symbolfile(), librarydir) diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua index d30ba2172..2582d74ae 100644 --- a/xmake/rules/qt/install/windows.lua +++ b/xmake/rules/qt/install/windows.lua @@ -24,11 +24,18 @@ import("core.project.config") import("core.tool.toolchain") import("lib.detect.find_path") +-- 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 installfile = path.join(target:installdir(), "bin", path.filename(targetfile)) + local installdir = _get_installdir(target) + local installfile = path.join(installdir, "bin", path.filename(targetfile)) -- get qt sdk local qt = target:data("qt") -- cgit v1.3.1