summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-05 21:51:04 +0800
committerGitHub <[email protected]>2021-12-05 21:51:04 +0800
commit7dc1142890a81e5aed622b2832cca5e39b897ce7 (patch)
treea1df43be7899bef8d25651e3da37317fd47b5c39
parentbabc5cb8dadcdb774de506ca0d2478381181d2e4 (diff)
Update configfiles.lua
-rw-r--r--xmake/actions/config/configfiles.lua22
1 files changed, 18 insertions, 4 deletions
diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua
index 933ee4e66..72891136a 100644
--- a/xmake/actions/config/configfiles.lua
+++ b/xmake/actions/config/configfiles.lua
@@ -253,11 +253,25 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets)
elseif type(value) == "number" then
value = ("#define %s %d"):format(variable, value)
elseif type(value) == "string" then
- -- 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
+ local quote = true
+ local escape = false
+ if extraconf then
+ -- disable to wrap quote, @see https://github.com/xmake-io/xmake/issues/1694
+ if extraconf.quote == false then
+ quote = false
+ end
+ -- escape path seperator when with quote, @see https://github.com/xmake-io/xmake/issues/1872
+ if quote and extraconf.escape then
+ escape = true
+ end
+ end
+ if quote then
+ if escape then
+ value = value:gsub("\\", "\\\\")
+ end
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))