summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-09-02 16:15:54 +0800
committerGitHub <[email protected]>2022-09-02 16:15:54 +0800
commit25caa4753e423242d1757552fa5080c508b5cb0c (patch)
tree60fd60cfba7b069f45b7b5eec75a0b4422db3c8d
parentf4dd9cd1947161c6491e835330a40fe197cb2c67 (diff)
parent92d0a65431a580cb9b015aff649673691260a611 (diff)
Merge pull request #2761 from xmake-io/install
Improve to install package
m---------core/src/tbox/tbox0
-rw-r--r--xmake/core/base/os.lua14
-rw-r--r--xmake/modules/package/manager/xmake/find_package.lua39
-rw-r--r--xmake/modules/target/action/install/unix.lua11
-rw-r--r--xmake/modules/target/action/uninstall/unix.lua2
5 files changed, 23 insertions, 43 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox
-Subproject dc99c25f3c6fecafe1cf6791148f5656c007299
+Subproject 58a0801739c3fdc8e9d9741a33fdcad649e27d0
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index b67a497d1..cd17fed99 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -53,8 +53,6 @@ os.SYSERR_NOT_FILEDIR = 2
-- copy single file or directory
function os._cp(src, dst, rootdir, opt)
-
- -- check
assert(src and dst)
-- reserve the source directory structure if opt.rootdir is given
@@ -111,15 +109,11 @@ function os._cp(src, dst, rootdir, opt)
else
return false, string.format("cannot copy file %s, file not found!", src)
end
-
- -- ok
return true
end
-- move single file or directory
function os._mv(src, dst)
-
- -- check
assert(src and dst)
-- exists file or directory?
@@ -138,32 +132,24 @@ function os._mv(src, dst)
else
return false, string.format("cannot move %s to %s, file %s not found!", src, dst, os.strerror())
end
-
- -- ok
return true
end
-- remove single file or directory
function os._rm(filedir)
-
- -- check
assert(filedir)
-- is file or link?
if os.isfile(filedir) or os.islink(filedir) then
- -- remove file
if not os.rmfile(filedir) then
return false, string.format("cannot remove file %s %s", filedir, os.strerror())
end
-- is directory?
elseif os.isdir(filedir) then
- -- remove directory
if not os.rmdir(filedir) then
return false, string.format("cannot remove directory %s %s", filedir, os.strerror())
end
end
-
- -- ok
return true
end
diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua
index 503d1beda..8ba890591 100644
--- a/xmake/modules/package/manager/xmake/find_package.lua
+++ b/xmake/modules/package/manager/xmake/find_package.lua
@@ -76,7 +76,6 @@ function _find_package_from_repo(name, opt)
-- get links and link directories
local links = {}
local linkdirs = {}
- local libfiles = {}
if vars.links then
table.join2(links, vars.links)
else
@@ -87,14 +86,12 @@ function _find_package_from_repo(name, opt)
if file:endswith(".lib") or file:endswith(".a") then
found = true
table.insert(links, target.linkname(path.filename(file), {plat = opt.plat}))
- table.insert(libfiles, file)
end
end
if not found then
- for _, file in ipairs(os.files(path.join(installdir, "lib", "*"))) do
+ for _, file in ipairs(os.files(path.join(installdir, libdir, "*"))) do
if file:endswith(".so") or file:match(".+%.so%..+$") or file:endswith(".dylib") then -- maybe symlink to libxxx.so.1
table.insert(links, target.linkname(path.filename(file), {plat = opt.plat}))
- table.insert(libfiles, file)
end
end
end
@@ -105,11 +102,24 @@ function _find_package_from_repo(name, opt)
table.insert(linkdirs, path.join(installdir, libdir))
end
end
- if opt.plat == "windows" or opt.plat == "mingw" then
- for _, file in ipairs(os.files(path.join(installdir, "lib", "*.dll"))) do
- result.shared = true
- table.insert(libfiles, file)
+
+ -- get libfiles
+ local libfiles = {}
+ for _, libdir in ipairs(vars.linkdirs or "lib") do
+ for _, file in ipairs(os.files(path.join(installdir, libdir, "*"))) do
+ if file:endswith(".lib") or file:endswith(".a") then
+ result.static = true
+ table.insert(libfiles, file)
+ end
end
+ for _, file in ipairs(os.files(path.join(installdir, libdir, "*"))) do
+ if file:endswith(".so") or file:match(".+%.so%..+$") or file:endswith(".dylib") or file:endswith("*.dll") then -- maybe symlink to libxxx.so.1
+ result.shared = true
+ table.insert(libfiles, file)
+ end
+ end
+ end
+ if opt.plat == "windows" or opt.plat == "mingw" then
for _, file in ipairs(os.files(path.join(installdir, "bin", "*.dll"))) do
result.shared = true
table.insert(libfiles, file)
@@ -199,16 +209,11 @@ function _find_package_from_packagedirs(name, opt)
-- register filter handler
interp:filter():register("find_package", function (variable)
-
- -- init maps
- local maps =
- {
- arch = opt.arch
- , plat = opt.plat
- , mode = opt.mode
+ local maps = {
+ arch = opt.arch
+ , plat = opt.plat
+ , mode = opt.mode
}
-
- -- get variable
return maps[variable]
end)
diff --git a/xmake/modules/target/action/install/unix.lua b/xmake/modules/target/action/install/unix.lua
index 65fce1e3c..126191c0e 100644
--- a/xmake/modules/target/action/install/unix.lua
+++ b/xmake/modules/target/action/install/unix.lua
@@ -52,17 +52,6 @@ function _install_shared_for_package(target, pkg, outputdir)
-- we need reserve symlink
-- @see https://github.com/xmake-io/xmake/issues/1582
os.vcp(sopath, outputdir, {symlink = true})
- -- https://github.com/xmake-io/xmake/issues/2665#issuecomment-1209619081
- if os.islink(sopath) then
- -- relative link? e.g. libxx.so -> libxx.4.so
- local realitem = os.readlink(sopath)
- if realitem and not path.is_absolute(realitem) then
- local realpath = path.join(path.directory(sopath), realitem)
- if os.isfile(realpath) then
- os.vcp(realpath, outputdir)
- end
- end
- end
_g.installed_libfiles[sopath] = true
end
end
diff --git a/xmake/modules/target/action/uninstall/unix.lua b/xmake/modules/target/action/uninstall/unix.lua
index 904a28a77..7deeb53ef 100644
--- a/xmake/modules/target/action/uninstall/unix.lua
+++ b/xmake/modules/target/action/uninstall/unix.lua
@@ -30,7 +30,7 @@ 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
+ if sopath:endswith(".so") or sopath:match(".+%.so%..+$") or sopath:endswith(".dylib") then
local soname = path.filename(sopath)
local filepath = path.join(outputdir, soname)
-- https://github.com/xmake-io/xmake/issues/2665#issuecomment-1209619081