summaryrefslogtreecommitdiff
path: root/xmake/modules/package
diff options
context:
space:
mode:
authorAdel Vilkov <[email protected]>2019-04-14 17:55:18 +0300
committerAdel Vilkov <[email protected]>2019-04-14 17:55:18 +0300
commitba5f76ecdd4eb95ca942369fd9e52cf796beaa8b (patch)
tree08c8dd8311db83a8b13cd78d82e3e88967ecec04 /xmake/modules/package
parentf7d5a6a8d54df807badc1e9ce29a4fe5103c362f (diff)
First implementation of find_package for clib
Diffstat (limited to 'xmake/modules/package')
-rw-r--r--xmake/modules/package/manager/clib/find_package.lua22
-rw-r--r--xmake/modules/package/manager/clib/install_package.lua18
2 files changed, 35 insertions, 5 deletions
diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua
index 414093e33..d64884429 100644
--- a/xmake/modules/package/manager/clib/find_package.lua
+++ b/xmake/modules/package/manager/clib/find_package.lua
@@ -23,5 +23,25 @@ import("core.base.option")
import("core.project.config")
function main(name, opt)
--- TODO: Implement clib package search
+ -- check if a package marker file with install directory exists
+ local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages")
+ local marker_filename = string.gsub(name, "%/", "=")
+ local marker_path = path.join(cache_dir, marker_filename)
+ dprint("reading clib marker file for %s from %s", name, marker_filename)
+
+ if not io.exists(marker_filename) then
+ return
+ end
+
+ local marker_file = io.open(marker_path, "r")
+ if marker_file then
+ local install_path = marker_file:read("*all")
+ marker_file:close()
+ dprint("%s is installed to %s", name, install_path)
+
+ return {
+ headerdirs = { install_path },
+ includedirs = { install_path }
+ }
+ end
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
index b7f76cbce..250ef8b66 100644
--- a/xmake/modules/package/manager/clib/install_package.lua
+++ b/xmake/modules/package/manager/clib/install_package.lua
@@ -23,8 +23,8 @@ 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",
+-- @param name the package name, e.g. clib::clibs/[email protected]
+-- @param opt the options, .e.g { verbose = true, out_dir = "myDir",
-- save = false, save_dev = false }
--
-- @return true or false
@@ -35,10 +35,11 @@ function main(name, opt)
if not clib then
raise("clib not found!")
end
+
-- default options
local all_opts = {
verbose = true,
- out_dir = "deps",
+ out_dir = path.join(".xmake", "cache", "packages", ".clib"),
save = false,
save_dev = false
}
@@ -51,7 +52,7 @@ function main(name, opt)
local argv = {"install", name}
- local abs_out = all_opts.out_dir
+ local abs_out = path.join(os.projectdir(), all_opts.out_dir)
dprint("installing %s to %s", name, abs_out)
table.insert(argv, "-o " .. abs_out)
@@ -67,4 +68,13 @@ function main(name, opt)
-- do install
os.vrunv(clib.program, argv)
+
+ -- add a package marker file with install directory
+ local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages")
+ local marker_filename = string.gsub(name, "%/", "=")
+ local marker_path = path.join(cache_dir, marker_filename)
+ dprint("writing clib marker file for %s to %s", name, marker_filename)
+ local marker_file = io.open(marker_path, "w")
+ marker_file:write(abs_out)
+ marker_file:close()
end \ No newline at end of file