summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-10 10:18:05 +0800
committerruki <[email protected]>2016-07-10 10:18:05 +0800
commitfd39adb3d959e605370098a72ec7e92b462fce62 (patch)
tree392b866ab32e33cae167c95daa7bff7cfbb9767c /xmake/core
parent4d2231a5136ddf5dca5398feaccc2d82bb56e1e0 (diff)
check include dependence
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/option.lua6
-rw-r--r--xmake/core/project/target.lua28
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/compiler.lua4
-rw-r--r--xmake/core/tool/compiler.lua4
4 files changed, 35 insertions, 7 deletions
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index 1d554d887..af727808f 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -94,7 +94,7 @@ function option:_check_include(include, srcpath, objpath)
end
-- attempt to run this command
- local ok, errors = instance:compile(srcpath, objpath, self)
+ local ok, errors = instance:compile(srcpath, objpath, nil, self)
if not ok and option_.get("verbose") then
print(errors)
end
@@ -148,7 +148,7 @@ function option:_check_function(checkcode, srcpath, objpath)
srcfile:close()
-- execute the compile command
- local ok, errors = instance:compile(srcpath, objpath, self)
+ local ok, errors = instance:compile(srcpath, objpath, nil, self)
if not ok and option_.get("verbose") then
print(errors)
end
@@ -202,7 +202,7 @@ function option:_check_typedef(typedef, srcpath, objpath)
srcfile:close()
-- execute the compile command
- local ok, errors = instance:compile(srcpath, objpath, self)
+ local ok, errors = instance:compile(srcpath, objpath, nil, self)
if not ok and option_.get("verbose") then
print(errors)
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 5e3669c69..27d4e926b 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -358,6 +358,34 @@ function target:headerfiles(outputdir)
return srcheaders, dstheaders
end
+-- get the dependent include files
+function target:incdepfiles()
+
+ -- the previous object files
+ local objectfiles_prev = self._OBJECTFILES
+
+ -- the object files
+ local objectfiles = self:objectfiles()
+
+ -- cached? return it directly
+ local modified = objectfiles_prev ~= objectfiles
+ if self._INCDEPFILES and not modified then
+ return self._INCDEPFILES
+ end
+
+ -- make include files
+ local incdepfiles = {}
+ for _, objectfile in ipairs(objectfiles) do
+ table.insert(incdepfiles, path.join(path.directory(objectfile), path.basename(objectfile) .. ".d"))
+ end
+
+ -- cache it
+ self._INCDEPFILES = incdepfiles
+
+ -- ok
+ return incdepfiles
+end
+
-- get the kinds of sourcefiles
--
-- .e.g cc cxx mm mxx as ...
diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
index 71059ad16..340b32734 100644
--- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
@@ -42,7 +42,7 @@ function sandbox_core_tool_compiler.compcmd(sourcefile, objectfile, target)
end
-- compile source file
-function sandbox_core_tool_compiler.compile(sourcefile, objectfile, target, multitasking)
+function sandbox_core_tool_compiler.compile(sourcefile, objectfile, incdepfile, target, multitasking)
-- get the compiler instance
local instance, errors = compiler.load(compiler.kind_of_file(sourcefile))
@@ -51,7 +51,7 @@ function sandbox_core_tool_compiler.compile(sourcefile, objectfile, target, mult
end
-- compile it
- local ok, errors = instance:compile(sourcefile, objectfile, target, multitasking)
+ local ok, errors = instance:compile(sourcefile, objectfile, incdepfile, target, multitasking)
if not ok then
raise(errors)
end
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index bb4aa2455..a523af449 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -399,7 +399,7 @@ function compiler:get(name)
end
-- compile the source file
-function compiler:compile(sourcefile, objectfile, target, multitasking)
+function compiler:compile(sourcefile, objectfile, incdepfile, target, multitasking)
-- get flags
local flags = nil
@@ -408,7 +408,7 @@ function compiler:compile(sourcefile, objectfile, target, multitasking)
end
-- compile it
- return sandbox.load(self:_tool().compile, sourcefile, objectfile, flags or "", multitasking)
+ return sandbox.load(self:_tool().compile, sourcefile, objectfile, incdepfile, flags or "", multitasking)
end
-- get the compile command