2019-06-11 15:33:29 +02:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
#***************************************************************************
|
|
|
|
|
# _ _ ____ _
|
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
|
#
|
2023-01-02 13:51:48 +01:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2019-06-11 15:33:29 +02:00
|
|
|
#
|
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 14:02:01 +01:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2019-06-11 15:33:29 +02:00
|
|
|
#
|
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
|
#
|
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
# KIND, either express or implied.
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: curl
|
2022-05-17 11:16:50 +02:00
|
|
|
#
|
2019-06-11 15:33:29 +02:00
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
|
|
# the DISABLE options that can be set by configure
|
|
|
|
|
my %disable;
|
2023-11-17 21:42:54 +00:00
|
|
|
# the DISABLE options that can be set by CMakeLists.txt
|
|
|
|
|
my %disable_cmake;
|
2025-12-19 14:57:10 +01:00
|
|
|
# the DISABLE options propagated via curl_config-cmake.h.in
|
2024-09-01 16:55:53 +02:00
|
|
|
my %disable_cmake_config_h;
|
2019-06-11 15:33:29 +02:00
|
|
|
# the DISABLE options that are used in C files
|
|
|
|
|
my %file;
|
2019-11-11 17:16:04 +01:00
|
|
|
# the DISABLE options that are documented
|
|
|
|
|
my %docs;
|
2019-06-11 15:33:29 +02:00
|
|
|
|
2025-11-15 00:27:38 +01:00
|
|
|
# we may get the directory root pointed out
|
2026-06-11 17:22:30 +02:00
|
|
|
my $root = $ARGV[0] || ".";
|
|
|
|
|
my $DOCS = "CURL-DISABLE.md";
|
2019-06-11 15:33:29 +02:00
|
|
|
|
2021-04-15 12:11:41 +02:00
|
|
|
sub scanconf {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($f) = @_;
|
2026-06-29 19:01:04 +02:00
|
|
|
open(S, "<", $f);
|
2019-06-11 15:33:29 +02:00
|
|
|
while(<S>) {
|
2024-02-08 18:41:55 +01:00
|
|
|
if(/(CURL_DISABLE_[A-Z0-9_]+)/g) {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($sym) = ($1);
|
2026-02-20 15:03:17 +01:00
|
|
|
if(not $sym =~ /^(CURL_DISABLE_TYPECHECK)$/) {
|
|
|
|
|
$disable{$sym} = 1;
|
|
|
|
|
}
|
2019-06-11 15:33:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
close S;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 12:11:41 +02:00
|
|
|
sub scan_configure {
|
2026-06-15 01:26:04 +02:00
|
|
|
opendir(my $m, "$root/m4") or die "Cannot opendir $root/m4: $!";
|
2021-04-15 12:11:41 +02:00
|
|
|
my @m4 = grep { /\.m4$/ } readdir($m);
|
|
|
|
|
closedir $m;
|
|
|
|
|
scanconf("$root/configure.ac");
|
|
|
|
|
# scan all m4 files too
|
|
|
|
|
for my $e (@m4) {
|
|
|
|
|
scanconf("$root/m4/$e");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 21:42:54 +00:00
|
|
|
sub scanconf_cmake {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($hashr, $f) = @_;
|
2026-06-29 19:01:04 +02:00
|
|
|
open(S, "<", $f);
|
2023-11-17 21:42:54 +00:00
|
|
|
while(<S>) {
|
2024-02-08 18:41:55 +01:00
|
|
|
if(/(CURL_DISABLE_[A-Z0-9_]+)/g) {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($sym) = ($1);
|
2026-07-04 12:19:47 +02:00
|
|
|
if(not $sym =~ /^(CURL_DISABLE_INSTALL|CURL_DISABLE_TYPECHECK)$/) {
|
2024-09-01 16:55:53 +02:00
|
|
|
$hashr->{$sym} = 1;
|
2023-11-17 21:42:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
close S;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub scan_cmake {
|
2024-09-01 16:55:53 +02:00
|
|
|
scanconf_cmake(\%disable_cmake, "$root/CMakeLists.txt");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub scan_cmake_config_h {
|
2025-12-19 14:57:10 +01:00
|
|
|
scanconf_cmake(\%disable_cmake_config_h, "$root/lib/curl_config-cmake.h.in");
|
2023-11-17 21:42:54 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-20 15:03:17 +01:00
|
|
|
my %whitelisted = (
|
|
|
|
|
'CURL_DISABLE_DEPRECATION' => 1,
|
|
|
|
|
'CURL_DISABLE_TYPECHECK' => 1,
|
|
|
|
|
);
|
2025-04-27 17:35:20 +02:00
|
|
|
|
2019-06-11 15:33:29 +02:00
|
|
|
sub scan_file {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($source) = @_;
|
2026-06-29 19:01:04 +02:00
|
|
|
open(F, "<", $source);
|
2019-06-11 15:33:29 +02:00
|
|
|
while(<F>) {
|
2024-02-08 18:41:55 +01:00
|
|
|
while(s/(CURL_DISABLE_[A-Z0-9_]+)//) {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($sym) = ($1);
|
2025-04-27 17:35:20 +02:00
|
|
|
|
|
|
|
|
if(!$whitelisted{$sym}) {
|
|
|
|
|
$file{$sym} = $source;
|
|
|
|
|
}
|
2019-06-11 15:33:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
close F;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub scan_dir {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($dir) = @_;
|
2026-06-15 01:26:04 +02:00
|
|
|
opendir(my $dh, $dir) or die "Cannot opendir $dir: $!";
|
2021-03-28 23:12:23 +02:00
|
|
|
my @cfiles = grep { /\.[ch]\z/ && -f "$dir/$_" } readdir($dh);
|
2019-06-11 15:33:29 +02:00
|
|
|
closedir $dh;
|
|
|
|
|
for my $f (sort @cfiles) {
|
|
|
|
|
scan_file("$dir/$f");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub scan_sources {
|
2025-11-21 12:43:54 +01:00
|
|
|
scan_dir("$root/include/curl");
|
2019-06-11 15:33:29 +02:00
|
|
|
scan_dir("$root/src");
|
|
|
|
|
scan_dir("$root/lib");
|
|
|
|
|
scan_dir("$root/lib/vtls");
|
|
|
|
|
scan_dir("$root/lib/vauth");
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-11 17:16:04 +01:00
|
|
|
sub scan_docs {
|
2026-06-29 19:01:04 +02:00
|
|
|
open(F, "<", "$root/docs/$DOCS");
|
2019-11-11 17:16:04 +01:00
|
|
|
my $line = 0;
|
|
|
|
|
while(<F>) {
|
|
|
|
|
$line++;
|
2024-02-08 18:41:55 +01:00
|
|
|
if(/^## `(CURL_DISABLE_[A-Z0-9_]+)`/g) {
|
2026-06-11 17:22:30 +02:00
|
|
|
my ($sym) = ($1);
|
2026-02-20 15:03:17 +01:00
|
|
|
if(not $sym =~ /^(CURL_DISABLE_TYPECHECK)$/) {
|
|
|
|
|
$docs{$sym} = $line;
|
|
|
|
|
}
|
2019-11-11 17:16:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
close F;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 15:33:29 +02:00
|
|
|
scan_configure();
|
2023-11-17 21:42:54 +00:00
|
|
|
scan_cmake();
|
2024-09-01 16:55:53 +02:00
|
|
|
scan_cmake_config_h();
|
2019-06-11 15:33:29 +02:00
|
|
|
scan_sources();
|
2019-11-11 17:16:04 +01:00
|
|
|
scan_docs();
|
2019-06-11 15:33:29 +02:00
|
|
|
|
|
|
|
|
my $error = 0;
|
|
|
|
|
# Check the configure symbols for use in code
|
|
|
|
|
for my $s (sort keys %disable) {
|
|
|
|
|
if(!$file{$s}) {
|
|
|
|
|
printf "Present in configure.ac, not used by code: %s\n", $s;
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2019-11-11 17:16:04 +01:00
|
|
|
if(!$docs{$s}) {
|
|
|
|
|
printf "Present in configure.ac, not documented in $DOCS: %s\n", $s;
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2019-06-11 15:33:29 +02:00
|
|
|
}
|
|
|
|
|
|
2023-11-17 21:42:54 +00:00
|
|
|
# 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++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-19 14:57:10 +01:00
|
|
|
# Check the CMakeLists.txt symbols for use in curl_config-cmake.h.in
|
2024-09-01 16:55:53 +02:00
|
|
|
for my $s (sort keys %disable_cmake) {
|
|
|
|
|
if(!$disable_cmake_config_h{$s}) {
|
2025-12-19 14:57:10 +01:00
|
|
|
printf "Present in CMakeLists.txt, not propagated via curl_config-cmake.h.in: %s\n", $s;
|
2024-09-01 16:55:53 +02:00
|
|
|
$error++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 15:33:29 +02:00
|
|
|
# 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++;
|
|
|
|
|
}
|
2023-11-17 21:42:54 +00:00
|
|
|
if(!$disable_cmake{$s}) {
|
|
|
|
|
printf "Not set by CMakeLists.txt: %s (%s)\n", $s, $file{$s};
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2019-11-11 17:16:04 +01:00
|
|
|
if(!$docs{$s}) {
|
|
|
|
|
printf "Used in code, not documented in $DOCS: %s\n", $s;
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check the documented symbols
|
|
|
|
|
for my $s (sort keys %docs) {
|
|
|
|
|
if(!$disable{$s}) {
|
|
|
|
|
printf "Documented but not in configure: %s\n", $s;
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2023-11-17 21:42:54 +00:00
|
|
|
if(!$disable_cmake{$s}) {
|
|
|
|
|
printf "Documented but not in CMakeLists.txt: %s\n", $s;
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2019-11-11 17:16:04 +01:00
|
|
|
if(!$file{$s}) {
|
|
|
|
|
printf "Documented, but not used by code: %s\n", $s;
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2019-06-11 15:33:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit $error;
|