diff options
| author | ruki <[email protected]> | 2017-06-23 23:26:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-23 23:26:34 +0800 |
| commit | 918093af27a737b7dee986f5b70ca4d43cb1fb2f (patch) | |
| tree | a0bb743928564c0be7a1da95874b928f110cdeb0 /xmake/modules/lib/detect/has_snippets.lua | |
| parent | b359250e9cdec42b2503ee3f148c52d0e35a32b4 (diff) | |
add has_ctypes
Diffstat (limited to 'xmake/modules/lib/detect/has_snippets.lua')
| -rw-r--r-- | xmake/modules/lib/detect/has_snippets.lua | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/xmake/modules/lib/detect/has_snippets.lua b/xmake/modules/lib/detect/has_snippets.lua index 6ae58489e..86036c7e7 100644 --- a/xmake/modules/lib/detect/has_snippets.lua +++ b/xmake/modules/lib/detect/has_snippets.lua @@ -24,24 +24,12 @@ -- imports import("core.base.option") -import("core.language.language") import("core.tool.compiler") +import("core.language.language") -- has this snippet? function _has_snippet(snippet, opt) - -- init cache and key - local key = opt.name - local results = _g._RESULTS or {} - - -- get result from the cache first - if key ~= nil then - local result = results[key] - if result ~= nil then - return result - end - end - -- get the source kind local sourcekind = opt.sourcekind if not sourcekind and opt.extension then @@ -54,6 +42,19 @@ function _has_snippet(snippet, opt) extension = table.wrap(language.sourcekinds()[opt.sourcekind])[1] or ".c" end + -- init cache and key + local key = opt.name + local results = _g._RESULTS or {} + + -- get result from the cache first + if key ~= nil then + key = key .. sourcekind + local result = results[key] + if result ~= nil then + return result + end + end + -- make the source file local sourcefile = os.tmpfile() .. extension local objectfile = os.tmpfile() .. ".o" @@ -68,7 +69,7 @@ function _has_snippet(snippet, opt) -- trace if opt.name and (option.get("verbose") or opt.verbose) then - cprint("checking for the snippets %s ... %s", opt.name, ifelse(result, "${green}ok", "${red}no")) + cprint("checking for the %s %s ... %s", opt.kind or "snippet", opt.name, ifelse(result, "${green}ok", "${red}no")) end -- save result to cache @@ -81,10 +82,10 @@ function _has_snippet(snippet, opt) return result end --- has the given snippets for the current tool? +-- has the given snippets? -- -- @param snippets the snippets --- @param opt the argument options, .e.g {name = "", verbose = false, target = [target|option], sourcekind = "[cc|cxx|mm|mxx|sc|dc|gc|rc]", extension = "[.c|.cpp|.m|.mm|.swift|.d|.go|.rs]"} +-- @param opt the argument options, .e.g {kind = "snippet", name = "", verbose = false, target = [target|option], sourcekind = "[cc|cxx|mm|mxx|sc|dc|gc|rc]", extension = "[.c|.cpp|.m|.mm|.swift|.d|.go|.rs]"} -- -- @return true or false -- |
