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.

102 lines
2.2 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. my $srcDir = $ARGV[ 0 ];
  19. my $pyVer = $ARGV[ 1 ];
  20. my $swigFile = $ARGV[ 2 ];
  21. my $outBinDir = $ARGV[ 3 ];
  22. my $swigOutDir = "swig_python${pyVer}";
  23. my $swigC = "${swigFile}_wrap_python${pyVer}.cpp";
  24. my $swig = $srcDir . "\\devtools\\swigwin-1.3.40\\swig.exe";
  25. $swig =~ s:/:\\:g;
  26. if ( ! -x $swig )
  27. {
  28. $! = 1;
  29. die( "${pre} ERROR: Can't find swig executable ${swig}" );
  30. }
  31. if ( ! -d ${swigOutDir} )
  32. {
  33. print( "${pre} mkdir ${swigOutDir}\n" );
  34. mkdir ${swigOutDir};
  35. }
  36. if ( ! -d ${swigOutDir} )
  37. {
  38. $! = 1;
  39. die( "${pre} ERROR: Can't create directory ${swigOutDir}" );
  40. }
  41. if ( ! -d ${outBinDir} )
  42. {
  43. print( "${pre} mkdir ${outBinDir}\n" );
  44. mkdir ${outBinDir};
  45. }
  46. if ( ! -d ${outBinDir} )
  47. {
  48. $! = 1;
  49. die( "${pre} ERROR: Can't create directory ${swigOutDir}" );
  50. }
  51. if ( -f "${swigOutDir}/${swigC}" )
  52. {
  53. if ( $opt_v )
  54. {
  55. print( "${pre} unlink ${swigOutDir}/${swigC}\n" );
  56. }
  57. unlink "${swigOutDir}/${swigC}" || die( "${pre} Can't unlink ${swigOutDir}/${swigC}" );
  58. }
  59. # Warning 383 is: Warning(383): operator++ ignored
  60. # Warning 503 is: Warning(503): Can't wrap 'operator |' unless renamed to a valid identifier.
  61. # We disable these to avoid spamming the console.
  62. my $swigCmd = "${swig} -Fmicrosoft -ignoremissing -w383 -w503 -c++ -Iswig_python${pyVer} -I${srcDir}/public -outdir ${swigOutDir} -o ${swigOutDir}/${swigC} -python ${swigFile}.i";
  63. $swigCmd =~ s:/:\\:g;
  64. if ( !$opt_q )
  65. {
  66. print( "${pre} $swigCmd\n" );
  67. }
  68. system( ${swigCmd} );
  69. if ( $? )
  70. {
  71. $! = 1;
  72. print( "${pre} ERROR: Swig failed\n" );
  73. exit( 255 );
  74. die( "${pre} ERROR: Swig failed" );
  75. }
  76. if ( ! -r "${swigOutDir}/${swigFile}.py" )
  77. {
  78. $! = 1;
  79. die( "${pre} ERROR: No python code generated from swig" );
  80. }
  81. if ( $opt_v )
  82. {
  83. print( "${pre} *** Swig Complete!\n" );
  84. }
  85. exit( 0 );