summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-17 13:41:08 +0800
committerruki <[email protected]>2017-05-17 13:41:08 +0800
commitb9c4cc501cff6a48a77d32cb3cddf233e7c76bdf (patch)
tree7f2af0d6482eb4821992262eb21dc5fe7b804d2d
parent541bb082036726eecddc5a18e07c7569fb244acc (diff)
add some find_xx modules
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua2
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_programver.lua10
-rw-r--r--xmake/modules/lib/detect/find_curl.lua55
-rw-r--r--xmake/modules/lib/detect/find_git.lua55
-rw-r--r--xmake/modules/lib/detect/find_tar.lua55
-rw-r--r--xmake/modules/lib/detect/find_unzip.lua55
-rw-r--r--xmake/modules/lib/detect/find_wget.lua55
7 files changed, 281 insertions, 6 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index 5eaadfe9f..f7d19d616 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -122,8 +122,6 @@ end
--
function sandbox_lib_detect_find_program.main(name, dirs, check)
- -- TODO which name
-
-- get detect cache
local detectcache = cache(utils.ifelse(os.isfile(project.file()), "local.detect", "memory.detect"))
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
index fb00f7365..01ebeef4f 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
@@ -39,17 +39,19 @@ local raise = require("sandbox/modules/raise")
-- find program version
--
-- @param program the program
+-- @param command the version command, default: --version
-- @param parse the version parse script or lua match pattern
--
-- @return the version string
--
-- @code
-- local version = find_programver("ccache")
--- local version = find_programver("ccache", "(%d+%.?%d*%.?%d*.-)%s")
--- local version = find_programver("ccache", function (output) return output:match("(%d+%.?%d*%.?%d*.-)%s") end)
+-- local version = find_programver("ccache", "-v")
+-- local version = find_programver("ccache", "--version", "(%d+%.?%d*%.?%d*.-)%s")
+-- local version = find_programver("ccache", "--version", function (output) return output:match("(%d+%.?%d*%.?%d*.-)%s") end)
-- @endcode
--
-function sandbox_lib_detect_find_programver.main(program, parse)
+function sandbox_lib_detect_find_programver.main(program, command, parse)
-- get detect cache
local detectcache = cache(utils.ifelse(os.isfile(project.file()), "local.detect", "memory.detect"))
@@ -62,7 +64,7 @@ function sandbox_lib_detect_find_programver.main(program, parse)
end
-- attempt to get version output info
- local ok, outdata = os.iorunv(program, {"--version"})
+ local ok, outdata = os.iorunv(program, {command or "--version"})
-- find version info
if ok and outdata and #outdata > 0 then
diff --git a/xmake/modules/lib/detect/find_curl.lua b/xmake/modules/lib/detect/find_curl.lua
new file mode 100644
index 000000000..56fcee857
--- /dev/null
+++ b/xmake/modules/lib/detect/find_curl.lua
@@ -0,0 +1,55 @@
+--!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_curl.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find curl
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local git = find_curl()
+-- local git, version = find_curl({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("curl", { "/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
diff --git a/xmake/modules/lib/detect/find_git.lua b/xmake/modules/lib/detect/find_git.lua
new file mode 100644
index 000000000..de34651ec
--- /dev/null
+++ b/xmake/modules/lib/detect/find_git.lua
@@ -0,0 +1,55 @@
+--!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_git.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find git
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local git = find_git()
+-- local git, version = find_git({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("git", { "/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
diff --git a/xmake/modules/lib/detect/find_tar.lua b/xmake/modules/lib/detect/find_tar.lua
new file mode 100644
index 000000000..b785b2d1d
--- /dev/null
+++ b/xmake/modules/lib/detect/find_tar.lua
@@ -0,0 +1,55 @@
+--!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_tar.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find tar
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local tar = find_tar()
+-- local tar, version = find_tar({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("tar", { "/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
diff --git a/xmake/modules/lib/detect/find_unzip.lua b/xmake/modules/lib/detect/find_unzip.lua
new file mode 100644
index 000000000..87c49e888
--- /dev/null
+++ b/xmake/modules/lib/detect/find_unzip.lua
@@ -0,0 +1,55 @@
+--!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_unzip.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find unzip
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local unzip = find_unzip()
+-- local unzip, version = find_unzip({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("unzip", { "/usr/bin", "/usr/local/bin"}, "-v")
+
+ -- find program version
+ local version = nil
+ if argv and argv.version then
+ version = find_programver(program, "-v")
+ end
+
+ -- ok?
+ return program, version
+end
diff --git a/xmake/modules/lib/detect/find_wget.lua b/xmake/modules/lib/detect/find_wget.lua
new file mode 100644
index 000000000..5c0891327
--- /dev/null
+++ b/xmake/modules/lib/detect/find_wget.lua
@@ -0,0 +1,55 @@
+--!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_wget.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find wget
+--
+-- @param argv the arguments, .e.g {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local wget = find_wget()
+-- local wget, version = find_wget({version = true})
+--
+-- @endcode
+--
+function main(argv)
+
+ -- find program
+ local program = find_program("wget", { "/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