summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/find_lib.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-22 00:40:49 +0800
committerruki <[email protected]>2017-09-21 22:04:55 +0800
commitab5456ca3457c7b59de6cc590068d91d7749d096 (patch)
tree329742618ea8ef110542f27fa48f4226a20dde9c /xmake/modules/detect/tools/find_lib.lua
parent034185734b5bc91f8188c15c9e02b0ce8ebaa850 (diff)
modify find_program interface
Diffstat (limited to 'xmake/modules/detect/tools/find_lib.lua')
-rw-r--r--xmake/modules/detect/tools/find_lib.lua20
1 files changed, 12 insertions, 8 deletions
diff --git a/xmake/modules/detect/tools/find_lib.lua b/xmake/modules/detect/tools/find_lib.lua
index ae493e879..29fced8d0 100644
--- a/xmake/modules/detect/tools/find_lib.lua
+++ b/xmake/modules/detect/tools/find_lib.lua
@@ -40,12 +40,12 @@ import("lib.detect.find_programver")
--
function main(opt)
- -- init options
- opt = opt or {}
-
- -- find program
+ -- init version info first
local verinfo = nil
- local program = find_program(opt.program or "lib.exe", opt.pathes, opt.check or function (program)
+
+ -- init options
+ opt = opt or {}
+ opt.check = opt.check or function (program)
-- make an stub source file
local libraryfile = os.tmpfile() .. ".lib"
@@ -62,13 +62,17 @@ function main(opt)
os.rm(objectfile)
os.rm(sourcefile)
os.rm(libraryfile)
- end)
+ end
+ opt.command = opt.command or function () return verinfo end
+ opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
+
+ -- find program
+ local program = find_program(opt.program or "lib.exe", opt)
-- find program version
local version = nil
if program and opt and opt.version then
- version = find_programver(program, function () return verinfo end,
- function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end)
+ version = find_programver(program, opt)
end
-- ok?