scripts: support building universal macOS .dmg (#338)
This commit is contained in:
parent
3833637b5b
commit
d6aa197c3b
2 changed files with 73 additions and 28 deletions
|
@ -11,6 +11,36 @@ import shlex
|
|||
import os
|
||||
from sys import platform
|
||||
|
||||
def package_dmg(install_path, destination):
|
||||
# for compiling on Darwin as 'genisoimage' doesn't exist
|
||||
# uses 'create-dmg' (brew install create-dmg)
|
||||
if platform == "darwin":
|
||||
command = shlex.split('''create-dmg
|
||||
--volname "Taisei"
|
||||
--volicon "Taisei.app/Contents/Resources/Taisei.icns"
|
||||
--window-pos 200 120
|
||||
--window-size 550 480
|
||||
--icon-size 64
|
||||
--icon "Taisei.app" 100 50
|
||||
--icon "README.txt" 50 200
|
||||
--icon "STORY.txt" 200 200
|
||||
--icon "GAME.html" 350 200
|
||||
--icon "COPYING" 125 350
|
||||
--icon "ENVIRON.html" 275 350
|
||||
--hide-extension "Taisei.app"
|
||||
--app-drop-link 300 50''') + [
|
||||
destination,
|
||||
str(install_path),
|
||||
]
|
||||
else:
|
||||
(install_path / 'Applications').symlink_to('/Applications')
|
||||
command = shlex.split('genisoimage -V Taisei -D -R -apple -no-pad -o') + [
|
||||
destination,
|
||||
str(install_path),
|
||||
]
|
||||
subprocess.check_call(command, cwd=str(install_path))
|
||||
|
||||
print('\nPackage generated:', destination)
|
||||
|
||||
def main(args):
|
||||
parser = argparse.ArgumentParser(description='Generate a .dmg package for macOS.', prog=args[0])
|
||||
|
@ -26,37 +56,20 @@ def main(args):
|
|||
nargs='?',
|
||||
)
|
||||
|
||||
parser.add_argument('installation',
|
||||
help='Specify a pre-built directory instead of making a new one from the build directory (i.e: in the case of a universal image)',
|
||||
type=Path,
|
||||
nargs='?',
|
||||
)
|
||||
|
||||
args = parser.parse_args(args[1:])
|
||||
|
||||
with temp_install(args.build_dir) as install_path:
|
||||
# for compiling on Darwin as 'genisoimage' doesn't exist
|
||||
# uses 'create-dmg' (brew install create-dmg)
|
||||
if platform == "darwin":
|
||||
command = shlex.split('''create-dmg
|
||||
--volname "Taisei"
|
||||
--volicon "Taisei.app/Contents/Resources/Taisei.icns"
|
||||
--window-pos 200 120
|
||||
--window-size 550 480
|
||||
--icon-size 64
|
||||
--icon "Taisei.app" 100 50
|
||||
--icon "README.txt" 50 200
|
||||
--icon "STORY.txt" 200 200
|
||||
--icon "GAME.html" 350 200
|
||||
--icon "COPYING" 125 350
|
||||
--icon "ENVIRON.html" 275 350
|
||||
--hide-extension "Taisei.app"
|
||||
--app-drop-link 300 50''') + [args.output, str(install_path)]
|
||||
else:
|
||||
(install_path / 'Applications').symlink_to('/Applications')
|
||||
if args.installation is None:
|
||||
with temp_install(args.build_dir) as install_path:
|
||||
package_dmg(install_path, args.output)
|
||||
else:
|
||||
package_dmg(args.installation, args.output)
|
||||
|
||||
command = shlex.split('genisoimage -V Taisei -D -R -apple -no-pad -o') + [
|
||||
args.output,
|
||||
str(install_path),
|
||||
]
|
||||
|
||||
subprocess.check_call(command, cwd=str(install_path))
|
||||
|
||||
print('\nPackage generated:', args.output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
32
scripts/macos_build_universal.sh
Executable file
32
scripts/macos_build_universal.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
if [[ -z $1 || -z $2 ]]; then
|
||||
echo "Usage: macos_build_universal.sh [taisei/build] [taisei/]\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export BUILD_DIR=$1
|
||||
export TAISEI_ROOT=$2
|
||||
export MESON_BUILD_ROOT_MACOS_X64=$BUILD_DIR/x64
|
||||
export MESON_BUILD_ROOT_MACOS_AARCH64=$BUILD_DIR/aarch64
|
||||
export MESON_BUILD_ROOT_MACOS_X64_COMPILED=$BUILD_DIR/compiled/x64
|
||||
export MESON_BUILD_ROOT_MACOS_AARCH64_COMPILED=$BUILD_DIR/compiled/aarch64
|
||||
export MESON_BUILD_ROOT_MACOS_COMBINED=$BUILD_DIR/compiled/combined
|
||||
export TAISEI_BIN_PATH=./Taisei.app/Contents/MacOS/Taisei
|
||||
|
||||
mkdir -p $BUILD_DIR/compiled $MESON_BUILD_ROOT_MACOS_COMBINED
|
||||
meson setup --native-file $TAISEI_ROOT/misc/ci/macos-x86_64-build-release.ini --prefix $MESON_BUILD_ROOT_MACOS_X64_COMPILED $MESON_BUILD_ROOT_MACOS_X64 $TAISEI_ROOT
|
||||
meson setup --cross-file $TAISEI_ROOT/misc/ci/macos-aarch64-build-release.ini --prefix $MESON_BUILD_ROOT_MACOS_AARCH64_COMPILED $MESON_BUILD_ROOT_MACOS_AARCH64 $TAISEI_ROOT
|
||||
|
||||
meson install -C $MESON_BUILD_ROOT_MACOS_X64
|
||||
meson install -C $MESON_BUILD_ROOT_MACOS_AARCH64
|
||||
|
||||
cp -a $MESON_BUILD_ROOT_MACOS_X64_COMPILED/ $MESON_BUILD_ROOT_MACOS_COMBINED
|
||||
echo "Combining x64 and AArch64 binaries...\n"
|
||||
lipo -create -output $MESON_BUILD_ROOT_MACOS_COMBINED/$TAISEI_BIN_PATH $MESON_BUILD_ROOT_MACOS_X64_COMPILED/$TAISEI_BIN_PATH $MESON_BUILD_ROOT_MACOS_AARCH64_COMPILED/$TAISEI_BIN_PATH
|
||||
|
||||
TAISEI_VERSION=$($PWD/scripts/version.py)
|
||||
|
||||
$TAISEI_ROOT/scripts/macos-gen-dmg.py $BUILD_DIR/compiled/Taisei-$TAISEI_VERSION-universal.dmg $MESON_BUILD_ROOT_MACOS_X64 $MESON_BUILD_ROOT_MACOS_COMBINED
|
Loading…
Add table
Add a link
Reference in a new issue