summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-28 23:44:36 +0800
committerruki <[email protected]>2017-09-28 16:27:39 +0800
commitb0c6c6c058dfe7fe21f42da4da8c8f03fbdb8951 (patch)
tree158a4a65af66c79a3c550393eeb4d12ee3aed206
parent603ecaeb969342384e55b1fe92ed6d55d8ea970c (diff)
fix compile error with space path
-rw-r--r--CHANGELOG.md2
-rw-r--r--tests/projects/static library c/s r c/interface.c6
-rw-r--r--tests/projects/static library c/s r c/interface.h8
-rw-r--r--tests/projects/static library c/s r c/test.c8
-rw-r--r--tests/projects/static library c/test.lua9
-rw-r--r--tests/projects/static library c/xmake.lua45
-rw-r--r--xmake/modules/core/tools/cl.lua6
-rw-r--r--xmake/modules/core/tools/dmd.lua6
-rw-r--r--xmake/modules/core/tools/gcc.lua18
-rw-r--r--xmake/modules/core/tools/go.lua4
-rw-r--r--xmake/modules/core/tools/link.lua2
-rw-r--r--xmake/modules/core/tools/ml.lua2
-rw-r--r--xmake/modules/core/tools/rc.lua2
-rw-r--r--xmake/modules/core/tools/rustc.lua2
-rw-r--r--xmake/modules/core/tools/swiftc.lua6
15 files changed, 102 insertions, 24 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29deebbd6..8d4cb8096 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,7 @@
* Fix `set_pcxxheader` bug
* [#140](https://github.com/tboox/xmake/issues/140): Fix `os.tmpdir()` in fakeroot
* [#142](https://github.com/tboox/xmake/issues/142): Fix `os.getenv` charset bug on windows
+* Fix compile error with spaces path
## v2.1.6
@@ -391,6 +392,7 @@
* 修复`set_pcxxheader`编译没有继承flags配置问题
* [#140](https://github.com/tboox/xmake/issues/140): 修复`os.tmpdir()`在fakeroot下的冲突问题
* [#142](https://github.com/tboox/xmake/issues/142): 修复`os.getenv` 在windows上的中文编码问题
+* 修复在带有空格路径的情况下,编译错误问题
## v2.1.6
diff --git a/tests/projects/static library c/s r c/interface.c b/tests/projects/static library c/s r c/interface.c
new file mode 100644
index 000000000..598d07560
--- /dev/null
+++ b/tests/projects/static library c/s r c/interface.c
@@ -0,0 +1,6 @@
+#include "interface.h"
+
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/tests/projects/static library c/s r c/interface.h b/tests/projects/static library c/s r c/interface.h
new file mode 100644
index 000000000..10ec0f856
--- /dev/null
+++ b/tests/projects/static library c/s r c/interface.h
@@ -0,0 +1,8 @@
+/*! calculate add(a, b)
+ *
+ * @param a the first argument
+ * @param b the second argument
+ *
+ * @return the result
+ */
+int add(int a, int b);
diff --git a/tests/projects/static library c/s r c/test.c b/tests/projects/static library c/s r c/test.c
new file mode 100644
index 000000000..9505a2f75
--- /dev/null
+++ b/tests/projects/static library c/s r c/test.c
@@ -0,0 +1,8 @@
+#include "interface.h"
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+ printf("add(1, 2) = %d\n", add(1, 2));
+ return 0;
+}
diff --git a/tests/projects/static library c/test.lua b/tests/projects/static library c/test.lua
new file mode 100644
index 000000000..1ff9219ba
--- /dev/null
+++ b/tests/projects/static library c/test.lua
@@ -0,0 +1,9 @@
+-- imports
+import("..build")
+
+-- main entry
+function main()
+
+ -- build project
+ build()
+end
diff --git a/tests/projects/static library c/xmake.lua b/tests/projects/static library c/xmake.lua
new file mode 100644
index 000000000..318c286ee
--- /dev/null
+++ b/tests/projects/static library c/xmake.lua
@@ -0,0 +1,45 @@
+-- the debug mode
+if is_mode("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if is_mode("release") then
+
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
+
+ -- enable fastest optimization
+ set_optimize("fastest")
+
+ -- strip all symbols
+ set_strip("all")
+end
+
+-- add target
+target("static_library_c")
+
+ -- set kind
+ set_kind("static")
+
+ -- add files
+ add_files("s r c/interface.c")
+
+-- add target
+target("test")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("static_library_c")
+
+ -- add files
+ add_files("s r c/test.c")
+
+
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 81da0f528..23fcd9086 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -220,7 +220,7 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-I" .. dir
+ return "-I" .. os.args(dir)
end
-- make the c precompiled header flag
@@ -236,7 +236,7 @@ function nf_pcheader(self, pcheaderfile, target)
end
-- make flag
- return "-Yu" .. path.filename(pcheaderfile) .. " -FI" .. path.filename(pcheaderfile) .. " -Fp" .. target:pcoutputfile("c")
+ return "-Yu" .. path.filename(pcheaderfile) .. " -FI" .. path.filename(pcheaderfile) .. " -Fp" .. os.args(target:pcoutputfile("c"))
end
end
@@ -253,7 +253,7 @@ function nf_pcxxheader(self, pcheaderfile, target)
end
-- make flag
- return "-Yu" .. path.filename(pcheaderfile) .. " -FI" .. path.filename(pcheaderfile) .. " -Fp" .. target:pcoutputfile("cxx")
+ return "-Yu" .. path.filename(pcheaderfile) .. " -FI" .. path.filename(pcheaderfile) .. " -Fp" .. os.args(target:pcoutputfile("cxx"))
end
end
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua
index f2a951925..0c6db3844 100644
--- a/xmake/modules/core/tools/dmd.lua
+++ b/xmake/modules/core/tools/dmd.lua
@@ -129,7 +129,7 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-I" .. dir
+ return "-I" .. os.args(dir)
end
-- make the link flag
@@ -139,12 +139,12 @@ end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return "-L-L" .. dir
+ return "-L-L" .. os.args(dir)
end
-- make the rpathdir flag
function nf_rpathdir(self, dir)
- local flag = "-L-rpath=" .. dir
+ local flag = "-L-rpath=" .. os.args(dir)
if self:has_flags(flag) then
return flag
end
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index e011d8c68..007ce26bb 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -219,7 +219,7 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-I" .. dir
+ return "-I" .. os.args(dir)
end
-- make the link flag
@@ -229,18 +229,18 @@ end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return "-L" .. dir
+ return "-L" .. os.args(dir)
end
-- make the rpathdir flag
function nf_rpathdir(self, dir)
if self:has_flags("-Wl,-rpath=" .. dir) then
- return "-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name)
+ return "-Wl,-rpath=" .. os.args(dir:gsub("@[%w_]+", function (name)
local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"}
return maps[name]
end))
elseif self:has_flags("-Xlinker -rpath -Xlinker " .. dir) then
- return "-Xlinker -rpath -Xlinker " .. (dir:gsub("%$ORIGIN", "@loader_path"))
+ return "-Xlinker -rpath -Xlinker " .. os.args(dir:gsub("%$ORIGIN", "@loader_path"))
end
end
@@ -251,16 +251,16 @@ end
-- make the frameworkdir flag
function nf_frameworkdir(self, frameworkdir)
- return "-F " .. frameworkdir
+ return "-F " .. os.args(frameworkdir)
end
-- make the c precompiled header flag
function nf_pcheader(self, pcheaderfile, target)
if self:kind() == "cc" then
if self:name() == "clang" then
- return "-include " .. pcheaderfile .. " -include-pch " .. target:pcoutputfile("c")
+ return "-include " .. os.args(pcheaderfile) .. " -include-pch " .. os.args(target:pcoutputfile("c"))
else
- return "-include " .. pcheaderfile
+ return "-include " .. os.args(pcheaderfile)
end
end
end
@@ -269,9 +269,9 @@ end
function nf_pcxxheader(self, pcheaderfile, target)
if self:kind() == "cxx" then
if self:name() == "clang" then
- return "-include " .. pcheaderfile .. " -include-pch " .. target:pcoutputfile("cxx")
+ return "-include " .. os.args(pcheaderfile) .. " -include-pch " .. os.args(target:pcoutputfile("cxx"))
else
- return "-include " .. pcheaderfile
+ return "-include " .. os.args(pcheaderfile)
end
end
end
diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua
index 1f1e8bda1..1979f37dd 100644
--- a/xmake/modules/core/tools/go.lua
+++ b/xmake/modules/core/tools/go.lua
@@ -96,12 +96,12 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-I " .. dir
+ return "-I " .. os.args(dir)
end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return "-L " .. dir
+ return "-L " .. os.args(dir)
end
-- make the link arguments list
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 3af9e4cb3..af0d23a21 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -91,7 +91,7 @@ end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return "-libpath:" .. dir
+ return "-libpath:" .. os.args(dir)
end
-- make the link arguments list
diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua
index b60e063e7..a01f95d27 100644
--- a/xmake/modules/core/tools/ml.lua
+++ b/xmake/modules/core/tools/ml.lua
@@ -93,7 +93,7 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-I" .. dir
+ return "-I" .. os.args(dir)
end
-- make the complie arguments list
diff --git a/xmake/modules/core/tools/rc.lua b/xmake/modules/core/tools/rc.lua
index 9db2858da..0d4045362 100644
--- a/xmake/modules/core/tools/rc.lua
+++ b/xmake/modules/core/tools/rc.lua
@@ -53,7 +53,7 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-I" .. dir
+ return "-I" .. os.args(dir)
end
-- make the complie arguments list
diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua
index 10cb653cf..89bde3690 100644
--- a/xmake/modules/core/tools/rustc.lua
+++ b/xmake/modules/core/tools/rustc.lua
@@ -91,7 +91,7 @@ end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return "-L" .. dir
+ return "-L" .. os.args(dir)
end
-- make the build arguments list
diff --git a/xmake/modules/core/tools/swiftc.lua b/xmake/modules/core/tools/swiftc.lua
index 320e93a08..461dd75bd 100644
--- a/xmake/modules/core/tools/swiftc.lua
+++ b/xmake/modules/core/tools/swiftc.lua
@@ -152,7 +152,7 @@ end
-- make the includedir flag
function nf_includedir(self, dir)
- return "-Xcc -I" .. dir
+ return "-Xcc -I" .. os.args(dir)
end
-- make the define flag
@@ -172,7 +172,7 @@ end
-- make the frameworkdir flag
function nf_frameworkdir(self, frameworkdir)
- return "-F " .. frameworkdir
+ return "-F " .. os.args(frameworkdir)
end
-- make the link flag
@@ -182,7 +182,7 @@ end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return "-L" .. dir
+ return "-L" .. os.args(dir)
end
-- make the link arguments list