summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-29 22:08:43 +0800
committerruki <[email protected]>2018-09-29 22:08:43 +0800
commit12d62a3b18d65fb65b20381ba360f8686ee002d3 (patch)
tree194c5bf79c5fe89934656d938860d7d07cfab7b3
parent1bc9bfbc31c3004457261351ceb96677b2c81fcc (diff)
remove repeat packages when installing
-rw-r--r--xmake/actions/require/package.lua42
-rw-r--r--xmake/modules/package/tools/autoconf.lua8
2 files changed, 20 insertions, 30 deletions
diff --git a/xmake/actions/require/package.lua b/xmake/actions/require/package.lua
index 4317845bf..fc67ea232 100644
--- a/xmake/actions/require/package.lua
+++ b/xmake/actions/require/package.lua
@@ -198,15 +198,9 @@ function _load_package(packagename, requireinfo)
return package
end
--- search package package from project
-function _search_package_from_project(name)
- return core_package.search_from_project(name)
-end
-
--- search package package from repositories
-function _search_package_from_repository(name)
+-- search packages from repositories
+function _search_packages(name)
- -- search package directories from the given package name
local packages = {}
for _, packageinfo in ipairs(repository.searchdirs(name)) do
local package = core_package.load_from_repository(packageinfo.name, packageinfo.repo, packageinfo.packagedir)
@@ -214,23 +208,6 @@ function _search_package_from_repository(name)
table.insert(packages, package)
end
end
-
- -- ok?
- return packages
-end
-
--- search package from the project and repositories
-function _search_package(name)
-
- -- search package from project first
- local packages = _search_package_from_project(name)
-
- -- search package from repositories
- if not packages or #packages == 0 then
- packages = _search_package_from_repository(name)
- end
-
- -- ok?
return packages
end
@@ -412,8 +389,17 @@ function load_packages(requires, opt)
-- select packages version
_select_packages_version(packages)
- -- ok
- return packages
+ -- remove repeat packages with same the package name and version
+ local unique = {}
+ local results = {}
+ for _, package in ipairs(packages) do
+ local key = package:name() .. (package:version_str() or "")
+ if not unique[key] then
+ table.insert(results, package)
+ unique[key] = true
+ end
+ end
+ return results
end
-- install packages
@@ -549,7 +535,7 @@ function search_packages(names)
-- search all names
local results = {}
for _, name in ipairs(names) do
- local packages = _search_package(name)
+ local packages = _search_packages(name)
if packages then
results[name] = packages
end
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index 7a20d0664..2958d48fa 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -26,8 +26,12 @@
function install(package, configs)
-- generate configure file
- if not os.isfile("configure") and os.isfile("configure.ac") then
- os.vrun("autoreconf --install --symlink")
+ if not os.isfile("configure") then
+ if os.isfile("autogen.sh") then
+ os.vrun("./autogen.sh")
+ elseif os.isfile("configure.ac") then
+ os.vrun("autoreconf --install --symlink")
+ end
end
-- inherit require and option configs