diff options
| author | ruki <[email protected]> | 2024-07-17 23:51:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-17 23:51:28 +0800 |
| commit | 9310167ec7254b065e687cba9740902939c005fd (patch) | |
| tree | b95a8deacadbc24500cda037a73c4106e50eb9fe | |
| parent | 95c8f8615eb91de863c1eebeb27bb5c1c5e409a7 (diff) | |
revert bindir
| -rw-r--r-- | tests/actions/install/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/main.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/target/action/uninstall/main.lua | 8 | ||||
| -rw-r--r-- | xmake/plugins/pack/batchcmds.lua | 32 |
4 files changed, 17 insertions, 43 deletions
diff --git a/tests/actions/install/xmake.lua b/tests/actions/install/xmake.lua index f21deb5db..652857116 100644 --- a/tests/actions/install/xmake.lua +++ b/tests/actions/install/xmake.lua @@ -11,13 +11,13 @@ target("foo") add_headerfiles("src/foo.h", {public = true}) add_installfiles("src/foo.txt", {prefixdir = "assets", public = true}) set_prefixdir("/", {libdir = "foo_lib"}) - add_rpathdirs("@loader_path/../../foo_lib", {installonly = true, public = true}) target("app") set_kind("binary") add_deps("foo") add_files("src/main.cpp") - set_prefixdir("app") + set_prefixdir("app", {libdir = "app_lib"}) + add_rpathdirs("@loader_path/../app_lib", {installonly = true}) includes("@builtin/xpack") diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua index 9e5e0c54c..0b5ac126e 100644 --- a/xmake/modules/target/action/install/main.lua +++ b/xmake/modules/target/action/install/main.lua @@ -29,13 +29,12 @@ 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 local filename = path.filename(libfile) if filename:endswith(".dll") or filename:endswith(".so") or filename:find("%.so%.%d+$") or filename:endswith(".dylib") then - table.insert(libfiles, path.joinenv({libfile, bindir})) + table.insert(libfiles, libfile) end end end @@ -48,10 +47,7 @@ function _get_target_package_libfiles(target, opt) for _, libfile in ipairs(depend_libraries) do depends:insert(path.filename(libfile)) end - table.remove_if(libfiles, function (_, libfile) - libfile = path.splitenv(libfile)[1] - return not depends:has(path.filename(libfile)) - end) + table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end) end return libfiles end @@ -108,15 +104,15 @@ end -- install shared libraries function _install_shared_libraries(target, opt) + local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() -- get all dependent shared libraries local libfiles = {} for _, dep in ipairs(target:orderdeps()) do - local bindir = dep:is_plat("windows", "mingw") and dep:bindir() or dep:libdir() if dep:kind() == "shared" then local depfile = dep:targetfile() if os.isfile(depfile) then - table.insert(libfiles, path.joinenv({depfile, bindir})) + table.insert(libfiles, depfile) end end table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true})) @@ -128,10 +124,6 @@ function _install_shared_libraries(target, opt) -- do install for _, libfile in ipairs(libfiles) do - local splitinfo = path.splitenv(libfile) - libfile = splitinfo[1] - local bindir = splitinfo[2] - assert(libfile and bindir) local filename = path.filename(libfile) local filepath = path.join(bindir, filename) if os.isfile(filepath) and hash.sha256(filepath) ~= hash.sha256(libfile) then diff --git a/xmake/modules/target/action/uninstall/main.lua b/xmake/modules/target/action/uninstall/main.lua index 1c8b80ae9..2b082d3cb 100644 --- a/xmake/modules/target/action/uninstall/main.lua +++ b/xmake/modules/target/action/uninstall/main.lua @@ -98,15 +98,15 @@ end -- uninstall shared libraries function _uninstall_shared_libraries(target, opt) + local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir() -- get all dependent shared libraries local libfiles = {} for _, dep in ipairs(target:orderdeps()) do - local bindir = dep:is_plat("windows", "mingw") and dep:bindir() or dep:libdir() if dep:kind() == "shared" then local depfile = dep:targetfile() if os.isfile(depfile) then - table.insert(libfiles, path.joinenv({depfile, bindir})) + table.insert(libfiles, depfile) end end table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true})) @@ -118,10 +118,6 @@ function _uninstall_shared_libraries(target, opt) -- do uninstall for _, libfile in ipairs(libfiles) do - local splitinfo = path.splitenv(libfile) - libfile = splitinfo[1] - local bindir = splitinfo[2] - assert(libfile and bindir) local filename = path.filename(libfile) local filepath = path.join(bindir, filename) _remove_file_with_symbols(filepath) diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua index f810b934c..c41efb89d 100644 --- a/xmake/plugins/pack/batchcmds.lua +++ b/xmake/plugins/pack/batchcmds.lua @@ -61,15 +61,14 @@ function _get_target_installdir(package, target) return path.normalize(installdir) end -function _get_target_package_libfiles(package, target, opt) +function _get_target_package_libfiles(target, opt) local libfiles = {} - local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target) 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 local filename = path.filename(libfile) if filename:endswith(".dll") or filename:endswith(".so") or filename:find("%.so%.%d+$") or filename:endswith(".dylib") then - table.insert(libfiles, path.joinenv({libfile, bindir})) + table.insert(libfiles, libfile) end end end @@ -82,10 +81,7 @@ function _get_target_package_libfiles(package, target, opt) for _, libfile in ipairs(depend_libraries) do depends:insert(path.filename(libfile)) end - table.remove_if(libfiles, function (_, libfile) - libfile = path.splitenv(libfile)[1] - return not depends:has(path.filename(libfile)) - end) + table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end) end return libfiles end @@ -174,31 +170,26 @@ end -- install target shared libraries function _install_target_shared_libraries(target, batchcmds_, opt) local package = opt.package + local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target) -- get all dependent shared libraries local libfiles = {} for _, dep in ipairs(target:orderdeps()) do - local bindir = dep:is_plat("windows", "mingw") and _get_target_bindir(package, dep) or _get_target_libdir(package, dep) if dep:kind() == "shared" then local depfile = dep:targetfile() if os.isfile(depfile) then - table.insert(libfiles, path.joinenv({depfile, bindir})) + table.insert(libfiles, depfile) end end - table.join2(libfiles, _get_target_package_libfiles(package, dep, {interface = true})) + table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true})) end - table.join2(libfiles, _get_target_package_libfiles(package, target)) + table.join2(libfiles, _get_target_package_libfiles(target)) -- deduplicate libfiles, prevent packages using the same libfiles from overwriting each other libfiles = table.unique(libfiles) -- do install for _, libfile in ipairs(libfiles) do - local splitinfo = path.splitenv(libfile) - libfile = splitinfo[1] - local bindir = splitinfo[2] - assert(libfile and bindir) - local filename = path.filename(libfile) _copy_file_with_symlinks(batchcmds_, libfile, bindir) end @@ -237,15 +228,15 @@ end -- uninstall target shared libraries function _uninstall_target_shared_libraries(target, batchcmds_, opt) local package = opt.package + local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target) -- get all dependent shared libraries local libfiles = {} for _, dep in ipairs(target:orderdeps()) do - local bindir = dep:is_plat("windows", "mingw") and _get_target_bindir(package, dep) or _get_target_libdir(package, dep) if dep:kind() == "shared" then local depfile = dep:targetfile() if os.isfile(depfile) then - table.insert(libfiles, path.joinenv({depfile, bindir})) + table.insert(libfiles, depfile) end end table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true})) @@ -257,11 +248,6 @@ function _uninstall_target_shared_libraries(target, batchcmds_, opt) -- do uninstall for _, libfile in ipairs(libfiles) do - local splitinfo = path.splitenv(libfile) - libfile = splitinfo[1] - local bindir = splitinfo[2] - assert(libfile and bindir) - local filename = path.filename(libfile) batchcmds_:rm(libfile, path.join(bindir, filename), {emptydirs = true}) end |
