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.

103 lines
1.7 KiB

  1. use strict;
  2. my $forceBuild = 0;
  3. if ( $ARGV[1] =~ /-forcebuild/ )
  4. {
  5. $forceBuild = 1;
  6. }
  7. # Read in the list of changed maps
  8. my $filename = "buildlist.txt";
  9. open(INFILE, $filename);
  10. my @maps = <INFILE>;
  11. close( INFILE );
  12. # forcelist.txt allows maps to be manually added to the build.
  13. open(INFILE, "forcelist.txt");
  14. my @forcemaps = <INFILE>;
  15. close( INFILE );
  16. my $retval = 1;
  17. system( "echo. > $filename" );
  18. system( "echo. > forcelist.txt" );
  19. # Run through the list of maps to see if any should be built
  20. for( @maps)
  21. {
  22. if( /updating (.*)|adding (.*)/ )
  23. {
  24. # Check if this map should be built now
  25. if ( shouldBuild( $1 ) == 0 )
  26. {
  27. next;
  28. }
  29. # Add this map name to the build list
  30. system( "p4 sync -f $1 >> $filename" );
  31. system( "echo Adding to the build list: $1 >> log.txt" );
  32. $retval = 0;
  33. }
  34. }
  35. for( @forcemaps )
  36. {
  37. if ( /\.vmf/ )
  38. {
  39. # Add this map name to the build list
  40. $_ =~ /(.*)/;
  41. system( "p4 sync -f $1 >> $filename" );
  42. system( "echo Forcing add to the build list: $1 >> log.txt" );
  43. $retval = 0;
  44. }
  45. }
  46. exit $retval;
  47. #-----------------------------------
  48. # Check if this map should build now
  49. #-----------------------------------
  50. sub shouldBuild
  51. {
  52. my $map = shift;
  53. # if command line flag was set, build the map
  54. if ( $forceBuild == 1 )
  55. {
  56. return 1;
  57. }
  58. # if the map line contains the force flag, build the map
  59. if ( $map =~ /-forcebuild/ )
  60. {
  61. return 1;
  62. }
  63. # Dump the comments from the last checkin of this map
  64. system( "p4 changes -m 1 -s submitted -l $map > comments.txt" );
  65. # parse comments for the autocompile keyword
  66. open(INFILE, "comments.txt");
  67. my @comments = <INFILE>;
  68. close(INFILE);
  69. for( @comments )
  70. {
  71. if ( /autocompile/i )
  72. {
  73. return 1;
  74. }
  75. }
  76. return 0;
  77. }