summaryrefslogtreecommitdiff
path: root/xmake/modules/devel/package/manager.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-20 22:36:46 +0800
committerruki <[email protected]>2017-09-20 09:40:39 +0800
commit218e2711e1afacd334ce50b37b0fa2d2db573e8e (patch)
tree1f335873793c96d5e3cd1e9e9d149bb3fcba0bef /xmake/modules/devel/package/manager.lua
parent8edce1f3f7f2e779eb3bf66702d4b5271e82a63b (diff)
add some install scripts for package manager
Diffstat (limited to 'xmake/modules/devel/package/manager.lua')
-rw-r--r--xmake/modules/devel/package/manager.lua30
1 files changed, 29 insertions, 1 deletions
diff --git a/xmake/modules/devel/package/manager.lua b/xmake/modules/devel/package/manager.lua
index e05ae0c29..f927c263d 100644
--- a/xmake/modules/devel/package/manager.lua
+++ b/xmake/modules/devel/package/manager.lua
@@ -23,8 +23,36 @@
--
-- imports
-import("core.base.option")
+import("apt")
+import("yum")
+import("brew")
+import("pacman")
-- install package using third-party package manager
+--
+-- @param name the package name
+-- @param opt the options, .e.g {verbose = true, brew = "the package name in brew", pacman = "xxx", apt = "xxx"}
+--
+--
function install(name, opt)
+
+ -- init scripts
+ local scripts = {}
+ local host = os.host()
+ if host == "macosx" then
+ table.insert(scripts, brew.install)
+ elseif host == "linux" then
+ table.insert(scripts, apt.install)
+ table.insert(scripts, yum.install)
+ table.insert(scripts, pacman.install)
+ table.insert(scripts, brew.install)
+ end
+ assert(#scripts > 0, "package manager not found!")
+
+ -- run install script
+ for _, script in ipairs(scripts) do
+ if script(name, opt) then
+ break
+ end
+ end
end