diff options
| author | ruki <[email protected]> | 2023-03-17 22:37:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-17 22:37:44 +0800 |
| commit | 7204348905ab1280f83a2b7d6f6a845988cb261e (patch) | |
| tree | 01882ddc11457b844bf13fabeefa4c3797ed18bb | |
| parent | 102d82df48e78f2bc0ef9d8650956c57504a3f1f (diff) | |
add find_xxx tag
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_file.lua | 20 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_path.lua | 20 |
2 files changed, 26 insertions, 14 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua index 0c878e87d..9d7448ea8 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua @@ -26,6 +26,7 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local table = require("base/table") +local profiler = require("base/profiler") local raise = require("sandbox/modules/raise") local vformat = require("sandbox/modules/vformat") @@ -70,16 +71,18 @@ function sandbox_lib_detect_find_file.main(name, paths, opt) opt = opt or {} -- find file + profiler:enter("find_file", name) + local results local suffixes = table.wrap(opt.suffixes) for _, _path in ipairs(table.wrap(paths)) do -- format path for builtin variables if type(_path) == "function" then - local ok, results = sandbox.load(_path) + local ok, result_or_errors = sandbox.load(_path) if ok then - _path = results or "" + _path = result_or_errors or "" else - raise(results) + raise(result_or_errors) end elseif type(_path) == "string" then if _path:match("^%$%(env .+%)$") then @@ -95,21 +98,24 @@ function sandbox_lib_detect_find_file.main(name, paths, opt) if #suffixes > 0 then for _, suffix in ipairs(suffixes) do local filedir = path.join(_s_path, suffix) - local results = sandbox_lib_detect_find_file._find(filedir, name) + results = sandbox_lib_detect_find_file._find(filedir, name) if results then - return results + goto found end end else -- find file in the given path - local results = sandbox_lib_detect_find_file._find(_s_path, name) + results = sandbox_lib_detect_find_file._find(_s_path, name) if results then - return results + goto found end end end end end +::found:: + profiler:leave("find_file", name) + return results end -- return module diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua index a88562a76..78b9f4c9d 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua @@ -25,6 +25,7 @@ local sandbox_lib_detect_find_path = sandbox_lib_detect_find_path or {} local os = require("base/os") local path = require("base/path") local table = require("base/table") +local profiler = require("base/profiler") local raise = require("sandbox/modules/raise") local vformat = require("sandbox/modules/vformat") @@ -76,16 +77,18 @@ function sandbox_lib_detect_find_path.main(name, paths, opt) opt = opt or {} -- find path + local results + profiler:enter("find_path", name) local suffixes = table.wrap(opt.suffixes) for _, _path in ipairs(table.wrap(paths)) do -- format path for builtin variables if type(_path) == "function" then - local ok, results = sandbox.load(_path) + local ok, result_or_errors = sandbox.load(_path) if ok then - _path = results or "" + _path = result_or_errors or "" else - raise(results) + raise(result_or_errors) end else _path = vformat(_path) @@ -95,19 +98,22 @@ function sandbox_lib_detect_find_path.main(name, paths, opt) if #suffixes > 0 then for _, suffix in ipairs(suffixes) do local filedir = path.join(_path, suffix) - local results = sandbox_lib_detect_find_path._find(filedir, name) + results = sandbox_lib_detect_find_path._find(filedir, name) if results then - return results + goto found end end else -- find file in the given path - local results = sandbox_lib_detect_find_path._find(_path, name) + results = sandbox_lib_detect_find_path._find(_path, name) if results then - return results + goto found end end end +::found:: + profiler:leave("find_path", name) + return results end -- return module |
