From cdb5fd2f2d96abc68fd46b4778db14157f11a460 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 27 Nov 2020 00:12:14 +0800 Subject: improve parse cl includes --- xmake/modules/private/tools/cl/parse_include.lua | 51 ++++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'xmake/modules/private/tools/cl/parse_include.lua') diff --git a/xmake/modules/private/tools/cl/parse_include.lua b/xmake/modules/private/tools/cl/parse_include.lua index cd311ec49..708d87667 100644 --- a/xmake/modules/private/tools/cl/parse_include.lua +++ b/xmake/modules/private/tools/cl/parse_include.lua @@ -22,37 +22,44 @@ import("core.project.project") import("core.base.hashset") --- contain: "Note: including file: "? +-- probe include note prefix from cl +function _probe_include_note_from_cl() + -- TODO +end + +-- get include notes prefix, e.g. "Note: including file: " -- -- @note we cannot get better solution to distinguish between `includes` and `error infos` -- -function main(line) +function _get_include_notes() + local notes = _g.notes + if not notes then + notes = {} + local note = _probe_include_note_from_cl() + if note then + table.insert(notes, note) + end + table.join2(notes, { + "Note: including file: ", -- en + "注意: 包含文件: ", -- zh + "Remarque : inclusion du fichier : ", -- fr + "メモ: インクルード ファイル: " -- jp + }) + _g.notes = notes + end + return notes +end - -- init notes - -- - -- TODO zh-tw, zh-hk, jp, ... - -- - _g.notes = _g.notes or - { - "Note: including file: " -- en - , "注意: 包含文件: " -- zh - , "Remarque : inclusion du fichier : " -- fr - , "メモ: インクルード ファイル: " -- jp - } +-- main entry +function main(line) -- contain notes? - for idx, note in ipairs(_g.notes) do - - -- dump line bytes - --[[ - print(line) - line:gsub(".", function (ch) print(string.byte(ch)) end) - --]] - + local notes = _get_include_notes() + for idx, note in ipairs(notes) do if line:startswith(note) then -- optimization: move this note to head if idx ~= 1 then - table.insert(_g.notes, 1, note) + table.insert(notes, 1, note) end return line:sub(#note):trim() end -- cgit v1.3.1