diff options
| author | ruki <[email protected]> | 2017-07-10 09:21:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-10 09:21:34 +0800 |
| commit | def23a930fc3780e54b2a8a6fc60854d2e193000 (patch) | |
| tree | d6f268cb27b56c4c191e913cccb3e5d9beaab31a | |
| parent | cc484e28d357f9b65358001c10a6cd95190e684e (diff) | |
add target.on_load
| -rw-r--r-- | CHANGELOG.md | 6 | ||||
| -rw-r--r-- | xmake/core/project/option.lua | 4 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 12 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 4 |
4 files changed, 20 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 11327afc0..aa65cb767 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,9 @@ * Add `net.*` and `devel.*` extension modules * Add `val()` api to get the value of builtin-variable, .e.g `val("host")`, `val("env PATH")`, `val("shell echo hello")` and `val("reg HKEY_LOCAL_MACHINE\\XX;Value")` * Support to compile the microsoft resource file (.rc) -* Add `has_flags` module interfaces. +* Add `has_flags`, `features` and `has_features` for detect module interfaces. * Add `option.on_check`, `option.after_check` and `option.before_check` api +* Add `target.on_load` api ### Changes @@ -314,8 +315,9 @@ * 添加`net.*`和`devel.*`扩展模块 * 添加`val()`接口去获取内置变量,例如:`val("host")`, `val("env PATH")`, `val("shell echo hello")` and `val("reg HKEY_LOCAL_MACHINE\\XX;Value")` * 增加对微软.rc资源文件的编译支持,当在windows上编译时,可以增加资源文件了 -* 增加`has_flags`模块接口 +* 增加`has_flags`, `features`和`has_features`等探测模块接口 * 添加`option.on_check`, `option.after_check` 和 `option.before_check` 接口 +* 添加`target.on_load`接口 ### 改进 diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua index e7231de8b..222c5ba93 100644 --- a/xmake/core/project/option.lua +++ b/xmake/core/project/option.lua @@ -237,7 +237,7 @@ function option:set(name_or_info, ...) self._INFO[name_or_info] = nil end elseif type(name_or_info) == "table" and #name_or_info == 0 then - for name, info in pairs(name_or_info) do + for name, info in pairs(table.join(name_or_info, ...)) do self:set(name, info) end end @@ -248,7 +248,7 @@ function option:add(name_or_info, ...) if type(name_or_info) == "string" then self._INFO[name_or_info] = table.unique(table.join2(table.wrap(self._INFO[name_or_info]), ...)) elseif type(name_or_info) == "table" and #name_or_info == 0 then - for name, info in pairs(name_or_info) do + for name, info in pairs(table.join(name_or_info, ...)) do self:add(name, info) end end diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 4368a7220..f16d61c5d 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -246,6 +246,7 @@ function project._interpreter() { -- target.on_xxx "target.on_run" + , "target.on_load" , "target.on_build" , "target.on_clean" , "target.on_package" @@ -433,6 +434,17 @@ function project.load() -- save targets project._TARGETS = targets + -- on load for each target + for _, target in pairs(targets) do + local on_load = target:script("load") + if on_load then + ok, errors = sandbox.load(on_load, target) + if not ok then + return false, errors + end + end + end + -- ok return true end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index ebc778c3a..4b72d5c2e 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -80,7 +80,7 @@ function target:set(name_or_info, ...) self._INFO[name_or_info] = nil end elseif type(name_or_info) == "table" and #name_or_info == 0 then - for name, info in pairs(name_or_info) do + for name, info in pairs(table.join(name_or_info, ...)) do self:set(name, info) end end @@ -91,7 +91,7 @@ function target:add(name_or_info, ...) if type(name_or_info) == "string" then self._INFO[name_or_info] = table.unique(table.join2(table.wrap(self._INFO[name_or_info]), ...)) elseif type(name_or_info) == "table" and #name_or_info == 0 then - for name, info in pairs(name_or_info) do + for name, info in pairs(table.join(name_or_info, ...)) do self:add(name, info) end end |
