diff options
| author | A2va <[email protected]> | 2024-09-18 15:41:23 +0200 |
|---|---|---|
| committer | A2va <[email protected]> | 2024-09-18 15:41:23 +0200 |
| commit | 6f6fa84e93428ad6695fcdedb3aef7b60383bf19 (patch) | |
| tree | 958123bcf14c94cc111353bd39722ef08c4071c1 | |
| parent | 971318d9d33ab5190745cb4a86b4c75e916e72e4 (diff) | |
Allows installdir, bindir and libdir to be configured via opt arguments
| -rw-r--r-- | xmake/modules/target/action/install/main.lua | 21 | ||||
| -rw-r--r-- | xmake/modules/target/action/uninstall/main.lua | 20 |
2 files changed, 31 insertions, 10 deletions
diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua index b1ae56a4d..04f85e905 100644 --- a/xmake/modules/target/action/install/main.lua +++ b/xmake/modules/target/action/install/main.lua @@ -124,6 +124,11 @@ end -- install shared libraries function _install_shared_libraries(target, opt) local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() + if target:is_plat("windows", "mingw") and opt.bindir then + bindir = target:installdir(opt.bindir) + elseif opt.libdir then + bindir = target:installdir(opt.libdir) + end -- get all dependent shared libraries local libfiles = {} @@ -158,7 +163,7 @@ function _update_install_rpath(target, opt) if target:is_plat("windows", "mingw") then return end - local bindir = target:bindir() + local bindir = opt.bindir and target:installdir(opt.bindir) or target:bindir() local targetfile = path.join(bindir, target:filename()) if target:policy("install.rpath") then local result, sources = target:get_from("rpathdirs", "*") @@ -179,7 +184,7 @@ end -- install binary function _install_binary(target, opt) - local bindir = target:bindir() + local bindir = opt.bindir and target:installdir(opt.bindir) or target:bindir() os.mkdir(bindir) os.vcp(target:targetfile(), bindir) os.trycp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile()))) @@ -190,6 +195,11 @@ end -- install shared library function _install_shared(target, opt) local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() + if target:is_plat("windows", "mingw") and opt.bindir then + bindir = target:installdir(opt.bindir) + elseif opt.libdir then + bindir = target:installdir(opt.libdir) + end os.mkdir(bindir) local targetfile = target:targetfile() @@ -197,7 +207,7 @@ function _install_shared(target, opt) -- install *.lib for shared/windows (*.dll) target -- @see https://github.com/xmake-io/xmake/issues/714 os.vcp(target:targetfile(), bindir) - local libdir = target:libdir() + local libdir = opt.libdir and target:installdir(opt.libdir) or target:libdir() local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. (target:is_plat("mingw") and ".dll.a" or ".lib")) if os.isfile(targetfile_lib) then os.mkdir(libdir) @@ -215,7 +225,7 @@ end -- install static library function _install_static(target, opt) - local libdir = target:libdir() + local libdir = opt.libdir and target:installdir(opt.libdir) or target:libdir() os.mkdir(libdir) os.vcp(target:targetfile(), libdir) os.trycp(target:symbolfile(), path.join(libdir, path.filename(target:symbolfile()))) @@ -233,7 +243,8 @@ function _install_moduleonly(target, opt) end function main(target, opt) - local installdir = target:installdir() + opt = opt or {} + local installdir = opt.installdir and target:set("installdir", opt.installdir) or target:installdir() if not installdir then wprint("please use `xmake install -o installdir` or `set_installdir` to set install directory.") return diff --git a/xmake/modules/target/action/uninstall/main.lua b/xmake/modules/target/action/uninstall/main.lua index 912e5140f..5d4ea943f 100644 --- a/xmake/modules/target/action/uninstall/main.lua +++ b/xmake/modules/target/action/uninstall/main.lua @@ -50,7 +50,6 @@ function _get_target_package_libfiles(target, opt) return {} end local libfiles = {} - local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() for _, pkg in ipairs(target:orderpkgs(opt)) do if pkg:enabled() and pkg:get("libfiles") then for _, libfile in ipairs(table.wrap(pkg:get("libfiles"))) do @@ -115,6 +114,11 @@ end -- uninstall shared libraries function _uninstall_shared_libraries(target, opt) local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() + if target:is_plat("windows", "mingw") and opt.bindir then + bindir = target:installdir(opt.bindir) + elseif opt.libdir then + bindir = target:installdir(opt.libdir) + end -- get all dependent shared libraries local libfiles = {} @@ -142,7 +146,7 @@ end -- uninstall binary function _uninstall_binary(target, opt) - local bindir = target:bindir() + local bindir = opt.bindir and target:installdir(opt.bindir) or target:bindir() remove_files(path.join(bindir, path.filename(target:targetfile())), {emptydir = true}) remove_files(path.join(bindir, path.filename(target:symbolfile())), {emptydir = true}) _uninstall_shared_libraries(target, opt) @@ -151,11 +155,16 @@ end -- uninstall shared library function _uninstall_shared(target, opt) local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() + if target:is_plat("windows", "mingw") and opt.bindir then + bindir = target:installdir(opt.bindir) + elseif opt.libdir then + bindir = target:installdir(opt.libdir) + end if target:is_plat("windows", "mingw") then -- uninstall *.lib for shared/windows (*.dll) target -- @see https://github.com/xmake-io/xmake/issues/714 - local libdir = target:libdir() + local libdir = opt.libdir and target:installdir(opt.libdir) or target:libdir() local targetfile = target:targetfile() remove_files(path.join(bindir, path.filename(targetfile)), {emptydir = true}) remove_files(path.join(libdir, path.basename(targetfile) .. (target:is_plat("mingw") and ".dll.a" or ".lib")), {emptydir = true}) @@ -171,7 +180,7 @@ end -- uninstall static library function _uninstall_static(target, opt) - local libdir = target:libdir() + local libdir = opt.libdir and target:installdir(opt.libdir) or target:libdir() remove_files(path.join(libdir, path.filename(target:targetfile())), {emptydir = true}) remove_files(path.join(libdir, path.filename(target:symbolfile())), {emptydir = true}) _uninstall_headers(target, opt) @@ -188,7 +197,8 @@ function _uninstall_moduleonly(target, opt) end function main(target, opt) - local installdir = target:installdir() + opt = opt or {} + local installdir = opt.installdir and target:set("installdir", opt.installdir) or target:installdir() if not installdir then wprint("please use `xmake install -o installdir` or `set_installdir` to set install directory.") return |
