summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-05-17 15:13:12 +0200
committerCarl Hetherington <cth@carlh.net>2021-05-18 07:38:34 +0200
commite102a01b4d9e00a712090a3a82a596703dc65812 (patch)
tree5a8b202baf533ea88ca7c95375423dd517dfb168
parent3b28f6ad6e4ebdbab8928079b63f962844060c2b (diff)
Restore support for building thin or universal binaries for macOS.
-rw-r--r--cscript3
-rw-r--r--platform/osx/make_dmg.sh120
2 files changed, 79 insertions, 44 deletions
diff --git a/cscript b/cscript
index cdbc8decb..9808e4d9b 100644
--- a/cscript
+++ b/cscript
@@ -703,7 +703,8 @@ def package(target, version, options):
elif target.distro == 'centos' or target.distro == 'fedora' or target.distro == 'mageia':
return package_rpm(target, cpu, version, options)
elif target.platform == 'osx':
- target.command('bash platform/osx/make_dmg.sh %s %s %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password))
+ archs = ' '.join(f'{t.arch}/{t.deployment}' for t in target.sub_targets)
+ target.command('bash platform/osx/make_dmg.sh %s %s %s %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password, archs))
packages = []
for x in glob.glob('build/platform/osx/DCP-o-matic*.dmg'):
a = os.path.abspath(x)
diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh
index 3427bf95a..5a7c4897f 100644
--- a/platform/osx/make_dmg.sh
+++ b/platform/osx/make_dmg.sh
@@ -1,8 +1,8 @@
#!/bin/bash
#
-SYNTAX="make_dmg.sh <environment> <builddir> <apple-id> <apple-password>"
+SYNTAX="make_dmg.sh <environment> <builddir> <apple-id> <apple-password> <arch1> [<arch2>]"
#
-# e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist foo@bar.net opensesame
+# e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist foo@bar.net opensesame x86_64/10.10 arm64/11.0
# Don't set -e here as egrep (used a few times) returns 1 if no matches
# were found.
@@ -15,6 +15,8 @@ ENV=$1
ROOT=$2
APPLE_ID=$3
APPLE_PASSWORD=$4
+ARCH1=$5
+ARCH2=$6
# This is our work area for making up the .dmgs
mkdir -p build/platform/osx
@@ -34,38 +36,66 @@ cat <<EOF > entitlements.plist
EOF
function copy {
- for f in $1/arm64/$2; do
- if [ -h $f ]; then
- ln -s $(readlink $f) "$3/`basename $f`"
- else
- g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
- mkdir -p "$3"
- lipo -create $f $g -output "$3/`basename $f`"
- fi
- done
+ if [ "$ARCH2" == "" ]; then
+ for f in $1/$2; do
+ if [ -h $f ]; then
+ ln -s $(readlink $f) "$3/`basename $f`"
+ else
+ cp $f "$3/`basename $f`"
+ fi
+ done
+ else
+ for f in $1/$ARCH1/$2; do
+ if [ -h $f ]; then
+ ln -s $(readlink $f) "$3/`basename $f`"
+ else
+ if [ "$ARCH2" == "" ]; then
+ cp $f "$3/`basename $f`"
+ else:
+ g=`echo $f | sed -e "s@/$ARCH1/@/$ARCH2/@g"`
+ mkdir -p "$3"
+ lipo -create $f $g -output "$3/`basename $f`"
+ fi
+ fi
+ done
+ fi
}
function copy_lib_root {
- for f in $ROOT/arm64/lib/$1*.dylib; do
- if [ -h $f ]; then
- ln -s $(readlink $f) "$2/`basename $f`"
- else
- g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
- mkdir -p "$2"
- lipo -create $f $g -output "$2/`basename $f`"
- fi
- done
+ if [ "$ARCH2" == "" ]; then
+ for f in $ROOT/lib/$1*.dylib; do
+ if [ -h $f ]; then
+ ln -s $(readlink $f) "$2/`basename $f`"
+ else
+ cp $f "$2/`basename $f`"
+ fi
+ done
+ else
+ for f in $ROOT/$ARCH1/lib/$1*.dylib; do
+ if [ -h $f ]; then
+ ln -s $(readlink $f) "$2/`basename $f`"
+ else
+ g=`echo $f | sed -e "s@/$ARCH1/@/$ARCH2/@g"`
+ mkdir -p "$2"
+ lipo -create $f $g -output "$2/`basename $f`"
+ fi
+ done
+ fi
to_relink="$to_relink|$1"
}
function copy_lib_env {
- for f in $ENV/arm64/lib/$1*.dylib; do
+ for f in $ENV/$ARCH1/lib/$1*.dylib; do
if [ -h $f ]; then
ln -s $(readlink $f) "$2/`basename $f`"
else
- g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
- mkdir -p "$2"
- lipo -create $f $g -output "$2/`basename $f`"
+ if [ "$ARCH2" == "" ]; then
+ cp $f "$2/`basename $f`"
+ else
+ g=`echo $f | sed -e "s@/$ARCH1/@/$ARCH2/@g"`
+ mkdir -p "$2"
+ lipo -create $f $g -output "$2/`basename $f`"
+ fi
fi
done
to_relink="$to_relink|$1"
@@ -144,7 +174,11 @@ function copy_libs {
# @param #1 directory to copy to
function copy_resources {
local dest="$1"
- local prefix=$ROOT/x86_64
+ if [ "$ARCH2" == "" ]; then
+ local prefix=$ROOT
+ else
+ local prefix=$ROOT/$ARCH1
+ fi
cp $prefix/src/dcpomatic/graphics/osx/dcpomatic_small.png "$dest"
cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2.icns "$dest"
cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_kdm.icns "$dest"
@@ -208,7 +242,7 @@ function copy_resources {
# i18n: wxWidgets .mo files
for lang in de es fr it sv nl ru pl da cs; do
mkdir "$dest/$lang"
- cp $ENV/x86_64/share/locale/$lang/LC_MESSAGES/wxstd.mo "$dest/$lang"
+ cp $ENV/$ARCH1/share/locale/$lang/LC_MESSAGES/wxstd.mo "$dest/$lang"
done
}
@@ -218,17 +252,15 @@ function relink_relative {
local linkers=("$@")
for obj in "${linkers[@]}"; do
- for arch in x86_64 arm64; do
- deps=`otool -arch $arch -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
- changes=""
- for dep in $deps; do
- base=`basename $dep`
- changes="$changes -change $dep @executable_path/../Frameworks/$base"
- done
- if test "x$changes" != "x"; then
- install_name_tool $changes -id `basename "$obj"` "$obj"
- fi
+ deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
+ changes=""
+ for dep in $deps; do
+ base=`basename $dep`
+ changes="$changes -change $dep @executable_path/../Frameworks/$base"
done
+ if test "x$changes" != "x"; then
+ install_name_tool $changes -id `basename "$obj"` "$obj"
+ fi
done
}
@@ -241,12 +273,10 @@ function relink_absolute {
local linkers=("$@")
for obj in "${linkers[@]}"; do
- for arch in x86_64 arm64; do
- deps=`otool -arch $arch -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
- for dep in $deps; do
- base=`basename $dep`
- install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
- done
+ deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
+ for dep in $deps; do
+ base=`basename $dep`
+ install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
done
done
}
@@ -391,7 +421,11 @@ function copy_verify {
relink_relative "${rl[@]}"
}
-prefix=$ROOT/arm64
+if [ "$ARCH2" == "" ]; then
+ prefix=$ROOT
+else
+ prefix=$ROOT/$ARCH1
+fi
# DCP-o-matic main
setup "DCP-o-matic 2.app"