summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-06 22:35:48 +0800
committerruki <[email protected]>2015-06-06 22:35:48 +0800
commit7c091cff74f038381c5e16576afeb7d4713bc917 (patch)
treedd3490039c2d114c471151819d62144d9549546e
parent6222a6ede3f06a0c67eccf0225d0ffb88cf9d4c8 (diff)
add warning and escape verboses
-rw-r--r--tests/console/src/hello1/hello1.c2
-rw-r--r--tests/console/src/hello1/hello1.h2
-rw-r--r--tests/console/src/hello2/hello2.c2
-rw-r--r--tests/console/src/hello2/hello2.h2
-rw-r--r--tests/console/src/hello3/hello3.c2
-rw-r--r--tests/console/src/hello3/hello3.h2
-rw-r--r--tests/console/xmake.xproj4
-rw-r--r--xmake/scripts/base/compiler.lua23
-rw-r--r--xmake/scripts/base/makefile.lua4
-rw-r--r--xmake/scripts/base/project.lua1
-rw-r--r--xmake/scripts/platform/windows/tools/cl.lua5
-rw-r--r--xmake/scripts/tools/echo.lua2
-rw-r--r--xmake/scripts/tools/verbose.lua2
13 files changed, 41 insertions, 12 deletions
diff --git a/tests/console/src/hello1/hello1.c b/tests/console/src/hello1/hello1.c
index b946071f0..8a1093c5c 100644
--- a/tests/console/src/hello1/hello1.c
+++ b/tests/console/src/hello1/hello1.c
@@ -1,6 +1,6 @@
#include "hello1.h"
-char const* hello1()
+char const* hello1(void)
{
return "hello1";
}
diff --git a/tests/console/src/hello1/hello1.h b/tests/console/src/hello1/hello1.h
index 328f996c3..0916d6bb4 100644
--- a/tests/console/src/hello1/hello1.h
+++ b/tests/console/src/hello1/hello1.h
@@ -2,7 +2,7 @@
extern "C" {
#endif
-char const* hello1();
+char const* hello1(void);
#ifdef __cplusplus
}
diff --git a/tests/console/src/hello2/hello2.c b/tests/console/src/hello2/hello2.c
index 1124ab563..4d2e9c562 100644
--- a/tests/console/src/hello2/hello2.c
+++ b/tests/console/src/hello2/hello2.c
@@ -1,6 +1,6 @@
#include "hello2.h"
-char const* hello2()
+char const* hello2(void)
{
return "hello2";
}
diff --git a/tests/console/src/hello2/hello2.h b/tests/console/src/hello2/hello2.h
index 080c37c66..90e062942 100644
--- a/tests/console/src/hello2/hello2.h
+++ b/tests/console/src/hello2/hello2.h
@@ -2,7 +2,7 @@
extern "C" {
#endif
-char const* hello2();
+char const* hello2(void);
#ifdef __cplusplus
}
diff --git a/tests/console/src/hello3/hello3.c b/tests/console/src/hello3/hello3.c
index 0ccc5015f..0c22929e8 100644
--- a/tests/console/src/hello3/hello3.c
+++ b/tests/console/src/hello3/hello3.c
@@ -1,6 +1,6 @@
#include "hello3.h"
-char const* hello3()
+char const* hello3(void)
{
return "hello3";
}
diff --git a/tests/console/src/hello3/hello3.h b/tests/console/src/hello3/hello3.h
index 0404a4381..c6da59f5e 100644
--- a/tests/console/src/hello3/hello3.h
+++ b/tests/console/src/hello3/hello3.h
@@ -2,7 +2,7 @@
extern "C" {
#endif
-char const* hello3();
+char const* hello3(void);
#ifdef __cplusplus
}
diff --git a/tests/console/xmake.xproj b/tests/console/xmake.xproj
index d830f5a39..bc14881dc 100644
--- a/tests/console/xmake.xproj
+++ b/tests/console/xmake.xproj
@@ -18,16 +18,20 @@ project: console
# the modes
modes: debug
{
+ warning: all
optimize: none
}
modes: release
{
+ cflags: -Wno-error=deprecated-declarations
+ warning: error
optimize: smallest
}
modes: profile
{
+ warning: none
optimize: fastest
}
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index af18758a5..2f0ef38b5 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -45,8 +45,9 @@ function compiler._mapflag(module, flag)
-- find and replace it using pattern
for k, v in pairs(module.mapflags) do
- if flag:find(k) then
- return flag:gsub(k, v)
+ local flag_mapped, count = flag:gsub(k, v)
+ if flag_mapped and count ~= 0 then
+ return utils.ifelse(#flag_mapped ~= 0, flag_mapped, nil)
end
end
@@ -82,6 +83,21 @@ function compiler._mapflags(module, flags)
return flags_mapped
end
+-- get the compiler warning flags from name
+function compiler._flag_warning(module, name)
+
+ -- init the flags table
+ local flags =
+ {
+ none = "-w"
+ , all = "-Wall"
+ , error = {"-Wall", "-Werror"}
+ }
+
+ -- get it
+ return compiler._mapflags(module, flags[name])
+end
+
-- get the compiler optimize flags from name
function compiler._flag_optimize(module, name)
@@ -184,6 +200,9 @@ function compiler.make(module, target, srcfile, objfile)
table.join2(flags, compiler._mapflags(module, target[flag_name]))
end
+ -- append the warning flags from the current project
+ table.join2(flags, compiler._flag_warning(module, target.warning))
+
-- append the optimize flags from the current project
table.join2(flags, compiler._flag_optimize(module, target.optimize))
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua
index b0658bfed..9287c1bae 100644
--- a/xmake/scripts/base/makefile.lua
+++ b/xmake/scripts/base/makefile.lua
@@ -74,7 +74,7 @@ function makefile._make_object(file, target, srcfile, objfile)
-- make body
file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile))
- file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("%s", "%%20"):gsub("=", "%%3d"):gsub("\"", "%%22")))
+ file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end)))
file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile)))
file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE))
@@ -156,7 +156,7 @@ function makefile._make_target(file, name, target)
-- make body
local cmd = linker.make(l, target, objfiles, targetfile)
file:write(string.format("\t@echo linking%s %s\n", mode, path.filename(targetfile)))
- file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("%s", "%%20"):gsub("=", "%%3d"):gsub("\"", "%%22")))
+ file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end)))
file:write(string.format("\t@xmake l mkdir %s\n", path.directory(targetfile)))
file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE))
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index 03fe0c375..c42d30908 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -189,6 +189,7 @@ function project.loadxproj(file)
, "ldflags"
, "shflags"
, "defines"
+ , "warning"
, "optimize"}
-- init filter
diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua
index 9feda6e98..fe962427a 100644
--- a/xmake/scripts/platform/windows/tools/cl.lua
+++ b/xmake/scripts/platform/windows/tools/cl.lua
@@ -40,10 +40,15 @@ function cl.init(name)
-- init flags map
cl.mapflags =
{
+ -- optimize
["-O0"] = "-Od"
, ["-O3"] = "-Ot"
, ["-Ofast"] = "-Ox"
, ["-fomit-frame-pointer"] = "-Oy"
+
+ -- warning
+ , ["-Werror"] = "-WX"
+ , ["%-Wno%-error=(.*)"] = ""
}
end
diff --git a/xmake/scripts/tools/echo.lua b/xmake/scripts/tools/echo.lua
index d9ee8f872..45abf8c24 100644
--- a/xmake/scripts/tools/echo.lua
+++ b/xmake/scripts/tools/echo.lua
@@ -32,7 +32,7 @@ function echo.main(...)
-- echo all
for _, v in ipairs(...) do
- io.write(string.format("%s ", v:gsub("%%20", " "):gsub("%%3d", "="):gsub("%%22", "\"")))
+ io.write(string.format("%s ", v:gsub("%%(%x%x)", function (w) return string.char(tonumber(w, 16)) end)))
end
io.write("\n")
diff --git a/xmake/scripts/tools/verbose.lua b/xmake/scripts/tools/verbose.lua
index fdcfb3e46..fcf72c3f0 100644
--- a/xmake/scripts/tools/verbose.lua
+++ b/xmake/scripts/tools/verbose.lua
@@ -33,7 +33,7 @@ function verbose.main(...)
-- verbose all
if xmake._OPTIONS.verbose then
for _, v in ipairs(...) do
- io.write(string.format("%s ", v:gsub("%%20", " "):gsub("%%3d", "="):gsub("%%22", "\"")))
+ io.write(string.format("%s ", v:gsub("%%(%x%x)", function (w) return string.char(tonumber(w, 16)) end)))
end
io.write("\n")
end