From 0393ff118a61d3f5fc87e02df3752f28db5e8626 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 15 Jun 2016 11:46:47 +0800 Subject: remove on_check and deps for option --- xmake/core/project/option.lua | 84 +++++++++++++----------------------------- xmake/core/project/project.lua | 24 +----------- 2 files changed, 27 insertions(+), 81 deletions(-) diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua index f225a01a1..192660d74 100644 --- a/xmake/core/project/option.lua +++ b/xmake/core/project/option.lua @@ -430,37 +430,6 @@ function option:_check_condition() return true end --- check option -function option:_check() - - -- enable it? - local enable = self:get("enable") - if enable ~= nil and enable then - - -- enable this option - config.set(self:name(), true) - - -- save this option to configure - self:save() - - -- check option - elseif enable == nil and self:_check_condition() then - - -- enable this option - config.set(self:name(), true) - - -- save this option to configure - self:save() - else - - -- disable this option - config.set(self:name(), false) - - -- clear this option to configure - self:clear() - end -end - -- attempt to check option function option:check() @@ -474,24 +443,32 @@ function option:check() -- need check? if config.get(name) == nil then - - -- the option scripts - local scripts = - { - self:get("check_before") - , self:get("check") or option._check - , self:get("check_after") - } - - -- run the target scripts - for i = 1, 3 do - local script = scripts[i] - if script ~= nil then - local ok, errors = sandbox.load(script, self) - if not ok then - os.raise(errors) - end - end + + -- enable it? + local enable = self:get("enable") + if enable ~= nil and enable then + + -- enable this option + config.set(name, true) + + -- save this option to configure + self:save() + + -- check option + elseif enable == nil and self:_check_condition() then + + -- enable this option + config.set(name, true) + + -- save this option to configure + self:save() + else + + -- disable this option + config.set(name, false) + + -- clear this option to configure + self:clear() end -- no check @@ -501,15 +478,6 @@ function option:check() self:save() end - -- on result - local on_result = self:get("result") - if on_result ~= nil then - local ok, errors = sandbox.load(on_result, self, self:enabled()) - if not ok then - os.raise(errors) - end - end - -- checked self._CHECKED = true end diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 948eab3a8..e30d751ef 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -520,28 +520,6 @@ function project._interpreter() return interp end --- check option -function project._check(options, opt) - - -- exists the dependent options? - for _, dep in ipairs(table.wrap(opt:get("deps"))) do - - -- get the dependent option - opt = options[dep] - - -- no this option? - if not opt then - os.raise("invalid dependent option: %s", dep) - end - - -- check this dependent option - project._check(options, opt) - end - - -- check option - opt:check() -end - -- get the project directory function project.directory() @@ -569,7 +547,7 @@ function project.check() -- check all options for _, opt in pairs(options) do - project._check(options, opt) + opt:check() end -- leave toolchains environment -- cgit v1.3.1