diff options
| author | ruki <[email protected]> | 2019-01-11 00:33:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-01-10 21:20:24 +0800 |
| commit | 8fb4e12b6214cb8a21ce055c64e24bf0f47ce9e6 (patch) | |
| tree | 0c0e46353c80a08acbb62aef61d41b7ea0c4a2c7 /xmake/modules/lib/detect | |
| parent | 89271a60c4b4e56e9801dc11241b5d67cd3b2a2b (diff) | |
improve check_cxsnippets
Diffstat (limited to 'xmake/modules/lib/detect')
| -rw-r--r-- | xmake/modules/lib/detect/check_cxsnippets.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua index 56e1d9562..3239996be 100644 --- a/xmake/modules/lib/detect/check_cxsnippets.lua +++ b/xmake/modules/lib/detect/check_cxsnippets.lua @@ -93,7 +93,7 @@ function _sourcecode(snippets, opt) sourcecode = sourcecode .. "\n" -- add snippets - for _, snippet in ipairs(snippets) do + for _, snippet in pairs(snippets) do sourcecode = sourcecode .. "\n" .. snippet end sourcecode = sourcecode .. "\n" @@ -133,6 +133,7 @@ end -- @code -- local ok = check_cxsnippets("void test() {}") -- local ok = check_cxsnippets({"void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"}) +-- local ok = check_cxsnippets({snippet_name = "void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"}) -- @endcode -- function main(snippets, opt) @@ -200,19 +201,23 @@ function main(snippets, opt) if opt.verbose or option.get("verbose") or option.get("diagnosis") then local kind = ifelse(sourcekind == "cc", "c", "c++") if #includes > 0 then - cprint("${dim}checking for the %s includes %s ... %s", kind, table.concat(includes, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") + cprint("${dim}checking for the %s includes(%s) ... %s", kind, table.concat(includes, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") end if #types > 0 then - cprint("${dim}checking for the %s types %s ... %s", kind, table.concat(types, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") + cprint("${dim}checking for the %s types(%s) ... %s", kind, table.concat(types, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") end if #funcs > 0 then - cprint("${dim}checking for the %s funcs %s ... %s", kind, table.concat(funcs, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") + cprint("${dim}checking for the %s funcs(%s) ... %s", kind, table.concat(funcs, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") end if #links > 0 then - cprint("${dim}checking for the %s links %s ... %s", kind, table.concat(links, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") + cprint("${dim}checking for the %s links(%s) ... %s", kind, table.concat(links, ", "), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") end - for _, snippet in ipairs(snippets) do - cprint("${dim}checking for the %s snippet %s ... %s", kind, snippet:sub(1, 16), ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") + for idx_or_name, snippet in pairs(snippets) do + local name = idx_or_name + if type(name) == "number" then + name = snippet:sub(1, 16) + end + cprint("${dim}checking for the %s snippet(%s) ... %s", kind, name, ok and "${color.success}${text.success}" or "${color.nothing}${text.nothing}") end end if errors and #errors > 0 and option.get("diagnosis") then |
