summaryrefslogtreecommitdiff
path: root/xmake/modules/core
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-18 00:53:59 +0800
committerruki <[email protected]>2020-06-17 23:23:59 +0800
commit44f12faeef61cfc28339b8dcbaf8b7ee0abfa054 (patch)
treeff10edad74f955c9cc0a035bc74ac109332fcf53 /xmake/modules/core
parent0a9c848f7a31acd027dea5b4a5b91d60516eddea (diff)
support deps for rc
Diffstat (limited to 'xmake/modules/core')
-rw-r--r--xmake/modules/core/project/depend.lua4
-rw-r--r--xmake/modules/core/tools/rc.lua40
2 files changed, 19 insertions, 25 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua
index 20b63e7e6..9c1484943 100644
--- a/xmake/modules/core/project/depend.lua
+++ b/xmake/modules/core/project/depend.lua
@@ -20,6 +20,7 @@
-- imports
import("private.tools.cl.parse_deps", {alias = "parse_deps_cl"})
+import("private.tools.rc.parse_deps", {alias = "parse_deps_rc"})
import("private.tools.gcc.parse_deps", {alias = "parse_deps_gcc"})
-- load depfiles
@@ -48,6 +49,9 @@ function load(dependfile)
elseif dependinfo.depfiles_cl then
_load_depfiles(parse_deps_cl, dependinfo, dependinfo.depfiles_cl)
dependinfo.depfiles_cl = nil
+ elseif dependinfo.depfiles_rc then
+ _load_depfiles(parse_deps_rc, dependinfo, dependinfo.depfiles_rc)
+ dependinfo.depfiles_rc = nil
end
return dependinfo
end
diff --git a/xmake/modules/core/tools/rc.lua b/xmake/modules/core/tools/rc.lua
index 12c94fa5f..cdaaa6b49 100644
--- a/xmake/modules/core/tools/rc.lua
+++ b/xmake/modules/core/tools/rc.lua
@@ -44,12 +44,12 @@ function nf_includedir(self, dir)
end
-- make the compile arguments list
-function _compargv1(self, sourcefile, objectfile, flags)
+function compargv(self, sourcefile, objectfile, flags)
return self:program(), table.join(flags, "-Fo" .. objectfile, sourcefile)
end
-- compile the source file
-function _compile1(self, sourcefile, objectfile, dependinfo, flags)
+function compile(self, sourcefile, objectfile, dependinfo, flags)
-- ensure the object directory
os.mkdir(path.directory(objectfile))
@@ -59,7 +59,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
{
function ()
-- @note we need not uses vstool.iorunv to enable unicode output for rc.exe
- local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, flags))
+ local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, flags))
return (outdata or "") .. (errdata or "")
end,
catch
@@ -79,34 +79,24 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
finally
{
function (ok, warnings)
-
- -- print some warnings
if warnings and #warnings > 0 and option.get("verbose") then
cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n'))
end
end
}
}
-end
-
--- make the compile arguments list
-function compargv(self, sourcefiles, objectfile, flags)
-
- -- only support single source file now
- assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
- -- for only single source file
- return _compargv1(self, sourcefiles, objectfile, flags)
+ -- parse includes
+ local sourcedata = io.readfile(sourcefile)
+ if sourcedata then
+ local depfiles_rc
+ local sourcedir = path.directory(sourcefile)
+ for headerfile in sourcedata:gmatch("#include%s+[\"<](.-)[\">]") do
+ depfiles_rc = (depfiles_rc or "") .. "\n" .. path.join(sourcedir, headerfile)
+ end
+ if dependinfo then
+ dependinfo.depfiles_rc = depfiles_rc
+ end
+ end
end
--- compile the source file
-function compile(self, sourcefiles, objectfile, dependinfo, flags)
-
- -- only support single source file now
- assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
-
- -- for only single source file
- _compile1(self, sourcefiles, objectfile, dependinfo, flags)
-end
-
-