Commit cf2663ec authored by Ben Boeckel's avatar Ben Boeckel
Browse files

cmake: indicate the type of each formatter

parent 49f89ea8
function (add_formatter name)
function (add_formatter name type)
if (type STREQUAL "check")
elseif (type STREQUAL "reformat")
else ()
"The formatter type of ${name} must be either `check` or `reformat`.")
endif ()
set_property(GLOBAL APPEND
PROPERTY "formatter_${name}_type" "${type}")
set(tools_exist TRUE)
foreach (tool IN LISTS ARGN)
......@@ -59,6 +69,13 @@ if (formatters)
continue ()
endif ()
# Do not reformat with check-only tools.
get_property(formatter_type GLOBAL
PROPERTY "formatter_${formatter}_type")
if (NOT formatter_type STREQUAL "reformat")
continue ()
endif ()
get_property("formatter_script" GLOBAL
PROPERTY "formatter_${formatter}_script")
string(APPEND formatters_build "format_all '${formatter}' '${formatter_script}'\n")
add_formatter(clang-format clang-format)
add_formatter(clang-format reformat clang-format)
add_formatter(autopep8 autopep8)
add_formatter(pep8 pep8)
add_formatter(flake8 flake8)
add_formatter(autopep8 reformat autopep8)
add_formatter(pep8 check pep8)
add_formatter(flake8 check flake8)
add_formatter(rustfmt rustfmt)
add_formatter(rustfmt reformat rustfmt)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment