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 | |
| parent | f2dea7df338f116631fa8d6d567478855684fa07 (diff) | |
add sourceinfo to xxx_values
| -rw-r--r-- | xmake/core/base/interpreter.lua | 21 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 6 |
2 files changed, 23 insertions, 4 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 diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 8fae3eaa5..dc8f68bae 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -434,7 +434,8 @@ function target:fileconfig(sourcefile) -- match source files local results = os.match(filepath) if #results == 0 then - utils.warning("cannot match add_files(\"%s\")", filepath) + local sourceinfo = (self:get("__sourceinfo_files") or {})[filepath] + utils.warning("cannot match add_files(\"%s\") at %s:%d", filepath, sourceinfo.file or "", sourceinfo.line or -1) end -- process source files @@ -511,7 +512,8 @@ function target:sourcefiles() -- match source files local results = os.match(file) if #results == 0 then - utils.warning("cannot match %s_files(\"%s\")", utils.ifelse(deleted, "del", "add"), file) + local sourceinfo = (self:get("__sourceinfo_files") or {})[file] + utils.warning("cannot match %s_files(\"%s\") at %s:%d", utils.ifelse(deleted, "del", "add"), file, sourceinfo.file or "", sourceinfo.line or -1) end -- process source files |
