summaryrefslogtreecommitdiff
path: root/xmake/modules/lib
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-17 11:51:34 +0800
committerruki <[email protected]>2017-05-17 11:51:34 +0800
commitcfb1dd7f7b3ece03825c686651c2f88ac65b33d5 (patch)
tree5f25b6568f076d9b21120865934c8ef656e86cae /xmake/modules/lib
parentbeb2fe1f4981307bf75a1552acd744771ad750d8 (diff)
parse program version
Diffstat (limited to 'xmake/modules/lib')
-rw-r--r--xmake/modules/lib/detect/find_ccache.lua30
1 files changed, 26 insertions, 4 deletions
diff --git a/xmake/modules/lib/detect/find_ccache.lua b/xmake/modules/lib/detect/find_ccache.lua
index b90856c19..55f0d5a95 100644
--- a/xmake/modules/lib/detect/find_ccache.lua
+++ b/xmake/modules/lib/detect/find_ccache.lua
@@ -24,10 +24,32 @@
-- imports
import("lib.detect.find_program")
+import("lib.detect.find_programver")
-- find ccache
-function main()
- return find_program("ccache", { "/usr/bin",
- "/usr/local/bin"}
- , function (program) os.run("%s -h", program) end)
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local ccache = find_ccache()
+-- local ccache, version = find_ccache({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("ccache", { "/usr/bin", "/usr/local/bin"})
+
+ -- find program version
+ local version = nil
+ if argv and argv.version then
+ version = find_programver(program)
+ end
+
+ -- ok?
+ return program, version
end