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.

86 lines
1.8 KiB

  1. BEGIN {use File::Basename; push @INC, dirname($0); }
  2. require "valve_perl_helpers.pl";
  3. use Cwd;
  4. use String::CRC32;
  5. my $txtfilename = shift;
  6. my $arg = shift;
  7. my $is360 = 0;
  8. my $platformextension = "";
  9. if( $arg =~ m/-x360/i )
  10. {
  11. $is360 = 1;
  12. $platformextension = ".360";
  13. }
  14. # Get the changelist number for the Shader Auto Checkout changelist. Will create the changelist if it doesn't exist.
  15. my $changelistnumber = `valve_p4_create_changelist.cmd ..\\..\\..\\game\\hl2\\shaders \"Shader Auto Checkout VCS\"`;
  16. # Get rid of the newline
  17. $changelistnumber =~ s/\n//g;
  18. my $changelistarg = "";
  19. if( $changelistnumber != 0 )
  20. {
  21. $changelistarg = "-c $changelistnumber"
  22. }
  23. open TXTFILE, "<$txtfilename";
  24. my $src;
  25. my $dst;
  26. while( $src = <TXTFILE> )
  27. {
  28. # get rid of comments
  29. $src =~ s,//.*,,g;
  30. # skip blank lines
  31. if( $src =~ m/^\s*$/ )
  32. {
  33. next;
  34. }
  35. # Get rid of newlines.
  36. $src =~ s/\n//g;
  37. # Save off the shader source filename.
  38. my $dst = $src;
  39. $dst =~ s/_tmp//gi;
  40. # Does the dst exist?
  41. my $dstexists = -e $dst;
  42. my $srcexists = -e $src;
  43. # What are the time stamps for the src and dst?
  44. my $srcmodtime = ( stat $src )[9];
  45. my $dstmodtime = ( stat $dst )[9];
  46. # Open for edit or add if different than what is in perforce already.
  47. if( !$dstexists || ( $srcmodtime != $dstmodtime ) )
  48. {
  49. # Make the target writable if it exists
  50. if( $dstexists )
  51. {
  52. MakeFileWritable( $dst );
  53. }
  54. my $dir = $dst;
  55. $dir =~ s,([^/\\]*$),,; # rip the filename off the end
  56. my $filename = $1;
  57. # create the target directory if it doesn't exist
  58. if( !$dstexists )
  59. {
  60. &MakeDirHier( $dir, 0777 );
  61. }
  62. # copy the file to its targets. . . we want to see STDERR here if there is an error.
  63. my $cmd = "copy $src $dst > nul";
  64. # print STDERR "$cmd\n";
  65. system $cmd;
  66. MakeFileReadOnly( $dst );
  67. }
  68. }
  69. close TXTFILE;