summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/check_cxsnippets.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-03 00:36:46 +0800
committerruki <[email protected]>2023-11-03 00:36:46 +0800
commitd92d8ad1fda4d9605d08ae4c44271d9273642a93 (patch)
treef4737cb1df283336ed87c32c0962171cd8399331 /xmake/modules/lib/detect/check_cxsnippets.lua
parent8d73a80b51d05aa81b0aaf6da02824e33352ca57 (diff)
improve binary match
Diffstat (limited to 'xmake/modules/lib/detect/check_cxsnippets.lua')
-rw-r--r--xmake/modules/lib/detect/check_cxsnippets.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua
index 912345909..987e7f10e 100644
--- a/xmake/modules/lib/detect/check_cxsnippets.lua
+++ b/xmake/modules/lib/detect/check_cxsnippets.lua
@@ -240,7 +240,7 @@ function main(snippets, opt)
cprint("${dim}> %s", compiler.compcmd(sourcefile, objectfile, opt))
end
compiler.compile(sourcefile, objectfile, opt)
- if #links > 0 or opt.tryrun or opt.binaryfind then
+ if #links > 0 or opt.tryrun or opt.binary_match then
if option.get("diagnosis") then
cprint("${dim}> %s", linker.linkcmd("binary", {"cc", "cxx"}, objectfile, binaryfile, opt))
end
@@ -257,10 +257,11 @@ function main(snippets, opt)
os.vrun(binaryfile)
end
end
- if opt.binaryfind then
+ local binary_match = opt.binary_match
+ if binary_match then
local content = io.readfile(binaryfile, {encoding = "binary"})
- local match = content:match(opt.binaryfind)
- if match then
+ local match = type(binary_match) == "function" and binary_match(content) or content:match(binary_match)
+ if match ~= nil then
return true, match
end
end