diff options
| author | ruki <[email protected]> | 2025-01-12 21:27:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-12 21:27:13 +0800 |
| commit | 543fa337184df181eae18b35eb8f80c125ab8a84 (patch) | |
| tree | df9a70fea3cec29276a389fda86983c761ad16ac | |
| parent | 5bc5ce579fe5af900fc5dd653dfde7be486ea9a1 (diff) | |
fix errors for apis
| -rw-r--r-- | xmake/core/base/task.lua | 12 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 32 | ||||
| -rw-r--r-- | xmake/core/project/option.lua | 12 | ||||
| -rw-r--r-- | xmake/core/project/rule.lua | 4 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 4 |
5 files changed, 37 insertions, 27 deletions
diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index a3fde1913..b792c3637 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -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 diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index ea33e24fa..f7b49db38 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -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)) + 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 - 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 #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 diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua index 18b9dc363..0124c9f5f 100644 --- a/xmake/core/project/option.lua +++ b/xmake/core/project/option.lua @@ -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 diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index 5d44f7c25..571790fc5 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -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 diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index a8796076c..360edb9cc 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -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 |
