Counter Strike : Global Offensive Source Code
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.

92 lines
1.9 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\\platform\\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. if( $dstexists && !$srcexists )
  47. {
  48. printf STDERR "$src doesn't exist, deleting $dst\n";
  49. unlink $dst;
  50. }
  51. # Open for edit or add if different than what is in perforce already.
  52. if( !$dstexists || ( $srcmodtime != $dstmodtime ) )
  53. {
  54. # Make the target writable if it exists
  55. if( $dstexists )
  56. {
  57. MakeFileWritable( $dst );
  58. }
  59. my $dir = $dst;
  60. $dir =~ s,([^/\\]*$),,; # rip the filename off the end
  61. my $filename = $1;
  62. # create the target directory if it doesn't exist
  63. if( !$dstexists )
  64. {
  65. &MakeDirHier( $dir, 0777 );
  66. }
  67. # copy the file to its targets. . . we want to see STDERR here if there is an error.
  68. my $cmd = "copy $src $dst > nul";
  69. # print STDERR "$cmd\n";
  70. system $cmd;
  71. MakeFileReadOnly( $dst );
  72. }
  73. }
  74. close TXTFILE;