mirror of
https://github.com/libssh2/libssh2.git
synced 2026-01-27 00:18:12 +03:00
checksrc: replace bash starter with checksrc-all.pl
To remove dependence on a shell script to start `checksrc.pl`. Fixes #1775 Closes #1778
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: 'checksrc'
|
||||
run: ci/checksrc.sh
|
||||
run: ci/checksrc-all.pl
|
||||
|
||||
linters:
|
||||
name: 'linters'
|
||||
|
||||
@@ -538,8 +538,18 @@ if(BUILD_TESTING)
|
||||
endif()
|
||||
|
||||
option(LINT "Check style while building" OFF)
|
||||
option(LIBSSH2_BUILD_DOCS "Build man pages" ON)
|
||||
|
||||
if(LINT OR LIBSSH2_BUILD_DOCS)
|
||||
find_package(Perl)
|
||||
endif()
|
||||
|
||||
if(LINT)
|
||||
add_custom_target(lint ALL "./ci/checksrc.sh" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
add_custom_target(lint ALL
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/ci/checksrc-all.pl"
|
||||
DEPENDS "${PROJECT_SOURCE_DIR}/ci/checksrc-all.pl" "${PROJECT_SOURCE_DIR}/ci/checksrc.pl"
|
||||
)
|
||||
if(BUILD_STATIC_LIBS)
|
||||
add_dependencies(${LIB_STATIC} lint)
|
||||
else()
|
||||
@@ -547,10 +557,8 @@ if(LINT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(LIBSSH2_BUILD_DOCS "Build man pages" ON)
|
||||
set(_build_docs FALSE)
|
||||
if(LIBSSH2_BUILD_DOCS)
|
||||
find_package(Perl)
|
||||
if(PERL_FOUND)
|
||||
set(_build_docs TRUE)
|
||||
add_subdirectory(docs)
|
||||
|
||||
@@ -81,4 +81,4 @@ gen-coverage:
|
||||
coverage: init-coverage build-coverage gen-coverage
|
||||
|
||||
checksrc:
|
||||
ci/checksrc.sh
|
||||
ci/checksrc-all.pl
|
||||
|
||||
63
ci/checksrc-all.pl
Executable file
63
ci/checksrc-all.pl
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env perl
|
||||
# Copyright (C) Viktor Szakats
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Basename;
|
||||
use File::Find;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
my @options = (
|
||||
"-i4", "-m79",
|
||||
"-AFIXME", "-AERRNOVAR", "-AFOPENMODE", "-ATYPEDEFSTRUCT",
|
||||
"-aaccept",
|
||||
"-aatoi",
|
||||
"-acalloc",
|
||||
"-aCreateFileA",
|
||||
"-afclose",
|
||||
"-afopen",
|
||||
"-afprintf",
|
||||
"-afree",
|
||||
"-amalloc",
|
||||
"-aprintf",
|
||||
"-arealloc",
|
||||
"-arecv",
|
||||
"-asend",
|
||||
"-asnprintf",
|
||||
"-asocket",
|
||||
"-asocketpair",
|
||||
"-astrdup",
|
||||
"-astrtok",
|
||||
"-astrtol",
|
||||
"-avsnprintf",
|
||||
);
|
||||
|
||||
my @files;
|
||||
if(system('git rev-parse --is-inside-work-tree >/dev/null 2>&1') == 0) {
|
||||
@files = `git ls-files '*.[ch]'`;
|
||||
}
|
||||
else {
|
||||
find(sub { if(/\.[ch]$/) { push(@files, $File::Find::name) } }, ('.'));
|
||||
}
|
||||
if(@ARGV) {
|
||||
find(sub { if(/\.[ch]$/) { push(@files, $File::Find::name) } }, @ARGV);
|
||||
}
|
||||
|
||||
@files = grep !/\/CMakeFiles\//, @files;
|
||||
@files = map { dirname($_) } @files;
|
||||
my @dirs = sort { $a cmp $b } keys %{{ map { $_ => 1 } @files }};
|
||||
|
||||
my $scripts_dir = dirname(abs_path($0));
|
||||
my $anyfailed = 0;
|
||||
|
||||
for my $dir (@dirs) {
|
||||
@files = glob("$dir/*.[ch]");
|
||||
if(@files && system("$scripts_dir/checksrc.pl", @options, @files) != 0) {
|
||||
$anyfailed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
exit $anyfailed;
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (C) The libssh2 project and its contributors.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
git ls-files '*.[ch]' '*.cc' | xargs -n1 \
|
||||
ci/checksrc.pl -i4 -m79 -AFIXME -AERRNOVAR -AFOPENMODE -ATYPEDEFSTRUCT \
|
||||
-aaccept \
|
||||
-aatoi \
|
||||
-acalloc \
|
||||
-aCreateFileA \
|
||||
-afclose \
|
||||
-afopen \
|
||||
-afprintf \
|
||||
-afree \
|
||||
-amalloc \
|
||||
-aprintf \
|
||||
-arealloc \
|
||||
-arecv \
|
||||
-asend \
|
||||
-asnprintf \
|
||||
-asocket \
|
||||
-asocketpair \
|
||||
-astrdup \
|
||||
-astrtok \
|
||||
-astrtol \
|
||||
-avsnprintf
|
||||
Reference in New Issue
Block a user