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.

129 lines
2.9 KiB

  1. use strict;
  2. BEGIN {use File::Basename; push @INC, dirname($0); }
  3. require "valve_perl_helpers.pl";
  4. my $dynamic_compile = defined $ENV{"dynamic_shaders"} && $ENV{"dynamic_shaders"} != 0;
  5. # ----------------------------------------------
  6. # COMMAND-LINE ARGS
  7. # ----------------------------------------------
  8. my $g_x360 = 0;
  9. my $g_ps3 = 0;
  10. my $g_tmpfolder = "";
  11. my $g_vcsext = ".vcs";
  12. my $g_SrcDir = ".";
  13. my $inputbase;
  14. my $g_SourceDir;
  15. while( 1 )
  16. {
  17. $inputbase = shift;
  18. if( $inputbase =~ m/-source/ )
  19. {
  20. $g_SourceDir = shift;
  21. }
  22. elsif( $inputbase =~ m/-x360/ )
  23. {
  24. $g_x360 = 1;
  25. $g_tmpfolder = "_360";
  26. $g_vcsext = ".360.vcs";
  27. }
  28. elsif( $inputbase =~ m/-ps3/ )
  29. {
  30. $g_ps3 = 1;
  31. $g_tmpfolder = "_ps3";
  32. $g_vcsext = ".ps3.vcs";
  33. }
  34. else
  35. {
  36. last;
  37. }
  38. }
  39. # ----------------------------------------------
  40. # Load the list of shaders that we care about.
  41. # ----------------------------------------------
  42. my @srcfiles = &LoadShaderListFile( $inputbase );
  43. my %incHash;
  44. my %vcsHash;
  45. my $shader;
  46. foreach $shader ( @srcfiles )
  47. {
  48. my $shadertype = &LoadShaderListFile_GetShaderType( $shader );
  49. my $shaderbase = &LoadShaderListFile_GetShaderBase( $shader );
  50. my $shadersrc = &LoadShaderListFile_GetShaderSrc( $shader );
  51. if( $shadertype eq "fxc" || $shadertype eq "vsh" )
  52. {
  53. # We only generate inc files for fxc and vsh files.
  54. my $incFileName = "$shadertype" . "tmp9" . $g_tmpfolder . "/" . $shaderbase . "\.inc";
  55. $incFileName =~ tr/A-Z/a-z/;
  56. $incHash{$incFileName} = 1;
  57. }
  58. my $vcsFileName = "$shadertype/$shaderbase" . $g_vcsext;
  59. $vcsFileName =~ tr/A-Z/a-z/;
  60. $vcsHash{$vcsFileName} = 1;
  61. }
  62. # ----------------------------------------------
  63. # Get the list of inc files to consider for reverting
  64. # ----------------------------------------------
  65. sub RevertIntegratedFiles
  66. {
  67. my $path = shift;
  68. my $fileHashRef = shift;
  69. my $cmd = "p4 fstat $path";
  70. my @fstat = &RunCommand( $cmd );
  71. my $depotFile;
  72. my $action;
  73. my @openedforintegrate;
  74. my $line;
  75. foreach $line ( @fstat )
  76. {
  77. if( $line =~ m,depotFile (.*)\n, )
  78. {
  79. $depotFile = &NormalizePerforceFilename( $1 );
  80. }
  81. elsif( $line =~ m,action (.*)\n, )
  82. {
  83. $action = $1;
  84. }
  85. elsif( $line =~ m,^\s*$, )
  86. {
  87. if( defined $action && defined $fileHashRef->{$depotFile} && $action =~ m/integrate/i )
  88. {
  89. push @openedforintegrate, $depotFile;
  90. }
  91. undef $depotFile;
  92. undef $action;
  93. }
  94. }
  95. if( scalar( @openedforintegrate ) )
  96. {
  97. my $cmd = "p4 revert @openedforintegrate";
  98. # print "$cmd\n";
  99. my @revertOutput = &RunCommand( $cmd );
  100. &PrintCleanPerforceOutput( @revertOutput );
  101. }
  102. }
  103. my $path = "vshtmp9" . $g_tmpfolder . "/... fxctmp9" . $g_tmpfolder . "/...";
  104. &RevertIntegratedFiles( $path, \%incHash );
  105. if( !$dynamic_compile )
  106. {
  107. &MakeDirHier( "../../../game/platform/shaders" );
  108. # Might be in a different client for the vcs files, so chdir to the correct place.
  109. chdir "../../../game/platform/shaders" || die;
  110. my $path = "...";
  111. &RevertIntegratedFiles( $path, \%vcsHash );
  112. }