diff options
| author | ruki <[email protected]> | 2021-08-19 15:47:13 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-19 15:47:13 +0800 |
| commit | 0750e9f48dba55600eae8e0068297a1cded6859a (patch) | |
| tree | 825ee49b8d2fe7bfb9b39353188794c7f91cd019 | |
| parent | 19eee763e481570b2bfd1e1a62ec547892d80097 (diff) | |
Update unix.lua
| -rw-r--r-- | xmake/modules/target/action/uninstall/unix.lua | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/xmake/modules/target/action/uninstall/unix.lua b/xmake/modules/target/action/uninstall/unix.lua index b582aecf6..e13057fa1 100644 --- a/xmake/modules/target/action/uninstall/unix.lua +++ b/xmake/modules/target/action/uninstall/unix.lua @@ -18,14 +18,8 @@ -- @file unix.lua -- --- uninstall library -function _uninstall_library(target, opt) - - -- remove the target file - local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib") - os.vrm(path.join(librarydir, path.filename(target:targetfile()))) - - -- remove headers from the include directory +-- uninstall headers +function _uninstall_headers(target, opt) local includedir = path.join(target:installdir(), opt and opt.includedir or "include") local _, dstheaders = target:headerfiles(includedir) for _, dstheader in ipairs(dstheaders) do @@ -33,18 +27,71 @@ function _uninstall_library(target, opt) end end +-- uninstall shared libraries for package +function _uninstall_shared_for_package(target, pkg, outputdir) + for _, sopath in ipairs(table.wrap(pkg:get("libfiles"))) do + if sopath:endswith(".so") or sopath:endswith(".dylib") then + local soname = path.filename(sopath) + os.vrm(path.join(outputdir, soname)) + end + end +end + +-- uninstall shared libraries for packages +function _uninstall_shared_for_packages(target, outputdir) + _g.uninstalled_packages = _g.uninstalled_packages or {} + for _, pkg in ipairs(target:orderpkgs()) do + if not _g.uninstalled_packages[pkg:name()] then + if pkg:enabled() and pkg:get("libfiles") then + _uninstall_shared_for_package(target, pkg, outputdir) + end + _g.uninstalled_packages[pkg:name()] = true + end + end +end + -- uninstall binary function uninstall_binary(target, opt) + + -- remove the target file local binarydir = path.join(target:installdir(), opt and opt.bindir or "bin") os.vrm(path.join(binarydir, path.filename(target:targetfile()))) + + -- remove the dependent shared (*.so) target + -- @see https://github.com/xmake-io/xmake/issues/961 + local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib") + for _, dep in ipairs(target:orderdeps()) do + if dep:kind() == "shared" then + os.vrm(path.join(librarydir, path.filename(dep:targetfile()))) + end + _uninstall_shared_for_packages(dep, librarydir) + end + + -- uninstall shared libraries for packages + _uninstall_shared_for_packages(target, librarydir) end -- uninstall shared library function uninstall_shared(target, opt) - _uninstall_library(target, opt) + + -- remove the target file + local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib") + os.vrm(path.join(librarydir, path.filename(target:targetfile()))) + + -- remove headers from the include directory + _uninstall_headers(target, opt) + + -- uninstall shared libraries for packages + _uninstall_shared_for_packages(target, librarydir) end -- uninstall static library function uninstall_static(target, opt) - _uninstall_library(target, opt) + + -- remove the target file + local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib") + os.vrm(path.join(librarydir, path.filename(target:targetfile()))) + + -- remove headers from the include directory + _uninstall_headers(target, opt) end |
