summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-17 21:43:04 +0800
committerruki <[email protected]>2017-05-17 21:43:04 +0800
commitc315b83eb9a5b84aeab8fb1f93a9086664f5177e (patch)
tree34f49bfe3f37a309c24a62a6b6e417e631c1889f /xmake/modules
parentb406ed83128331bf9360154606fbcde2ca4f325d (diff)
add find gzip module
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/lib/detect/find_ccache.lua2
-rw-r--r--xmake/modules/lib/detect/find_git.lua2
-rw-r--r--xmake/modules/lib/detect/find_gzip.lua58
-rw-r--r--xmake/modules/lib/detect/find_tar.lua2
-rw-r--r--xmake/modules/lib/detect/find_unzip.lua2
-rw-r--r--xmake/modules/lib/detect/find_wget.lua2
6 files changed, 63 insertions, 5 deletions
diff --git a/xmake/modules/lib/detect/find_ccache.lua b/xmake/modules/lib/detect/find_ccache.lua
index 55f0d5a95..30348c6e6 100644
--- a/xmake/modules/lib/detect/find_ccache.lua
+++ b/xmake/modules/lib/detect/find_ccache.lua
@@ -46,7 +46,7 @@ function main(argv)
-- find program version
local version = nil
- if argv and argv.version then
+ if program and argv and argv.version then
version = find_programver(program)
end
diff --git a/xmake/modules/lib/detect/find_git.lua b/xmake/modules/lib/detect/find_git.lua
index de34651ec..00665d8be 100644
--- a/xmake/modules/lib/detect/find_git.lua
+++ b/xmake/modules/lib/detect/find_git.lua
@@ -46,7 +46,7 @@ function main(argv)
-- find program version
local version = nil
- if argv and argv.version then
+ if program and argv and argv.version then
version = find_programver(program)
end
diff --git a/xmake/modules/lib/detect/find_gzip.lua b/xmake/modules/lib/detect/find_gzip.lua
new file mode 100644
index 000000000..2ec660cfe
--- /dev/null
+++ b/xmake/modules/lib/detect/find_gzip.lua
@@ -0,0 +1,58 @@
+--!The Make-like Build Utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you 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 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_gzip.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find gzip
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local gzip = find_gzip()
+-- local gzip, version = find_gzip({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("gzip", { "/usr/bin", "/usr/local/bin"})
+
+ -- find program version
+ local version = nil
+ if program and argv and argv.version then
+ version = find_programver(program, function()
+ local outdata, errdata = os.iorunv(program, {"--version"})
+ return (outdata or "") .. (errdata or "")
+ end)
+ end
+
+ -- ok?
+ return program, version
+end
diff --git a/xmake/modules/lib/detect/find_tar.lua b/xmake/modules/lib/detect/find_tar.lua
index b785b2d1d..503701e0a 100644
--- a/xmake/modules/lib/detect/find_tar.lua
+++ b/xmake/modules/lib/detect/find_tar.lua
@@ -46,7 +46,7 @@ function main(argv)
-- find program version
local version = nil
- if argv and argv.version then
+ if program and argv and argv.version then
version = find_programver(program)
end
diff --git a/xmake/modules/lib/detect/find_unzip.lua b/xmake/modules/lib/detect/find_unzip.lua
index 87c49e888..006d18be2 100644
--- a/xmake/modules/lib/detect/find_unzip.lua
+++ b/xmake/modules/lib/detect/find_unzip.lua
@@ -46,7 +46,7 @@ function main(argv)
-- find program version
local version = nil
- if argv and argv.version then
+ if program and argv and argv.version then
version = find_programver(program, "-v")
end
diff --git a/xmake/modules/lib/detect/find_wget.lua b/xmake/modules/lib/detect/find_wget.lua
index 5c0891327..13b12c43e 100644
--- a/xmake/modules/lib/detect/find_wget.lua
+++ b/xmake/modules/lib/detect/find_wget.lua
@@ -46,7 +46,7 @@ function main(argv)
-- find program version
local version = nil
- if argv and argv.version then
+ if program and argv and argv.version then
version = find_programver(program)
end