@setlocal enableextensions & "%2\..\game\sdktools\Perl\bin\perl.exe" -x "%~f0" %* & goto :EOF
#!/usr/bin/perl

my $swigFile = $ARGV[ 0 ];
my $srcDir = $ARGV[ 1 ];
my $pyVer = $ARGV[ 2 ];

my $swig = $srcDir . "\\devtools\\swigwin-1.3.34\\swig.exe";

$dirtyFile = $swigFile . ".dep";

if ( ! -f $dirtyFile )
{
	open DIRTY, ">${dirtyFile}";
	print DIRTY <<"EOF";
//
//	This file is simply here to be a build dependency for ${swigFile}.i
//	The modification time of this file will be the newest modification time
//	of all of the dependencies of ${baseFile}.i as generated by
//
//	${swig} \\
//	 -Fmicrosoft -ignoremissing -c++ -I${srcDir}\\public -python -M ${swigFile}.i
//
//	If this file doesn't exist, it is created by the pre-build step
//
EOF

	( $dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks ) = stat( $dirtyFile );

	print( "[swig_depend] Setting ${dirtyFile} Modification Time To: " . localtime( $atime ) . "\n" );

	exit( 0 );
}

if ( ! -f $dirtyFile )
{
	die( "Can't Find ${dirtyFile}\n" );
}

( $dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks ) = stat( $dirtyFile );

my $dirtyTime = $mtime;
my $maxTime = $mtime;

open SWIG, "$swig -Fmicrosoft -ignoremissing -c++ -Iswig_python${pyVer} -I${srcDir}\\public -python -M ${swigFile}.i |" || die( "Couldn't Run Swig\n" );

while ( <SWIG> )
{
	chomp;
	s/^\s+//;
	s/\s+\\\s*$//;

	( $dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks ) = stat( $_ );

	if ( $mtime > $maxTime )
	{
		$maxTime = $mtime;
	}
}

close SWIG;

if ( $maxTime > $dirtyTime )
{
	print( "[swig_depend] Setting ${dirtyFile} Modification Time To: " . localtime( $atime ) . "\n" );
	utime $maxTime, $maxTime, $dirtyFile;
}

exit( 0 );