summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-10 09:21:34 +0800
committerruki <[email protected]>2017-07-10 09:21:34 +0800
commitdef23a930fc3780e54b2a8a6fc60854d2e193000 (patch)
treed6f268cb27b56c4c191e913cccb3e5d9beaab31a /xmake/core
parentcc484e28d357f9b65358001c10a6cd95190e684e (diff)
add target.on_load
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/option.lua4
-rw-r--r--xmake/core/project/project.lua12
-rw-r--r--xmake/core/project/target.lua4
3 files changed, 16 insertions, 4 deletions
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