From: Viktor Szakats Date: Fri, 17 Nov 2023 21:42:54 +0000 (+0000) Subject: cmake: add test for `DISABLE` options, add `CURL_DISABLE_HEADERS_API` X-Git-Tag: curl-8_5_0~75 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33493db2af2dc6d9910f5d7c702aae6f63b8a6a6;p=thirdparty%2Fcurl.git cmake: add test for `DISABLE` options, add `CURL_DISABLE_HEADERS_API` - tests: verify CMake `DISABLE` options. Make an exception for 2 CMake-only ones, and one more that's using a different naming scheme, also in autotools and source. - cmake: add support for `CURL_DISABLE_HEADERS_API`. Suggested-by: Daniel Stenberg Ref: https://github.com/curl/curl/pull/12345#pullrequestreview-1736238641 Closes #12353 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index db138237aa..a71b5b0b5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,6 +222,8 @@ option(CURL_DISABLE_GETOPTIONS "disables curl_easy_options API for existing opti mark_as_advanced(CURL_DISABLE_GETOPTIONS) option(CURL_DISABLE_GOPHER "disables Gopher" OFF) mark_as_advanced(CURL_DISABLE_GOPHER) +option(CURL_DISABLE_HEADERS_API "disables headers-api support" OFF) +mark_as_advanced(CURL_DISABLE_HEADERS_API) option(CURL_DISABLE_HSTS "disables HSTS support" OFF) mark_as_advanced(CURL_DISABLE_HSTS) option(CURL_DISABLE_HTTP "disables HTTP" OFF) diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 3da5a41eb7..274c2c1682 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -80,6 +80,9 @@ /* disables GOPHER */ #cmakedefine CURL_DISABLE_GOPHER 1 +/* disables headers-api support */ +#cmakedefine CURL_DISABLE_HEADERS_API 1 + /* disables HSTS support */ #cmakedefine CURL_DISABLE_HSTS 1 diff --git a/tests/disable-scan.pl b/tests/disable-scan.pl index 99f5436af5..b6f3179cf7 100755 --- a/tests/disable-scan.pl +++ b/tests/disable-scan.pl @@ -29,6 +29,8 @@ use warnings; # the DISABLE options that can be set by configure my %disable; +# the DISABLE options that can be set by CMakeLists.txt +my %disable_cmake; # the DISABLE options that are used in C files my %file; # the DISABLE options that are documented @@ -61,6 +63,24 @@ sub scan_configure { } } +sub scanconf_cmake { + my ($f)=@_; + open S, "<$f"; + while() { + if(/(CURL_DISABLE_[A-Z_]+)/g) { + my ($sym)=($1); + if(not $sym =~ /(CURL_DISABLE_INSTALL|CURL_DISABLE_TESTS|CURL_DISABLE_SRP)/) { + $disable_cmake{$sym} = 1; + } + } + } + close S; +} + +sub scan_cmake { + scanconf_cmake("$root/CMakeLists.txt"); +} + sub scan_file { my ($source)=@_; open F, "<$source"; @@ -104,6 +124,7 @@ sub scan_docs { } scan_configure(); +scan_cmake(); scan_sources(); scan_docs(); @@ -121,12 +142,28 @@ for my $s (sort keys %disable) { } } +# Check the CMakeLists.txt symbols for use in code +for my $s (sort keys %disable_cmake) { + if(!$file{$s}) { + printf "Present in CMakeLists.txt, not used by code: %s\n", $s; + $error++; + } + if(!$docs{$s}) { + printf "Present in CMakeLists.txt, not documented in $DOCS: %s\n", $s; + $error++; + } +} + # Check the code symbols for use in configure for my $s (sort keys %file) { if(!$disable{$s}) { printf "Not set by configure: %s (%s)\n", $s, $file{$s}; $error++; } + if(!$disable_cmake{$s}) { + printf "Not set by CMakeLists.txt: %s (%s)\n", $s, $file{$s}; + $error++; + } if(!$docs{$s}) { printf "Used in code, not documented in $DOCS: %s\n", $s; $error++; @@ -139,6 +176,10 @@ for my $s (sort keys %docs) { printf "Documented but not in configure: %s\n", $s; $error++; } + if(!$disable_cmake{$s}) { + printf "Documented but not in CMakeLists.txt: %s\n", $s; + $error++; + } if(!$file{$s}) { printf "Documented, but not used by code: %s\n", $s; $error++;