checksrc.bat 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. @echo off
  2. rem ***************************************************************************
  3. rem * _ _ ____ _
  4. rem * Project ___| | | | _ \| |
  5. rem * / __| | | | |_) | |
  6. rem * | (__| |_| | _ <| |___
  7. rem * \___|\___/|_| \_\_____|
  8. rem *
  9. rem * Copyright (C) 2014 - 2016, 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. :parseArgs
  33. if "%~1" == "" goto prerequisites
  34. if /i "%~1" == "-?" (
  35. goto syntax
  36. ) else if /i "%~1" == "-h" (
  37. goto syntax
  38. ) else if /i "%~1" == "-help" (
  39. goto syntax
  40. ) else if /i "%~1" == "lib" (
  41. set CHECK_LIB=TRUE
  42. set CHECK_SRC=FALSE
  43. set CHECK_TESTS=FALSE
  44. set CHECK_EXAMPLES=FALSE
  45. ) else if /i "%~1" == "src" (
  46. set CHECK_LIB=FALSE
  47. set CHECK_SRC=TRUE
  48. set CHECK_TESTS=FALSE
  49. set CHECK_EXAMPLES=FALSE
  50. ) else if /i "%~1" == "tests" (
  51. set CHECK_LIB=FALSE
  52. set CHECK_SRC=FALSE
  53. set CHECK_TESTS=TRUE
  54. set CHECK_EXAMPLES=FALSE
  55. ) else if /i "%~1" == "examples" (
  56. set CHECK_LIB=FALSE
  57. set CHECK_SRC=FALSE
  58. set CHECK_TESTS=FALSE
  59. set CHECK_EXAMPLES=TRUE
  60. ) else (
  61. if not defined SRC_DIR (
  62. set SRC_DIR=%~1%
  63. ) else (
  64. goto unknown
  65. )
  66. )
  67. shift & goto parseArgs
  68. :prerequisites
  69. rem Check we have Perl in our path
  70. perl --version <NUL 1>NUL 2>&1
  71. if errorlevel 1 (
  72. rem It isn't so check we have it installed and set the path if it is
  73. if exist "%SystemDrive%\Perl" (
  74. set "PATH=%SystemDrive%\Perl\bin;%PATH%"
  75. ) else (
  76. if exist "%SystemDrive%\Perl64" (
  77. set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
  78. ) else (
  79. goto noperl
  80. )
  81. )
  82. )
  83. :configure
  84. if "%SRC_DIR%" == "" set SRC_DIR=..
  85. if not exist "%SRC_DIR%" goto nosrc
  86. :start
  87. if "%CHECK_SRC%" == "TRUE" (
  88. rem Check the src directory
  89. if exist %SRC_DIR%\src (
  90. 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"
  91. 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"
  92. )
  93. )
  94. if "%CHECK_LIB%" == "TRUE" (
  95. rem Check the lib directory
  96. if exist %SRC_DIR%\lib (
  97. 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"
  98. 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"
  99. )
  100. rem Check the lib\vauth directory
  101. if exist %SRC_DIR%\lib\vauth (
  102. 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"
  103. 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"
  104. )
  105. rem Check the lib\vtls directory
  106. if exist %SRC_DIR%\lib\vtls (
  107. 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"
  108. 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"
  109. )
  110. )
  111. if "%CHECK_TESTS%" == "TRUE" (
  112. rem Check the tests\libtest directory
  113. if exist %SRC_DIR%\tests\libtest (
  114. 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"
  115. 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"
  116. )
  117. rem Check the tests\unit directory
  118. if exist %SRC_DIR%\tests\unit (
  119. 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"
  120. 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"
  121. )
  122. rem Check the tests\server directory
  123. if exist %SRC_DIR%\tests\server (
  124. 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"
  125. 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"
  126. )
  127. )
  128. if "%CHECK_EXAMPLES%" == "TRUE" (
  129. rem Check the docs\examples directory
  130. if exist %SRC_DIR%\docs\examples (
  131. 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"
  132. )
  133. )
  134. goto success
  135. :syntax
  136. rem Display the help
  137. echo.
  138. echo Usage: checksrc [what] [directory]
  139. echo.
  140. echo What to scan:
  141. echo.
  142. echo lib - Scan the libcurl source
  143. echo src - Scan the command-line tool source
  144. echo tests - Scan the library tests and unit tests
  145. echo examples - Scan the examples
  146. echo.
  147. echo directory - Specifies the curl source directory
  148. goto success
  149. :unknown
  150. echo.
  151. echo Error: Unknown argument '%1'
  152. goto error
  153. :nodos
  154. echo.
  155. echo Error: Only a Windows NT based Operating System is supported
  156. goto error
  157. :noperl
  158. echo.
  159. echo Error: Perl is not installed
  160. goto error
  161. :nosrc
  162. echo.
  163. echo Error: "%SRC_DIR%" does not exist
  164. goto error
  165. :error
  166. if "%OS%" == "Windows_NT" endlocal
  167. exit /B 1
  168. :success
  169. endlocal
  170. exit /B 0