| 1 |
@echo off |
| 2 |
rem *************************************************************************** |
| 3 |
rem * _ _ ____ _ |
| 4 |
rem * Project ___| | | | _ \| | |
| 5 |
rem * / __| | | | |_) | | |
| 6 |
rem * | (__| |_| | _ <| |___ |
| 7 |
rem * \___|\___/|_| \_\_____| |
| 8 |
rem * |
| 9 |
rem * Copyright (C) 2014 - 2020, Steve Holme, <[email protected]>. |
| 10 |
rem * |
| 11 |
rem * This software is licensed as described in the file COPYING, which |
| 12 |
rem * you should have received as part of this distribution. The terms |
| 13 |
rem * are also available at https://curl.haxx.se/docs/copyright.html. |
| 14 |
rem * |
| 15 |
rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 16 |
rem * copies of the Software, and permit persons to whom the Software is |
| 17 |
rem * furnished to do so, under the terms of the COPYING file. |
| 18 |
rem * |
| 19 |
rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 20 |
rem * KIND, either express or implied. |
| 21 |
rem * |
| 22 |
rem *************************************************************************** |
| 23 |
|
| 24 |
:begin |
| 25 |
rem Check we are running on a Windows NT derived OS |
| 26 |
if not "%OS%" == "Windows_NT" goto nodos |
| 27 |
|
| 28 |
rem Set our variables |
| 29 |
setlocal |
| 30 |
set CHECK_LIB=TRUE |
| 31 |
set CHECK_SRC=TRUE |
| 32 |
set CHECK_TESTS=TRUE |
| 33 |
set CHECK_EXAMPLES=TRUE |
| 34 |
set SRC_DIR= |
| 35 |
set CUR_DIR=%cd% |
| 36 |
set ARG0_DIR=%~dp0 |
| 37 |
|
| 38 |
:parseArgs |
| 39 |
if "%~1" == "" goto prerequisites |
| 40 |
|
| 41 |
if /i "%~1" == "-?" ( |
| 42 |
goto syntax |
| 43 |
) else if /i "%~1" == "-h" ( |
| 44 |
goto syntax |
| 45 |
) else if /i "%~1" == "-help" ( |
| 46 |
goto syntax |
| 47 |
) else if /i "%~1" == "lib" ( |
| 48 |
set CHECK_LIB=TRUE |
| 49 |
set CHECK_SRC=FALSE |
| 50 |
set CHECK_TESTS=FALSE |
| 51 |
set CHECK_EXAMPLES=FALSE |
| 52 |
) else if /i "%~1" == "src" ( |
| 53 |
set CHECK_LIB=FALSE |
| 54 |
set CHECK_SRC=TRUE |
| 55 |
set CHECK_TESTS=FALSE |
| 56 |
set CHECK_EXAMPLES=FALSE |
| 57 |
) else if /i "%~1" == "tests" ( |
| 58 |
set CHECK_LIB=FALSE |
| 59 |
set CHECK_SRC=FALSE |
| 60 |
set CHECK_TESTS=TRUE |
| 61 |
set CHECK_EXAMPLES=FALSE |
| 62 |
) else if /i "%~1" == "examples" ( |
| 63 |
set CHECK_LIB=FALSE |
| 64 |
set CHECK_SRC=FALSE |
| 65 |
set CHECK_TESTS=FALSE |
| 66 |
set CHECK_EXAMPLES=TRUE |
| 67 |
) else ( |
| 68 |
if not defined SRC_DIR ( |
| 69 |
set SRC_DIR=%~1% |
| 70 |
) else ( |
| 71 |
goto unknown |
| 72 |
) |
| 73 |
) |
| 74 |
|
| 75 |
shift & goto parseArgs |
| 76 |
|
| 77 |
:prerequisites |
| 78 |
rem Check we have Perl in our path |
| 79 |
perl --version <NUL 1>NUL 2>&1 |
| 80 |
if errorlevel 1 ( |
| 81 |
rem It isn't so check we have it installed and set the path if it is |
| 82 |
if exist "%SystemDrive%\Perl" ( |
| 83 |
set "PATH=%SystemDrive%\Perl\bin;%PATH%" |
| 84 |
) else ( |
| 85 |
if exist "%SystemDrive%\Perl64" ( |
| 86 |
set "PATH=%SystemDrive%\Perl64\bin;%PATH%" |
| 87 |
) else ( |
| 88 |
goto noperl |
| 89 |
) |
| 90 |
) |
| 91 |
) |
| 92 |
|
| 93 |
:configure |
| 94 |
if "%SRC_DIR%" == "" ( |
| 95 |
rem Are we being executed from the "projects" or main directory? |
| 96 |
if "%CUR_DIR%\" == "%ARG0_DIR%" ( |
| 97 |
set SRC_DIR=.. |
| 98 |
) else if exist projects ( |
| 99 |
if exist docs ( |
| 100 |
if exist lib ( |
| 101 |
if exist src ( |
| 102 |
if exist tests ( |
| 103 |
set SRC_DIR=. |
| 104 |
) |
| 105 |
) |
| 106 |
) |
| 107 |
) |
| 108 |
) |
| 109 |
) |
| 110 |
if not exist "%SRC_DIR%" goto nosrc |
| 111 |
|
| 112 |
:start |
| 113 |
if "%CHECK_SRC%" == "TRUE" ( |
| 114 |
rem Check the src directory |
| 115 |
if exist %SRC_DIR%\src ( |
| 116 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\src" -Wtool_hugehelp.c "%%i" |
| 117 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\src" "%%i" |
| 118 |
) |
| 119 |
) |
| 120 |
|
| 121 |
if "%CHECK_LIB%" == "TRUE" ( |
| 122 |
rem Check the lib directory |
| 123 |
if exist %SRC_DIR%\lib ( |
| 124 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib" "%%i" |
| 125 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib" -Wcurl_config.h.cmake -Wcurl_config.h.in -Wcurl_config.h "%%i" |
| 126 |
) |
| 127 |
|
| 128 |
rem Check the lib\vauth directory |
| 129 |
if exist %SRC_DIR%\lib\vauth ( |
| 130 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vauth\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vauth" "%%i" |
| 131 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vauth\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vauth" "%%i" |
| 132 |
) |
| 133 |
|
| 134 |
rem Check the lib\vquic directory |
| 135 |
if exist %SRC_DIR%\lib\vquic ( |
| 136 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vquic\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vquic" "%%i" |
| 137 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vquic\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vquic" "%%i" |
| 138 |
) |
| 139 |
|
| 140 |
rem Check the lib\vssh directory |
| 141 |
if exist %SRC_DIR%\lib\vssh ( |
| 142 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vssh\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vssh" "%%i" |
| 143 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vssh\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vssh" "%%i" |
| 144 |
) |
| 145 |
|
| 146 |
rem Check the lib\vtls directory |
| 147 |
if exist %SRC_DIR%\lib\vtls ( |
| 148 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i" |
| 149 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i" |
| 150 |
) |
| 151 |
) |
| 152 |
|
| 153 |
if "%CHECK_TESTS%" == "TRUE" ( |
| 154 |
rem Check the tests\libtest directory |
| 155 |
if exist %SRC_DIR%\tests\libtest ( |
| 156 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\libtest\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\tests\libtest" "%%i" |
| 157 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\libtest\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\tests\libtest" "%%i" |
| 158 |
) |
| 159 |
|
| 160 |
rem Check the tests\unit directory |
| 161 |
if exist %SRC_DIR%\tests\unit ( |
| 162 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\unit\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\tests\unit" "%%i" |
| 163 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\unit\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\tests\unit" "%%i" |
| 164 |
) |
| 165 |
|
| 166 |
rem Check the tests\server directory |
| 167 |
if exist %SRC_DIR%\tests\server ( |
| 168 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\server\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\tests\server" "%%i" |
| 169 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\server\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\tests\server" "%%i" |
| 170 |
) |
| 171 |
) |
| 172 |
|
| 173 |
if "%CHECK_EXAMPLES%" == "TRUE" ( |
| 174 |
rem Check the docs\examples directory |
| 175 |
if exist %SRC_DIR%\docs\examples ( |
| 176 |
for /f "delims=" %%i in ('dir "%SRC_DIR%\docs\examples\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\lib\checksrc.pl" "-D%SRC_DIR%\docs\examples" -ASNPRINTF "%%i" |
| 177 |
) |
| 178 |
) |
| 179 |
|
| 180 |
goto success |
| 181 |
|
| 182 |
:syntax |
| 183 |
rem Display the help |
| 184 |
echo. |
| 185 |
echo Usage: checksrc [what] [directory] |
| 186 |
echo. |
| 187 |
echo What to scan: |
| 188 |
echo. |
| 189 |
echo lib - Scan the libcurl source |
| 190 |
echo src - Scan the command-line tool source |
| 191 |
echo tests - Scan the library tests and unit tests |
| 192 |
echo examples - Scan the examples |
| 193 |
echo. |
| 194 |
echo directory - Specifies the curl source directory |
| 195 |
goto success |
| 196 |
|
| 197 |
:unknown |
| 198 |
echo. |
| 199 |
echo Error: Unknown argument '%1' |
| 200 |
goto error |
| 201 |
|
| 202 |
:nodos |
| 203 |
echo. |
| 204 |
echo Error: Only a Windows NT based Operating System is supported |
| 205 |
goto error |
| 206 |
|
| 207 |
:noperl |
| 208 |
echo. |
| 209 |
echo Error: Perl is not installed |
| 210 |
goto error |
| 211 |
|
| 212 |
:nosrc |
| 213 |
echo. |
| 214 |
echo Error: "%SRC_DIR%" does not exist |
| 215 |
goto error |
| 216 |
|
| 217 |
:error |
| 218 |
if "%OS%" == "Windows_NT" endlocal |
| 219 |
exit /B 1 |
| 220 |
|
| 221 |
:success |
| 222 |
endlocal |
| 223 |
exit /B 0 |