Search
lxdream.org :: lxdream/bundlelibs.pl
lxdream 0.9.1
released Jun 29
Download Now
filename bundlelibs.pl
changeset 716:f353e54a3a85
prev713:e5256202cc9e
author nkeynes
date Wed Oct 20 17:56:59 2010 +1000 (13 years ago)
permissions -rwxr-xr-x
last change Perform backface culling in scene preparation rather than leaving it to the
GL - this is a huge performance win, at least on the 9400M - changing cull
state appears to be very expensive, whereas the CPU needed to do the same
job is only just barely measurable.
file annotate diff log raw
nkeynes@713
     1
#!/usr/bin/perl
nkeynes@713
     2
# Script for OS X to copy all non-core library dependencies into the bundle, and fixup the lib naming
nkeynes@713
     3
# Run after the executable is already in the bundle.
nkeynes@713
     4
nkeynes@713
     5
if( $#ARGV <= 0 ) {
nkeynes@713
     6
   die( "Usage: bundlelibs.pl <target-binary> <target-lib-path>\n" );
nkeynes@713
     7
}
nkeynes@713
     8
nkeynes@713
     9
my $BINARY=shift();
nkeynes@713
    10
my $TARGETDIR=shift();
nkeynes@713
    11
my $OTOOL="otool";
nkeynes@713
    12
my $NTOOL="install_name_tool";
nkeynes@713
    13
nkeynes@713
    14
mkdir $TARGETDIR;
nkeynes@713
    15
nkeynes@713
    16
my %done=();
nkeynes@713
    17
my @worklist = ($BINARY);
nkeynes@713
    18
nkeynes@713
    19
while( $#worklist >= 0 ) {
nkeynes@713
    20
    my $target = shift @worklist;
nkeynes@713
    21
    $done{$target} = 2;
nkeynes@713
    22
    
nkeynes@713
    23
    open FH, "$OTOOL -L $target|" || die "Unable to run otool";
nkeynes@713
    24
    $skip = <FH>;
nkeynes@713
    25
nkeynes@713
    26
    while(<FH>){
nkeynes@713
    27
        $lib = $_;
nkeynes@713
    28
        $lib =~ s/^\s+([^\s]+)\s.*$/$1/s;
nkeynes@713
    29
        if( $lib !~ /^\/System\/Library/ && $lib !~ /^\/usr\/lib/ && $lib !~ /^\@executable_path\// ) {
nkeynes@713
    30
            $libname = $lib;
nkeynes@713
    31
            $libname =~ s#^.*/##;
nkeynes@713
    32
            $targetpath = "$TARGETDIR/$libname";
nkeynes@713
    33
            $libid = "\@executable_path/../Frameworks/$libname";
nkeynes@713
    34
            if( !$done{$libname} ) {
nkeynes@716
    35
                $done{$libname} = 1;
nkeynes@713
    36
                push @worklist, $targetpath;
nkeynes@713
    37
                system( ("cp", $lib, $targetpath) ) == 0 || die "Failed to copy $lib to $targetpath";
nkeynes@713
    38
                system( ($NTOOL, "-id", $libid, $targetpath) ) == 0 || die "Failed to set $lib ID to $libid";
nkeynes@713
    39
                print "Copied $lib => $targetpath\n";
nkeynes@713
    40
            }
nkeynes@713
    41
            system( ($NTOOL, "-change", $lib, $libid, $target ) ) == 0 || die "Failed to change $lib ID to $libid";
nkeynes@713
    42
        }
nkeynes@713
    43
    }
nkeynes@713
    44
    close FH;
nkeynes@713
    45
}
.