From 81b9a331623e03c13eecc3c86db48b9cecc81d6b Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 23 Sep 2022 22:55:03 +0800 Subject: find version --- xmake/modules/package/manager/xmake/search_package.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'xmake/modules/package') diff --git a/xmake/modules/package/manager/xmake/search_package.lua b/xmake/modules/package/manager/xmake/search_package.lua index f4a235246..cfd384ac6 100644 --- a/xmake/modules/package/manager/xmake/search_package.lua +++ b/xmake/modules/package/manager/xmake/search_package.lua @@ -26,19 +26,31 @@ import("private.action.require.impl.repository") -- search package using the xmake package manager -- -- @param name the package name with pattern +-- @param opt the options, e.g. {require_version = "1.x"} -- -function main(name) +function main(name, opt) + opt = opt or {} local results = {} for _, packageinfo in ipairs(repository.searchdirs(name)) do local package = core_package.load_from_repository(packageinfo.name, packageinfo.repo, packageinfo.packagedir) if package then local repo = package:repo() + local version local versions = package:versions() if versions then versions = table.copy(versions) table.sort(versions, function (a, b) return semver.compare(a, b) > 0 end) + if opt.require_version then + for _, ver in ipairs(versions) do + if semver.satisfies(ver, opt.require_version) then + version = ver + end + end + else + version = versions[1] + end end - table.insert(results, {name = package:name(), version = versions and versions[1], description = package:get("description"), reponame = repo and repo:name()}) + table.insert(results, {name = package:name(), version = version, description = package:get("description"), reponame = repo and repo:name()}) end end return results -- cgit v1.3.1 From 31e4124be2ae66eb10ac43f0b673ee1728104a67 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 23 Sep 2022 23:04:26 +0800 Subject: improve verbose info --- xmake/modules/package/tools/autoconf.lua | 4 ++-- xmake/modules/package/tools/cmake.lua | 4 ++-- xmake/modules/package/tools/ninja.lua | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'xmake/modules/package') diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index b8429e9f5..c9fa019bf 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -444,7 +444,7 @@ function build(package, configs, opt) opt = opt or {} local njob = opt.jobs or option.get("jobs") or tostring(os.default_njob()) local argv = {"-j" .. njob} - if option.get("verbose") then + if option.get("diagnosis") then table.insert(argv, "V=1") end if opt.makeconfigs then @@ -471,7 +471,7 @@ function install(package, configs, opt) -- do install local argv = {"install"} - if option.get("verbose") then + if option.get("diagnosis") then table.insert(argv, "V=1") end if opt.makeconfigs then diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index a9223ce85..30f809671 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -649,7 +649,7 @@ function _build_for_make(package, configs, opt) end local jobs = _get_parallel_njobs(opt) table.insert(argv, "-j" .. jobs) - if option.get("verbose") then + if option.get("diagnosis") then table.insert(argv, "VERBOSE=1") end if is_host("bsd") then @@ -727,7 +727,7 @@ end function _install_for_make(package, configs, opt) local jobs = _get_parallel_njobs(opt) local argv = {"-j" .. jobs} - if option.get("verbose") then + if option.get("diagnosis") then table.insert(argv, "VERBOSE=1") end if is_host("bsd") then diff --git a/xmake/modules/package/tools/ninja.lua b/xmake/modules/package/tools/ninja.lua index d61e144b2..42dc73ed6 100644 --- a/xmake/modules/package/tools/ninja.lua +++ b/xmake/modules/package/tools/ninja.lua @@ -34,7 +34,7 @@ function build(package, configs, opt) end table.insert(argv, "-C") table.insert(argv, buildir) - if option.get("verbose") then + if option.get("diagnosis") then table.insert(argv, "-v") end table.insert(argv, "-j") -- cgit v1.3.1