Skip to content

Commit

Permalink
fix errors for apis
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 12, 2025
1 parent 5bc5ce5 commit 543fa33
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 28 deletions.
12 changes: 7 additions & 5 deletions xmake/core/base/task.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,13 @@ end
-- new a task instance
function task.new(name, info)
local instance = table.inherit(task)
local parts = name:split("::", {plain = true})
instance._NAME = parts[#parts]
table.remove(parts)
if #parts > 0 then
instance._NAMESPACE = table.concat(parts, "::")
if name then
local parts = name:split("::", {plain = true})
instance._NAME = parts[#parts]
table.remove(parts)
if #parts > 0 then
instance._NAMESPACE = table.concat(parts, "::")
end
end
instance._INFO = info
return instance
Expand Down
34 changes: 18 additions & 16 deletions xmake/core/package/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,25 @@ local sandbox_module = require("sandbox/modules/import/core/sandbox/module")
-- new an instance
function _instance.new(name, info, opt)
opt = opt or {}
local parts = name:split("::", {plain = true})
local instance = table.inherit(_instance)
local managers = package._memcache():get("managers")
if managers == nil and #parts == 2 then
managers = hashset.new()
for _, dir in ipairs(os.dirs(path.join(os.programdir(), "modules/package/manager/*"))) do
managers:insert(path.filename(dir))
end
package._memcache():set("managers", managers)
end
if #parts == 2 and managers and managers:has(parts[1]) then
instance._NAME = name
else
instance._NAME = parts[#parts]
table.remove(parts)
if #parts > 0 then
instance._NAMESPACE = table.concat(parts, "::")
if name then
local parts = name:split("::", {plain = true})
local managers = package._memcache():get("managers")
if managers == nil and #parts == 2 then
managers = hashset.new()
for _, dir in ipairs(os.dirs(path.join(os.programdir(), "modules/package/manager/*"))) do
managers:insert(path.filename(dir))
end
package._memcache():set("managers", managers)
end
if #parts == 2 and managers and managers:has(parts[1]) then
instance._NAME = name
else
instance._NAME = parts[#parts]
table.remove(parts)
if #parts > 0 then
instance._NAMESPACE = table.concat(parts, "::")
end
end
end
instance._INFO = info
Expand Down
12 changes: 7 additions & 5 deletions xmake/core/project/option.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ local sandbox_module = require("sandbox/modules/import/core/sandbox/module")
-- new an instance
function _instance.new(name, info)
local instance = table.inherit(_instance)
local parts = name:split("::", {plain = true})
instance._NAME = parts[#parts]
table.remove(parts)
if #parts > 0 then
instance._NAMESPACE = table.concat(parts, "::")
if name then
local parts = name:split("::", {plain = true})
instance._NAME = parts[#parts]
table.remove(parts)
if #parts > 0 then
instance._NAMESPACE = table.concat(parts, "::")
end
end
instance._INFO = info
instance._CACHEID = 1
Expand Down
4 changes: 3 additions & 1 deletion xmake/core/project/rule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ end
function rule.new(name, info, opt)
opt = opt or {}
local instance = table.inherit(_instance)
instance:name_set(name)
if name then
instance:name_set(name)
end
instance._INFO = info
instance._PACKAGE = opt.package
if opt.package then
Expand Down
4 changes: 3 additions & 1 deletion xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function _instance.new(name, info)
local instance = table.inherit(_instance)
instance._INFO = info
instance._CACHEID = 1
instance:name_set(name)
if name then
instance:name_set(name)
end
return instance
end

Expand Down

0 comments on commit 543fa33

Please sign in to comment.