From cab174afcbf6bfbb1f4cfd446406e95d4e3b00fa Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 13 Oct 2023 22:35:47 +0800 Subject: improve includes --- xmake/core/base/interpreter.lua | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'xmake/core/base/interpreter.lua') diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 6060fc319..109032e28 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -1686,15 +1686,33 @@ function interpreter:api_builtin_includes(...) local subpaths = table.join(...) local subpaths_matched = {} for _, subpath in ipairs(subpaths) do - -- find the given files from the project directory local found = false - local files = os.match(subpath, not subpath:endswith(".lua")) - if files and #files > 0 then - table.join2(subpaths_matched, files) - found = true - elseif not path.is_absolute(subpath) then - -- attempt to find files from programdir/includes/*.lua - files = os.files(path.join(os.programdir(), "includes", subpath)) + -- attempt to find files from programdir/includes/*.lua + -- e.g. includes("@builtin/check") + if subpath:startswith("@builtin/") then + local builtin_path = subpath:sub(10) + local files + if builtin_path:endswith(".lua") then + files = os.files(path.join(os.programdir(), "includes", builtin_path)) + else + files = os.files(path.join(os.programdir(), "includes", builtin_path, "xmake.lua")) + end + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + end + end + -- find the given files from the project directory + if not found then + local files = os.match(subpath, not subpath:endswith(".lua")) + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + end + end + -- attempt to find files from programdir/includes/*.lua (deprecated) + if not found and not path.is_absolute(subpath) then + local files = os.files(path.join(os.programdir(), "includes", subpath)) if files and #files > 0 then table.join2(subpaths_matched, files) found = true -- cgit v1.3.1 From 4e84c69824df8815b6120c74c165326c224301eb Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 13 Oct 2023 22:37:18 +0800 Subject: mark includes check_xxx as deprecated --- xmake/core/base/interpreter.lua | 12 ++-- xmake/includes/check_cflags.lua | 79 --------------------- xmake/includes/check_cfuncs.lua | 116 ------------------------------ xmake/includes/check_cincludes.lua | 73 ------------------- xmake/includes/check_csnippets.lua | 134 ----------------------------------- xmake/includes/check_ctypes.lua | 98 ------------------------- xmake/includes/check_cxxflags.lua | 79 --------------------- xmake/includes/check_cxxfuncs.lua | 116 ------------------------------ xmake/includes/check_cxxincludes.lua | 67 ------------------ xmake/includes/check_cxxsnippets.lua | 134 ----------------------------------- xmake/includes/check_cxxtypes.lua | 98 ------------------------- xmake/includes/check_features.lua | 91 ------------------------ xmake/includes/check_links.lua | 67 ------------------ xmake/includes/check_macros.lua | 134 ----------------------------------- xmake/includes/check_syslinks.lua | 67 ------------------ 15 files changed, 8 insertions(+), 1357 deletions(-) delete mode 100644 xmake/includes/check_cflags.lua delete mode 100644 xmake/includes/check_cfuncs.lua delete mode 100644 xmake/includes/check_cincludes.lua delete mode 100644 xmake/includes/check_csnippets.lua delete mode 100644 xmake/includes/check_ctypes.lua delete mode 100644 xmake/includes/check_cxxflags.lua delete mode 100644 xmake/includes/check_cxxfuncs.lua delete mode 100644 xmake/includes/check_cxxincludes.lua delete mode 100644 xmake/includes/check_cxxsnippets.lua delete mode 100644 xmake/includes/check_cxxtypes.lua delete mode 100644 xmake/includes/check_features.lua delete mode 100644 xmake/includes/check_links.lua delete mode 100644 xmake/includes/check_macros.lua delete mode 100644 xmake/includes/check_syslinks.lua (limited to 'xmake/core/base/interpreter.lua') diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 109032e28..8be5a8e4f 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -1712,10 +1712,14 @@ function interpreter:api_builtin_includes(...) end -- attempt to find files from programdir/includes/*.lua (deprecated) if not found and not path.is_absolute(subpath) then - local files = os.files(path.join(os.programdir(), "includes", subpath)) - if files and #files > 0 then - table.join2(subpaths_matched, files) - found = true + -- e.g. includes("check_cflags.lua") + if subpath:startswith("check_") then + local files = os.files(path.join(os.programdir(), "includes", "check", subpath)) + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + utils.warning("deprecated: please use includes(\"@builtin/check\") instead of includes(\"%s\")", subpath) + end end end if not found then diff --git a/xmake/includes/check_cflags.lua b/xmake/includes/check_cflags.lua deleted file mode 100644 index 5da75b699..000000000 --- a/xmake/includes/check_cflags.lua +++ /dev/null @@ -1,79 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cflags.lua --- - --- check c flags and add macro definition --- --- e.g. --- --- check_cflags("HAS_SSE2", "-msse2") --- check_cflags("HAS_SSE2", {"-msse", "-msse2"}) --- -function check_cflags(definition, flags, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_defines(definition) - on_check(function (option) - import("core.tool.compiler") - if compiler.has_flags("c", flags, opt) then - option:enable(true) - end - end) - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c flags and add macro definition to the configuration flags --- --- e.g. --- --- configvar_check_cflags("HAS_SSE2", "-msse2") --- configvar_check_cflags("HAS_SSE2", {"-msse", "-msse2"}) --- configvar_check_cflags("HAS_SSE2", "-msse2", {default = 0}) --- configvar_check_cflags("SSE_STR=2", "-msse2") --- configvar_check_cflags("SSE=2", "-msse2", {quote = false}) --- -function configvar_check_cflags(definition, flags, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - on_check(function (option) - import("core.tool.compiler") - if compiler.has_flags("c", flags, opt) then - option:enable(true) - end - end) - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cfuncs.lua b/xmake/includes/check_cfuncs.lua deleted file mode 100644 index a7a2cfb22..000000000 --- a/xmake/includes/check_cfuncs.lua +++ /dev/null @@ -1,116 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cfuncs.lua --- - --- check c funcs and add macro definition --- --- the function syntax --- - sigsetjmp --- - sigsetjmp((void*)0, 0) --- - sigsetjmp{sigsetjmp((void*)0, 0);} --- - sigsetjmp{int a = 0; sigsetjmp((void*)a, a);} --- --- e.g. --- --- check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}}) --- check_cfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"}) --- -function check_cfuncs(definition, funcs, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cfuncs(funcs) - add_defines(definition) - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c funcs and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}}) --- configvar_check_cfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"}) --- configvar_check_cfuncs("HAS_SETJMP", "setjmp", {includes = {"setjmp.h"}, default = 0}) --- configvar_check_cfuncs("CUSTOM_SETJMP=setjmp", "setjmp", {includes = {"setjmp.h"}, default = "", quote = false}) --- -function configvar_check_cfuncs(definition, funcs, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cfuncs(funcs) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cincludes.lua b/xmake/includes/check_cincludes.lua deleted file mode 100644 index 68ace5980..000000000 --- a/xmake/includes/check_cincludes.lua +++ /dev/null @@ -1,73 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cincludes.lua --- - --- check include c files and add macro definition --- --- e.g. --- --- check_cincludes("HAS_STRING_H", "string.h") --- check_cincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"}) --- -function check_cincludes(definition, includes, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cincludes(includes) - if opt.includedirs then - add_includedirs(opt.includedirs) - end - add_defines(definition) - option_end() - interp_restore_scope() - add_options(optname) -end - --- check include c files and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_cincludes("HAS_STRING_H", "string.h") --- configvar_check_cincludes("HAS_STRING_H", "string.h", {default = 0}) --- configvar_check_cincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"}) --- -function configvar_check_cincludes(definition, includes, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cincludes(includes) - if opt.includedirs then - add_includedirs(opt.includedirs) - end - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_csnippets.lua b/xmake/includes/check_csnippets.lua deleted file mode 100644 index 2e22c3220..000000000 --- a/xmake/includes/check_csnippets.lua +++ /dev/null @@ -1,134 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_csnippets.lua --- - --- check c snippets and add macro definition --- --- e.g. --- --- check_csnippets("HAS_STATIC_ASSERT", "_Static_assert(1, \"\");", {includes = "stdio.h"}) --- check_csnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true}) --- check_csnippets("PTR_SIZE", 'printf("%d", sizeof(void*)); return 0;', {output = true, number = true}) --- -function check_csnippets(definition, snippets, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_csnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output}) - if not opt.output then - add_defines(definition) - end - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - if opt.output then - after_check(function (option) - if option:value() then - if opt.number then - option:add("defines", definition .. "=" .. tonumber(option:value())) - elseif opt.quote == false then - option:add("defines", definition .. "=" .. option:value()) - else - option:add("defines", definition .. "=\"" .. option:value() .. "\"") - end - end - end) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c snippets and add macro definition to the configuration snippets --- --- e.g. --- --- configvar_check_csnippets("HAS_STATIC_ASSERT", "_Static_assert(1, \"\");", {includes = "stdio.h"}) --- configvar_check_csnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true}) --- configvar_check_csnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true, default = 0}) --- configvar_check_csnippets("LONG_SIZE=8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true, quote = false}) --- configvar_check_csnippets("PTR_SIZE", 'printf("%d", sizeof(void*)); return 0;', {output = true, number = true}) --- -function configvar_check_csnippets(definition, snippets, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_csnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output}) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - if opt.output then - after_check(function (option) - if option:value() then - option:set("configvar", defname, opt.number and tonumber(option:value()) or option:value(), {quote = opt.quote}) - end - end) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_ctypes.lua b/xmake/includes/check_ctypes.lua deleted file mode 100644 index e89345eea..000000000 --- a/xmake/includes/check_ctypes.lua +++ /dev/null @@ -1,98 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_ctypes.lua --- - --- check c types and add macro definition --- --- e.g. --- --- check_ctypes("HAS_WCHAR", "wchar_t") --- check_ctypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"}) --- -function check_ctypes(definition, types, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_ctypes(types) - add_defines(definition) - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.includes then - add_cincludes(opt.includes) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c types and add macro definition to the configuration types --- --- e.g. --- --- configvar_check_ctypes("HAS_WCHAR", "wchar_t") --- configvar_check_ctypes("HAS_WCHAR", "wchar_t", {default = 0}) --- configvar_check_ctypes("CUSTOM_WCHAR=wchar_t", "wchar_t", {default = "", quote = false}) --- configvar_check_ctypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"}) --- -function configvar_check_ctypes(definition, types, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_ctypes(types) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.includes then - add_cincludes(opt.includes) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cxxflags.lua b/xmake/includes/check_cxxflags.lua deleted file mode 100644 index 6b6e78d0f..000000000 --- a/xmake/includes/check_cxxflags.lua +++ /dev/null @@ -1,79 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cxxflags.lua --- - --- check c++ flags and add macro definition --- --- e.g. --- --- check_cxxflags("HAS_SSE2", "-msse2") --- check_cxxflags("HAS_SSE2", {"-msse", "-msse2"}) --- -function check_cxxflags(definition, flags, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_defines(definition) - on_check(function (option) - import("core.tool.compiler") - if compiler.has_flags("cxx", flags, opt) then - option:enable(true) - end - end) - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c++ flags and add macro definition to the configuration flags --- --- e.g. --- --- configvar_check_cxxflags("HAS_SSE2", "-msse2") --- configvar_check_cxxflags("HAS_SSE2", {"-msse", "-msse2"}) --- configvar_check_cxxflags("HAS_SSE2", "-msse2", {default = 0}) --- configvar_check_cxxflags("SSE_STR=2", "-msse2") --- configvar_check_cxxflags("SSE=2", "-msse2", {quote = false}) --- -function configvar_check_cxxflags(definition, flags, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - on_check(function (option) - import("core.tool.compiler") - if compiler.has_flags("cxx", flags, opt) then - option:enable(true) - end - end) - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cxxfuncs.lua b/xmake/includes/check_cxxfuncs.lua deleted file mode 100644 index 2ac98d799..000000000 --- a/xmake/includes/check_cxxfuncs.lua +++ /dev/null @@ -1,116 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cxxfuncs.lua --- - --- check c++ funcs and add macro definition --- --- the function syntax --- - sigsetjmp --- - sigsetjmp((void*)0, 0) --- - sigsetjmp{sigsetjmp((void*)0, 0);} --- - sigsetjmp{int a = 0; sigsetjmp((void*)a, a);} --- --- e.g. --- --- check_cxxfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}}) --- check_cxxfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"}) --- -function check_cxxfuncs(definition, funcs, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxfuncs(funcs) - add_defines(definition) - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cxxincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c++ funcs and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_cxxfuncs("HAS_SETJMP", "setjmp", {includes = {"signal.h", "setjmp.h"}, links = {}}) --- configvar_check_cxxfuncs("HAS_SETJMP", {"setjmp", "sigsetjmp{sigsetjmp((void*)0, 0);}"}) --- configvar_check_cxxfuncs("HAS_SETJMP", "setjmp", {includes = {"setjmp.h"}, default = 0}) --- configvar_check_cxxfuncs("CUSTOM_SETJMP=setjmp", "setjmp", {includes = {"setjmp.h"}, default = "", quote = false}) --- -function configvar_check_cxxfuncs(definition, funcs, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxfuncs(funcs) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cxxincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cxxincludes.lua b/xmake/includes/check_cxxincludes.lua deleted file mode 100644 index 4eff5f53e..000000000 --- a/xmake/includes/check_cxxincludes.lua +++ /dev/null @@ -1,67 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cxxincludes.lua --- - --- check include c++ files and add macro definition --- --- e.g. --- --- check_cxxincludes("HAS_STRING_H", "string.h") --- check_cxxincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"}) --- -function check_cxxincludes(definition, includes, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxincludes(includes) - add_defines(definition) - option_end() - interp_restore_scope() - add_options(optname) -end - --- check include c++ files and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_cxxincludes("HAS_STRING_H", "string.h") --- configvar_check_cxxincludes("HAS_STRING_H", "string.h", {default = 0}) --- configvar_check_cxxincludes("HAS_STRING_AND_STDIO_H", {"string.h", "stdio.h"}) --- -function configvar_check_cxxincludes(definition, includes, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxincludes(includes) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cxxsnippets.lua b/xmake/includes/check_cxxsnippets.lua deleted file mode 100644 index 358818844..000000000 --- a/xmake/includes/check_cxxsnippets.lua +++ /dev/null @@ -1,134 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cxxsnippets.lua --- - --- check c++ snippets and add macro definition --- --- e.g. --- --- check_cxxsnippets("HAS_STATIC_ASSERT", "static_assert(1, \"\");") --- check_csnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true}) --- check_csnippets("PTR_SIZE", 'printf("%d", sizeof(void*)); return 0;', {output = true, number = true}) --- -function check_cxxsnippets(definition, snippets, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxsnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output}) - if not opt.output then - add_defines(definition) - end - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cxxincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - if opt.output then - after_check(function (option) - if option:value() then - if opt.number then - option:add("defines", definition .. "=" .. tonumber(option:value())) - elseif opt.quote == false then - option:add("defines", definition .. "=" .. option:value()) - else - option:add("defines", definition .. "=\"" .. option:value() .. "\"") - end - end - end) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c++ snippets and add macro definition to the configuration snippets --- --- e.g. --- --- configvar_check_cxxsnippets("HAS_STATIC_ASSERT", "static_assert(1, \"\");") --- configvar_check_cxxsnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true}) --- configvar_check_cxxsnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true, default = 0}) --- configvar_check_cxxsnippets("LONG_SIZE=8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true, quote = false}) --- configvar_check_cxxsnippets("PTR_SIZE", 'printf("%d", sizeof(void*)); return 0;', {output = true, number = true}) --- -function configvar_check_cxxsnippets(definition, snippets, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxsnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output}) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.links then - add_links(opt.links) - end - if opt.includes then - add_cxxincludes(opt.includes) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.warnings then - set_warnings(opt.warnings) - end - if opt.output then - after_check(function (option) - if option:value() then - option:set("configvar", defname, opt.number and tonumber(option:value()) or option:value(), {quote = opt.quote}) - end - end) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_cxxtypes.lua b/xmake/includes/check_cxxtypes.lua deleted file mode 100644 index 28964b6f4..000000000 --- a/xmake/includes/check_cxxtypes.lua +++ /dev/null @@ -1,98 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_cxxtypes.lua --- - --- check c++ types and add macro definition --- --- e.g. --- --- check_cxxtypes("HAS_WCHAR", "wchar_t") --- check_cxxtypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"}) --- -function check_cxxtypes(definition, types, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxtypes(types) - add_defines(definition) - if opt.languages then - set_languages(opt.languages) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.includes then - add_cxxincludes(opt.includes) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check c++ types and add macro definition to the configuration types --- --- e.g. --- --- configvar_check_cxxtypes("HAS_WCHAR", "wchar_t") --- configvar_check_cxxtypes("HAS_WCHAR", "wchar_t", {default = 0}) --- configvar_check_cxxtypes("CUSTOM_WCHAR=wchar_t", "wchar_t", {default = "", quote = false}) --- configvar_check_cxxtypes("HAS_WCHAR_AND_FLOAT", {"wchar_t", "float"}) --- -function configvar_check_cxxtypes(definition, types, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_cxxtypes(types) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - if opt.defines then - add_defines(opt.defines) - end - if opt.includes then - add_cxxincludes(opt.includes) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_features.lua b/xmake/includes/check_features.lua deleted file mode 100644 index 2dca743fa..000000000 --- a/xmake/includes/check_features.lua +++ /dev/null @@ -1,91 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_features.lua --- - --- check features and add macro definition --- --- e.g. --- --- check_features("HAS_CONSTEXPR", "cxx_constexpr") --- check_features("HAS_CONSEXPR_AND_STATIC_ASSERT", {"cxx_constexpr", "c_static_assert"}, {cxflags = "", languages = "c++11"}) --- -function check_features(definition, features, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_features(features) - add_defines(definition) - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check features and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_features("HAS_CONSTEXPR", "cxx_constexpr") --- configvar_check_features("HAS_CONSTEXPR", "cxx_constexpr", {default = 0}) --- configvar_check_features("HAS_CONSEXPR_AND_STATIC_ASSERT", {"cxx_constexpr", "c_static_assert"}, {languages = "c++11"}) --- -function configvar_check_features(definition, features, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_features(features) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_links.lua b/xmake/includes/check_links.lua deleted file mode 100644 index 075be25b0..000000000 --- a/xmake/includes/check_links.lua +++ /dev/null @@ -1,67 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_links.lua --- - --- check links and add macro definition --- --- e.g. --- --- check_links("HAS_PTHREAD", "pthread") --- check_links("HAS_PTHREAD", {"pthread", "m", "dl"}) --- -function check_links(definition, links, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_links(links) - add_defines(definition) - option_end() - interp_restore_scope() - add_options(optname) -end - --- check links and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_links("HAS_PTHREAD", "pthread") --- configvar_check_links("HAS_PTHREAD", "pthread", {default = 0}) --- configvar_check_links("HAS_PTHREAD", {"pthread", "m", "dl"}) --- -function configvar_check_links(definition, links, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_links(links) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_macros.lua b/xmake/includes/check_macros.lua deleted file mode 100644 index 2235798ec..000000000 --- a/xmake/includes/check_macros.lua +++ /dev/null @@ -1,134 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_macros.lua --- - --- check macros and add macro definition --- --- e.g. --- --- check_macros("HAS_GCC", "__GNUC__") --- check_macros("NO_GCC", "__GNUC__", {defined = false}) --- check_macros("HAS_CXX20", "__cplusplus >= 202002L", {languages = "c++20"}) --- -function check_macros(definition, macros, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local snippets = {} - interp_save_scope() - option(optname) - set_showmenu(false) - for _, macro in ipairs(macros) do - if macro:find(' ', 1, true) then - table.insert(snippets, ([[ - #if %s - #else - # #error %s is not satisfied! - #endif - ]]):format(macro, macro)) - else - table.insert(snippets, ([[ - #if%s %s - #else - # #error %s is not defined! - #endif - ]]):format(opt.defined ~= false and "def" or "ndef", macro, macro)) - end - end - if opt.languages and opt.languages:startswith("c++") then - add_cxxsnippets(definition, table.concat(snippets, "\n")) - else - add_csnippets(definition, table.concat(snippets, "\n")) - end - add_defines(definition) - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - option_end() - interp_restore_scope() - add_options(optname) -end - --- check macros and add macro definition to the configuration files --- --- e.g. --- configvar_check_macros("HAS_GCC", "__GNUC__") --- configvar_check_macros("NO_GCC", "__GNUC__", {defined = false}) --- configvar_check_macros("HAS_CXX20", "__cplusplus >= 202002L", {languages = "c++20"}) -function configvar_check_macros(definition, macros, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - local snippets = {} - interp_save_scope() - option(optname) - set_showmenu(false) - for _, macro in ipairs(macros) do - if macro:find(' ', 1, true) then - table.insert(snippets, ([[ - #if %s - #else - # #error %s is not satisfied! - #endif - ]]):format(macro, macro)) - else - table.insert(snippets, ([[ - #if%s %s - #else - # #error %s is not defined! - #endif - ]]):format(opt.defined ~= false and "def" or "ndef", macro, macro)) - end - end - if opt.languages and opt.languages:startswith("c++") then - add_cxxsnippets(definition, table.concat(snippets, "\n")) - else - add_csnippets(definition, table.concat(snippets, "\n")) - end - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - if opt.languages then - set_languages(opt.languages) - end - if opt.cflags then - add_cflags(opt.cflags) - end - if opt.cxflags then - add_cxflags(opt.cxflags) - end - if opt.cxxflags then - add_cxxflags(opt.cxxflags) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end diff --git a/xmake/includes/check_syslinks.lua b/xmake/includes/check_syslinks.lua deleted file mode 100644 index ff44f8098..000000000 --- a/xmake/includes/check_syslinks.lua +++ /dev/null @@ -1,67 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file check_syslinks.lua --- - --- check links and add macro definition --- --- e.g. --- --- check_syslinks("HAS_PTHREAD", "pthread") --- check_syslinks("HAS_PTHREAD", {"pthread", "m", "dl"}) --- -function check_syslinks(definition, links, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - interp_save_scope() - option(optname) - set_showmenu(false) - add_syslinks(links) - add_defines(definition) - option_end() - interp_restore_scope() - add_options(optname) -end - --- check links and add macro definition to the configuration files --- --- e.g. --- --- configvar_check_syslinks("HAS_PTHREAD", "pthread") --- configvar_check_syslinks("HAS_PTHREAD", "pthread", {default = 0}) --- configvar_check_syslinks("HAS_PTHREAD", {"pthread", "m", "dl"}) --- -function configvar_check_syslinks(definition, links, opt) - opt = opt or {} - local optname = opt.name or ("__" .. definition) - local defname, defval = table.unpack(definition:split('=')) - interp_save_scope() - option(optname) - set_showmenu(false) - add_syslinks(links) - if opt.default == nil then - set_configvar(defname, defval or 1, {quote = opt.quote}) - end - option_end() - interp_restore_scope() - if opt.default == nil then - add_options(optname) - else - set_configvar(defname, has_config(optname) and (defval or 1) or opt.default, {quote = opt.quote}) - end -end -- cgit v1.3.1 From 736522b097bc41506b6b3694c0f1ff095362bfea Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 13 Oct 2023 22:38:13 +0800 Subject: add builtin/qt includes --- tests/projects/qt/quickapp_static/xmake.lua | 2 +- tests/projects/qt/widgetapp_static/xmake.lua | 2 +- xmake/core/base/interpreter.lua | 7 ++++ xmake/includes/qt/qt_add_static_plugins.lua | 43 ++++++++++++++++++++++ xmake/includes/qt/xmake.lua | 21 +++++++++++ xmake/includes/qt_add_static_plugins.lua | 43 ---------------------- .../c++/qt.quickapp_static/project/xmake.lua | 2 +- .../c++/qt.widgetapp_static/project/xmake.lua | 2 +- 8 files changed, 75 insertions(+), 47 deletions(-) create mode 100644 xmake/includes/qt/qt_add_static_plugins.lua create mode 100644 xmake/includes/qt/xmake.lua delete mode 100644 xmake/includes/qt_add_static_plugins.lua (limited to 'xmake/core/base/interpreter.lua') diff --git a/tests/projects/qt/quickapp_static/xmake.lua b/tests/projects/qt/quickapp_static/xmake.lua index 196749658..b6bc9a8cb 100644 --- a/tests/projects/qt/quickapp_static/xmake.lua +++ b/tests/projects/qt/quickapp_static/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("demo") add_rules("qt.quickapp_static") diff --git a/tests/projects/qt/widgetapp_static/xmake.lua b/tests/projects/qt/widgetapp_static/xmake.lua index 8ae0094bf..5ca10c888 100644 --- a/tests/projects/qt/widgetapp_static/xmake.lua +++ b/tests/projects/qt/widgetapp_static/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("demo") add_rules("qt.widgetapp_static") diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 8be5a8e4f..7ba677a8f 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -1720,6 +1720,13 @@ function interpreter:api_builtin_includes(...) found = true utils.warning("deprecated: please use includes(\"@builtin/check\") instead of includes(\"%s\")", subpath) end + elseif subpath:startswith("qt_") then + local files = os.files(path.join(os.programdir(), "includes", "qt", subpath)) + if files and #files > 0 then + table.join2(subpaths_matched, files) + found = true + utils.warning("deprecated: please use includes(\"@builtin/qt\") instead of includes(\"%s\")", subpath) + end end end if not found then diff --git a/xmake/includes/qt/qt_add_static_plugins.lua b/xmake/includes/qt/qt_add_static_plugins.lua new file mode 100644 index 000000000..e65965972 --- /dev/null +++ b/xmake/includes/qt/qt_add_static_plugins.lua @@ -0,0 +1,43 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file qt_add_static_plugins.lua +-- + +-- add static plugins for qt rules +-- +-- e.g. +-- +-- @code +-- includes("qt_add_static_plugins.lua") +-- target("test") +-- add_rules("qt.quickapp") +-- add_files("src/*.c") +-- qt_add_static_plugins("QSvgPlugin", {linkdirs = "plugins/imageformats", links = {"qsvg"}}) +-- @endcode +-- +function qt_add_static_plugins(plugin, opt) + opt = opt or {} + add_values("qt.plugins", plugin) + if opt.links then + add_values("qt.links", table.unpack(table.wrap(opt.links))) + end + if opt.linkdirs then + add_values("qt.linkdirs", table.unpack(table.wrap(opt.linkdirs))) + end +end + diff --git a/xmake/includes/qt/xmake.lua b/xmake/includes/qt/xmake.lua new file mode 100644 index 000000000..c08485bf6 --- /dev/null +++ b/xmake/includes/qt/xmake.lua @@ -0,0 +1,21 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +includes("@builtin/qt/qt_add_static_plugins.lua") diff --git a/xmake/includes/qt_add_static_plugins.lua b/xmake/includes/qt_add_static_plugins.lua deleted file mode 100644 index e65965972..000000000 --- a/xmake/includes/qt_add_static_plugins.lua +++ /dev/null @@ -1,43 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file qt_add_static_plugins.lua --- - --- add static plugins for qt rules --- --- e.g. --- --- @code --- includes("qt_add_static_plugins.lua") --- target("test") --- add_rules("qt.quickapp") --- add_files("src/*.c") --- qt_add_static_plugins("QSvgPlugin", {linkdirs = "plugins/imageformats", links = {"qsvg"}}) --- @endcode --- -function qt_add_static_plugins(plugin, opt) - opt = opt or {} - add_values("qt.plugins", plugin) - if opt.links then - add_values("qt.links", table.unpack(table.wrap(opt.links))) - end - if opt.linkdirs then - add_values("qt.linkdirs", table.unpack(table.wrap(opt.linkdirs))) - end -end - diff --git a/xmake/templates/c++/qt.quickapp_static/project/xmake.lua b/xmake/templates/c++/qt.quickapp_static/project/xmake.lua index 860dc513c..0d752b270 100644 --- a/xmake/templates/c++/qt.quickapp_static/project/xmake.lua +++ b/xmake/templates/c++/qt.quickapp_static/project/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("${TARGETNAME}") add_rules("qt.quickapp_static") diff --git a/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua b/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua index ac08f5c2e..b2cc1ac86 100644 --- a/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua +++ b/xmake/templates/c++/qt.widgetapp_static/project/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -includes("qt_add_static_plugins.lua") +includes("@builtin/qt") target("${TARGETNAME}") add_rules("qt.widgetapp_static") -- cgit v1.3.1