diff options
| author | ruki <[email protected]> | 2019-03-09 00:30:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-08 21:01:21 +0800 |
| commit | 7a68e6ad25e28c1b1c375147bb0f543ef3a47862 (patch) | |
| tree | ed73c0d33c51f6a6f753a90166f58653978ef955 /xmake/core/base/scopeinfo.lua | |
| parent | bc397edd2f7bb1ce6a40b3967878f682973351ca (diff) | |
improve target:get
Diffstat (limited to 'xmake/core/base/scopeinfo.lua')
| -rw-r--r-- | xmake/core/base/scopeinfo.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua index 49f333428..351572dfa 100644 --- a/xmake/core/base/scopeinfo.lua +++ b/xmake/core/base/scopeinfo.lua @@ -512,6 +512,45 @@ function _instance:apival_del(name, ...) end end +-- get the extra configuration +-- +-- e.g. +-- +-- add_includedirs("inc", {public = true}) +-- +-- function (target) +-- _instance:extraconf("includedirs", "inc", "public") -> true +-- _instance:extraconf("includedirs", "inc") -> {public = true} +-- _instance:extraconf("includedirs") -> {["inc"] = {public = true}} +-- end +-- +function _instance:extraconf(name, item, key) + + -- get extra configurations + local extraconfs = self._EXTRACONFS + if not extraconfs then + extraconfs = {} + self._EXTRACONFS = extraconfs + end + + -- get configuration + local extraconf = extraconfs[name] + if not extraconf then + extraconf = self:get("__extra_" .. name) + extraconfs[name] = extraconf + end + + -- get configuration value + local value = extraconf + if item then + value = extraconf and extraconf[item] or nil + if value and key then + value = value[key] + end + end + return value +end + -- new an scope instance function scopeinfo.new(...) return _instance.new(...) |
