summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-13 22:37:18 +0800
committerruki <[email protected]>2023-10-13 22:37:18 +0800
commit4e84c69824df8815b6120c74c165326c224301eb (patch)
tree73568a2c6cfd70e07e078b3463ab6fdebac80ae5
parentcab174afcbf6bfbb1f4cfd446406e95d4e3b00fa (diff)
mark includes check_xxx as deprecated
-rw-r--r--xmake/core/base/interpreter.lua12
-rw-r--r--xmake/includes/check_cflags.lua79
-rw-r--r--xmake/includes/check_cfuncs.lua116
-rw-r--r--xmake/includes/check_cincludes.lua73
-rw-r--r--xmake/includes/check_csnippets.lua134
-rw-r--r--xmake/includes/check_ctypes.lua98
-rw-r--r--xmake/includes/check_cxxflags.lua79
-rw-r--r--xmake/includes/check_cxxfuncs.lua116
-rw-r--r--xmake/includes/check_cxxincludes.lua67
-rw-r--r--xmake/includes/check_cxxsnippets.lua134
-rw-r--r--xmake/includes/check_cxxtypes.lua98
-rw-r--r--xmake/includes/check_features.lua91
-rw-r--r--xmake/includes/check_links.lua67
-rw-r--r--xmake/includes/check_macros.lua134
-rw-r--r--xmake/includes/check_syslinks.lua67
15 files changed, 8 insertions, 1357 deletions
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