From 5ccc226acf853c44e845ee76c7adc16ce7799de1 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 11 Oct 2023 00:46:12 +0800 Subject: add diagnosis.check_build_deps policy --- xmake/modules/core/project/depend.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'xmake/modules/core/project/depend.lua') diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 5e96c7b2a..1e9bee660 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -68,6 +68,20 @@ function load(dependfile, opt) end end +-- show diagnosis info? +function _is_show_diagnosis_info() + local show = _g.is_show_diagnosis_info + if show == nil then + if option.get("diagnosis") and project.policy("diagnosis.check_build_deps") then + show = true + else + show = false + end + _g.is_show_diagnosis_info = show + end + return show +end + -- save dependent info to file function save(dependinfo, dependfile) io.save(dependfile, dependinfo) @@ -100,6 +114,9 @@ function is_changed(dependinfo, opt) -- source and header files have been changed or not exists? if mtime == 0 or mtime > lastmtime then + if _is_show_diagnosis_info() then + cprint("${color.warning}depend file %s is changed, mtime: %s, lastmtime: %s", file, mtime, lastmtime) + end return true end end @@ -117,10 +134,16 @@ function is_changed(dependinfo, opt) if deptype ~= opttype then return true elseif deptype == "string" and depvalue ~= optvalue then + if _is_show_diagnosis_info() then + cprint("${color.warning}depend value %s != %s", depvalue, optvalue) + end return true elseif deptype == "table" then for subidx, subvalue in ipairs(depvalue) do if subvalue ~= optvalue[subidx] then + if _is_show_diagnosis_info() then + cprint("${color.warning}depend value %s != %s at index %d", subvalue, optvalue[subidx], subidx) + end return true end end @@ -135,6 +158,9 @@ function is_changed(dependinfo, opt) end for idx, file in ipairs(files) do if file ~= optfiles[idx] then + if _is_show_diagnosis_info() then + cprint("${color.warning}depend file %s != %s at index %d", file, optfiles[subidx], idx) + end return true end end -- cgit v1.3.1