Skip to content

Commit

Permalink
Apple M1: Support non-Xcode based universal builds
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
skylersaleh committed May 8, 2021
1 parent f4ab719 commit 2ba88d5
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions BuildMacOSUniversalBinary.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import filecmp
import glob
import json
import multiprocessing
import os
import shutil
import subprocess
Expand Down Expand Up @@ -65,7 +66,11 @@

# Minimum macOS version for each architecture slice
"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"

}

Expand All @@ -91,7 +96,16 @@ def parse_args(conf=DEFAULT_CONFIG):
help='Build target in generated project files',
default=conf["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(
'--dst_app',
help='Directory where universal binary will be stored',
Expand Down Expand Up @@ -221,7 +235,8 @@ def build(config):

subprocess.check_call([
'arch', '-'+arch,
'cmake', '../../', '-G', 'Xcode',
'cmake', '../../', '-G', config['generator'],
'-DCMAKE_BUILD_TYPE=' + config['build_type'],
'-DCMAKE_OSX_DEPLOYMENT_TARGET='
+ config[arch+"_mac_os_deployment_target"],
'-DMACOS_CODE_SIGNING_IDENTITY='
Expand All @@ -232,11 +247,10 @@ def build(config):
],
env=env, cwd=arch)

# Build project
subprocess.check_call(['xcodebuild',
'-project', 'dolphin-emu.xcodeproj',
'-target', config["build_target"],
'-configuration', 'Release'], cwd=arch)
threads = multiprocessing.cpu_count()
subprocess.check_call(['cmake', '--build', '.',
'--config', config['build_type'],
'--parallel', '{}'.format(threads)], cwd=arch)

dst_app = config["dst_app"]

Expand All @@ -247,11 +261,14 @@ def build(config):
os.mkdir(dst_app)

# Source binary trees to merge together
src_app0 = ARCHITECTURES[0]+"/Binaries/release"
src_app1 = ARCHITECTURES[1]+"/Binaries/release"
src_app0 = ARCHITECTURES[0]+"/Binaries/"
src_app1 = ARCHITECTURES[1]+"/Binaries/"

recursiveMergeBinaries(src_app0, src_app1, dst_app)
for path in glob.glob(dst_app+"/*"):
if os.path.isdir(path) and os.path.splitext(path) != ".app":
continue

subprocess.check_call([
'codesign',
'-d',
Expand Down

0 comments on commit 2ba88d5

Please sign in to comment.