Skip to content

Support tvOS compilation #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ opts.Add(EnumVariable(
'platform',
'Target platform',
host_platform,
allowed_values=('linux', 'osx', 'windows', 'android', 'ios'),
allowed_values=('linux', 'osx', 'windows', 'android', 'ios', 'tvos'),
ignorecase=2
))
opts.Add(EnumVariable(
Expand Down Expand Up @@ -145,11 +145,22 @@ opts.Add(EnumVariable(
'arm64',
['armv7', 'arm64', 'x86_64']
))
opts.Add(EnumVariable(
'tvos_arch',
'Target tvOS architecture',
'arm64',
['arm64', 'x86_64']
))
opts.Add(BoolVariable(
'ios_simulator',
'Target iOS Simulator',
False
))
opts.Add(BoolVariable(
'tvos_simulator',
'Target tvOS Simulator',
False
))
opts.Add(
'IPHONEPATH',
'Path to iPhone toolchain',
Expand Down Expand Up @@ -231,6 +242,47 @@ elif env['platform'] == 'osx':
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])

elif env['platform'] == 'tvos':
if env['tvos_simulator']:
sdk_name = 'appletvsimulator'

env.Append(CCFLAGS=['-mappletvsimulator-version-min=10.0'])
env.Append(LINKFLAGS=["-mappletvsimulator-version-min=10.0"])
env['LIBSUFFIX'] = ".simulator" + env['LIBSUFFIX']
else:
sdk_name = 'appletvos'

env.Append(CCFLAGS=['-mappletvos-version-min=10.0'])
env.Append(LINKFLAGS=["-mappletvos-version-min=10.0"])

try:
sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip())
except (subprocess.CalledProcessError, OSError):
raise ValueError("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))

compiler_path = env['IPHONEPATH'] + '/usr/bin/'
env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH']

env['CC'] = compiler_path + 'clang'
env['CXX'] = compiler_path + 'clang++'
env['AR'] = compiler_path + 'ar'
env['RANLIB'] = compiler_path + 'ranlib'

env.Append(CCFLAGS=['-std=c++14', '-arch', env['tvos_arch'], '-isysroot', sdk_path])
env.Append(LINKFLAGS=[
'-arch',
env['tvos_arch'],
'-framework',
'Cocoa',
'-Wl,-undefined,dynamic_lookup',
'-isysroot', sdk_path,
'-F' + sdk_path
])

if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
elif env['platform'] == 'ios':
if env['ios_simulator']:
sdk_name = 'iphonesimulator'
Expand Down Expand Up @@ -403,6 +455,8 @@ if env['platform'] == 'android':
arch_suffix = env['android_arch']
if env['platform'] == 'ios':
arch_suffix = env['ios_arch']
if env['platform'] == 'tvos':
arch_suffix = env['tvos_arch']

library = env.StaticLibrary(
target='bin/' + 'libgodot-cpp.{}.{}.{}{}'.format(
Expand Down