summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-22 11:10:25 +0800
committerruki <[email protected]>2016-03-22 11:10:25 +0800
commitc1460e5be7f4b4e3356a8bda99703828c356cbfb (patch)
treed490ad26a4291c8e38513212ff34380abec60214
parent399d87fadad1e965c1fbb11db74c0c249abfaf9f (diff)
escape $ for vformat
-rwxr-xr-xxmake/actions/config/makefile.lua8
-rw-r--r--xmake/core/sandbox/modules/string.lua6
2 files changed, 10 insertions, 4 deletions
diff --git a/xmake/actions/config/makefile.lua b/xmake/actions/config/makefile.lua
index 3b199de63..3f3832837 100755
--- a/xmake/actions/config/makefile.lua
+++ b/xmake/actions/config/makefile.lua
@@ -45,7 +45,7 @@ function _make_object_for_object(makefile, target, srcfile, objfile)
-- make body
makefile:print("\t@echo inserting.$(mode) %s", srcfile)
- makefile:write(format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:encode()))
+ makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", cmd:encode())
makefile:print("\t@%s", cmd)
-- make tail
@@ -67,7 +67,7 @@ function _make_object_for_static(makefile, target, srcfile, objfile)
-- make body
makefile:print("\t@echo inserting.$(mode) %s", srcfile)
- makefile:write(format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:encode()))
+ makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", cmd:encode())
makefile:print("\t@xmake l rmdir %s\n", path.directory(objfile))
makefile:print("\t@%s", cmd)
@@ -106,7 +106,7 @@ function _make_object(makefile, target, srcfile, objfile)
-- make body
makefile:print("\t@echo %scompiling.$(mode) %s", ifelse(ccache, "ccache ", ""), srcfile)
- makefile:write(format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:encode()))
+ makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", cmd:encode())
makefile:print("\t@xmake l mkdir %s", path.directory(objfile))
makefile:print("\t@%s", cmd)
@@ -168,7 +168,7 @@ function _make_target(makefile, target)
-- make body
makefile:print("\t@echo linking.$(mode) %s", path.filename(targetfile))
- makefile:write(format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", verbose))
+ makefile:print("\t@xmake l %$(VERBOSE) verbose \"%s\"", verbose)
makefile:print("\t@xmake l mkdir %s", path.directory(targetfile))
makefile:print("\t@%s", cmd)
diff --git a/xmake/core/sandbox/modules/string.lua b/xmake/core/sandbox/modules/string.lua
index 69ddbb723..6a7a455d7 100644
--- a/xmake/core/sandbox/modules/string.lua
+++ b/xmake/core/sandbox/modules/string.lua
@@ -44,6 +44,9 @@ function sandbox_string.vformat(format, ...)
local instance = sandbox.instance()
assert(instance)
+ -- ignore %$(...)
+ format = format:gsub("%%%$", "__$__")
+
-- format string
local result = string.format(format, ...)
assert(result)
@@ -54,6 +57,9 @@ function sandbox_string.vformat(format, ...)
result = filter:handle(result)
end
+ -- escape to $(...)
+ result = result:gsub("__%$__", "$")
+
-- ok?
return result
end