diff options
| author | ruki <[email protected]> | 2018-02-03 17:02:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-02-03 17:02:16 +0800 |
| commit | 5b201819dfc59ecc516f2d3b812b6a782d6244fd (patch) | |
| tree | 305bcfa260a1454a5feb2620006e575879ef801c /xmake/core/base/interpreter.lua | |
| parent | f2dea7df338f116631fa8d6d567478855684fa07 (diff) | |
add sourceinfo to xxx_values
Diffstat (limited to 'xmake/core/base/interpreter.lua')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index cb5b831d8..e405e6d85 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -247,6 +247,19 @@ function interpreter:_api_register_xxx_values(scope_kind, action, apifunc, ...) scope["__override_" .. apiname] = true end + -- save api source info, .e.g call api() in sourcefile:linenumber + local sourceinfo = debug.getinfo(2, "Sl") + if sourceinfo then + scope["__sourceinfo_" .. apiname] = scope["__sourceinfo_" .. apiname] or {} + local values = {...} + local sourcescope = scope["__sourceinfo_" .. apiname] + for _, value in ipairs(values) do + if type(value) == "string" then + sourcescope[value] = {file = sourceinfo.short_src or sourceinfo.source, line = sourceinfo.currentline} + end + end + end + -- call function return apifunc(self, scope, apiname, ...) end @@ -783,7 +796,9 @@ function interpreter:api_register(scope_kind, name, func) local scope = apis[scope_kind] -- register api - scope[name] = function (...) return func(self, ...) end + scope[name] = function (...) + return func(self, ...) + end else -- get root apis @@ -791,7 +806,9 @@ function interpreter:api_register(scope_kind, name, func) local apis = self._PRIVATE._ROOTAPIS -- register api to the root scope - apis[name] = function (...) return func(self, ...) end + apis[name] = function (...) + return func(self, ...) + end end end |
