Apple M1: Support non-Xcode based universal builds

This change adds the -G and --build_type arguments to the
BuildMacOSUniversalBinaray.py build script to allow the CMake generator and
build type to be specified for universal binary builds.

The defaults are:
-G "Unix Makefiles"
--build_type "Release"
This commit is contained in:
Skyler Saleh 2021-05-01 17:57:39 -07:00
parent 12c439860d
commit 9163312779
1 changed files with 27 additions and 10 deletions

View File

@ -27,6 +27,7 @@ import argparse
import filecmp import filecmp
import glob import glob
import json import json
import multiprocessing
import os import os
import shutil import shutil
import subprocess import subprocess
@ -65,7 +66,11 @@ DEFAULT_CONFIG = {
# Minimum macOS version for each architecture slice # Minimum macOS version for each architecture slice
"arm64_mac_os_deployment_target": "11.0.0", "arm64_mac_os_deployment_target": "11.0.0",
"x86_64_mac_os_deployment_target": "10.12.0" "x86_64_mac_os_deployment_target": "10.12.0",
# CMake Generator to use for building
"generator": "Unix Makefiles",
"build_type": "Release"
} }
@ -91,7 +96,16 @@ def parse_args(conf=DEFAULT_CONFIG):
help='Build target in generated project files', help='Build target in generated project files',
default=conf["build_target"], default=conf["build_target"],
dest="build_target") dest="build_target")
parser.add_argument(
'-G',
help='CMake Generator to use for creating project files',
default=conf["generator"],
dest="generator")
parser.add_argument(
'--build_type',
help='CMake build type [Debug, Release, RelWithDebInfo, MinSizeRel]',
default=conf["build_type"],
dest="build_type")
parser.add_argument( parser.add_argument(
'--dst_app', '--dst_app',
help='Directory where universal binary will be stored', help='Directory where universal binary will be stored',
@ -221,7 +235,8 @@ def build(config):
subprocess.check_call([ subprocess.check_call([
'arch', '-'+arch, 'arch', '-'+arch,
'cmake', '../../', '-G', 'Xcode', 'cmake', '../../', '-G', config['generator'],
'-DCMAKE_BUILD_TYPE=' + config['build_type'],
'-DCMAKE_OSX_DEPLOYMENT_TARGET=' '-DCMAKE_OSX_DEPLOYMENT_TARGET='
+ config[arch+"_mac_os_deployment_target"], + config[arch+"_mac_os_deployment_target"],
'-DMACOS_CODE_SIGNING_IDENTITY=' '-DMACOS_CODE_SIGNING_IDENTITY='
@ -232,11 +247,10 @@ def build(config):
], ],
env=env, cwd=arch) env=env, cwd=arch)
# Build project threads = multiprocessing.cpu_count()
subprocess.check_call(['xcodebuild', subprocess.check_call(['cmake', '--build', '.',
'-project', 'dolphin-emu.xcodeproj', '--config', config['build_type'],
'-target', config["build_target"], '--parallel', '{}'.format(threads)], cwd=arch)
'-configuration', 'Release'], cwd=arch)
dst_app = config["dst_app"] dst_app = config["dst_app"]
@ -247,11 +261,14 @@ def build(config):
os.mkdir(dst_app) os.mkdir(dst_app)
# Source binary trees to merge together # Source binary trees to merge together
src_app0 = ARCHITECTURES[0]+"/Binaries/release" src_app0 = ARCHITECTURES[0]+"/Binaries/"
src_app1 = ARCHITECTURES[1]+"/Binaries/release" src_app1 = ARCHITECTURES[1]+"/Binaries/"
recursiveMergeBinaries(src_app0, src_app1, dst_app) recursiveMergeBinaries(src_app0, src_app1, dst_app)
for path in glob.glob(dst_app+"/*"): for path in glob.glob(dst_app+"/*"):
if os.path.isdir(path) and os.path.splitext(path) != ".app":
continue
subprocess.check_call([ subprocess.check_call([
'codesign', 'codesign',
'-d', '-d',