summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-11-11 21:23:57 +0800
committerruki <[email protected]>2017-11-11 21:23:57 +0800
commitf50cc8971ad01966cb5bfbcd2bef354fdef42cd8 (patch)
tree69c6f0123120175998b581d362a568b3999f9f1b
parentd8c3db4f8bd8a63eb1748bf1e0fd90001e318668 (diff)
improve project plugin
-rw-r--r--tests/apis/rules/src/main.c1
-rw-r--r--tests/apis/rules/xmake.lua2
-rw-r--r--xmake/core/project/target.lua10
-rw-r--r--xmake/plugins/project/clang/compile_commands.lua10
-rw-r--r--xmake/plugins/project/makefile/makefile.lua21
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua4
6 files changed, 28 insertions, 20 deletions
diff --git a/tests/apis/rules/src/main.c b/tests/apis/rules/src/main.c
index b86c9ad8e..f2e46be48 100644
--- a/tests/apis/rules/src/main.c
+++ b/tests/apis/rules/src/main.c
@@ -4,5 +4,6 @@ extern int test(int a, int b);
int main(int argc, char** argv)
{
printf("1 + 1 = %d\n", test(1, 1));
+ printf("%s\n", TEST);
return 0;
}
diff --git a/tests/apis/rules/xmake.lua b/tests/apis/rules/xmake.lua
index af4486428..545e53938 100644
--- a/tests/apis/rules/xmake.lua
+++ b/tests/apis/rules/xmake.lua
@@ -44,6 +44,8 @@ rule("stub")
-- define target
target("test")
+ add_cxflags("-DTEST=\"D:/asdasd/adasd/adsad\"")
+
-- set kind
set_kind("binary")
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 49cbcdeae..23d65f384 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -543,7 +543,9 @@ function target:objectfiles()
-- get object files from source batches
local objectfiles = {}
for sourcekind, sourcebatch in pairs(self:sourcebatches()) do
- table.join2(objectfiles, sourcebatch.objectfiles)
+ if not sourcebatch.rulename then
+ table.join2(objectfiles, sourcebatch.objectfiles)
+ end
end
-- cache it
@@ -638,7 +640,9 @@ function target:incdepfiles()
-- get incdep files from source batches
local incdepfiles = {}
for sourcekind, sourcebatch in pairs(self:sourcebatches()) do
- table.join2(incdepfiles, sourcebatch.incdepfiles)
+ if not sourcebatch.rulename then
+ table.join2(incdepfiles, sourcebatch.incdepfiles)
+ end
end
-- cache it
@@ -752,7 +756,7 @@ function target:sourcebatches()
for sourcekind, sourcebatch in pairs(sourcebatches) do
-- skip source files with the custom rule
- if not sourcekind:startswith("__rule_") then
+ if not sourcebatch.rulename then
-- this batch support to compile multiple objects at the same time?
local instance = compiler.load(sourcekind)
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua
index 9c9ebea16..b805f188c 100644
--- a/xmake/plugins/project/clang/compile_commands.lua
+++ b/xmake/plugins/project/clang/compile_commands.lua
@@ -85,10 +85,12 @@ function _make_target(jsonfile, target)
-- build source batches
for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
- if type(sourcebatch.objectfiles) == "string" then
- _make_single_object(jsonfile, target, sourcekind, sourcebatch)
- else
- _make_each_objects(jsonfile, target, sourcekind, sourcebatch)
+ if not sourcebatch.rulename then
+ if type(sourcebatch.objectfiles) == "string" then
+ _make_single_object(jsonfile, target, sourcekind, sourcebatch)
+ else
+ _make_each_objects(jsonfile, target, sourcekind, sourcebatch)
+ end
end
end
end
diff --git a/xmake/plugins/project/makefile/makefile.lua b/xmake/plugins/project/makefile/makefile.lua
index 7f50d569a..d4061359f 100644
--- a/xmake/plugins/project/makefile/makefile.lua
+++ b/xmake/plugins/project/makefile/makefile.lua
@@ -306,16 +306,13 @@ function _make_target(makefile, target)
-- build source batches
for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
-
- -- compile source files to single object at the same time?
- if type(sourcebatch.objectfiles) == "string" then
-
- -- make single object
- _make_single_object(makefile, target, sourcekind, sourcebatch)
- else
-
- -- make each objects
- _make_each_objects(makefile, target, sourcekind, sourcebatch)
+ if not sourcebatch.rulename then
+ -- compile source files to single object at once
+ if type(sourcebatch.objectfiles) == "string" then
+ _make_single_object(makefile, target, sourcekind, sourcebatch)
+ else
+ _make_each_objects(makefile, target, sourcekind, sourcebatch)
+ end
end
end
end
@@ -359,7 +356,9 @@ function _make_all(makefile)
for targetname, target in pairs(project.targets()) do
if not target:isphony() then
for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
- makefile:print("%s_%s=%s", targetname, sourcekind:upper(), os.args(compiler.compflags(sourcebatch.sourcefiles, {target = target, sourcekind = sourcekind})))
+ if not sourcebatch.rulename then
+ makefile:print("%s_%s=%s", targetname, sourcekind:upper(), os.args(compiler.compflags(sourcebatch.sourcefiles, {target = target, sourcekind = sourcekind})))
+ end
end
makefile:print("%s_%s=%s", targetname, target:linker():kind():upper(), os.args(target:linkflags()))
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index 7277d6ed3..687339b45 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -408,7 +408,7 @@ function _make_common_items(vcxprojfile, vsinfo, target, vcxprojdir)
local first_flags = nil
targetinfo.sourceflags = {}
for sourcekind, sourcebatch in pairs(targetinfo.sourcebatches) do
- if sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as" then
+ if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as") then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
-- make compiler flags
@@ -650,7 +650,7 @@ function _make_source_files(vcxprojfile, vsinfo, target, vcxprojdir)
local sourceinfos = {}
for _, targetinfo in ipairs(target.info) do
for sourcekind, sourcebatch in pairs(targetinfo.sourcebatches) do
- if sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as" then
+ if not sourcebatch.rulename and (sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as") then
local objectfiles = sourcebatch.objectfiles
for idx, sourcefile in ipairs(sourcebatch.sourcefiles) do
local objectfile = objectfiles[idx]