diff --git a/.cmake-format.py b/.cmake-format.py index a4adcf5..d5dd45a 100644 --- a/.cmake-format.py +++ b/.cmake-format.py @@ -4,5 +4,15 @@ "kwargs": { "PKG": "*" } + }, + "format_and_lint": { + "kwargs": { + "CC": "*", + "CCDEPENDS": "*", + "CMAKE": "*", + "PY": "*", + "JS": "*", + "EXCLUDE": "*" + } } } diff --git a/CMakeLists.txt b/CMakeLists.txt index ae682cd..43aeae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ set(CXX_STANDARD set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${CXX_STANDARD}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") +add_custom_target(chkfmt) add_custom_target(doc) add_custom_target(format) add_custom_target(gen) @@ -126,4 +127,7 @@ add_custom_target( ) add_custom_target(pre-push) -add_dependencies(pre-push better-test doc format gen lint) +add_dependencies(pre-push lint chkfmt) + +add_custom_target(pre-release) +add_dependencies(pre-release better-test doc lint chkfmt) diff --git a/cmake/codestyle.cmake b/cmake/codestyle.cmake index d014c51..6ae5ef1 100644 --- a/cmake/codestyle.cmake +++ b/cmake/codestyle.cmake @@ -35,137 +35,271 @@ # cannot find the headers or if they are stale. We will need the code generator # to run before linting the dependant files. # ~~~ +if(EXISTS ${CMAKE_SOURCE_DIR}/cmake_format) + set(CMAKE_FORMAT_CMD python -Bm cmake_format) +else() + set(CMAKE_FORMAT_CMD cmake-format) +endif() + function(format_and_lint module) - set(cmake_files_) - set(cc_files_) - set(ccdepends_files_) - set(py_files_) - set(js_files_) - set(unknown_files_) - set(state_ "AUTO") - - # TODO(josh): I'm pretty sure this can be covered by a cmake_parse_args(args - # "" "" "CMAKE;CC;CCDEPENDS;PY" ${ARGN}) where the "auto" list is just - # ${args_UNPARED_ARGUMENTS} - foreach(arg ${ARGN}) - # assign by filename - if(state_ STREQUAL "AUTO") - if(arg STREQUAL "CMAKE" - OR arg STREQUAL "CC" - OR arg STREQUAL "CCDEPENDS" - OR arg STREQUAL "PY") - set(state_ SPECIFIC) - string(TOLOWER ${arg} typename_) - set(active_list_ ${typename_}_files_) - else() - if(arg MATCHES ".*\.cmake$" OR arg MATCHES ".*CMakeLists.txt") - list(APPEND cmake_files_ ${arg}) - elseif(arg MATCHES ".*\.py$") - list(APPEND py_files_ ${arg}) - elseif(arg MATCHES ".*\.(c|cc|h|hpp)$") - list(APPEND cc_files_ ${arg}) - elseif(arg MATCHES ".*\.js(\.tpl)?$") - list(APPEND js_files_ ${arg}) - else() - list(APPEND unknown_files_ ${arg}) - endif() - endif() - elseif(state_ STREQUAL "SPECIFIC") - if(arg STREQUAL "CMAKE" - OR arg STREQUAL "CC" - OR arg STREQUAL "PY" - OR arg STREQUAL "CCDEPENDS") - string(TOLOWER ${arg} typename_) - set(active_list_ ${typename_}_files_) - else() - list(APPEND ${active_list_} ${arg}) - endif() + set(_multiargs CMAKE CC CCDEPENDS PY JS EXCLUDE) + cmake_parse_arguments(_args "" "" "${_multiargs}" ${ARGN}) + set(_unknown_files) + foreach(_arg ${_args_UNPARSED_ARGUMENTS}) + if("${_arg}" MATCHES ".*\.cmake$" OR "${_arg}" MATCHES ".*CMakeLists.txt") + list(APPEND _args_CMAKE ${_arg}) + elseif("${_arg}" MATCHES ".*\.py$") + list(APPEND _args_PY ${_arg}) + elseif("${_arg}" MATCHES ".*\.(h|(hh)|(hpp))$") + list(APPEND _args_CC ${_arg}) + elseif("${_arg}" MATCHES ".*\.(c|(cc)|(cpp))$") + list(APPEND _args_CC ${_arg}) + elseif("${_arg}" MATCHES ".*\.js(\.tpl)?$") + list(APPEND _args_JS ${_arg}) + else() + list(APPEND _unknown_files ${_arg}) endif() endforeach() - set(fmtcmds_) - set(depfiles_ ${ccdepends_files_}) - if(cmake_files_) - # cmake-format: off - list( - APPEND fmtcmds_ - COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} - python -Bm cmake_format -i ${cmake_files_}) - # cmake-format: on - list(APPEND depfiles_ ${cmake_files_} ${CMAKE_SOURCE_DIR}/.cmake-format.py) - endif() - if(cc_files_) - # cmake-format: off - list( - APPEND fmtcmds_ - COMMAND clang-format-6.0 -style file -i ${cc_files_}) - # cmake-format: on - list(APPEND lntcmds_ COMMAND clang-tidy-6.0 -p ${CMAKE_BINARY_DIR} - ${cc_files_}) - list(APPEND lntcmds_ COMMAND cpplint ${cc_files_}) - list(APPEND depfiles_ ${cc_files_} ${CMAKE_SOURCE_DIR}/.clang-format - ${CMAKE_SOURCE_DIR}/CPPLINT.cfg) - endif() - if(py_files_) - list(APPEND fmtcmds_ COMMAND autopep8 -i ${py_files_}) - # NOTE(josh): --rcfile= is required because some of our python files are - # note entirely within the package tree from the root of the repository. As - # such pylint will not match the rcfile in the root of the repository. - # cmake-format: off - list( - APPEND lntcmds_ - COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} - pylint --rcfile=${CMAKE_SOURCE_DIR}/pylintrc ${py_files_}) - # cmake-format: on - # NOTE(josh): flake8 tries to use semaphores which fail in our containers - # https://bugs.python.org/issue3770 (probably due to /proc/shmem or - # something not being mounted) - # cmake-format: off - list( - APPEND lntcmds_ - COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} flake8 --jobs 1 ${py_files_}) - # cmake-format: on - list(APPEND depfiles_ ${py_files_} ${CMAKE_SOURCE_DIR}/.flake8 - ${CMAKE_SOURCE_DIR}/.pep8 ${CMAKE_SOURCE_DIR}/pylintrc) - endif() - if(js_files_) - # list(APPEND fmtcmds_ COMMAND esformat ${js_files_}) - list(APPEND lntcmds_ COMMAND eslint ${js_files_}) - list(APPEND depfiles_ ${js_files_} ${CMAKE_SOURCE_DIR}/.eslintrc.js) - endif() + set(_cmake_lintdeps) + set(_cmake_fmtdeps) + set(_cmake_chkfmtdeps) + foreach(_filename ${_args_CMAKE}) + get_filename_component(_dirpath ${CMAKE_CURRENT_BINARY_DIR}/${_filename} + DIRECTORY) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp + # NOTE(josh): disabled for now + # ~~~ + # COMMAND cmake-lint ${_filename} + # ~~~ + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND _cmake_lintdeps + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp) - set(fmtstamp_ ${CMAKE_CURRENT_BINARY_DIR}/${module}_format.stamp) - add_custom_command( - OUTPUT ${fmtstamp_} ${fmtcmds_} - COMMAND touch ${fmtstamp_} - DEPENDS ${depfiles_} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - add_custom_target(${module}_format DEPENDS ${fmtstamp_}) - add_dependencies(format ${module}_format) - - set(lntstamp_ ${CMAKE_CURRENT_BINARY_DIR}/${module}_lint.stamp) - add_custom_command( - OUTPUT ${lntstamp_} ${lntcmds_} - COMMAND touch ${lntstamp_} - DEPENDS ${depfiles_} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - add_custom_target(${module}_lint DEPENDS ${lntstamp_}) - add_dependencies(lint ${module}_lint) - - if(unknown_files_) - string(REPLACE ";" "\n " filelist_ "${unknown_files_}") + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + COMMAND ${CMAKE_FORMAT_CMD} -i ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _cmake_fmtdeps + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + COMMAND ${CMAKE_FORMAT_CMD} --check + ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _cmake_chkfmtdeps + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt) + endforeach() + + set(_cc_lintdeps) + set(_cc_fmtdeps) + set(_cc_chkfmtdeps) + foreach(_filename ${_args_CC}) + get_filename_component(_dirpath ${CMAKE_CURRENT_BINARY_DIR}/${_filename} + DIRECTORY) + + if("${_filename}" MATCHES ".*\.(c|(cc)|(cpp))$") + # NOTE(josh): clang-tidy doesn't work on header files. It will check + # headers that it finds in the inclusion of translation units it + # understands + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.tidy + COMMAND + clang-tidy-8 -p ${CMAKE_BINARY_DIR} -header-filter=${CMAKE_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.tidy + DEPENDS ${_filename} ${_args_CCDEPENDS} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _cc_lintdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.tidy) + endif() + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.cpplint + COMMAND cpplint ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.cpplint + DEPENDS ${_filename} ${_args_CCDEPENDS} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _cc_lintdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.cpplint) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + COMMAND clang-format-8 -style file -i ${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + DEPENDS ${_filename} ${_args_CCDEPENDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND _cc_fmtdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + COMMAND + COMMAND + clang-format-8 -style file ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} "|" + diff -u ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} - + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + DEPENDS ${_filename} ${_args_CCDEPENDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND _cc_chkfmtdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt) + endforeach() + + set(_js_lintdeps) + set(_js_fmtdeps) + set(_js_chkfmtdeps) + foreach(_filename ${_args_JS}) + get_filename_component(_dirpath ${CMAKE_CURRENT_BINARY_DIR}/${_filename} + DIRECTORY) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp + COMMAND eslint ${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND _js_lintdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + COMMAND js-beautify -r ${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND _js_fmtdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + COMMAND js-beautify ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} "|" diff -u + ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} - + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _js_chkfmtdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt) + endforeach() + + set(_py_lintdeps) + set(_py_fmtdeps) + set(_py_chkfmtdeps) + foreach(_filename ${_args_PY}) + get_filename_component(_dirpath ${CMAKE_CURRENT_BINARY_DIR}/${_filename} + DIRECTORY) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp + # NOTE(josh): --rcfile= is required because some of our python + # files are note entirely within the package tree from the root of + # the repository. As such pylint will not match the rcfile in the + # root of the repository. + COMMAND + env PYTHONPATH=${CMAKE_SOURCE_DIR} pylint + --rcfile=${CMAKE_SOURCE_DIR}/pylintrc -sn -rn + ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} + # NOTE(josh): flake8 tries to use semaphores which fail in our + # containers https://bugs.python.org/issue3770 (probably due to + # /proc/shmem or something not being mounted) + COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} flake8 --jobs 1 + ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _py_lintdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.lintstamp) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + COMMAND autopep8 -i ${_filename} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND _py_fmtdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.fmtstamp) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + COMMAND autopep8 ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} "|" diff -u + ${CMAKE_CURRENT_SOURCE_DIR}/${_filename} - + COMMAND ${CMAKE_COMMAND} -E make_directory ${_dirpath} + COMMAND ${CMAKE_COMMAND} -E touch + ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt + DEPENDS ${_filename} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + list(APPEND _py_chkfmtdeps ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.chkfmt) + endforeach() + + if(_unknown_files) + string(REPLACE ";" "\n " filelist_ "${_unknown_files}") message( WARNING "The following files will not be linted/formatted because their" " extension is not recognized: \n ${filelist_}") endif() file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${module}.lint-manifest "") - foreach(listname_ cmake_files_ cc_files_ py_files_ js_files_) + foreach(listname_ _args_CC _args_CMAKE _args_JS _args_PY) if(${listname_}) string(REPLACE ";" "\n" filenames_ "${${listname_}}") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${module}.lint-manifest - "${filenames_}\n") + "${filenames_}\n") endif() endforeach() + add_custom_target(lint-cc-${module} DEPENDS ${_cc_lintdeps}) + add_custom_target(lint-cmake-${module} DEPENDS ${_cmake_lintdeps}) + add_custom_target(lint-js-${module} DEPENDS ${_js_lintdeps}) + add_custom_target(lint-py-${module} DEPENDS ${_py_lintdeps}) + add_custom_target( + lint-${module} DEPENDS lint-cc-${module} lint-cmake-${module} + lint-js-${module} lint-py-${module}) + add_dependencies(lint lint-${module}) + + add_custom_target(format-cc-${module} DEPENDS ${_cc_fmtdeps}) + add_custom_target(format-cmake-${module} DEPENDS ${_cmake_fmtdeps}) + add_custom_target(format-js-${module} DEPENDS ${_js_fmtdeps}) + add_custom_target(format-py-${module} DEPENDS ${_py_fmtdeps}) + add_custom_target( + format-${module} DEPENDS format-cc-${module} format-cmake-${module} + format-js-${module} format-py-${module}) + add_dependencies(format format-${module}) + + add_custom_target(chkfmt-cc-${module} DEPENDS ${_cc_chkfmtdeps}) + add_custom_target(chkfmt-cmake-${module} DEPENDS ${_cmake_chkfmtdeps}) + add_custom_target(chkfmt-js-${module} DEPENDS ${_js_chkfmtdeps}) + add_custom_target(chkfmt-py-${module} DEPENDS ${_py_chkfmtdeps}) + add_custom_target( + chkfmt-${module} DEPENDS chkfmt-cc-${module} chkfmt-cmake-${module} + chkfmt-js-${module} chkfmt-py-${module}) + add_dependencies(chkfmt chkfmt-${module}) + + add_test( + NAME validate-${module}-lint-manifest + COMMAND python -Bm cmake.validate_lint_manifest ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} --exclude ${_args_EXCLUDE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endfunction() diff --git a/cmake/validate_lint_manifest.py b/cmake/validate_lint_manifest.py index f9c6857..f016d60 100644 --- a/cmake/validate_lint_manifest.py +++ b/cmake/validate_lint_manifest.py @@ -89,7 +89,11 @@ def get_generated_manifest(rootdir): if filename.endswith(".lint-manifest"): fullpath_file = os.path.join(rootdir, relpath_file) with io.open(fullpath_file, "r", encoding="utf-8") as infile: - manifest.extend(line.strip() for line in infile) + if relpath_dir == ".": + manifest.extend(line.strip() for line in infile) + else: + manifest.extend( + os.path.join(relpath_dir, line.strip()) for line in infile) return manifest diff --git a/cmake_format/CMakeLists.txt b/cmake_format/CMakeLists.txt index 0e0694b..b02bb57 100644 --- a/cmake_format/CMakeLists.txt +++ b/cmake_format/CMakeLists.txt @@ -75,6 +75,7 @@ format_and_lint( tools/__init__.py tools/bump_version.py tools/create_pseudorelease_tag.py + tools/gen_config_details.py tools/gen_rtd_requirements.py tools/generate_missing_parsers.py tools/get_release_notes.py @@ -82,9 +83,9 @@ format_and_lint( tools/push_github_release.py tools/usage_lexer.py tools/usage_parser.py + tools/split_help.py vscode_extension/CMakeLists.txt - # EXCLUDE "command_tests/" "doc/stage" "test/.*" ".*\\.jinja.py$" -) + EXCLUDE "command_tests/" "doc/stage" "test/.*" ".*\\.jinja.py$") set(_testnames invocation_tests layout_tests lexer_tests markup_tests parser_tests) @@ -214,8 +215,8 @@ add_custom_target( COMMENT "Uploading release artifacts" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -# NOTE(josh): cmake is broken. It fails to produce an accurate build system -# when we correctly specify the .vsix path in the above rule. We must use -# target level dependencies to get the correct order of operations and then -# omit the actual file-level dependency. +# NOTE(josh): cmake is broken. It fails to produce an accurate build system when +# we correctly specify the .vsix path in the above rule. We must use target +# level dependencies to get the correct order of operations and then omit the +# actual file-level dependency. add_dependencies(push-github-release vscode-extension) diff --git a/cmake_format/tools/gen_config_details.py b/cmake_format/tools/gen_config_details.py index bbb8fba..03e7b91 100644 --- a/cmake_format/tools/gen_config_details.py +++ b/cmake_format/tools/gen_config_details.py @@ -30,7 +30,7 @@ def parse_sourcefile(infile): } varname = None - buffer = [] + buf = [] lineiter = enumerate(lines) for idx, line in lineiter: @@ -38,9 +38,9 @@ def parse_sourcefile(infile): if lines[idx + 2] == line: # Section heading if varname: - stack[-1][varname] = "\n".join(buffer) + stack[-1][varname] = "\n".join(buf) varname = None - buffer = [] + buf = [] title = lines[idx + 1] newdict = {} @@ -53,17 +53,17 @@ def parse_sourcefile(infile): elif line and ruler.match(lines[idx + 1]): # Variable heading if varname: - stack[-1][varname] = "\n".join(buffer[:-1]) + stack[-1][varname] = "\n".join(buf[:-1]) varname = None - buffer = [] + buf = [] varname = line next(lineiter) else: - buffer.append(line) + buf.append(line) if varname: - stack[-1][varname] = "\n".join(buffer[:-1]) - buffer = [] + stack[-1][varname] = "\n".join(buf[:-1]) + buf = [] varname = None return out @@ -98,10 +98,10 @@ def get_command_line(descr): def get_config_example(root, obj, descr): default_value = descr.__get__(obj, None) descr.__set__(obj, default_value) - buffer = io.StringIO() - root.dump(buffer, with_defaults=False) + buf = io.StringIO() + root.dump(buf, with_defaults=False) descr.unset(obj) - return buffer.getvalue() + return buf.getvalue() def write_outfile(outfile, data, obj, name=None, depth=0, root=None): diff --git a/cmake_format/tools/split_help.py b/cmake_format/tools/split_help.py index 34381da..26fcae3 100644 --- a/cmake_format/tools/split_help.py +++ b/cmake_format/tools/split_help.py @@ -4,7 +4,6 @@ """ import argparse -import inspect import io from cmake_format import configuration @@ -21,7 +20,7 @@ def main(): for _, item in vars(configuration).items(): if (isinstance(item, type) and issubclass(item, configuration.ConfigObject) and - not item is configuration.ConfigObject): + item is not configuration.ConfigObject): firstline = item.__doc__.strip().split("\n")[0] matchlines.append(firstline) @@ -44,5 +43,6 @@ def main(): with io.open(args.common_outfile, "w", encoding="utf-8") as outfile: outfile.write("".join(common_lines)) + if __name__ == "__main__": main() diff --git a/cmake_lint/CMakeLists.txt b/cmake_lint/CMakeLists.txt index 47b8f26..2681b24 100644 --- a/cmake_lint/CMakeLists.txt +++ b/cmake_lint/CMakeLists.txt @@ -13,8 +13,7 @@ format_and_lint( test/execution_tests.py test/expect_tests.py test/genfiles.py - #EXCLUDE "test/.*" -) + EXCLUDE "test/.*") set(_genfiles ${CMAKE_CURRENT_SOURCE_DIR}/test/expect_lint.cmake ${CMAKE_CURRENT_SOURCE_DIR}/test/lint_tests.cmake) diff --git a/tangent/CMakeLists.txt b/tangent/CMakeLists.txt index 297005a..c9cbd55 100644 --- a/tangent/CMakeLists.txt +++ b/tangent/CMakeLists.txt @@ -1,3 +1,3 @@ -if(EXISTS gtkutil/CMakeLists.txt) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gtkutil/CMakeLists.txt) add_subdirectory(gtkutil) endif()