1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(osx): Added macos instalation script

Implementation by @iphydf
Fix #3747.
This commit is contained in:
Diadlo 2017-01-09 23:06:52 +03:00
parent f0467abc34
commit 30e8a69d11
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

37
osx/macfixrpath Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env perl
# This script used in `CMakeList.txt`. It's not required to run manually
use strict;
use File::Find;
use Data::Dumper;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 1;
my $BUNDLE_PATH = @ARGV[0] or die "Usage: macfixrpath <BUNDLE_PATH>\n";
my $prefix = `brew --prefix`;
chomp $prefix;
$prefix .= "/Cellar/";
my @libs = <$BUNDLE_PATH/Contents/Frameworks/*.framework/Versions/5/Qt*>;
find sub {
/\.dylib$/ or return;
push @libs, $File::Find::name;
}, $BUNDLE_PATH;
my %deps;
for (@libs) {
my @deps = grep { @$_ } map { [m!^\t($prefix.+)/([^/]+) \(.+\)$!] } grep { /^\t/ } split /\n/, `otool -L $_`;
my @resolved = map { my $dep = $_; [@$dep, grep { m!/$dep->[1]$! } @libs] } @deps;
$_->[2] =~ s|\Q$BUNDLE_PATH\E/Contents/|\@executable_path/../| for @resolved;
$deps{$_} = \@resolved if @deps;
}
for my $lib (sort keys %deps) {
my $count = @{$deps{$lib}};
for my $dep (@{$deps{$lib}}) {
my ($path, $name, $dest) = @$dep;
system "install_name_tool", "-change", "$path/$name", $dest, $lib;
}
}