diff --git a/.gersemirc.example b/.gersemirc.example index ca8bb81..429629a 100644 --- a/.gersemirc.example +++ b/.gersemirc.example @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/0.18.0-rc1/gersemi/configuration.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/0.18.0/gersemi/configuration.schema.json definitions: [] disable_formatting: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a61ef9..43ea1b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog -## [0.18.0] 2025-XX-XX +## [0.18.0] 2025-01-10 ### Added - Add support for extensions and provide example extension as a template. ### Fixed - Recognize `unquoted_legacy` rule of CMake language. (#49) +- Cut down excessive memory usage when used on a project with big number of files. +- Correctly recognize keywords from download, upload and patch steps of `ExternalProject_Add` in `FetchContent_Declare`. (#50) ## [0.17.1] 2024-11-29 ### Fixed diff --git a/gersemi/__version__.py b/gersemi/__version__.py index f4e43b4..70377c1 100644 --- a/gersemi/__version__.py +++ b/gersemi/__version__.py @@ -4,4 +4,4 @@ __license__ = "MPL 2.0" __title__ = "gersemi" __url__ = "/~https://github.com/BlankSpruce/gersemi" -__version__ = "0.18.0-rc1" +__version__ = "0.18.0" diff --git a/gersemi/builtin_commands.py b/gersemi/builtin_commands.py index e8a8a3e..f4ac919 100644 --- a/gersemi/builtin_commands.py +++ b/gersemi/builtin_commands.py @@ -53,6 +53,61 @@ "one_value_keywords": ["debug", "optimized", "general"] } +_ExternalProject_Add_DownloadStep = { + "one_value_keywords": { + # Described in "Directory Options" + "DOWNLOAD_DIR", + # + "URL_HASH", + "URL_MD5", + "DOWNLOAD_NAME", + "DOWNLOAD_EXTRACT_TIMESTAMP", + "DOWNLOAD_NO_EXTRACT", + "DOWNLOAD_NO_PROGRESS", + "TIMEOUT", + "INACTIVITY_TIMEOUT", + "HTTP_USERNAME", + "HTTP_PASSWORD", + "TLS_VERSION", + "TLS_VERIFY", + "TLS_CAINFO", + "NETRC", + "NETRC_FILE", + "GIT_REPOSITORY", + "GIT_TAG", + "GIT_REMOTE_NAME", + "GIT_SUBMODULES_RECURSE", + "GIT_SHALLOW", + "GIT_PROGRESS", + "GIT_REMOTE_UPDATE_STRATEGY", + "SVN_REPOSITORY", + "SVN_REVISION", + "SVN_USERNAME", + "SVN_PASSWORD", + "SVN_TRUST_CERT", + "HG_REPOSITORY", + "HG_TAG", + "CVS_REPOSITORY", + "CVS_MODULE", + "CVS_TAG", + }, + "multi_value_keywords": { + "DOWNLOAD_COMMAND", + "URL", + "HTTP_HEADER", + "GIT_SUBMODULES", + "GIT_CONFIG", + }, +} +_ExternalProject_Add_UpdateStep = { + "one_value_keywords": ["UPDATE_DISCONNECTED"], + "multi_value_keywords": ["UPDATE_COMMAND"], +} +_ExternalProject_Add_PatchStep = { + "one_value_keywords": [], + "multi_value_keywords": ["PATCH_COMMAND"], +} + builtin_commands_impl = { #### Legend @@ -2148,38 +2203,11 @@ "BINARY_DIR", "INSTALL_DIR", # Download Step - "URL_HASH", - "URL_MD5", - "DOWNLOAD_NAME", - "DOWNLOAD_NO_EXTRACT", - "TIMEOUT", - "HTTP_USERNAME", - "HTTP_PASSWORD", - "TLS_VERIFY", - "TLS_CAINFO", - "NETRC", - "NETRC_FILE", - "GIT_REPOSITORY", - "GIT_TAG", - "GIT_REMOTE_NAME", - "GIT_SUBMODULES_RECURSE", - "GIT_SHALLOW", - "GIT_PROGRESS", - "GIT_REMOTE_UPDATE_STRATEGY", - "SVN_REPOSITORY", - "SVN_REVISION", - "SVN_USERNAME", - "SVN_PASSWORD", - "SVN_TRUST_CERT", - "HG_REPOSITORY", - "HG_TAG", - "CVS_REPOSITORY", - "CVS_MODULE", - "CVS_TAG", - "DOWNLOAD_EXTRACT_TIMESTAMP", - "TLS_VERSION", - # Update/Patch Step - "UPDATE_DISCONNECTED", + *_ExternalProject_Add_DownloadStep["one_value_keywords"], + # Update Step + *_ExternalProject_Add_UpdateStep["one_value_keywords"], + # Patch Step + *_ExternalProject_Add_PatchStep["one_value_keywords"], # Configure Step "CMAKE_COMMAND", "CMAKE_GENERATOR", @@ -2222,14 +2250,11 @@ ], "multi_value_keywords": [ # Download Step - "DOWNLOAD_COMMAND", - "URL", - "HTTP_HEADER", - "GIT_SUBMODULES", - "GIT_CONFIG", - # Update/Patch Step - "UPDATE_COMMAND", - "PATCH_COMMAND", + *_ExternalProject_Add_DownloadStep["multi_value_keywords"], + # Update Step + *_ExternalProject_Add_UpdateStep["multi_value_keywords"], + # Patch Step + *_ExternalProject_Add_PatchStep["multi_value_keywords"], # Configure Step "CONFIGURE_COMMAND", "CMAKE_ARGS", @@ -2318,49 +2343,20 @@ "options": ["SYSTEM", "OVERRIDE_FIND_PACKAGE", "EXCLUDE_FROM_ALL"], "one_value_keywords": [ # Download Step - "URL_HASH", - "URL_MD5", - "DOWNLOAD_NAME", - "DOWNLOAD_NO_EXTRACT", - "TIMEOUT", - "HTTP_USERNAME", - "HTTP_PASSWORD", - "TLS_VERIFY", - "TLS_CAINFO", - "NETRC", - "NETRC_FILE", - "GIT_REPOSITORY", - "GIT_TAG", - "GIT_REMOTE_NAME", - "GIT_SUBMODULES_RECURSE", - "GIT_SHALLOW", - "GIT_PROGRESS", - "GIT_REMOTE_UPDATE_STRATEGY", - "SVN_REPOSITORY", - "SVN_REVISION", - "SVN_USERNAME", - "SVN_PASSWORD", - "SVN_TRUST_CERT", - "HG_REPOSITORY", - "HG_TAG", - "CVS_REPOSITORY", - "CVS_MODULE", - "CVS_TAG", - "SOURCE_SUBDIR", - # Update/Patch Step - "UPDATE_DISCONNECTED", + *_ExternalProject_Add_DownloadStep["one_value_keywords"], + # Update Step + *_ExternalProject_Add_UpdateStep["one_value_keywords"], + # Patch Step + *_ExternalProject_Add_PatchStep["one_value_keywords"], ], "multi_value_keywords": [ "FIND_PACKAGE_ARGS", # Download Step - "DOWNLOAD_COMMAND", - "URL", - "HTTP_HEADER", - "GIT_SUBMODULES", - "GIT_CONFIG", - # Update/Patch Step - "UPDATE_COMMAND", - "PATCH_COMMAND", + *_ExternalProject_Add_DownloadStep["multi_value_keywords"], + # Update Step + *_ExternalProject_Add_UpdateStep["multi_value_keywords"], + # Patch Step + *_ExternalProject_Add_PatchStep["multi_value_keywords"], ], "keyword_kinds": { key: KeywordKind.CommandLine diff --git a/tests/formatter/issue_0050_fetchcontent_declare.in.cmake b/tests/formatter/issue_0050_fetchcontent_declare.in.cmake new file mode 100644 index 0000000..24dc1ed --- /dev/null +++ b/tests/formatter/issue_0050_fetchcontent_declare.in.cmake @@ -0,0 +1,19 @@ +### {list_expansion: favour-expansion} +# https://cmake.org/cmake/help/latest/module/FetchContent.html#commands +# +# The can be any of the download, update, or patch +# options that the ExternalProject_Add() command understands. + +FetchContent_Declare( + ${fetchcontent_target} + HTTP_USERNAME + "$ENV{USERNAME}" + HTTP_PASSWORD "$ENV{PASSWORD}" + URL + "${src_url}" + DOWNLOAD_NO_EXTRACT TRUE + URL_HASH SHA256=${exp_hash} + DOWNLOAD_DIR + ${dst_folder} + DOWNLOAD_NAME ${download_name} +) diff --git a/tests/formatter/issue_0050_fetchcontent_declare.out.cmake b/tests/formatter/issue_0050_fetchcontent_declare.out.cmake new file mode 100644 index 0000000..f78ec8e --- /dev/null +++ b/tests/formatter/issue_0050_fetchcontent_declare.out.cmake @@ -0,0 +1,16 @@ +# https://cmake.org/cmake/help/latest/module/FetchContent.html#commands +# +# The can be any of the download, update, or patch +# options that the ExternalProject_Add() command understands. + +FetchContent_Declare( + ${fetchcontent_target} + HTTP_USERNAME "$ENV{USERNAME}" + HTTP_PASSWORD "$ENV{PASSWORD}" + URL + "${src_url}" + DOWNLOAD_NO_EXTRACT TRUE + URL_HASH SHA256=${exp_hash} + DOWNLOAD_DIR ${dst_folder} + DOWNLOAD_NAME ${download_name} +)