diff options
| author | ruki <[email protected]> | 2023-10-11 00:46:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-10-11 00:46:12 +0800 |
| commit | 5ccc226acf853c44e845ee76c7adc16ce7799de1 (patch) | |
| tree | 25ce8430d3f73dde38b90ca2fa93f728339caeca | |
| parent | cfb5ce758e5ffd7bcc41d09fafa9d5be3604c7a8 (diff) | |
add diagnosis.check_build_deps policy
| -rw-r--r-- | xmake/core/project/policy.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 02a6132df..aa8e9ef9d 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -118,7 +118,9 @@ function policy.policies() -- Stop to test on the first failure ["test.stop_on_first_failure"] = {description = "Stop to test on the first failure", default = false, type = "boolean"}, -- Return zero as exit code on failure - ["test.return_zero_on_failure"] = {description = "Return zero as the exit code on failure", default = false, type = "boolean"} + ["test.return_zero_on_failure"] = {description = "Return zero as the exit code on failure", default = false, type = "boolean"}, + -- Show diagnosis info for checking build dependencies + ["diagnosis.check_build_deps"] = {description = "Show diagnosis info for checking build dependencies", default = false, type = "boolean"} } policy._POLICIES = policies end 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 |
