2
0

checksrc.bat 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. @echo off
  2. rem ***************************************************************************
  3. rem * _ _ ____ _
  4. rem * Project ___| | | | _ \| |
  5. rem * / __| | | | |_) | |
  6. rem * | (__| |_| | _ <| |___
  7. rem * \___|\___/|_| \_\_____|
  8. rem *
  9. rem * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
  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.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 * SPDX-License-Identifier: curl
  23. rem *
  24. rem ***************************************************************************
  25. :begin
  26. rem Check we are running on a Windows NT derived OS
  27. if not "%OS%" == "Windows_NT" goto nodos
  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. :parseArgs
  38. if "%~1" == "" goto prerequisites
  39. if /i "%~1" == "-?" (
  40. goto syntax
  41. ) else if /i "%~1" == "-h" (
  42. goto syntax
  43. ) else if /i "%~1" == "-help" (
  44. goto syntax
  45. ) else if /i "%~1" == "lib" (
  46. set CHECK_LIB=TRUE
  47. set CHECK_SRC=FALSE
  48. set CHECK_TESTS=FALSE
  49. set CHECK_EXAMPLES=FALSE
  50. ) else if /i "%~1" == "src" (
  51. set CHECK_LIB=FALSE
  52. set CHECK_SRC=TRUE
  53. set CHECK_TESTS=FALSE
  54. set CHECK_EXAMPLES=FALSE
  55. ) else if /i "%~1" == "tests" (
  56. set CHECK_LIB=FALSE
  57. set CHECK_SRC=FALSE
  58. set CHECK_TESTS=TRUE
  59. set CHECK_EXAMPLES=FALSE
  60. ) else if /i "%~1" == "examples" (
  61. set CHECK_LIB=FALSE
  62. set CHECK_SRC=FALSE
  63. set CHECK_TESTS=FALSE
  64. set CHECK_EXAMPLES=TRUE
  65. ) else (
  66. if not defined SRC_DIR (
  67. set SRC_DIR=%~1%
  68. ) else (
  69. goto unknown
  70. )
  71. )
  72. shift & goto parseArgs
  73. :prerequisites
  74. rem Check we have Perl in our path
  75. perl --version <NUL 1>NUL 2>&1
  76. if errorlevel 1 (
  77. rem It isn't so check we have it installed and set the path if it is
  78. if exist "%SystemDrive%\Perl" (
  79. set "PATH=%SystemDrive%\Perl\bin;%PATH%"
  80. ) else (
  81. if exist "%SystemDrive%\Perl64" (
  82. set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
  83. ) else (
  84. goto noperl
  85. )
  86. )
  87. )
  88. :configure
  89. if "%SRC_DIR%" == "" (
  90. rem Are we being executed from the "projects" or main directory?
  91. if "%CUR_DIR%\" == "%ARG0_DIR%" (
  92. set SRC_DIR=..
  93. ) else if exist projects (
  94. if exist docs (
  95. if exist lib (
  96. if exist src (
  97. if exist tests (
  98. set SRC_DIR=.
  99. )
  100. )
  101. )
  102. )
  103. )
  104. )
  105. if not exist "%SRC_DIR%" goto nosrc
  106. :start
  107. if "%CHECK_SRC%" == "TRUE" (
  108. rem Check the src directory
  109. if exist %SRC_DIR%\src (
  110. for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\src" -Wtool_hugehelp.c "%%i"
  111. for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\src" "%%i"
  112. )
  113. )
  114. if "%CHECK_LIB%" == "TRUE" (
  115. rem Check the lib directory
  116. if exist %SRC_DIR%\lib (
  117. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib" "%%i"
  118. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib" -Wcurl_config.h.cmake -Wcurl_config.h.in -Wcurl_config.h "%%i"
  119. )
  120. rem Check the lib\vauth directory
  121. if exist %SRC_DIR%\lib\vauth (
  122. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vauth\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vauth" "%%i"
  123. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vauth\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vauth" "%%i"
  124. )
  125. rem Check the lib\vquic directory
  126. if exist %SRC_DIR%\lib\vquic (
  127. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vquic\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vquic" "%%i"
  128. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vquic\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vquic" "%%i"
  129. )
  130. rem Check the lib\vssh directory
  131. if exist %SRC_DIR%\lib\vssh (
  132. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vssh\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vssh" "%%i"
  133. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vssh\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vssh" "%%i"
  134. )
  135. rem Check the lib\vtls directory
  136. if exist %SRC_DIR%\lib\vtls (
  137. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i"
  138. for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i"
  139. )
  140. )
  141. if "%CHECK_TESTS%" == "TRUE" (
  142. rem Check the tests\libtest directory
  143. if exist %SRC_DIR%\tests\libtest (
  144. for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\libtest\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\libtest" "%%i"
  145. for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\libtest\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\libtest" "%%i"
  146. )
  147. rem Check the tests\unit directory
  148. if exist %SRC_DIR%\tests\unit (
  149. for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\unit\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\unit" "%%i"
  150. for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\unit\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\unit" "%%i"
  151. )
  152. rem Check the tests\server directory
  153. if exist %SRC_DIR%\tests\server (
  154. for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\server\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\server" "%%i"
  155. for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\server\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\server" "%%i"
  156. )
  157. )
  158. if "%CHECK_EXAMPLES%" == "TRUE" (
  159. rem Check the docs\examples directory
  160. if exist %SRC_DIR%\docs\examples (
  161. for /f "delims=" %%i in ('dir "%SRC_DIR%\docs\examples\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\docs\examples" -ASNPRINTF "%%i"
  162. )
  163. )
  164. goto success
  165. :syntax
  166. rem Display the help
  167. echo.
  168. echo Usage: checksrc [what] [directory]
  169. echo.
  170. echo What to scan:
  171. echo.
  172. echo lib - Scan the libcurl source
  173. echo src - Scan the command-line tool source
  174. echo tests - Scan the library tests and unit tests
  175. echo examples - Scan the examples
  176. echo.
  177. echo directory - Specifies the curl source directory
  178. goto success
  179. :unknown
  180. echo.
  181. echo Error: Unknown argument '%1'
  182. goto error
  183. :nodos
  184. echo.
  185. echo Error: Only a Windows NT based Operating System is supported
  186. goto error
  187. :noperl
  188. echo.
  189. echo Error: Perl is not installed
  190. goto error
  191. :nosrc
  192. echo.
  193. echo Error: "%SRC_DIR%" does not exist
  194. goto error
  195. :error
  196. if "%OS%" == "Windows_NT" endlocal
  197. exit /B 1
  198. :success
  199. endlocal
  200. exit /B 0