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.

95 lines
1.7 KiB

  1. #!perl
  2. use File::Spec;
  3. use File::Basename;
  4. use Getopt::Std;
  5. my $opt_q = 0;
  6. my $opt_v = 0;
  7. getopts( 'qv' );
  8. if ( $opt_v )
  9. {
  10. $opt_q = 0;
  11. }
  12. #
  13. # Perl command to build and install swig generated things
  14. #
  15. our $sScriptPath = File::Spec->rel2abs( File::Spec->canonpath( $0 ) );
  16. our ( $sScript, $sVpcDir ) = fileparse( ${sScriptPath} );
  17. our $pre = "[" . $sScript . "]";
  18. our $srcDir = File::Spec->catdir( $sVpcDir, '..' );
  19. our $diff = File::Spec->catdir( ${srcDir}, "devtools/bin/diff.exe" );
  20. our $p4Edit = File::Spec->catdir( ${srcDir}, "vpc_scripts/valve_p4_edit.cmd" );
  21. if ( ! -x $diff )
  22. {
  23. $! = 1;
  24. die( "${pre} ERROR: Can't find diff executable ${diff}" );
  25. }
  26. if ( ! -x $p4Edit )
  27. {
  28. $! = 1;
  29. die( "${pre} ERROR: Can't find versioning executable ${p4Edit}" );
  30. }
  31. our $src = File::Spec->canonpath( shift( @ARGV ) );
  32. our $dst = File::Spec->canonpath( shift( @ARGV ) );
  33. my $bAdd = 0;
  34. my $bCopy = 0;
  35. if ( -r ${dst} )
  36. {
  37. $diffCmd = "${diff} -q \"${src}\" \"${dst}\"";
  38. if ( $opt_v )
  39. {
  40. print( "${pre} ${diffCmd}\n" );
  41. }
  42. system( $diffCmd );
  43. if ( $? )
  44. {
  45. $bCopy = 1;
  46. }
  47. }
  48. else
  49. {
  50. $bAdd = 1;
  51. $bCopy = 1;
  52. }
  53. if ( $bCopy )
  54. {
  55. if ( ! $bAdd )
  56. {
  57. $editCmd = "${p4Edit} \"${dst}\" ${srcDir}";
  58. $editCmd =~ s:/:\\:g;
  59. if ( !$opt_q )
  60. {
  61. print( "${pre}: ${editCmd}\n" );
  62. }
  63. system( ${editCmd} );
  64. }
  65. $copyCmd = "\"${src}\" \"${dst}\"";
  66. $copyCmd =~ s:/:\\:g;
  67. $copyCmd = "copy /Y ${copyCmd}";
  68. if ( !$opt_q )
  69. {
  70. print( "${pre}: ${copyCmd}\n" );
  71. }
  72. system( ${copyCmd} );
  73. if ( $bAdd )
  74. {
  75. $editCmd = "${p4Edit} \"${dst}\" ${srcDir}";
  76. $editCmd =~ s:/:\\:g;
  77. if ( !$opt_q )
  78. {
  79. print( "${pre}: ${editCmd}\n" );
  80. }
  81. system( ${editCmd} );
  82. }
  83. }