Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # This script should be pointed to a valid llvm.build folder that |
| 4 | # was created using the "build-llvm.pl" shell script. It will create |
| 5 | # a new llvm.zip file that can be checked into the respository |
| 6 | # at lldb/llvm.zip |
| 7 | |
| 8 | use strict; |
| 9 | use Cwd 'abs_path'; |
| 10 | use File::Basename; |
| 11 | use File::Temp qw/ tempfile tempdir /; |
| 12 | our $debug = 1; |
| 13 | |
| 14 | |
| 15 | sub do_command |
| 16 | { |
| 17 | my $cmd = shift; |
| 18 | my $description = @_ ? shift : "command"; |
| 19 | my $die_on_fail = @_ ? shift : undef; |
| 20 | $debug and print "% $cmd\n"; |
| 21 | system ($cmd); |
| 22 | if ($? == -1) |
| 23 | { |
| 24 | $debug and printf ("error: %s failed to execute: $!\n", $description); |
| 25 | $die_on_fail and $? and exit(1); |
| 26 | return $?; |
| 27 | } |
| 28 | elsif ($? & 127) |
| 29 | { |
| 30 | $debug and printf("error: %s child died with signal %d, %s coredump\n", |
| 31 | $description, |
| 32 | ($? & 127), |
| 33 | ($? & 128) ? 'with' : 'without'); |
| 34 | $die_on_fail and $? and exit(1); |
| 35 | return $?; |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | my $exit = $? >> 8; |
| 40 | if ($exit) |
| 41 | { |
| 42 | $debug and printf("error: %s child exited with value %d\n", $description, $exit); |
| 43 | $die_on_fail and exit(1); |
| 44 | } |
| 45 | return $exit; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if (@ARGV == 4) |
| 50 | { |
| 51 | my $llvm_source_dir = abs_path(shift @ARGV); # The llvm source that contains full llvm and clang sources |
| 52 | my $llvm_build_dir = abs_path(shift @ARGV); # The llvm build directory that contains headers and |
| 53 | my $lldb_build_dir = abs_path(shift @ARGV); # the build directory that contains the fat libEnhancedDisassembly.dylib |
| 54 | my $llvm_zip_file = abs_path(shift @ARGV); |
| 55 | |
| 56 | printf("LLVM sources : '%s'\n", $llvm_source_dir); |
| 57 | printf("LLVM build : '%s'\n", $llvm_build_dir); |
| 58 | printf("LLDB build : '%s'\n", $lldb_build_dir); |
| 59 | printf("LLVM zip file: '%s'\n", $llvm_zip_file); |
| 60 | |
| 61 | -e $llvm_build_dir or die "LLVM build directory doesn't exist: '$llvm_build_dir': $!\n"; |
| 62 | -l "$llvm_build_dir/llvm" || die "Couldn't find llvm symlink '$llvm_build_dir/llvm': $!\n"; |
| 63 | |
| 64 | my $temp_dir = tempdir( CLEANUP => 1 ); |
| 65 | print "temp dir = '$temp_dir'\n"; |
| 66 | my $llvm_checkpoint_dir = "$temp_dir/llvm"; |
| 67 | mkdir "$llvm_checkpoint_dir" or die "Couldn't make 'llvm' in '$temp_dir'\n"; |
| 68 | |
| 69 | my @rsync_src_dst_paths = |
| 70 | ( |
| 71 | "$llvm_source_dir/include", "$llvm_checkpoint_dir", |
| 72 | "$llvm_source_dir/tools/clang/include", "$llvm_checkpoint_dir/tools/clang", |
| 73 | "$llvm_build_dir/llvm/include", "$llvm_checkpoint_dir", |
| 74 | "$llvm_build_dir/llvm/tools/clang/include", "$llvm_checkpoint_dir/tools/clang", |
| 75 | ); |
| 76 | |
| 77 | while (@rsync_src_dst_paths) |
| 78 | { |
| 79 | my $rsync_src = shift @rsync_src_dst_paths; |
| 80 | my $rsync_dst = shift @rsync_src_dst_paths; |
| 81 | print "rsync_src = '$rsync_src'\n"; |
| 82 | print "rsync_dst = '$rsync_dst'\n"; |
| 83 | if (-e $rsync_src) |
| 84 | { |
| 85 | my ($rsync_dst_file, $rsync_dst_dir) = fileparse ($rsync_dst); |
| 86 | print "rsync_dst_dir = '$rsync_dst_dir'\n"; |
| 87 | -e $rsync_dst_dir or do_command ("mkdir -p '$rsync_dst_dir'"); |
| 88 | do_command ("rsync -amvC --exclude='*.tmp' --exclude='*.txt' --exclude='*.TXT' --exclude='*.td' --exclude='\.dir' --exclude=Makefile '$rsync_src' '$rsync_dst'"); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | do_command ("cp '$llvm_build_dir/libllvmclang.a' '$llvm_checkpoint_dir'", "Copying libllvmclang.a", 1); |
| 93 | do_command ("cp '$lldb_build_dir/libEnhancedDisassembly.dylib' '$llvm_checkpoint_dir'", "Copying libEnhancedDisassembly.dylib", 1); |
| 94 | do_command ("rm -rf '$llvm_zip_file'", "Removing old llvm checkpoint file '$llvm_zip_file'", 1); |
| 95 | do_command ("(cd '$temp_dir' ; zip -r '$llvm_zip_file' 'llvm')", "Zipping llvm checkpoint directory '$llvm_checkpoint_dir' to '$llvm_zip_file'", 1); |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | print "USAGE\n\tcheckpoint-llvm.pl <llvm-sources> <llvm-build> <lldb-build> <llvm-zip>\n\n"; |
Sean Callanan | e6c6f49 | 2011-03-26 00:52:28 +0000 | [diff] [blame] | 100 | print "EXAMPLE\n\tcd lldb\n\t./scripts/checkpoint-llvm.pl llvm build/lldb.build/BuildAndIntegration/lldb-core.build/DerivedSources/llvm.build build/BuildAndIntegration llvm.zip\n"; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 101 | } |