diff options
| author | ruki <[email protected]> | 2022-09-02 23:12:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-02 23:12:45 +0800 |
| commit | dea67e8f08265301565cf487c842bc7f3642e3b7 (patch) | |
| tree | 30250563cf3645efdbe8f8d5143001d8e23d123a | |
| parent | 1acf248c04f6ccf89bc3dfed5f37bd3b3a1617f2 (diff) | |
improve to find_package and install package
| -rw-r--r-- | xmake/modules/package/manager/xmake/find_package.lua | 39 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/unix.lua | 11 |
2 files changed, 22 insertions, 28 deletions
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 |
