]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: add `curl-lint`/`lint` targets, `CURL_LINT` cmake option
authorViktor Szakats <commit@vsz.me>
Sat, 3 Jan 2026 16:08:18 +0000 (17:08 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 12 Jan 2026 15:45:24 +0000 (16:45 +0100)
To run checksrc and spacecheck on the source tree. Also for cmake
to sync up with autotools' `checksrc` target.

- cmake: `curl-lint`
  With `-DCURL_LINT=ON`, checks run automatically for all targets.
- autotools: `lint`

Closes #20175

.github/workflows/checksrc.yml
CMakeLists.txt
Makefile.am
docs/INSTALL-CMAKE.md
scripts/Makefile.am
scripts/spacecheck.pl [moved from .github/scripts/spacecheck.pl with 100% similarity]

index 1baf0125fa7ed5c859f876f37aacd9d71489713e..4c0a5909b925b01d7bd316f15f90a055afba7b95 100644 (file)
@@ -173,7 +173,7 @@ jobs:
           .github/scripts/shellcheck.sh
 
       - name: 'spacecheck'
-        run: .github/scripts/spacecheck.pl
+        run: scripts/spacecheck.pl
 
       - name: 'yamlcheck'
         run: .github/scripts/yamlcheck.sh
index 92c6b920266ea9666c16006fc186b1b5f6577fa4..b0daa102d3658252dc3202c3822211f472f56add 100644 (file)
@@ -500,6 +500,8 @@ if(WINDOWS_STORE)
   set(CURL_DISABLE_TELNET ON)  # telnet code needs fixing to compile for UWP.
 endif()
 
+option(CURL_LINT "Run lint checks while building" OFF)
+
 find_package(Perl)
 
 if(PERL_EXECUTABLE)
@@ -513,6 +515,18 @@ if(PERL_EXECUTABLE)
     COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/firefox-db2pem.sh" "lib/ca-bundle.crt"
     DEPENDS "${PROJECT_SOURCE_DIR}/scripts/firefox-db2pem.sh"
   )
+  if(CURL_LINT)
+    set(_lint_all ALL)
+  endif()
+  add_custom_target(curl-lint "${_lint_all}"
+    COMMENT "Running lint checks" VERBATIM USES_TERMINAL
+    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+    COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/checksrc-all.pl"
+    COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/spacecheck.pl"
+    DEPENDS
+      "${PROJECT_SOURCE_DIR}/scripts/checksrc-all.pl" "${PROJECT_SOURCE_DIR}/scripts/checksrc.pl"
+      "${PROJECT_SOURCE_DIR}/scripts/spacecheck.pl"
+  )
 endif()
 
 option(BUILD_LIBCURL_DOCS "Build libcurl man pages" ON)
index 5434d5e4d34fd1057b8ce98eedccd74b0527a984..bb405ee569f481bdbf8094dcd5c014755ebdd27e 100644 (file)
@@ -200,6 +200,9 @@ checksrc:
        (cd docs/examples && $(MAKE) checksrc)
        (cd packages && $(MAKE) checksrc)
 
+lint: checksrc
+       @PERL@ $(top_srcdir)/scripts/spacecheck.pl
+
 tidy:
        (cd src && $(MAKE) tidy)
        (cd lib && $(MAKE) tidy)
index 03b96761459cb4d65ec7eac757cdb6b47ef5df9c..c8bd7b4ad974b7b5f3860e9eac811588c74ace90 100644 (file)
@@ -241,6 +241,7 @@ target_link_libraries(my_target PRIVATE CURL::libcurl)
 - `CURL_LIBCURL_SOVERSION`:                 Enable libcurl SOVERSION. Default: `ON` for supported platforms
 - `CURL_LIBCURL_VERSIONED_SYMBOLS`:         Enable libcurl versioned symbols. Default: `OFF`
 - `CURL_LIBCURL_VERSIONED_SYMBOLS_PREFIX`:  Override default versioned symbol prefix. Default: `<TLS-BACKEND>_` or `MULTISSL_`
+- `CURL_LINT`:                              Run lint checks while building. Default: `OFF`
 - `CURL_LTO`:                               Enable compiler Link Time Optimizations. Default: `OFF`
 - `CURL_STATIC_CRT`:                        Build libcurl with static CRT with MSVC (`/MT`) (requires UCRT, static libcurl or no curl executable). Default: `OFF`
 - `CURL_TARGET_WINDOWS_VERSION`:            Minimum target Windows version as hex string.
@@ -544,6 +545,7 @@ Note: These variables are internal and subject to change.
 - `curl-completion-zsh`:    Build shell completions for zsh (built by default if enabled)
 - `curl-ca-bundle`:         Build the CA bundle via `scripts/mk-ca-bundle.pl`
 - `curl-ca-firefox`:        Build the CA bundle via `scripts/firefox-db2pem.sh`
+- `curl-lint`:              Run lint checks.
 - `curl-listcats`:          Generate help category constants for `src/tool_help.h` from documentation.
 - `curl-listhelp`:          Generate `src/tool_listhelp.c` from documentation.
 - `curl-optiontable`:       Generate `lib/easyoptions.c` from documentation.
index da9b6b4b7723df0c9cba8f671896b95bebeb33ad..b35c1f2a377e13e99c553c0785760d326df7f789 100644 (file)
@@ -25,8 +25,8 @@
 EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl checksrc-all.pl \
   mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen    \
   dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck          \
-  CMakeLists.txt perlcheck.sh pythonlint.sh randdisable wcurl top-complexity         \
-  extract-unit-protos .checksrc
+  CMakeLists.txt perlcheck.sh pythonlint.sh spacecheck.pl randdisable wcurl          \
+  top-complexity extract-unit-protos .checksrc
 
 dist_bin_SCRIPTS = wcurl