summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-05 16:48:43 +0800
committerruki <[email protected]>2017-09-05 16:48:43 +0800
commitfa7b871c4880fd8947e872a8fcef815de36ea358 (patch)
tree6f7150c4590c2ddf4ab939230c868f3818a65ade
parent59d673ea76a08ae2cbab83eaad82de915c8ee803 (diff)
add required package to target
-rw-r--r--tests/projects/requires/xmake.lua3
-rw-r--r--xmake/actions/require/install.lua19
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/projects/requires/xmake.lua b/tests/projects/requires/xmake.lua
index 9d8852735..fd67d64fb 100644
--- a/tests/projects/requires/xmake.lua
+++ b/tests/projects/requires/xmake.lua
@@ -46,3 +46,6 @@ target("console_c")
-- add files
add_files("src/*.c")
+ -- add packages
+ add_packages("tboox.tbox", "zlib-mbedtls")
+
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua
index 16d2aea0a..709289ed4 100644
--- a/xmake/actions/require/install.lua
+++ b/xmake/actions/require/install.lua
@@ -108,8 +108,25 @@ function main(requires)
action.install(instance)
end
+ -- fetch all local paclages
+ local packages_local = {}
+ for _, instance in ipairs(packages) do
+ if instance:phony() then
+ -- TODO
+ print(instance:fullname())
+ else
+ packages_local[instance:fullname()] = instance:fetch()
+ end
+ end
+
-- TODO add installed package infos to the given targets
- -- ...
+ for _, target in pairs(project.targets()) do
+ for _, opt in ipairs(target:options()) do
+ if opt:enabled() then
+ target:add(packages_local[opt:name()])
+ end
+ end
+ end
-- leave environment
environment.leave()