diff options
| author | ruki <[email protected]> | 2017-06-16 15:45:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-16 15:45:31 +0800 |
| commit | b3cc1e1c42d8b367f2d0b1a93c236abe1cc94b34 (patch) | |
| tree | 206f6249f3f61d856ecbfb731661a2514923a91f /xmake/modules/detect | |
| parent | 4ce04f4a25ac9fa21e19ae4c568d7a253959680a (diff) | |
replace old find compiler scripts and fix string.endswith
Diffstat (limited to 'xmake/modules/detect')
33 files changed, 181 insertions, 31 deletions
diff --git a/xmake/modules/detect/tool/find_7z.lua b/xmake/modules/detect/tool/find_7z.lua index 58a4ea24e..bc5c3d340 100644 --- a/xmake/modules/detect/tool/find_7z.lua +++ b/xmake/modules/detect/tool/find_7z.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("7z", {}, "--help") + local program = find_program(opt.program or "7z", opt.pathes, opt.check or "--help") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_ar.lua b/xmake/modules/detect/tool/find_ar.lua index 2cb78ddff..6bbf840c5 100644 --- a/xmake/modules/detect/tool/find_ar.lua +++ b/xmake/modules/detect/tool/find_ar.lua @@ -66,5 +66,5 @@ function main(opt) opt = opt or {} -- find program - return find_program(opt.program or "ar", {}, _check) + return find_program(opt.program or "ar", opt.pathes, opt.check or _check) end diff --git a/xmake/modules/detect/tool/find_brew.lua b/xmake/modules/detect/tool/find_brew.lua index 07fb8dae6..e4c07403f 100644 --- a/xmake/modules/detect/tool/find_brew.lua +++ b/xmake/modules/detect/tool/find_brew.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("brew") + local program = find_program(opt.program or "brew", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_ccache.lua b/xmake/modules/detect/tool/find_ccache.lua index c32bbc4b6..9e4fe4aa6 100644 --- a/xmake/modules/detect/tool/find_ccache.lua +++ b/xmake/modules/detect/tool/find_ccache.lua @@ -45,7 +45,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "ccache") + local program = find_program(opt.program or "ccache", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_cl.lua b/xmake/modules/detect/tool/find_cl.lua index 8287120f9..3ab7cf5c1 100644 --- a/xmake/modules/detect/tool/find_cl.lua +++ b/xmake/modules/detect/tool/find_cl.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "cl.exe", {}, function (program) os.run(program) end) + local program = find_program(opt.program or "cl.exe", opt.pathes, opt.check or function (program) os.run(program) end) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_clang.lua b/xmake/modules/detect/tool/find_clang.lua index 1de30f6a9..5e1dc95d4 100644 --- a/xmake/modules/detect/tool/find_clang.lua +++ b/xmake/modules/detect/tool/find_clang.lua @@ -45,7 +45,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "clang") + local program = find_program(opt.program or "clang", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_clangxx.lua b/xmake/modules/detect/tool/find_clangxx.lua index c7d9f45d1..77e80304f 100644 --- a/xmake/modules/detect/tool/find_clangxx.lua +++ b/xmake/modules/detect/tool/find_clangxx.lua @@ -45,7 +45,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "clang++") + local program = find_program(opt.program or "clang++", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_curl.lua b/xmake/modules/detect/tool/find_curl.lua index 3b49247ef..a5ba49e20 100644 --- a/xmake/modules/detect/tool/find_curl.lua +++ b/xmake/modules/detect/tool/find_curl.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("curl") + local program = find_program(opt.program or "curl", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_dmd.lua b/xmake/modules/detect/tool/find_dmd.lua index fe47fc618..f244c0ad0 100644 --- a/xmake/modules/detect/tool/find_dmd.lua +++ b/xmake/modules/detect/tool/find_dmd.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "dmd") + local program = find_program(opt.program or "dmd", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_doxygen.lua b/xmake/modules/detect/tool/find_doxygen.lua index 3b3a6bee4..5824c574c 100644 --- a/xmake/modules/detect/tool/find_doxygen.lua +++ b/xmake/modules/detect/tool/find_doxygen.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("doxygen", { "/usr/bin", "/usr/local/bin"}) + local program = find_program(opt.program or "doxygen", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gcc.lua b/xmake/modules/detect/tool/find_gcc.lua index 0076d328f..d7cbce7d2 100644 --- a/xmake/modules/detect/tool/find_gcc.lua +++ b/xmake/modules/detect/tool/find_gcc.lua @@ -45,7 +45,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "gcc") + local program = find_program(opt.program or "gcc", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gccgo.lua b/xmake/modules/detect/tool/find_gccgo.lua index eaff5e3ea..a12be3067 100644 --- a/xmake/modules/detect/tool/find_gccgo.lua +++ b/xmake/modules/detect/tool/find_gccgo.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "gccgo") + local program = find_program(opt.program or "gccgo", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gdb.lua b/xmake/modules/detect/tool/find_gdb.lua index ff206288c..3e698022a 100644 --- a/xmake/modules/detect/tool/find_gdb.lua +++ b/xmake/modules/detect/tool/find_gdb.lua @@ -46,7 +46,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "gdb") + local program = find_program(opt.program or "gdb", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gdc.lua b/xmake/modules/detect/tool/find_gdc.lua index a094cf7ee..a2b2b4c9a 100644 --- a/xmake/modules/detect/tool/find_gdc.lua +++ b/xmake/modules/detect/tool/find_gdc.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "gdc") + local program = find_program(opt.program or "gdc", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_git.lua b/xmake/modules/detect/tool/find_git.lua index 12f08978d..b21455b0c 100644 --- a/xmake/modules/detect/tool/find_git.lua +++ b/xmake/modules/detect/tool/find_git.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("git") + local program = find_program(opt.program or "git", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_go.lua b/xmake/modules/detect/tool/find_go.lua index 9932f73ba..0b1b9103e 100644 --- a/xmake/modules/detect/tool/find_go.lua +++ b/xmake/modules/detect/tool/find_go.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "go", {}, "version") + local program = find_program(opt.program or "go", opt.pathes, opt.check or "version") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gxx.lua b/xmake/modules/detect/tool/find_gxx.lua index a58cfe75f..5ab35fa44 100644 --- a/xmake/modules/detect/tool/find_gxx.lua +++ b/xmake/modules/detect/tool/find_gxx.lua @@ -45,7 +45,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "g++") + local program = find_program(opt.program or "g++", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gzip.lua b/xmake/modules/detect/tool/find_gzip.lua index d1b286bba..95d364971 100644 --- a/xmake/modules/detect/tool/find_gzip.lua +++ b/xmake/modules/detect/tool/find_gzip.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("gzip") + local program = find_program(opt.program or "gzip", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_ldc2.lua b/xmake/modules/detect/tool/find_ldc2.lua index 77df85852..8b2f42c5d 100644 --- a/xmake/modules/detect/tool/find_ldc2.lua +++ b/xmake/modules/detect/tool/find_ldc2.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "ldc2") + local program = find_program(opt.program or "ldc2", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_lib.lua b/xmake/modules/detect/tool/find_lib.lua index 5b6545f40..107c33cbb 100644 --- a/xmake/modules/detect/tool/find_lib.lua +++ b/xmake/modules/detect/tool/find_lib.lua @@ -45,7 +45,7 @@ function main(opt) -- find program local verinfo = nil - local program = find_program(opt.program or "lib.exe", {}, function (program) + local program = find_program(opt.program or "lib.exe", opt.pathes, opt.check or function (program) -- make an stub source file local libraryfile = os.tmpfile() .. ".lib" diff --git a/xmake/modules/detect/tool/find_link.lua b/xmake/modules/detect/tool/find_link.lua index 209fa1300..d30fe6fbe 100644 --- a/xmake/modules/detect/tool/find_link.lua +++ b/xmake/modules/detect/tool/find_link.lua @@ -45,7 +45,7 @@ function main(opt) -- find program local verinfo = nil - local program = find_program(opt.program or "link.exe", {}, function (program) + local program = find_program(opt.program or "link.exe", opt.pathes, opt.check or function (program) -- make an stub source file local binaryfile = os.tmpfile() .. ".exe" diff --git a/xmake/modules/detect/tool/find_lipo.lua b/xmake/modules/detect/tool/find_lipo.lua index 85d1fba76..27be94c1f 100644 --- a/xmake/modules/detect/tool/find_lipo.lua +++ b/xmake/modules/detect/tool/find_lipo.lua @@ -44,5 +44,5 @@ function main(opt) opt = opt or {} -- find program - return find_program(opt.program or "lipo", {}, function (program) os.run("%s -info %s", program, os.programfile()) end) + return find_program(opt.program or "lipo", opt.pathes, opt.check or function (program) os.run("%s -info %s", program, os.programfile()) end) end diff --git a/xmake/modules/detect/tool/find_lldb.lua b/xmake/modules/detect/tool/find_lldb.lua index 3c15c2fb1..8a6e86341 100644 --- a/xmake/modules/detect/tool/find_lldb.lua +++ b/xmake/modules/detect/tool/find_lldb.lua @@ -46,7 +46,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "lldb") + local program = find_program(opt.program or "lldb", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_ml.lua b/xmake/modules/detect/tool/find_ml.lua index b4407e452..da3f026ac 100644 --- a/xmake/modules/detect/tool/find_ml.lua +++ b/xmake/modules/detect/tool/find_ml.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "ml.exe", {}, function (program) os.run(program) end) + local program = find_program(opt.program or "ml.exe", opt.pathes, opt.check or function (program) os.run(program) end) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_ml64.lua b/xmake/modules/detect/tool/find_ml64.lua new file mode 100644 index 000000000..d2377c19e --- /dev/null +++ b/xmake/modules/detect/tool/find_ml64.lua @@ -0,0 +1,59 @@ +--!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_ml64.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find ml64 +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local ml64 = find_ml64() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "ml64.exe", opt.pathes, opt.check or function (program) os.run(program) end) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, function () local _, info = os.iorun(program); return info end, + function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end) + end + + -- ok? + return program, version +end + diff --git a/xmake/modules/detect/tool/find_rc.lua b/xmake/modules/detect/tool/find_rc.lua new file mode 100644 index 000000000..cbd24e82a --- /dev/null +++ b/xmake/modules/detect/tool/find_rc.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_rc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find rc +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local rc = find_rc() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "rc.exe", opt.pathes, "-?") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "-?", function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end) + end + + -- ok? + return program, version +end + diff --git a/xmake/modules/detect/tool/find_rustc.lua b/xmake/modules/detect/tool/find_rustc.lua index 938c6c180..d01380d72 100644 --- a/xmake/modules/detect/tool/find_rustc.lua +++ b/xmake/modules/detect/tool/find_rustc.lua @@ -44,7 +44,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "rustc") + local program = find_program(opt.program or "rustc", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_sudo.lua b/xmake/modules/detect/tool/find_sudo.lua index 3d0082b17..3306f2fd3 100644 --- a/xmake/modules/detect/tool/find_sudo.lua +++ b/xmake/modules/detect/tool/find_sudo.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("sudo", {}, "-h") + local program = find_program(opt.program or "sudo", opt.pathes, opt.check or "-h") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_swiftc.lua b/xmake/modules/detect/tool/find_swiftc.lua index cc9bdf4d6..cf9373739 100644 --- a/xmake/modules/detect/tool/find_swiftc.lua +++ b/xmake/modules/detect/tool/find_swiftc.lua @@ -45,7 +45,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "swiftc") + local program = find_program(opt.program or "swiftc", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_tar.lua b/xmake/modules/detect/tool/find_tar.lua index e091d3204..f37843171 100644 --- a/xmake/modules/detect/tool/find_tar.lua +++ b/xmake/modules/detect/tool/find_tar.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("tar") + local program = find_program(opt.program or "tar", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_unzip.lua b/xmake/modules/detect/tool/find_unzip.lua index 19c30f517..c3533cd54 100644 --- a/xmake/modules/detect/tool/find_unzip.lua +++ b/xmake/modules/detect/tool/find_unzip.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("unzip", {}, "-v") + local program = find_program(opt.program or "unzip", opt.pathes, opt.check or "-v") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_wget.lua b/xmake/modules/detect/tool/find_wget.lua index 59a9c7d63..5f8dd7594 100644 --- a/xmake/modules/detect/tool/find_wget.lua +++ b/xmake/modules/detect/tool/find_wget.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("wget") + local program = find_program(opt.program or "wget", opt.pathes, opt.check) -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_zip.lua b/xmake/modules/detect/tool/find_zip.lua index b424d6e99..71405d3ff 100644 --- a/xmake/modules/detect/tool/find_zip.lua +++ b/xmake/modules/detect/tool/find_zip.lua @@ -40,9 +40,12 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) + + -- init options + opt = opt or {} -- find program - local program = find_program("zip", {}, "-v") + local program = find_program(opt.program or "zip", opt.pathes, opt.check or "-v") -- find program version local version = nil |
