diff options
| -rw-r--r-- | tests/apis/add_configfiles/config.h.in | 1 | ||||
| -rw-r--r-- | tests/apis/add_configfiles/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/config/configfiles.lua | 12 |
3 files changed, 12 insertions, 2 deletions
diff --git a/tests/apis/add_configfiles/config.h.in b/tests/apis/add_configfiles/config.h.in index 3cbeb4135..5ba4bddb3 100644 --- a/tests/apis/add_configfiles/config.h.in +++ b/tests/apis/add_configfiles/config.h.in @@ -4,6 +4,7 @@ ${define FOO_ENABLE} ${define FOO_ENABLE2} ${define FOO_STRING} +${define FOO_DEFINE} ${define FOO2_ENABLE} ${define FOO2_ENABLE2} diff --git a/tests/apis/add_configfiles/xmake.lua b/tests/apis/add_configfiles/xmake.lua index 0dcf1eceb..a6849d586 100644 --- a/tests/apis/add_configfiles/xmake.lua +++ b/tests/apis/add_configfiles/xmake.lua @@ -8,6 +8,7 @@ if has_config("foo") then set_configvar("FOO_ENABLE", 1) set_configvar("FOO_ENABLE2", false) set_configvar("FOO_STRING", get_config("foo")) + set_configvar("FOO_DEFINE", get_config("foo"), {quote = false}) end option("foo2") diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua index 33a44c1a8..974610a91 100644 --- a/xmake/actions/config/configfiles.lua +++ b/xmake/actions/config/configfiles.lua @@ -167,7 +167,9 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets) -- get variables from the target for name, value in pairs(target:get("configvar")) do if variables[name] == nil then - variables[name] = table.unwrap(value) + value = table.unwrap(value) + variables[name] = value + variables["__extraconf_" .. name] = target:extraconf("configvar." .. name, value) end end @@ -236,6 +238,7 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets) -- get variable value local value = variables[variable] + local extraconf = variables["__extraconf_" .. variable] if isdefine then if value == nil then value = ("/* #undef %s */"):format(variable) @@ -248,7 +251,12 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets) elseif type(value) == "number" then value = ("#define %s %d"):format(variable, value) elseif type(value) == "string" then - value = ("#define %s \"%s\""):format(variable, value) + -- disable to wrap quote, @see https://github.com/xmake-io/xmake/issues/1694 + if extraconf and extraconf.quote == false then + value = ("#define %s %s"):format(variable, value) + else + value = ("#define %s \"%s\""):format(variable, value) + end else raise("unknown variable(%s) type: %s", variable, type(value)) end |
