summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/nvcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-06-03 21:56:59 +0800
committerGitHub <[email protected]>2019-06-03 21:56:59 +0800
commit02b028733163015259df760e1cb4a86cd50bc40d (patch)
treeb1f4ca4ebf09dcc89ceff79dcb61a2e648c130de /xmake/modules/core/tools/nvcc.lua
parente1dbc594b0aef1d20c200baf1e0d85850a0f2c3b (diff)
parent18ac66eebce733b1112b419f9896cdfa2ede395a (diff)
Merge pull request #432 from OpportunityLiu/cu-deps
support deps analyze for cu file
Diffstat (limited to 'xmake/modules/core/tools/nvcc.lua')
-rw-r--r--xmake/modules/core/tools/nvcc.lua35
1 files changed, 31 insertions, 4 deletions
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 77cb4ce48..066e86cc9 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -24,6 +24,7 @@ import("core.project.config")
import("core.project.project")
import("core.language.language")
import("detect.tools.find_ccache")
+import("private.tools.nvcc.parse_deps")
-- init it
function init(self)
@@ -58,7 +59,7 @@ function nf_symbol(self, level)
-- the maps
local maps =
{
- debug = "-g"
+ debug = "-g -G"
}
-- make it
@@ -127,8 +128,8 @@ end
function nf_optimize(self, level)
-- the maps
- local maps =
- {
+ local maps =
+ {
none = "-O0"
, fast = "-O1"
, faster = "-O2"
@@ -138,7 +139,7 @@ function nf_optimize(self, level)
}
-- make it
- return maps[level]
+ return maps[level]
end
-- make the language flag
@@ -281,9 +282,22 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
os.mkdir(path.directory(objectfile))
-- compile it
+ local depfile = dependinfo and os.tmpfile() or nil
try
{
function ()
+ -- support `-M -MF depfile.d`?
+ if depfile and _g._HAS_M_MF == nil then
+ _g._HAS_M_MF = self:has_flags({"-M", "-MF", os.nuldev()}, "cuflags") or false
+ end
+
+ -- generate includes file
+ if depfile and _g._HAS_M_MF then
+ local compflags = table.join(flags, "-M", "-MF", depfile)
+ -- since -MD is not supported, run nvcc twice
+ os.iorunv(_compargv1(self, sourcefile, objectfile, compflags))
+ end
+
local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, flags))
return (outdata or "") .. (errdata or "")
end,
@@ -322,6 +336,19 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
if warnings and #warnings > 0 and (option.get("verbose") or option.get("warning")) then
cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n'))
end
+
+ -- generate the dependent includes
+ if depfile and os.isfile(depfile) then
+ local depdata = io.readfile(depfile)
+ if dependinfo and self:kind() ~= "as" and depdata then
+ local files = dependinfo.files or {}
+ table.join2(files, parse_deps(depdata))
+ dependinfo.files = table.unique(files)
+ end
+
+ -- remove the temporary dependent file
+ os.tryrm(depfile)
+ end
end
}
}