Skip to content

Commit c9df174

Browse files
committed
Add a script for merging separate macOS architecture builds
1 parent d14933a commit c9df174

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

merge-macos-universal.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2018 Martin Storsjo
4+
#
5+
# Permission to use, copy, modify, and/or distribute this software for any
6+
# purpose with or without fee is hereby granted, provided that the above
7+
# copyright notice and this permission notice appear in all copies.
8+
#
9+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
17+
set -e
18+
19+
if [ $# -lt 2 ]; then
20+
echo $0 archive1.tar.xz archive2.tar.xz
21+
exit 1
22+
fi
23+
24+
base1=${1%%.*}
25+
base2=${2%%.*}
26+
27+
rm -rf "$base1" "$base2"
28+
tar -Jxf $1
29+
tar -Jxf $2
30+
31+
outbase="${base1%-*}-universal"
32+
33+
rm -rf "$outbase"
34+
cp -a "$base1" "$outbase"
35+
36+
for i in $(cd "$base1"; find . -type f); do
37+
#for i in $(cd "$base1"; echo bin/* lib/*.dylib); do
38+
if [ -L "$base1/$i" ] || [ ! -x "$base1/$i" ]; then
39+
continue
40+
fi
41+
if [ ! -x "$base2/$i" ]; then
42+
continue
43+
fi
44+
if file "$base1/$i" | sed 's/.*: *//' | grep -q Mach-O; then
45+
echo Merging $i
46+
lipo -create -output "$outbase/$i" "$base1/$i" "$base2/$i"
47+
fi
48+
done
49+
50+
tar -Jcf $outbase.tar.xz $outbase

0 commit comments

Comments
 (0)