summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdel Vilkov <[email protected]>2019-04-14 12:48:45 +0300
committerAdel Vilkov <[email protected]>2019-04-14 12:48:45 +0300
commitf7d5a6a8d54df807badc1e9ce29a4fe5103c362f (patch)
tree5aa155d4c56c3148fb8fc1ec46bb4708e22aeb3a
parent85cb688e30f996c5ac1036ec99b6c7c1a45cb035 (diff)
Implemented package installation for clib
-rw-r--r--xmake/modules/package/manager/clib/find_package.lua27
-rw-r--r--xmake/modules/package/manager/clib/install_package.lua70
-rw-r--r--xmake/modules/package/manager/install_package.lua2
3 files changed, 98 insertions, 1 deletions
diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua
new file mode 100644
index 000000000..414093e33
--- /dev/null
+++ b/xmake/modules/package/manager/clib/find_package.lua
@@ -0,0 +1,27 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author Adel Vilkov (aka RaZeR-RBI)
+-- @file find_package.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+
+function main(name, opt)
+-- TODO: Implement clib package search
+end \ No newline at end of file
diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua
new file mode 100644
index 000000000..b7f76cbce
--- /dev/null
+++ b/xmake/modules/package/manager/clib/install_package.lua
@@ -0,0 +1,70 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author Adel Vilkov (aka RaZeR-RBI)
+-- @file install_package.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("lib.detect.find_tool")
+-- install package
+-- @param name the package name, e.g. clib::clibs/[email protected]
+-- @param opt the options, .e.g { verbose = true, out_dir = "deps",
+-- save = false, save_dev = false }
+--
+-- @return true or false
+--
+function main(name, opt)
+ -- find clib
+ local clib = find_tool("clib")
+ if not clib then
+ raise("clib not found!")
+ end
+ -- default options
+ local all_opts = {
+ verbose = true,
+ out_dir = "deps",
+ save = false,
+ save_dev = false
+ }
+ -- copy specified options
+ if opt then
+ for k, v in ipairs(opt) do
+ all_opts[k] = v
+ end
+ end
+
+ local argv = {"install", name}
+
+ local abs_out = all_opts.out_dir
+ dprint("installing %s to %s", name, abs_out)
+ table.insert(argv, "-o " .. abs_out)
+
+ if not all_opts.verbose then
+ table.insert(argv, "-q")
+ end
+ if all_opts.save then
+ table.insert(argv, "--save")
+ end
+ if all_opts.save_dev then
+ table.insert(argv, "--save-dev")
+ end
+
+ -- do install
+ os.vrunv(clib.program, argv)
+end \ No newline at end of file
diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua
index b46062c42..62256ebb6 100644
--- a/xmake/modules/package/manager/install_package.lua
+++ b/xmake/modules/package/manager/install_package.lua
@@ -31,7 +31,7 @@ function _install_package(manager_name, package_name, opt)
end
-- get suitable package managers
- local managers = {}
+ local managers = {"clib"}
if is_host("windows") then
table.insert(managers, "pacman") -- msys/mingw
elseif is_host("linux") then