diff --git a/.github/workflows/checksrc.yml b/.github/workflows/checksrc.yml index 1baf0125fa..4c0a5909b9 100644 --- a/.github/workflows/checksrc.yml +++ b/.github/workflows/checksrc.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 92c6b92026..b0daa102d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile.am b/Makefile.am index 5434d5e4d3..bb405ee569 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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) diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index 03b9676145..c8bd7b4ad9 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -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: `_` 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. diff --git a/scripts/Makefile.am b/scripts/Makefile.am index da9b6b4b77..b35c1f2a37 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -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 diff --git a/.github/scripts/spacecheck.pl b/scripts/spacecheck.pl similarity index 100% rename from .github/scripts/spacecheck.pl rename to scripts/spacecheck.pl