summaryrefslogtreecommitdiff
path: root/xmake/modules/detect/tools/find_bash.lua
diff options
context:
space:
mode:
authorxq114 <[email protected]>2021-04-05 10:58:21 +0800
committerxq114 <[email protected]>2021-04-05 10:58:21 +0800
commit3c2ca2356818dffe8c6b70e2fcf6f799a47927f2 (patch)
tree7f3a331040bdffa4a80e33a532d574836825a9f4 /xmake/modules/detect/tools/find_bash.lua
parentafbbe0900bd48341084c11bcf4e0120782dff6e5 (diff)
add find_bash.lua
Diffstat (limited to 'xmake/modules/detect/tools/find_bash.lua')
-rw-r--r--xmake/modules/detect/tools/find_bash.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/find_bash.lua b/xmake/modules/detect/tools/find_bash.lua
new file mode 100644
index 000000000..0c1322ad2
--- /dev/null
+++ b/xmake/modules/detect/tools/find_bash.lua
@@ -0,0 +1,61 @@
+--!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-present, TBOOX Open Source Group.
+--
+-- @author xq114
+-- @file find_bash.lua
+--
+
+-- imports
+import("lib.detect.find_tool")
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find bash
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local bash = find_bash()
+-- local bash, version = find_bash({version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- find bash from git for windows
+ if is_host("windows") then
+ opt.paths = opt.paths or {}
+ table.insert(opt.paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GitForWindows;InstallPath)\\bin")
+ end
+
+ -- find program
+ local program = find_program(opt.program or "bash", opt)
+
+ -- find program version
+ local version = nil
+ if program and opt and opt.version then
+ version = find_programver(program, opt)
+ end
+
+ -- ok?
+ return program, version
+end