summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-08-25 22:09:23 +0800
committerruki <[email protected]>2018-08-25 22:09:23 +0800
commit4ce0113475c5165303dedb594d1ac8cbc42a22f9 (patch)
tree7886c3a34b682a17320931afaab6395e063ffa26
parent3b88e27a78ac27480ce931023b47cfc40e754b46 (diff)
modify package tree
-rw-r--r--xmake/actions/require/action/build.lua2
-rw-r--r--xmake/actions/require/action/download.lua6
-rw-r--r--xmake/actions/require/action/install.lua4
-rw-r--r--xmake/actions/require/install.lua8
-rw-r--r--xmake/actions/require/list.lua2
-rw-r--r--xmake/actions/require/package.lua14
-rw-r--r--xmake/actions/require/repository.lua7
-rw-r--r--xmake/actions/require/search.lua2
-rw-r--r--xmake/core/package/package.lua24
-rw-r--r--xmake/repository/packages/c/cmake/xmake.lua (renamed from xmake/repository/packages/cmake/xmake.lua)0
-rw-r--r--xmake/repository/packages/g/git/xmake.lua (renamed from xmake/repository/packages/git/xmake.lua)0
11 files changed, 26 insertions, 43 deletions
diff --git a/xmake/actions/require/action/build.lua b/xmake/actions/require/action/build.lua
index 52b71aed4..74e53c587 100644
--- a/xmake/actions/require/action/build.lua
+++ b/xmake/actions/require/action/build.lua
@@ -198,7 +198,7 @@ function _on_build_package(package)
end
-- failed
- raise("attempt to build package %s failed!", package:fullname())
+ raise("attempt to build package %s failed!", package:name())
end
-- build the given package
diff --git a/xmake/actions/require/action/download.lua b/xmake/actions/require/action/download.lua
index 63d8160ab..66c989b24 100644
--- a/xmake/actions/require/action/download.lua
+++ b/xmake/actions/require/action/download.lua
@@ -47,7 +47,7 @@ end
function _checkout(package, url, sourcedir)
-- use previous source directory if exists
- local packagedir = path.join(sourcedir, package:fullname())
+ local packagedir = path.join(sourcedir, package:name())
if os.isdir(packagedir) and not option.get("force") then
-- clean the previous build files
@@ -59,7 +59,7 @@ function _checkout(package, url, sourcedir)
os.rm(sourcedir .. ".tmp")
-- download package from branches?
- packagedir = path.join(sourcedir .. ".tmp", package:fullname())
+ packagedir = path.join(sourcedir .. ".tmp", package:name())
if package:version_from("branches") then
-- only shadow clone this branch
@@ -92,7 +92,7 @@ function _download(package, url, sourcedir, url_alias)
-- get sha256
local sha256 = package:sha256(url_alias)
- assert(sha256, "cannot get sha256 of %s in package(%s)", url, package:fullname())
+ assert(sha256, "cannot get sha256 of %s in package(%s)", url, package:name())
-- the package file have been downloaded?
if option.get("force") or not os.isfile(packagefile) or sha256 ~= hash.sha256(packagefile) then
diff --git a/xmake/actions/require/action/install.lua b/xmake/actions/require/action/install.lua
index a1602431f..791a82f01 100644
--- a/xmake/actions/require/action/install.lua
+++ b/xmake/actions/require/action/install.lua
@@ -186,7 +186,7 @@ function _on_install_package(package)
end
-- failed
- raise("attempt to install package %s failed!", package:fullname())
+ raise("attempt to install package %s failed!", package:name())
end
-- install the given package
@@ -208,7 +208,7 @@ function main(package)
end
-- init tipname
- local tipname = package:fullname()
+ local tipname = package:name()
if package:version_str() then
tipname = tipname .. "-" .. package:version_str()
end
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua
index 85a1011fc..9c7d61be1 100644
--- a/xmake/actions/require/install.lua
+++ b/xmake/actions/require/install.lua
@@ -35,7 +35,7 @@ import("environment")
function _attach_to_option(instance, opt)
-- disable this option if this package is optional and missing
- if _g.optional_missing[instance:fullname()] then
+ if _g.optional_missing[instance:name()] then
opt:enable(false)
else
@@ -64,7 +64,7 @@ function _attach_to_targets(packages)
for _, instance in ipairs(packages) do
if instance:kind() ~= "binary" then
- local opt = project.option(instance:alias() or instance:fullname())
+ local opt = project.option(instance:alias() or instance:name())
if opt and opt:enabled() then
_attach_to_option(instance, opt)
end
@@ -81,9 +81,9 @@ function _check_missing_packages(packages)
for _, instance in ipairs(packages) do
if not instance:exists() and (#instance:urls() > 0 or instance:from("system")) then
if instance:requireinfo().optional then
- optional_missing[instance:fullname()] = instance
+ optional_missing[instance:name()] = instance
else
- table.insert(packages_missing, instance:fullname())
+ table.insert(packages_missing, instance:name())
end
end
end
diff --git a/xmake/actions/require/list.lua b/xmake/actions/require/list.lua
index a5b02f5ae..297de7d97 100644
--- a/xmake/actions/require/list.lua
+++ b/xmake/actions/require/list.lua
@@ -66,7 +66,7 @@ function main()
-- list all packages
for _, instance in ipairs(package.load_packages(requires, requires_extra)) do
local requireinfo = instance:requireinfo() or {}
- local packageopt = project.option(instance:alias() or instance:fullname())
+ local packageopt = project.option(instance:alias() or instance:name())
if packageopt then
cprint(" ${magenta}require${clear}(%s): %s%s%s", requireinfo.originstr, ifelse(instance:version_str(), instance:version_str(), "no version"), _from(instance), ifelse(requireinfo.optional, ", ${yellow}optional${clear}", ""))
for _, dep in ipairs(instance:orderdeps()) do
diff --git a/xmake/actions/require/package.lua b/xmake/actions/require/package.lua
index f111470ae..c9c385298 100644
--- a/xmake/actions/require/package.lua
+++ b/xmake/actions/require/package.lua
@@ -328,9 +328,9 @@ function _load_packages_gitrefs(packages)
if package then
-- attempt to get refs from cache first
- local refs = gitrefs[package:fullname()]
+ local refs = gitrefs[package:name()]
if refs then
- results[package:fullname()] = {tags = refs.tags, branches = refs.branches}
+ results[package:name()] = {tags = refs.tags, branches = refs.branches}
else
-- attempt to get refs from the git url
local tags = {}
@@ -345,10 +345,10 @@ function _load_packages_gitrefs(packages)
tags, branches = git.refs(url)
-- save result
- results[package:fullname()] = {tags = tags, branches = branches}
+ results[package:name()] = {tags = tags, branches = branches}
-- cache result
- gitrefs[package:fullname()] = {tags = tags, branches = branches}
+ gitrefs[package:name()] = {tags = tags, branches = branches}
break
end
end
@@ -393,7 +393,7 @@ function _select_packages_version(packages)
-- attempt to get tags and branches from the git url
local refs = {}
if gitrefs then
- refs = gitrefs[package:fullname()] or {}
+ refs = gitrefs[package:name()] or {}
end
-- select package version
@@ -426,7 +426,7 @@ function _get_confirm(packages)
-- show tips
cprint("${bright yellow}note: ${default yellow}try installing these packages (pass -y to skip confirm)?")
for _, package in ipairs(confirmed_packages) do
- print(" -> %s %s", package:fullname(), package:version_str() or "")
+ print(" -> %s %s", package:name(), package:version_str() or "")
end
cprint("please input: y (y/n)")
@@ -534,7 +534,7 @@ function install_packages(requires, requires_extra)
for _, index in ipairs(indices) do
local package = packages_remote[index]
if package then
- table.insert(downloading, package:fullname())
+ table.insert(downloading, package:name())
end
end
diff --git a/xmake/actions/require/repository.lua b/xmake/actions/require/repository.lua
index 371e1b012..8a4e1b272 100644
--- a/xmake/actions/require/repository.lua
+++ b/xmake/actions/require/repository.lua
@@ -65,7 +65,7 @@ function packagedir(packagename, reponame)
-- find the package directory from repositories
for _, repo in ipairs(repositories()) do
- local dir = path.join(repo:directory(), "packages", (packagename:gsub('%.', path.seperator())))
+ local dir = path.join(repo:directory(), "packages", packagename:sub(1, 1), packagename)
if os.isdir(dir) and (not reponame or reponame == repo:name()) then
foundir = {dir, repo}
break
@@ -89,14 +89,11 @@ end
-- search package directories from repositories
function searchdirs(name)
- -- split name by '.'
- local subdirs = "**" .. table.concat(name:split('%.'), "*" .. path.seperator() .. "*") .. "*"
-
-- find the package directories from all repositories
local unique = {}
local packageinfos = {}
for _, repo in ipairs(repositories()) do
- for _, file in ipairs(os.files(path.join(repo:directory(), "packages", subdirs, "xmake.lua"))) do
+ for _, file in ipairs(os.files(path.join(repo:directory(), "packages", "*", string.ipattern("*" .. name .. "*"), "xmake.lua"))) do
local packagename = path.basename(path.directory(file))
if not unique[packagename] then
table.insert(packageinfos, {name = packagename, repo = repo, packagedir = path.directory(file)})
diff --git a/xmake/actions/require/search.lua b/xmake/actions/require/search.lua
index 1397e2aff..c7e341337 100644
--- a/xmake/actions/require/search.lua
+++ b/xmake/actions/require/search.lua
@@ -58,7 +58,7 @@ function main(names)
-- show packages
for _, instance in ipairs(packages) do
local repo = instance:repo()
- cprint(" -> ${magenta}%s${clear}: %s %s", instance:fullname(), instance:get("description") or "", repo and ("(in " .. repo:name() .. ")") or "")
+ cprint(" -> ${magenta}%s${clear}: %s %s", instance:name(), instance:get("description") or "", repo and ("(in " .. repo:name() .. ")") or "")
end
end
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index a282c59d3..a7f6e92b9 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -47,13 +47,9 @@ function _instance.new(name, info, rootdir)
-- new an instance
local instance = table.inherit(_instance)
- -- parse name .e.g vendor.name
- local nameinfo = name:split("%.")
-
-- init instance
- instance._FULLNAME = name
- instance._NAME = nameinfo[2] or name
- instance._VENDOR = nameinfo[1]
+ instance._name = name
+ instance._NAME = name
instance._INFO = info
instance._ROOTDIR = rootdir
@@ -74,12 +70,7 @@ function _instance:get(name)
end
end
--- get the package full name with vendor
-function _instance:fullname()
- return self._FULLNAME
-end
-
--- get the package name without vendor
+-- get the package name
function _instance:name()
return self._NAME
end
@@ -97,11 +88,6 @@ function _instance:alias()
end
end
--- get the package vendor
-function _instance:vendor()
- return self._VENDOR
-end
-
-- get urls
function _instance:urls()
return self._URLS or table.wrap(self:get("urls"))
@@ -178,7 +164,7 @@ end
-- get the cached directory of this package
function _instance:cachedir()
- return path.join(package.cachedir(), self:fullname(), self:version_str())
+ return path.join(package.cachedir(), self:name(), self:version_str())
end
-- get the installed directory of this package
@@ -190,7 +176,7 @@ function _instance:installdir()
end
-- make install directory
- return path.join(package.installdir(self:from("global")), self:fullname(), self:version_str())
+ return path.join(package.installdir(self:from("global")), self:name(), self:version_str())
end
-- get versions
diff --git a/xmake/repository/packages/cmake/xmake.lua b/xmake/repository/packages/c/cmake/xmake.lua
index c78f590fd..c78f590fd 100644
--- a/xmake/repository/packages/cmake/xmake.lua
+++ b/xmake/repository/packages/c/cmake/xmake.lua
diff --git a/xmake/repository/packages/git/xmake.lua b/xmake/repository/packages/g/git/xmake.lua
index f6bbe8102..f6bbe8102 100644
--- a/xmake/repository/packages/git/xmake.lua
+++ b/xmake/repository/packages/g/git/xmake.lua