diff options
| author | ruki <[email protected]> | 2019-04-17 23:45:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-04-17 16:35:23 +0800 |
| commit | fd5f1f5a5b02967c13253dd7837abdb060d80cad (patch) | |
| tree | 9a89e661f847143ff18eb6cda54a4694ccd31be8 /xmake/modules/lib/detect | |
| parent | 0d6c065b3b20d98ae8a986a179f792923be3dbc3 (diff) | |
add check_csnippets and check_cxxsnippets
Diffstat (limited to 'xmake/modules/lib/detect')
| -rw-r--r-- | xmake/modules/lib/detect/check_csnippets.lua | 50 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/check_cxxsnippets.lua | 50 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cfuncs.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/has_cxxfuncs.lua | 11 |
4 files changed, 108 insertions, 14 deletions
diff --git a/xmake/modules/lib/detect/check_csnippets.lua b/xmake/modules/lib/detect/check_csnippets.lua new file mode 100644 index 000000000..364b09f51 --- /dev/null +++ b/xmake/modules/lib/detect/check_csnippets.lua @@ -0,0 +1,50 @@ +--!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 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file check_csnippets.lua +-- + +-- imports +import("lib.detect.check_cxsnippets") + +-- check the given c snippets? +-- +-- @param snippets the snippets +-- @param opt the argument options +-- .e.g +-- { verbose = false, target = [target|option] +-- , types = {"wchar_t", "char*"}, includes = "stdio.h", funcs = {"sigsetjmp", "sigsetjmp((void*)0, 0)"} +-- , configs = {defines = "xx", cxflags = ""}} +-- +-- funcs: +-- sigsetjmp +-- sigsetjmp((void*)0, 0) +-- sigsetjmp{sigsetjmp((void*)0, 0);} +-- sigsetjmp{int a = 0; sigsetjmp((void*)a, a);} +-- +-- @return true or false +-- +-- @code +-- local ok = check_csnippets("void test() {}") +-- local ok = check_csnippets({"void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"}) +-- local ok = check_csnippets({snippet_name = "void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"}) +-- @endcode +-- +function main(snippets, opt) + return check_cxsnippets(snippets, table.join(table.wrap(opt), {sourcekind = "cc"})) +end + diff --git a/xmake/modules/lib/detect/check_cxxsnippets.lua b/xmake/modules/lib/detect/check_cxxsnippets.lua new file mode 100644 index 000000000..06d9f6c4b --- /dev/null +++ b/xmake/modules/lib/detect/check_cxxsnippets.lua @@ -0,0 +1,50 @@ +--!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 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file check_cxxsnippets.lua +-- + +-- imports +import("lib.detect.check_cxsnippets") + +-- check the given c++ snippets? +-- +-- @param snippets the snippets +-- @param opt the argument options +-- .e.g +-- { verbose = false, target = [target|option] +-- , types = {"wchar_t", "char*"}, includes = "stdio.h", funcs = {"sigsetjmp", "sigsetjmp((void*)0, 0)"} +-- , configs = {defines = "xx", cxflags = ""}} +-- +-- funcs: +-- sigsetjmp +-- sigsetjmp((void*)0, 0) +-- sigsetjmp{sigsetjmp((void*)0, 0);} +-- sigsetjmp{int a = 0; sigsetjmp((void*)a, a);} +-- +-- @return true or false +-- +-- @code +-- local ok = check_cxxsnippets("void test() {}") +-- local ok = check_cxxsnippets({"void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"}) +-- local ok = check_cxxsnippets({snippet_name = "void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"}) +-- @endcode +-- +function main(snippets, opt) + return check_cxsnippets(snippets, table.join(table.wrap(opt), {sourcekind = "cxx"})) +end + diff --git a/xmake/modules/lib/detect/has_cfuncs.lua b/xmake/modules/lib/detect/has_cfuncs.lua index f497e7b0a..af1447852 100644 --- a/xmake/modules/lib/detect/has_cfuncs.lua +++ b/xmake/modules/lib/detect/has_cfuncs.lua @@ -19,7 +19,7 @@ -- -- imports -import("lib.detect.check_cxsnippets") +import("lib.detect.check_csnippets") -- has the given c funcs? -- @@ -44,13 +44,10 @@ import("lib.detect.check_cxsnippets") function main(funcs, opt) -- init options - opt = opt or {} - - -- init funcs - opt.sourcekind = "cc" - opt.funcs = funcs + opt = opt or {} + opt.funcs = funcs -- has funcs? local name = opt.name or "has_cfuncs" - return check_cxsnippets({[name] = ""}, opt) + return check_csnippets({[name] = ""}, opt) end diff --git a/xmake/modules/lib/detect/has_cxxfuncs.lua b/xmake/modules/lib/detect/has_cxxfuncs.lua index 37dfa8c98..6a545267a 100644 --- a/xmake/modules/lib/detect/has_cxxfuncs.lua +++ b/xmake/modules/lib/detect/has_cxxfuncs.lua @@ -19,7 +19,7 @@ -- -- imports -import("lib.detect.check_cxsnippets") +import("lib.detect.check_cxxsnippets") -- has the given c++ funcs? -- @@ -44,13 +44,10 @@ import("lib.detect.check_cxsnippets") function main(funcs, opt) -- init options - opt = opt or {} - - -- init funcs - opt.sourcekind = "cxx" - opt.funcs = funcs + opt = opt or {} + opt.funcs = funcs -- has funcs? local name = opt.name or "has_cxxfuncs" - return check_cxsnippets({[name] = ""}, opt) + return check_cxxsnippets({[name] = ""}, opt) end |
