diff options
| author | ruki <[email protected]> | 2020-12-12 00:58:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-12 00:58:50 +0800 |
| commit | 3b00d2ead350fcc5e26f40878d5e1e342adfc67a (patch) | |
| tree | f84cee581fbef231a41102f7382ff137a913a659 | |
| parent | 08754e4e8c7fca28482107e69cc4604f2574d1d1 (diff) | |
improve load
| -rw-r--r-- | xmake/core/project/project.lua | 14 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 25 |
2 files changed, 25 insertions, 14 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index d27c1ab1f..8098b88fc 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -346,8 +346,14 @@ end -- load target function project._load_target(t, requires) + -- do before_load() for target and all rules + local ok, errors = t:_load_before() + if not ok then + return false, errors + end + -- do on_load() for target and all rules - local ok, errors = t:_load() + ok, errors = t:_load() if not ok then return false, errors end @@ -380,6 +386,12 @@ function project._load_target(t, requires) table.insert(t._TOOLCHAINS, toolchain_inst) end end + + -- do after_load() for target and all rules + ok, errors = t:_load_after() + if not ok then + return false, errors + end return true end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 9c0ecdacd..257e1b93b 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -93,14 +93,19 @@ function _instance:_load_rules(suffix) return true end --- load all -function _instance:_load_all() +-- do before_load target and rules +function _instance:_load_before() -- do before_load with target rules local ok, errors = self:_load_rules("before") if not ok then return false, errors end + return true +end + +-- do load target and rules +function _instance:_load() -- do load with target rules local ok, errors = self:_load_rules() @@ -111,22 +116,16 @@ function _instance:_load_all() -- do load for target local on_load = self:script("load") if on_load then - local ok, errors = sandbox.load(on_load, self) + ok, errors = sandbox.load(on_load, self) if not ok then return false, errors end end - - -- do after_load with target rules - local ok, errors = self:_load_rules("after") - if not ok then - return false, errors - end return true end --- do load target and rules -function _instance:_load() +-- do after_load target and rules +function _instance:_load_after() -- enter the environments of the target packages local oldenvs = {} @@ -135,8 +134,8 @@ function _instance:_load() os.addenv(name, unpack(values)) end - -- load all - local ok, errors = self:_load_all() + -- do after_load with target rules + local ok, errors = self:_load_rules("after") if not ok then return false, errors end |
