diff options
| author | ruki <[email protected]> | 2017-07-18 11:28:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-18 11:28:12 +0800 |
| commit | f681b5830054511484277bdf82838cd5bb7a9b66 (patch) | |
| tree | dc62de31a9f8b5b5be8e83e2f8a8bee1e411226f /xmake/core/project/option.lua | |
| parent | a4648568818b4b5b3598e6c7d5179b5d720a8c94 (diff) | |
add option and target dep api
Diffstat (limited to 'xmake/core/project/option.lua')
| -rw-r--r-- | xmake/core/project/option.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua index c413640ca..daee85a69 100644 --- a/xmake/core/project/option.lua +++ b/xmake/core/project/option.lua @@ -147,7 +147,7 @@ function option:_check() end -- trace - utils.cprint("checking for the %s ... %s", name, utils.ifelse(self:is_enabled(), "${green}ok", "${red}no")) + utils.cprint("checking for the %s ... %s", name, utils.ifelse(self:enabled(), "${green}ok", "${red}no")) if not ok then os.raise(errors) end @@ -213,11 +213,6 @@ function option:set_value(value) self:_flush() end --- this option is enabled? -function option:is_enabled() - return config.get(self:name()) -end - -- clear the option status and need recheck it function option:clear() @@ -231,14 +226,19 @@ function option:clear() self:_flush() end +-- this option is enabled? +function option:enabled() + return config.get(self:name()) +end + -- enable or disable this option -function option:enable(is_enabled) +function option:enable(enabled) -- enable or disable this option? - config.set(self:name(), is_enabled) + config.set(self:name(), enabled) -- save or clear this option in cache - if is_enabled then + if enabled then self:_save() else self:_clear() @@ -285,6 +285,14 @@ function option:add(name_or_info, ...) end end +-- get the given dependent option +function option:dep(name) + local deps = self:deps() + if deps then + return deps[name] + end +end + -- get option deps function option:deps() return self._DEPS |
