summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-08 15:05:57 +0800
committerruki <[email protected]>2015-06-08 15:05:57 +0800
commitaf060cd47c0673ef415769b36222f42b37a4a146 (patch)
treecbb4e7d0e0e0e96739d403b12493c43314234306
parentd3258129a4a1ba9886b7e8d773ba8e4ec956b4a6 (diff)
add undefines for project
-rw-r--r--tests/console/xmake.xproj1
-rw-r--r--xmake/scripts/base/compiler.lua12
-rw-r--r--xmake/scripts/base/linker.lua4
-rw-r--r--xmake/scripts/base/project.lua10
-rw-r--r--xmake/scripts/platform/windows/tools/cl.lua7
-rw-r--r--xmake/scripts/tools/clang.lua7
-rw-r--r--xmake/scripts/tools/gcc.lua7
7 files changed, 44 insertions, 4 deletions
diff --git a/tests/console/xmake.xproj b/tests/console/xmake.xproj
index 3397da04a..a9adb91d7 100644
--- a/tests/console/xmake.xproj
+++ b/tests/console/xmake.xproj
@@ -87,6 +87,7 @@ project: console
switches: CCC_ENABLE
switches: FFF_ENABLE, KKK_ENABLE
switchfiles: plat/demo_cpp.xswf
+ undefines: HELLO2
cxxflags: -DHELLO1
, [_if (AAA_ENABLE, "-DAAA")]
, [_if (BBB_ENABLE, "-DBBB")]
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua
index 880139e1f..685d8dc66 100644
--- a/xmake/scripts/base/compiler.lua
+++ b/xmake/scripts/base/compiler.lua
@@ -233,7 +233,7 @@ function compiler.make(module, target, srcfile, objfile)
-- append the includedirs flags from the current project
- if module._make_includedir then
+ if module.flag_includedir then
local includedirs = utils.wrap(target.includedirs)
for _, includedir in ipairs(includedirs) do
table.join2(flags, module.flag_includedir(includedir))
@@ -241,13 +241,21 @@ function compiler.make(module, target, srcfile, objfile)
end
-- append the defines flags from the current project
- if module._make_define then
+ if module.flag_define then
local defines = utils.wrap(target.defines)
for _, define in ipairs(defines) do
table.join2(flags, module.flag_define(define))
end
end
+ -- append the undefines flags from the current project
+ if module.flag_undefine then
+ local undefines = utils.wrap(target.undefines)
+ for _, undefine in ipairs(undefines) do
+ table.join2(flags, module.flag_undefine(undefine))
+ end
+ end
+
-- append the flags from the configure
for _, flag_name in ipairs(flag_names) do
table.join2(flags, compiler._mapflags(module, config.get(flag_name)))
diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua
index 9d23c9d38..cefb24050 100644
--- a/xmake/scripts/base/linker.lua
+++ b/xmake/scripts/base/linker.lua
@@ -129,7 +129,7 @@ function linker.make(module, target, objfiles, targetfile)
table.join2(flags, linker._mapflags(module, target[flag_name]))
-- append the linkdirs flags from the current project
- if module._make_linkdir then
+ if module.flag_linkdir then
local linkdirs = utils.wrap(target.linkdirs)
for _, linkdir in ipairs(linkdirs) do
table.join2(flags, module.flag_linkdir(linkdir))
@@ -137,7 +137,7 @@ function linker.make(module, target, objfiles, targetfile)
end
-- append the links flags from the current project
- if module._make_link then
+ if module.flag_link then
local links = utils.wrap(target.links)
for _, link in ipairs(links) do
table.join2(flags, module.flag_link(link))
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index b8180fef7..8bd646602 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -60,6 +60,15 @@ function project._makeconf_for_target(target_name, target)
file:write(string.format("#define %s_CONFIG_H\n", prefix))
file:write("\n")
+ -- make the undefines
+ if target.undefines then
+ file:write("// undefines\n")
+ for _, undefine in ipairs(utils.wrap(target.undefines)) do
+ file:write(string.format("#undef %s\n", undefine))
+ end
+ file:write("\n")
+ end
+
-- make the defines
if target.defines then
file:write("// defines\n")
@@ -428,6 +437,7 @@ function project.loadxproj(file)
, "ldflags"
, "shflags"
, "defines"
+ , "undefines"
, "switches"
, "switchfiles"
, "strip"
diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua
index 84b5b33ac..7c97f653c 100644
--- a/xmake/scripts/platform/windows/tools/cl.lua
+++ b/xmake/scripts/platform/windows/tools/cl.lua
@@ -89,6 +89,13 @@ function cl.flag_define(define)
return "-D" .. define
end
+-- make the undefine flag
+function cl.flag_undefine(undefine)
+
+ -- make it
+ return "-U" .. undefine
+end
+
-- make the includedir flag
function cl.flag_includedir(includedir)
diff --git a/xmake/scripts/tools/clang.lua b/xmake/scripts/tools/clang.lua
index 5ee3171db..73acc5deb 100644
--- a/xmake/scripts/tools/clang.lua
+++ b/xmake/scripts/tools/clang.lua
@@ -126,6 +126,13 @@ function clang.flag_define(define)
return "-D" .. define
end
+-- make the undefine flag
+function clang.flag_undefine(undefine)
+
+ -- make it
+ return "-U" .. undefine
+end
+
-- make the includedir flag
function clang.flag_includedir(includedir)
diff --git a/xmake/scripts/tools/gcc.lua b/xmake/scripts/tools/gcc.lua
index a4b1ce21b..4dfd85c5b 100644
--- a/xmake/scripts/tools/gcc.lua
+++ b/xmake/scripts/tools/gcc.lua
@@ -119,6 +119,13 @@ function gcc.flag_define(define)
return "-D" .. define
end
+-- make the undefine flag
+function gcc.flag_undefine(undefine)
+
+ -- make it
+ return "-U" .. undefine
+end
+
-- make the includedir flag
function gcc.flag_includedir(includedir)