filename | bundlelibs.pl |
changeset | 716:f353e54a3a85 |
prev | 713:e5256202cc9e |
author | nkeynes |
date | Fri Mar 02 23:49:10 2012 +1000 (11 years ago) |
permissions | -rwxr-xr-x |
last change | Android WIP: * Rename gui_jni.c to gui_android.c - now quite android specific. * Implement generic EGL driver with very minimal Java wrapper * Run emulation in separate thread, and implement simple queue for inter-thread communication. * Add menu/action-bar items for start + reset |
view | annotate | diff | log | raw |
1 #!/usr/bin/perl
2 # Script for OS X to copy all non-core library dependencies into the bundle, and fixup the lib naming
3 # Run after the executable is already in the bundle.
5 if( $#ARGV <= 0 ) {
6 die( "Usage: bundlelibs.pl <target-binary> <target-lib-path>\n" );
7 }
9 my $BINARY=shift();
10 my $TARGETDIR=shift();
11 my $OTOOL="otool";
12 my $NTOOL="install_name_tool";
14 mkdir $TARGETDIR;
16 my %done=();
17 my @worklist = ($BINARY);
19 while( $#worklist >= 0 ) {
20 my $target = shift @worklist;
21 $done{$target} = 2;
23 open FH, "$OTOOL -L $target|" || die "Unable to run otool";
24 $skip = <FH>;
26 while(<FH>){
27 $lib = $_;
28 $lib =~ s/^\s+([^\s]+)\s.*$/$1/s;
29 if( $lib !~ /^\/System\/Library/ && $lib !~ /^\/usr\/lib/ && $lib !~ /^\@executable_path\// ) {
30 $libname = $lib;
31 $libname =~ s#^.*/##;
32 $targetpath = "$TARGETDIR/$libname";
33 $libid = "\@executable_path/../Frameworks/$libname";
34 if( !$done{$libname} ) {
35 $done{$libname} = 1;
36 push @worklist, $targetpath;
37 system( ("cp", $lib, $targetpath) ) == 0 || die "Failed to copy $lib to $targetpath";
38 system( ($NTOOL, "-id", $libid, $targetpath) ) == 0 || die "Failed to set $lib ID to $libid";
39 print "Copied $lib => $targetpath\n";
40 }
41 system( ($NTOOL, "-change", $lib, $libid, $target ) ) == 0 || die "Failed to change $lib ID to $libid";
42 }
43 }
44 close FH;
45 }
.