diff options
| author | ruki <[email protected]> | 2023-03-12 10:15:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-12 10:15:16 +0800 |
| commit | f6059fbf557f785dc4dfde88ecb7fc3c0128b1a6 (patch) | |
| tree | 2c17dcfbe3864d28ea943a5d4e69df3a677536d7 | |
| parent | f4609ef1afd0f24d6123ecf649b23edc6043a878 (diff) | |
improve note include for ninja generator
| -rw-r--r-- | xmake/modules/private/tools/cl/parse_include.lua | 8 | ||||
| -rw-r--r-- | xmake/plugins/project/ninja/build_ninja.lua | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/xmake/modules/private/tools/cl/parse_include.lua b/xmake/modules/private/tools/cl/parse_include.lua index afb43b056..700f9823f 100644 --- a/xmake/modules/private/tools/cl/parse_include.lua +++ b/xmake/modules/private/tools/cl/parse_include.lua @@ -27,7 +27,7 @@ import("lib.detect.find_tool") import("private.tools.vstool") -- probe include note prefix from cl -function _probe_include_note_from_cl() +function probe_include_note_from_cl() local key = "cldeps.parse_include.note" local note = detectcache:get(key) if not note then @@ -69,11 +69,11 @@ end -- -- @note we cannot get better solution to distinguish between `includes` and `error infos` -- -function _get_include_notes() +function get_include_notes() local notes = _g.notes if not notes then notes = {} - local note = _probe_include_note_from_cl() + local note = probe_include_note_from_cl() if note then table.insert(notes, note) end @@ -90,7 +90,7 @@ end -- main entry function main(line) - local notes = _get_include_notes() + local notes = get_include_notes() for idx, note in ipairs(notes) do if line:startswith(note) then -- optimization: move this note to head diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua index 5fce32b9a..a360d198d 100644 --- a/xmake/plugins/project/ninja/build_ninja.lua +++ b/xmake/plugins/project/ninja/build_ninja.lua @@ -27,6 +27,7 @@ import("core.tool.linker") import("core.tool.compiler") import("lib.detect.find_tool") import("lib.detect.find_toolname") +import("private.tools.cl.parse_include") -- this sourcebatch is built? function _sourcebatch_is_built(sourcebatch) @@ -174,7 +175,12 @@ end function _add_rules_for_compiler(ninjafile) ninjafile:print("# rules for compiler") if is_plat("windows") then - ninjafile:print("msvc_deps_prefix = Note: including file:") + -- @see https://github.com/ninja-build/ninja/issues/613 + local note_include = parse_include.probe_include_note_from_cl() + if not note_include then + note_include = "Note: including file:" + end + ninjafile:print("msvc_deps_prefix = %s", note_include:trim()) end local add_compiler_rules = { |
