tools/buildbot/bootstrap.pl
author David Anderson <dvander@alliedmods.net>
Sat Dec 29 00:12:27 2012 -0800 (2012-12-29)
changeset 249 82b1f8bc93a9
parent 110 1b0577b26837
permissions -rwxr-xr-x
Infer fixed array types from string literals.
     1 #!/usr/bin/perl
     2 # vim: set ts=2 sw=2 tw=99 et: 
     3 
     4 use strict;
     5 use Cwd;
     6 use File::Basename;
     7 use File::Path;
     8 
     9 my ($myself, $path) = fileparse($0);
    10 chdir($path);
    11 
    12 require 'helpers.pm';
    13 
    14 #Go back above build dir
    15 chdir(Build::PathFormat('../../..'));
    16 
    17 #Get the source path.
    18 our ($root) = getcwd();
    19 
    20 my $reconf = 0;
    21 
    22 #Create output folder if it doesn't exist.
    23 if (!(-d 'OUTPUT')) {
    24   $reconf = 1;
    25 } else {
    26   if (-f 'OUTPUT/sentinel') {
    27   	my @s = stat('OUTPUT/sentinel');
    28   	my $mtime = $s[9];
    29   	my @files = ('build/pushbuild.txt',
    30   							 'build/AMBuildScript',
    31   							 'build/product.version',
    32   							 'build/tools/bootstrap.pl');
    33   	my ($i);
    34   	for ($i = 0; $i <= $#files; $i++) {
    35   		if (IsNewer($files[$i], $mtime)) {
    36   			$reconf = 1;
    37   			last;
    38   		}
    39   	}
    40   } else {
    41   	$reconf = 1;
    42   }
    43 }
    44 
    45 if ($reconf) {
    46   rmtree('OUTPUT');
    47   mkdir('OUTPUT') or die("Failed to create output folder: $!\n");
    48   chdir('OUTPUT');
    49 
    50   print "Attempting to reconfigure...\n";
    51 
    52   my ($os, $bits, $mode);
    53   $os = $ARGV[0];
    54   $bits = $ARGV[1];
    55   $mode = $ARGV[2];
    56 
    57   my ($prefix, $python);
    58   if ($^O eq "darwin") {
    59   	$prefix = 'CC=clang CXX=clang++ ';
    60   	$python = 'python3';
    61   } elsif ($^O eq "linux") {
    62   	$prefix = 'CC="ccache gcc" CXX="ccache g++" ';
    63   	$python = 'python3';
    64   } elsif ($^O =~ /MSWin/) {
    65   	$prefix = '';
    66   	$python = "C:\\Python31\\Python.exe";
    67   }
    68 
    69   my ($cmdstring);
    70   $cmdstring = $prefix .
    71   						 $python . ' ' .
    72   						 Build::PathFormat('../build/configure.py') . ' ';
    73 
    74   if ($mode eq 'release') {
    75   	$cmdstring .= '--enable-optimize ';
    76   } else {
    77   	$cmdstring .= '--enable-debug ';
    78   }
    79 
    80   if ($bits eq '32') {
    81   	$cmdstring .= '--arch=x86 ';
    82   } else {
    83   	$cmdstring .= '--arch=x64 ';
    84   }
    85 
    86   my ($result);
    87   print "-> $cmdstring\n";
    88   $result = `$cmdstring`;
    89 
    90   print "$result\n";
    91   if ($? != 0) {
    92   	die("Could not configure: $!\n");
    93   }
    94   open(FILE, '>sentinel');
    95   print FILE "this is nothing.\n";
    96   close(FILE);
    97 }
    98 
    99 sub IsNewer
   100 {
   101   my ($file, $time) = (@_);
   102 
   103   my @s = stat($file);
   104   my $mtime = $s[9];
   105   return $mtime > $time;
   106 }
   107 
   108 exit(0);
   109 
   110