From 29b7e944629425f843ea65fa3231ba003f62d13c Mon Sep 17 00:00:00 2001 From: jingkaimori Date: Tue, 23 Jul 2024 14:29:28 +0800 Subject: fix error when qt.deploy.flags policy is a table --- xmake/rules/qt/install/mingw.lua | 22 +++++++++++++++++++++- xmake/rules/qt/install/windows.lua | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/xmake/rules/qt/install/mingw.lua b/xmake/rules/qt/install/mingw.lua index d3fce6990..d3fa02c6b 100644 --- a/xmake/rules/qt/install/mingw.lua +++ b/xmake/rules/qt/install/mingw.lua @@ -31,6 +31,26 @@ function _get_installdir(target) return installdir end +function _check_flag_is_release_or_debug(flags) + return flags:find("--debug", 1, true) or flags:find("--release", 1, true) +end + +function _check_flags_contain_release_or_debug(flags) + local type_of_flags = type(flags) + if type_of_flags == string then + return _check_flag_is_release_or_debug(flags) + elseif type_of_flags == table then + for _, flag in ipairs(flags) do + if _check_flag_is_release_or_debug(flags) then + return true + end + end + return false + else + return false + end +end + -- install application package for windows function main(target, opt) @@ -83,7 +103,7 @@ function main(target, opt) -- make sure user flags have priority over default local user_flags = target:values("qt.deploy.flags") - if not user_flags or not (user_flags:find("--debug", 1, true) or user_flags:find("--release", 1, true)) then + if not _check_flags_contain_release_or_debug(user_flags) then if is_mode("debug") then table.insert(argv, "--debug") else diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua index 06e61038b..9b7f012c6 100644 --- a/xmake/rules/qt/install/windows.lua +++ b/xmake/rules/qt/install/windows.lua @@ -31,6 +31,26 @@ function _get_installdir(target) return installdir end +function _check_flag_is_release_or_debug(flags) + return flags:find("--debug", 1, true) or flags:find("--release", 1, true) +end + +function _check_flags_contain_release_or_debug(flags) + local type_of_flags = type(flags) + if type_of_flags == string then + return _check_flag_is_release_or_debug(flags) + elseif type_of_flags == table then + for _, flag in ipairs(flags) do + if _check_flag_is_release_or_debug(flags) then + return true + end + end + return false + else + return false + end +end + -- install application package for windows function main(target, opt) @@ -93,7 +113,7 @@ function main(target, opt) -- make sure user flags have priority over default local user_flags = target:values("qt.deploy.flags") - if not user_flags or not (user_flags:find("--debug", 1, true) or user_flags:find("--release", 1, true)) then + if not _check_flags_contain_release_or_debug(user_flags) then if is_mode("debug") then table.insert(argv, "--debug") else -- cgit v1.3.1