Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <stdio.h>
  8. #include <windows.h>
  9. #include "depcheck_util.h"
  10. #include "icodeprocessor.h"
  11. #include "tier1/strtools.h"
  12. char *va(char *format, ...)
  13. {
  14. va_list argptr;
  15. static char string[1024];
  16. va_start (argptr, format);
  17. Q_vsnprintf( string, 1024, format, argptr );
  18. va_end (argptr);
  19. return string;
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose:
  23. //-----------------------------------------------------------------------------
  24. void printusage( void )
  25. {
  26. vprint( 0, "usage: depcheck -q -l <root source directory> <game: hl2 | tf2>\n\
  27. \t-q = quiet\n\
  28. \t-l = log to file log.txt\n" );
  29. // Exit app
  30. exit( 1 );
  31. }
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. // Input : *sourcetreebase -
  35. // *subdir -
  36. // *baseentityclass -
  37. //-----------------------------------------------------------------------------
  38. void ProcessDirectory( const char *game, const char *sourcetreebase, const char *subdir, const char *dsp, const char *config )
  39. {
  40. char rootdirectory[ 256 ];
  41. sprintf( rootdirectory, "%s\\%s", sourcetreebase, subdir );
  42. // check for existence
  43. if ( COM_DirectoryExists( rootdirectory ) )
  44. {
  45. processor->Process( game, rootdirectory, dsp, config );
  46. }
  47. else
  48. {
  49. vprint( 0, "Couldn't find directory %s, check path %s\n", rootdirectory, sourcetreebase );
  50. }
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. //-----------------------------------------------------------------------------
  55. void CheckLogFile( void )
  56. {
  57. if ( processor->GetLogFile() )
  58. {
  59. _unlink( "log.txt" );
  60. vprint( 0, " Outputting to log.txt\n" );
  61. }
  62. }
  63. //-----------------------------------------------------------------------------
  64. // Purpose:
  65. // Input : argc -
  66. // argv[] -
  67. // Output : int
  68. //-----------------------------------------------------------------------------
  69. int main( int argc, char* argv[] )
  70. {
  71. vprint( 0, "Valve Software - depcheck.exe (%s)\n", __DATE__ );
  72. vprint( 0, "--- Game Code Simple Build Dependency Analyzer ---\n" );
  73. int i=1;
  74. for ( i ; i<argc ; i++)
  75. {
  76. if ( argv[ i ][ 0 ] == '-' )
  77. {
  78. switch( argv[ i ][ 1 ] )
  79. {
  80. case 'q':
  81. processor->SetQuiet( true );
  82. break;
  83. case 'l':
  84. processor->SetLogFile( true );
  85. break;
  86. default:
  87. printusage();
  88. break;
  89. }
  90. }
  91. }
  92. if ( argc < 3 || ( i != argc ) )
  93. {
  94. printusage();
  95. }
  96. CheckLogFile();
  97. vprint( 0, " Looking for unneeded header includes...\n" );
  98. char sourcetreebase[ 256 ];
  99. strcpy( sourcetreebase, argv[i-2] );
  100. Q_StripTrailingSlash( sourcetreebase );
  101. // ProcessDirectory( argv[ i-1 ], sourcetreebase, "engine", "engdll.dsp", "quiver - Win32 GL Debug" );
  102. // ProcessDirectory( argv[ i-1 ], sourcetreebase, "dlls", "hl.dsp", va( "hl - Win32 %s Debug", argv[ i - 1 ] ) );
  103. ProcessDirectory( argv[ i-1 ], sourcetreebase, "cl_dll", "client.dsp", va( "client - Win32 Debug %s", argv[ i - 1 ] ) );
  104. return 0;
  105. }