Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
✨ feat: 添加manifest
Browse files Browse the repository at this point in the history
Signed-off-by: xqyjlj <xqyjlj@126.com>
  • Loading branch information
xqyjlj committed Mar 3, 2024
1 parent 4db58dc commit aba236a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/c/csp_hal_apm32f1/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"company": "Geehy",
"versions": {
"latest": {
"size": 0
},
"v0.0.1": {
"size": 14.8
}
}
}
29 changes: 27 additions & 2 deletions tools/scripts/tasks/csp-repo/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,25 @@ end

function dump_table()
local packagelist = {toolchain = {}, library = {}}
local repositories_dir = option.get("repositories")
local installed_list = nil

if repositories_dir then
installed_list = list_table(repositories_dir)
end

for _, packagedir in ipairs(os.dirs(path.join(rootdir, "packages", "*", "*"))) do
local packagename = path.filename(packagedir)
local packagefile = path.join(packagedir, "xmake.lua")
local manifestfile = path.join(packagedir, "manifest.json")
local packageinstance = package.load_from_repository(packagename, packagedir, {packagefile = packagefile})
local on_load = packageinstance:get("load")
if on_load then
on_load(packageinstance)
end
local pkg = {}
local urls = packageinstance:get("urls") or os.raise("%s urls is empty", packagename)
local versions = packageinstance:get("versions") or {latest = "nil"}
local versions = packageinstance:get("versions") or {latest = "nil", sha256 = "unknown"}
local description = packageinstance:get("description") or "unknown"
local homepage = packageinstance:get("homepage") or "unknown"
local license = packageinstance:get("license") or "unknown"
Expand All @@ -122,11 +130,28 @@ function dump_table()
pkg["urls"] = {urls}
end

pkg["versions"] = packageinstance:get("versions") or {latest = "nil"}
pkg["description"] = description
pkg["homepage"] = homepage
pkg["license"] = license

if os.isfile(manifestfile) then
manifest = json.loadfile(manifestfile)
pkg["company"] = manifest["company"]
pkg["versions"] = manifest["versions"]
else
pkg["company"] = "unknown"
pkg["versions"] = {}
end

for version, version_info in pairs(pkg["versions"]) do
version_info["sha256"] = versions[version] or "unknown"
if installed_list and installed_list[packagename] and installed_list[packagename][version] then
version_info["installed"] = true
else
version_info["installed"] = false
end
end

if packageinstance:get("kind") then
packagelist[packageinstance:get("kind")][packagename] = pkg
else
Expand Down

0 comments on commit aba236a

Please sign in to comment.