summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-24 15:47:23 +0800
committerGitHub <[email protected]>2021-09-24 15:47:23 +0800
commit1c3f72be90e527db15044d2677647507341eaf91 (patch)
tree9557eec5ee8a592df7a7652ca3ce96c4644c5478
parent024183f9c98dd03f22384203238ba661a5714640 (diff)
parent28efcb4f71051f9a5ede3ced4f03fad8f311e949 (diff)
Merge pull request #1701 from xq114/dev
improve configvar_check_ functions
-rw-r--r--tests/apis/check_xxx/config.h.in2
-rw-r--r--tests/apis/check_xxx/main.c1
-rw-r--r--tests/apis/check_xxx/xmake.lua3
-rw-r--r--xmake/actions/config/configfiles.lua2
-rw-r--r--xmake/core/base/interpreter.lua2
-rw-r--r--xmake/includes/check_cflags.lua18
-rw-r--r--xmake/includes/check_cfuncs.lua12
-rw-r--r--xmake/includes/check_cincludes.lua11
-rw-r--r--xmake/includes/check_csnippets.lua16
-rw-r--r--xmake/includes/check_ctypes.lua12
-rw-r--r--xmake/includes/check_cxxflags.lua18
-rw-r--r--xmake/includes/check_cxxfuncs.lua12
-rw-r--r--xmake/includes/check_cxxincludes.lua11
-rw-r--r--xmake/includes/check_cxxsnippets.lua16
-rw-r--r--xmake/includes/check_cxxtypes.lua12
-rw-r--r--xmake/includes/check_features.lua11
-rw-r--r--xmake/includes/check_links.lua11
-rw-r--r--xmake/includes/check_syslinks.lua11
18 files changed, 146 insertions, 35 deletions
diff --git a/tests/apis/check_xxx/config.h.in b/tests/apis/check_xxx/config.h.in
index 617ecf864..a8baad68d 100644
--- a/tests/apis/check_xxx/config.h.in
+++ b/tests/apis/check_xxx/config.h.in
@@ -9,4 +9,6 @@ ${define HAS_CONSEXPR_AND_STATIC_ASSERT}
${define HAS_SSE2}
${define HAS_LONG_8}
${define PTR_SIZE}
+${define HAVE_VISIBILITY}
+${define CUSTOM_ASSERT}
#define HAS_WCHAR ${default HAS_WCHAR 0}
diff --git a/tests/apis/check_xxx/main.c b/tests/apis/check_xxx/main.c
index 5549c309f..5e40e6691 100644
--- a/tests/apis/check_xxx/main.c
+++ b/tests/apis/check_xxx/main.c
@@ -1,3 +1,4 @@
+#include "config.h"
int main(int argc, char** argv)
{
diff --git a/tests/apis/check_xxx/xmake.lua b/tests/apis/check_xxx/xmake.lua
index 2a9916954..ffd9f9242 100644
--- a/tests/apis/check_xxx/xmake.lua
+++ b/tests/apis/check_xxx/xmake.lua
@@ -9,6 +9,7 @@ includes("check_cincludes.lua")
target("test")
set_kind("binary")
add_files("*.c")
+ add_includedirs("$(buildir)")
add_configfiles("config.h.in")
check_ctypes("HAS_WCHAR", "wchar_t")
@@ -25,3 +26,5 @@ target("test")
configvar_check_cflags("HAS_SSE2", "-msse2")
configvar_check_csnippets("HAS_LONG_8", "return (sizeof(long) == 8)? 0 : -1;", {tryrun = true})
configvar_check_csnippets("PTR_SIZE", 'printf("%d", sizeof(void*)); return 0;', {output = true, number = true})
+ configvar_check_csnippets("HAVE_VISIBILITY", 'extern __attribute__((__visibility__("hidden"))) int hiddenvar;', {default = 0})
+ configvar_check_csnippets("CUSTOM_ASSERT=assert", 'assert(1);', {default = "", quote = false})
diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua
index 974610a91..933ee4e66 100644
--- a/xmake/actions/config/configfiles.lua
+++ b/xmake/actions/config/configfiles.lua
@@ -178,6 +178,7 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets)
for name, value in pairs(opt:get("configvar")) do
if variables[name] == nil then
variables[name] = table.unwrap(value)
+ variables["__extraconf_" .. name] = target:extraconf("configvar." .. name, value)
end
end
end
@@ -187,6 +188,7 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets)
for name, value in pairs(pkg:get("configvar")) do
if variables[name] == nil then
variables[name] = table.unwrap(value)
+ variables["__extraconf_" .. name] = target:extraconf("configvar." .. name, value)
end
end
end
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index ecfcc7270..131a6d1c2 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -446,7 +446,7 @@ function interpreter:_filter(values, level)
if table.is_dictionary(values) then
local results = {}
for key, value in pairs(values) do
- key = filter:handle(key)
+ key = (type(key) == "string" and filter:handle(key) or key)
if type(value) == "string" then
results[key] = filter:handle(value)
elseif type(value) == "table" and level < 1 then
diff --git a/xmake/includes/check_cflags.lua b/xmake/includes/check_cflags.lua
index 85ee65f8e..85c9ef3c7 100644
--- a/xmake/includes/check_cflags.lua
+++ b/xmake/includes/check_cflags.lua
@@ -23,7 +23,7 @@
-- e.g.
--
-- check_cflags("HAS_SSE2", "-msse2")
--- check_cflags("HAS_SSE2", {"-msse2", "/arch:SSE2"})
+-- check_cflags("HAS_SSE2", {"-msse", "-msse2"})
--
function check_cflags(definition, flags, opt)
opt = opt or {}
@@ -45,15 +45,19 @@ end
-- e.g.
--
-- configvar_check_cflags("HAS_SSE2", "-msse2")
--- configvar_check_cflags("HAS_SSE2", {"-msse2", "/arch:SSE2"})
--- configvar_check_cflags("SSE=2", "-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 = unpack(definition:split('='))
option(optname)
- set_configvar(defname, defval or 1)
+ 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
@@ -61,5 +65,9 @@ function configvar_check_cflags(definition, flags, opt)
end
end)
option_end()
- add_options(optname)
+ 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
index 45b80519f..42d173a18 100644
--- a/xmake/includes/check_cfuncs.lua
+++ b/xmake/includes/check_cfuncs.lua
@@ -68,6 +68,8 @@ end
--
-- 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 {}
@@ -75,7 +77,9 @@ function configvar_check_cfuncs(definition, funcs, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_cfuncs(funcs)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.links then
add_links(opt.links)
end
@@ -98,5 +102,9 @@ function configvar_check_cfuncs(definition, funcs, opt)
set_warnings(opt.warnings)
end
option_end()
- add_options(optname)
+ 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
index 7f2727d77..f9d69aad5 100644
--- a/xmake/includes/check_cincludes.lua
+++ b/xmake/includes/check_cincludes.lua
@@ -43,6 +43,7 @@ end
-- 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)
@@ -54,7 +55,13 @@ function configvar_check_cincludes(definition, includes, opt)
if opt.includedirs then
add_includedirs(opt.includedirs)
end
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
option_end()
- add_options(optname)
+ 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
index 06fdc842e..95aa0b2d5 100644
--- a/xmake/includes/check_csnippets.lua
+++ b/xmake/includes/check_csnippets.lua
@@ -60,6 +60,8 @@ function check_csnippets(definition, snippets, opt)
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
@@ -76,6 +78,8 @@ end
--
-- 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)
@@ -84,7 +88,9 @@ function configvar_check_csnippets(definition, snippets, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_csnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output})
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.links then
add_links(opt.links)
end
@@ -109,10 +115,14 @@ function configvar_check_csnippets(definition, snippets, opt)
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())
+ option:set("configvar", defname, opt.number and tonumber(option:value()) or option:value(), {quote = opt.quote})
end
end)
end
option_end()
- add_options(optname)
+ 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
index d6bf77f82..e0c3caa47 100644
--- a/xmake/includes/check_ctypes.lua
+++ b/xmake/includes/check_ctypes.lua
@@ -55,6 +55,8 @@ end
-- 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)
@@ -63,7 +65,9 @@ function configvar_check_ctypes(definition, types, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_ctypes(types)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.languages then
set_languages(opt.languages)
end
@@ -80,5 +84,9 @@ function configvar_check_ctypes(definition, types, opt)
add_cincludes(opt.includes)
end
option_end()
- add_options(optname)
+ 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
index c2881ecdc..9a0880697 100644
--- a/xmake/includes/check_cxxflags.lua
+++ b/xmake/includes/check_cxxflags.lua
@@ -23,7 +23,7 @@
-- e.g.
--
-- check_cxxflags("HAS_SSE2", "-msse2")
--- check_cxxflags("HAS_SSE2", {"-msse2", "/arch:SSE2"})
+-- check_cxxflags("HAS_SSE2", {"-msse", "-msse2"})
--
function check_cxxflags(definition, flags, opt)
opt = opt or {}
@@ -45,15 +45,19 @@ end
-- e.g.
--
-- configvar_check_cxxflags("HAS_SSE2", "-msse2")
--- configvar_check_cxxflags("HAS_SSE2", {"-msse2", "/arch:SSE2"})
--- configvar_check_cxxflags("SSE=2", "-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 = unpack(definition:split('='))
option(optname)
- set_configvar(defname, defval or 1)
+ 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
@@ -61,5 +65,9 @@ function configvar_check_cxxflags(definition, flags, opt)
end
end)
option_end()
- add_options(optname)
+ 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
index bef5d8252..3a64075dc 100644
--- a/xmake/includes/check_cxxfuncs.lua
+++ b/xmake/includes/check_cxxfuncs.lua
@@ -68,6 +68,8 @@ end
--
-- 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 {}
@@ -75,7 +77,9 @@ function configvar_check_cxxfuncs(definition, funcs, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_cxxfuncs(funcs)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.links then
add_links(opt.links)
end
@@ -98,5 +102,9 @@ function configvar_check_cxxfuncs(definition, funcs, opt)
set_warnings(opt.warnings)
end
option_end()
- add_options(optname)
+ 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
index 4ef52b155..a779ffd15 100644
--- a/xmake/includes/check_cxxincludes.lua
+++ b/xmake/includes/check_cxxincludes.lua
@@ -40,6 +40,7 @@ end
-- 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)
@@ -48,7 +49,13 @@ function configvar_check_cxxincludes(definition, includes, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_cxxincludes(includes)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
option_end()
- add_options(optname)
+ 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
index 8f0f6f64d..b46c650ff 100644
--- a/xmake/includes/check_cxxsnippets.lua
+++ b/xmake/includes/check_cxxsnippets.lua
@@ -60,6 +60,8 @@ function check_cxxsnippets(definition, snippets, opt)
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
@@ -76,6 +78,8 @@ end
--
-- 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)
@@ -84,7 +88,9 @@ function configvar_check_cxxsnippets(definition, snippets, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_cxxsnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output})
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.links then
add_links(opt.links)
end
@@ -109,10 +115,14 @@ function configvar_check_cxxsnippets(definition, snippets, opt)
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())
+ option:set("configvar", defname, opt.number and tonumber(option:value()) or option:value(), {quote = opt.quote})
end
end)
end
option_end()
- add_options(optname)
+ 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
index 859e26c4d..e53caae6e 100644
--- a/xmake/includes/check_cxxtypes.lua
+++ b/xmake/includes/check_cxxtypes.lua
@@ -55,6 +55,8 @@ end
-- 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)
@@ -63,7 +65,9 @@ function configvar_check_cxxtypes(definition, types, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_cxxtypes(types)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.languages then
set_languages(opt.languages)
end
@@ -80,5 +84,9 @@ function configvar_check_cxxtypes(definition, types, opt)
add_cxxincludes(opt.includes)
end
option_end()
- add_options(optname)
+ 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
index 1340d32f5..7c02be173 100644
--- a/xmake/includes/check_features.lua
+++ b/xmake/includes/check_features.lua
@@ -52,6 +52,7 @@ end
-- 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)
@@ -60,7 +61,9 @@ function configvar_check_features(definition, features, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_features(features)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
if opt.languages then
set_languages(opt.languages)
end
@@ -74,5 +77,9 @@ function configvar_check_features(definition, features, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- add_options(optname)
+ 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
index a17561f5e..06b8cb38c 100644
--- a/xmake/includes/check_links.lua
+++ b/xmake/includes/check_links.lua
@@ -40,6 +40,7 @@ end
-- 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)
@@ -48,7 +49,13 @@ function configvar_check_links(definition, links, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_links(links)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
option_end()
- add_options(optname)
+ 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
index 0dab1fa7f..133e24dcd 100644
--- a/xmake/includes/check_syslinks.lua
+++ b/xmake/includes/check_syslinks.lua
@@ -40,6 +40,7 @@ end
-- 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)
@@ -48,7 +49,13 @@ function configvar_check_syslinks(definition, links, opt)
local defname, defval = unpack(definition:split('='))
option(optname)
add_syslinks(links)
- set_configvar(defname, defval or 1)
+ if opt.default == nil then
+ set_configvar(defname, defval or 1, {quote = opt.quote})
+ end
option_end()
- add_options(optname)
+ 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