diff options
| author | ruki <[email protected]> | 2020-03-01 17:23:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-01 17:23:46 +0800 |
| commit | a9bba11b49235dac9982cc2f632b65339cd17130 (patch) | |
| tree | 8cfda00774b823519e750f03c1556265083a7641 /xmake/modules/core | |
| parent | 99461db2fae34632c83417667c8955c3361e7751 (diff) | |
improve to save depfiles for cl
Diffstat (limited to 'xmake/modules/core')
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 37 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 72 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 1 |
3 files changed, 25 insertions, 85 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index aaa2c13a7..7c8fa2ca5 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -18,8 +18,23 @@ -- @file depend.lua -- --- imports -import("private.tools.gcc.parse_deps") +-- load depfiles for the given tool style, e.g. gcc, cl, .. +function _load_depfiles(dependinfo, style) + + -- parse depfiles for gcc + local depfiles = dependinfo["depfiles_" .. style] + if depfiles then + local depfiles = import("private.tools." .. style .. ".parse_deps", {anonymous = true})(depfiles) + if depfiles then + if dependinfo.files then + table.join2(dependinfo.files, depfiles) + else + dependinfo.files = depfiles + end + end + dependinfo["depfiles_" .. style] = nil + end +end -- load dependent info from the given file (.d) function load(dependfile) @@ -28,19 +43,11 @@ function load(dependfile) -- may be the depend file has been incomplete when if the compilation process is abnormally interrupted local dependinfo = try { function() return io.load(dependfile) end } if dependinfo then - - -- parse depfiles for gcc - local depfiles_gcc = dependinfo.depfiles_gcc - if depfiles_gcc then - local depfiles = parse_deps.from_str(depfiles_gcc) - if depfiles then - if dependinfo.files then - table.join2(dependinfo.files, depfiles) - else - dependinfo.files = depfiles - end - end - dependinfo.depfiles_gcc = nil + -- attempt to load depfiles from the compilers + if is_plat("windows") then + _load_depfiles(dependinfo, "cl") + else + _load_depfiles(dependinfo, "gcc") end return dependinfo end diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index eddfe0260..9ff2ffce3 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -23,6 +23,7 @@ import("core.base.option") import("core.project.project") import("core.language.language") import("private.tools.vstool") +import("private.tools.cl.parse_include") -- init it function init(self) @@ -290,72 +291,6 @@ function add_sourceflags(self, sourcefile, fileconfig, target, targetkind) end end --- contain: "Note: including file: "? --- --- @note we cannot get better solution to distinguish between `includes` and `error infos` --- -function _include_note(self, line) - - -- init notes - -- - -- TODO zh-tw, zh-hk, jp, ... - -- - _g.notes = _g.notes or - { - "Note: including file: " - , "注意: 包含文件: " - } - - -- contain notes? - for idx, note in ipairs(_g.notes) do - - -- dump line bytes - --[[ - print(line) - line:gsub(".", function (ch) print(string.byte(ch)) end) - --]] - - if line:startswith(note) then - -- optimization: move this note to head - if idx ~= 1 then - table.insert(_g.notes, 1, note) - end - return line:sub(#note):trim() - end - end -end - --- get include deps -function _include_deps(self, outdata) - - -- translate it - local results = {} - local uniques = {} - for _, line in ipairs(outdata:split("\n", {plain = true})) do - - -- get includefile - local includefile = _include_note(self, line:trim()) - if includefile then - - -- get the relative - includefile = path.relative(includefile, project.directory()) - includefile = path.absolute(includefile) - - -- save it if belong to the project - if includefile:startswith(os.projectdir()) then - - -- insert it and filter repeat - includefile = path.relative(includefile, project.directory()) - if not uniques[includefile] then - table.insert(results, includefile) - uniques[includefile] = true - end - end - end - end - return results -end - -- make the compile arguments list for the precompiled header function _compargv1_pch(self, pcheaderfile, pcoutputfile, flags) @@ -434,7 +369,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) local results = "" for _, line in ipairs(tostring(errors):split("\n", {plain = true})) do line = line:rtrim() - if not _include_note(self, line) then + if not parse_include(line) then results = results .. line .. "\r\n" end end @@ -471,8 +406,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) -- generate the dependent includes if dependinfo and outdata then - dependinfo.files = dependinfo.files or {} - table.join2(dependinfo.files, _include_deps(self, outdata)) + dependinfo.depfiles_cl = outdata end end diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 304075b0b..be951c2a9 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -25,7 +25,6 @@ import("core.project.project") import("core.platform.platform") import("core.language.language") import("private.tools.ccache") -import("private.tools.nvcc.parse_deps") -- init it function init(self) |
