Merge pull request #39 from godotengine/ios-and-m1-stuff

Apple silicon: arm64 macOS and arm64 iOS simulator
This commit is contained in:
Ignacio Roldán Etcheverry 2021-06-02 23:32:45 +02:00 committed by GitHub
commit 7937417c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 14 deletions

View File

@ -257,7 +257,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
target: [arm64, x86_64]
target: [arm64, x86_64, arm64-sim]
steps:
- name: Set Environment Variables
run: |

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
__pycache__/
*.pyc
.DS_Store

View File

@ -15,7 +15,7 @@ import runtime
targets = {
'linux': ['x86', 'x86_64'],
'windows': ['x86', 'x86_64'],
'osx': ['x86_64']
'osx': ['arm64', 'x86_64']
}
target_arch = {
@ -28,14 +28,24 @@ target_arch = {
'x86_64': 'x86_64'
},
'osx': {
'arm64': 'arm64',
'x86_64': 'x86_64'
}
}
host_triples = {
'linux': '%s-linux-gnu',
'windows': '%s-w64-mingw32',
'osx': '%s-apple-darwin',
'linux': {
'x86': 'i686-linux-gnu',
'x86_64': 'x86_64-linux-gnu'
},
'windows': {
'x86': 'i686-w64-mingw32',
'x86_64': 'x86_64-w64-mingw32'
},
'osx': {
'arm64': 'aarch64-apple-darwin20',
'x86_64': 'x86_64-apple-darwin'
}
}
llvm_table = {
@ -70,7 +80,7 @@ def get_osxcross_sdk(osxcross_bin, arch):
def setup_desktop_template(env: dict, opts: DesktopOpts, product: str, target_platform: str, target: str):
host_triple = host_triples[target_platform] % target_arch[target_platform][target]
host_triple = host_triples[target_platform][target]
CONFIGURE_FLAGS = [
'--disable-boehm',
@ -137,7 +147,20 @@ def setup_desktop_template(env: dict, opts: DesktopOpts, product: str, target_pl
# DTrace is not available when building with OSXCROSS
CONFIGURE_FLAGS += ['--enable-dtrace=no']
else:
env['_%s-%s_CC' % (product, target)] = 'cc'
osx_toolchain = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'
env['_%s-%s_CC' % (product, target)] = '%s/usr/bin/clang' % osx_toolchain
env['_%s-%s_CXX' % (product, target)] = '%s/usr/bin/clang++' % osx_toolchain
osx_sysroot = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk'
CFLAGS = [
'-isysroot', osx_sysroot,
'-arch', target_arch[target_platform][target]
]
env['_%s-%s_CFLAGS' % (product, target)] = CFLAGS
env['_%s-%s_CXXFLAGS' % (product, target)] = CFLAGS
env['_%s-%s_CONFIGURE_FLAGS' % (product, target)] = CONFIGURE_FLAGS

21
ios.py
View File

@ -14,7 +14,7 @@ import runtime
this_script_dir = os.path.dirname(os.path.realpath(__file__))
device_targets = ['armv7', 'arm64']
sim_targets = ['i386', 'x86_64']
sim_targets = ['i386', 'x86_64', 'arm64-sim']
cross_targets = ['cross-armv7', 'cross-arm64']
@ -26,6 +26,7 @@ class iOSTargetTable:
archs = {
'armv7': 'arm',
'arm64': 'arm64',
'arm64-sim': 'arm64',
'i386': 'i386',
'x86_64': 'x86_64'
}
@ -33,6 +34,7 @@ class iOSTargetTable:
host_triples = {
'armv7': 'arm-apple-darwin11',
'arm64': 'aarch64-apple-darwin11',
'arm64-sim': 'aarch64-apple-darwin11',
'i386': 'i386-apple-darwin11',
'x86_64': 'x86_64-apple-darwin11'
}
@ -40,6 +42,7 @@ class iOSTargetTable:
osxcross_tool_triples = {
'armv7': 'arm-apple-darwin11', # TODO: ?
'arm64': 'arm-apple-darwin11',
'arm64-sim': 'arm-apple-darwin11',
'i386': 'i386-apple-darwin11', # TODO: ?
'x86_64': 'x86_64-apple-darwin11'
}
@ -185,7 +188,7 @@ def setup_ios_simulator_template(env: dict, opts: iOSOpts, target: str):
if not ios_sysroot_path:
raise RuntimeError('Cannot find iOS SDK; specify one manually with \'--ios-sdk\'.')
sysroot_flags = ['-isysroot', ios_sysroot_path, '-miphoneos-version-min=%s' % opts.ios_version_min]
sysroot_flags = ['-isysroot', ios_sysroot_path, '-mios-simulator-version-min=%s' % opts.ios_version_min]
arch = iOSTargetTable.archs[target]
host_triple = iOSTargetTable.host_triples[target]
@ -306,8 +309,11 @@ class iOSCrossTable:
}
def setup_ios_cross_template(env: dict, opts: iOSOpts, target: str, host_arch: str):
def llvm_for(host_arch: str) -> str:
return 'llvmarm64' if host_arch == 'arm64' else 'llvm64'
def setup_ios_cross_template(env: dict, opts: iOSOpts, target: str, host_arch: str):
target_triple = iOSCrossTable.target_triples[target]
device_target = iOSCrossTable.device_targets[target]
offsets_dumper_abi = iOSCrossTable.offsets_dumper_abis[target]
@ -411,7 +417,7 @@ def setup_ios_cross_template(env: dict, opts: iOSOpts, target: str, host_arch: s
env['_ios-%s_CONFIGURE_FLAGS' % target] = CONFIGURE_FLAGS
# Runtime cross template
runtime.setup_runtime_cross_template(env, opts, 'ios', target, host_triple, target_triple, device_target, 'llvm64', offsets_dumper_abi)
runtime.setup_runtime_cross_template(env, opts, 'ios', target, host_triple, target_triple, device_target, llvm_for(host_arch), offsets_dumper_abi)
def strip_libs(opts: iOSOpts, product: str, target: str):
@ -427,8 +433,11 @@ def configure(opts: iOSOpts, product: str, target: str):
if is_cross(target):
import llvm
llvm.make(opts, 'llvm64')
setup_ios_cross_template(env, opts, target, host_arch='x86_64')
host_arch='x86_64'
llvm.make(opts, llvm_for(host_arch))
setup_ios_cross_template(env, opts, target, host_arch)
else:
if is_sim:
setup_ios_simulator_template(env, opts, target)

View File

@ -11,7 +11,7 @@ from os_utils import *
# TODO: OSXCROSS
target_values = ['llvm32', 'llvm64', 'llvmwin32', 'llvmwin64']
target_values = ['llvm32', 'llvm64', 'llvmarm64', 'llvmwin32', 'llvmwin64']
mxe_targets = {
'llvmwin32': {'arch': 'i686', 'mxe': 'mxe-Win32'},
'llvmwin64': {'arch': 'x86_64', 'mxe': 'mxe-Win64'}