checksrc.bat 7.4 KB

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