diff options
| author | zeromake <[email protected]> | 2023-11-01 23:18:56 +0800 |
|---|---|---|
| committer | zeromake <[email protected]> | 2023-11-01 23:18:56 +0800 |
| commit | 63a5c56f2b26a46729800d1447b721604ffbcbf3 (patch) | |
| tree | 5571d8d3b63bf7593b0f58c4c5a5a85f7e71b79a | |
| parent | 811a13462d38401c6d22810854c91b42c5c02d7f (diff) | |
fix: code clear and add commit
| -rw-r--r-- | xmake/includes/check/check_sizeof.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/check_cxsnippets.lua | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/xmake/includes/check/check_sizeof.lua b/xmake/includes/check/check_sizeof.lua index 52d407be0..3ae1dafea 100644 --- a/xmake/includes/check/check_sizeof.lua +++ b/xmake/includes/check/check_sizeof.lua @@ -12,22 +12,26 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- --- Copyright (C) 2023-present, TBOOX Open Source Group. +-- Copyright (C) 2023, TBOOX Open Source Group. -- -- @author zeromake -- @file check_sizeof.lua -- --- check c sizeof(type) add to macro definition +-- check c sizeof(type) add to macro definition support cross compile +-- +-- from https://github.com/xmake-io/xmake/issues/4345 -- -- e.g. -- --- check_sizeof("SIZEOF_WCHAR_T", "wchar_t") +-- check_sizeof("SIZEOF_LONG", "long") => SIZEOF_LONG=4 +-- +-- configvar_check_sizeof("SIZEOF_LONG", "long") => #define SIZEOF_LONG 4 -- local binary_match = 'INFO:size%[(%d+)%]' local function _match(content) - local match = string.match(content, binary_match) + local match = content:match(binary_match) if match == nil then return false end @@ -62,7 +66,7 @@ function check_sizeof(definition, typename, opt) interp_save_scope() option(optname) set_showmenu(false) - add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind=_match}) + add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind = _match}) if opt.links then add_links(opt.links) end @@ -111,7 +115,7 @@ function configvar_check_sizeof(definition, typename, opt) interp_save_scope() option(optname) set_showmenu(false) - add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind=_match}) + add_csnippets(definition, check_sizeof_template:gsub('${TYPE}', typename), {binaryfind = _match}) if opt.default == nil then set_configvar(defname, defval or 1, {quote = opt.quote}) end diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua index b3b7cde69..d74499ea3 100644 --- a/xmake/modules/lib/detect/check_cxsnippets.lua +++ b/xmake/modules/lib/detect/check_cxsnippets.lua @@ -258,9 +258,7 @@ function main(snippets, opt) end end if opt.binaryfind then - local f = io.open(binaryfile, "rb") - local content = f:read("*a") - f:close() + local content = io.readfile(binaryfile, {encoding = "binary"}) return opt.binaryfind(content) end return true |
