mirror of
https://github.com/Relintai/godot-mono-builds.git
synced 2024-11-20 10:57:28 +01:00
offsets-tool: new location and OSXCross support
Also fixed: - 'os_utils.find_executable' was not working. - Wrong macOS OSXCross tool prefix (was using target arch instead of host arch).
This commit is contained in:
parent
562afa310e
commit
33622ee670
28
ios.py
28
ios.py
@ -302,6 +302,7 @@ class iOSCrossTable:
|
||||
|
||||
|
||||
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]
|
||||
@ -334,7 +335,7 @@ def setup_ios_cross_template(env: dict, opts: iOSOpts, target: str, host_arch: s
|
||||
env['_ios-%s_PATH' % target] = osxcross_bin
|
||||
|
||||
wrapper_path = create_osxcross_wrapper(opts, 'ios', target, opts.osx_toolchain_path)
|
||||
name_fmt = path_join(osxcross_bin, target + '-apple-' + opts.osx_triple_abi + '-%s')
|
||||
name_fmt = path_join(osxcross_bin, host_arch + '-apple-' + opts.osx_triple_abi + '-%s')
|
||||
name_fmt = "%s %s" % (wrapper_path, name_fmt)
|
||||
else:
|
||||
tools_path = path_join(opts.osx_toolchain_path, 'usr', 'bin')
|
||||
@ -348,13 +349,34 @@ def setup_ios_cross_template(env: dict, opts: iOSOpts, target: str, host_arch: s
|
||||
env['_ios-%s_RANLIB' % target] = name_fmt % 'ranlib'
|
||||
env['_ios-%s_STRIP' % target] = name_fmt % 'strip'
|
||||
|
||||
libclang = path_join(opts.ios_toolchain_path, 'usr', 'lib', 'libclang.dylib') if sys.platform == 'darwin' else os.environ['LIBCLANG_PATH']
|
||||
libclang = os.environ.get('LIBCLANG_PATH', '')
|
||||
if libclang and not os.path.isfile(libclang):
|
||||
raise RuntimeError('Specified libclang file not found: \'%s\'' % libclang)
|
||||
|
||||
env['_ios-%s_OFFSETS_DUMPER_ARGS' % target] = [
|
||||
if not libclang:
|
||||
libclang = try_find_libclang(toolchain_path=opts.ios_toolchain_path)
|
||||
|
||||
if not libclang:
|
||||
raise RuntimeError('Cannot find libclang shared library; specify a path manually with the \'LIBCLANG_PATH\' environment variable.')
|
||||
|
||||
offsets_dumper_args = [
|
||||
'--libclang=%s' % libclang,
|
||||
'--sysroot=%s' % ios_sysroot_path
|
||||
]
|
||||
|
||||
if sys.platform != 'darwin':
|
||||
# Needed in order to locate the iOS toolchain's clang to use with offsets-tool
|
||||
setup_ios_device_template(env, opts, device_target)
|
||||
ios_clang = env['_ios-%s_CC' % device_target]
|
||||
|
||||
# Extra CFLAGS needed in order to make offsets-tool work with OSXCross.
|
||||
offsets_dumper_args += ['--extra-cflag=' + cflag for cflag in [
|
||||
'-target', 'aarch64-apple-darwin',
|
||||
'-resource-dir', get_clang_resource_dir(ios_clang)
|
||||
]]
|
||||
|
||||
env['_ios-%s_OFFSETS_DUMPER_ARGS' % target] = offsets_dumper_args
|
||||
|
||||
AC_VARS = ['ac_cv_func_shm_open_working_with_mmap=no']
|
||||
|
||||
CFLAGS = ['-isysroot', osx_sysroot_path, '-mmacosx-version-min=10.9', '-Qunused-arguments']
|
||||
|
42
os_utils.py
42
os_utils.py
@ -72,8 +72,8 @@ ENV_PATH_SEP = ';' if os.name == 'nt' else ':'
|
||||
|
||||
def find_executable(name) -> str:
|
||||
is_windows = os.name == 'nt'
|
||||
windows_exts = ENV_PATH_SEP.split(os.environ['PATHEXT']) if is_windows else None
|
||||
path_dirs = ENV_PATH_SEP.split(os.environ['PATH'])
|
||||
windows_exts = os.environ['PATHEXT'].split(ENV_PATH_SEP) if is_windows else None
|
||||
path_dirs = os.environ['PATH'].split(ENV_PATH_SEP)
|
||||
|
||||
search_dirs = path_dirs + [os.getcwd()] # cwd is last in the list
|
||||
|
||||
@ -160,6 +160,44 @@ def chmod_plus_x(file):
|
||||
os.chmod(file, st.st_mode | ((stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) & ~umask))
|
||||
|
||||
|
||||
def get_clang_resource_dir(clang_command):
|
||||
import shlex
|
||||
from subprocess import check_output
|
||||
return check_output(shlex.split(clang_command) + ['-print-resource-dir']).strip().decode('utf-8')
|
||||
|
||||
|
||||
def try_find_libclang(toolchain_path: str = '', llvm_config=''):
|
||||
import sys
|
||||
from subprocess import check_output
|
||||
|
||||
hint_paths = []
|
||||
|
||||
if toolchain_path:
|
||||
libclang = os.path.join(toolchain_path, 'usr', 'lib', 'libclang.dylib')
|
||||
if os.path.isfile(libclang):
|
||||
print('Found libclang at: \'%s\'' % libclang)
|
||||
return libclang
|
||||
|
||||
if not llvm_config:
|
||||
llvm_config = find_executable('llvm-config')
|
||||
if not llvm_config:
|
||||
print('WARNING: llvm-config not found')
|
||||
return ''
|
||||
elif not os.path.isfile(llvm_config):
|
||||
raise RuntimeError('Specified llvm-config file not found: \'%s\'' % llvm_config)
|
||||
|
||||
llvm_libdir = check_output([llvm_config, '--libdir']).strip().decode('utf-8')
|
||||
if llvm_libdir:
|
||||
libsuffix = '.dylib' if sys.platform == 'darwin' else '.so'
|
||||
hints = ['libclang', 'clang']
|
||||
libclang = next((p for p in [os.path.join(llvm_libdir, h + libsuffix) for h in hints] if os.path.isfile(p)), '')
|
||||
if libclang:
|
||||
print('Found libclang at: \'%s\'' % libclang)
|
||||
return libclang
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
def create_osxcross_wrapper(opts: RuntimeOpts, product: str, target: str, toolchain_path : str):
|
||||
# OSXCROSS toolchain executables use rpath to locate the toolchain's shared libraries.
|
||||
# However, when moving the toolchain without care, the rpaths can be broken.
|
||||
|
@ -32,6 +32,11 @@ def main(raw_args):
|
||||
'mono_ios_asl_log_deprecated.diff'
|
||||
]
|
||||
|
||||
if os.path.isfile(os.path.join(mono_source_root, 'mono/tools/offsets-tool/offsets-tool.py')):
|
||||
patches += ['offsets-tool-extra-cflags_new.diff']
|
||||
else:
|
||||
patches += ['offsets-tool-extra-cflags_old.diff']
|
||||
|
||||
from subprocess import Popen
|
||||
from sys import exit
|
||||
for patch in patches:
|
||||
|
21
runtime.py
21
runtime.py
@ -101,21 +101,28 @@ def setup_runtime_cross_template(env: dict, opts: RuntimeOpts, product: str, tar
|
||||
|
||||
env['_cross-runtime_%s-%s_CONFIGURE_FLAGS' % (product, target)] = CONFIGURE_FLAGS
|
||||
|
||||
# Setup offsets-tool-py
|
||||
run_command('make', ['-C', '%s/tools/offsets-tool-py' % opts.mono_source_root, 'setup'], name='make offsets-tool-py')
|
||||
new_offsets_tool_path = '%s/mono/tools/offsets-tool/offsets-tool.py' % opts.mono_source_root
|
||||
old_offsets_tool_path = '%s/tools/offsets-tool-py/offsets-tool.py' % opts.mono_source_root
|
||||
|
||||
# Run offsets-tool in its virtual env
|
||||
old_offsets_tool = not os.path.isfile(new_offsets_tool_path)
|
||||
|
||||
virtualenv_vars = source('%s/tools/offsets-tool-py/offtool/bin/activate' % opts.mono_source_root)
|
||||
offsets_tool_env = None
|
||||
|
||||
offsets_tool_env = os.environ.copy()
|
||||
offsets_tool_env.update(virtualenv_vars)
|
||||
if old_offsets_tool:
|
||||
# Setup old offsets-tool-py if present (new location doesn't require setup)
|
||||
run_command('make', ['-C', '%s/tools/offsets-tool-py' % opts.mono_source_root, 'setup'], name='make offsets-tool-py')
|
||||
|
||||
# Run offsets-tool in its virtual env
|
||||
virtualenv_vars = source('%s/tools/offsets-tool-py/offtool/bin/activate' % opts.mono_source_root)
|
||||
|
||||
offsets_tool_env = os.environ.copy()
|
||||
offsets_tool_env.update(virtualenv_vars)
|
||||
|
||||
build_dir = '%s/%s-%s-%s' % (opts.configure_dir, product, target, opts.configuration)
|
||||
mkdir_p(build_dir)
|
||||
|
||||
run_command('python3', [
|
||||
'%s/tools/offsets-tool-py/offsets-tool.py' % opts.mono_source_root,
|
||||
old_offsets_tool_path if old_offsets_tool else new_offsets_tool_path,
|
||||
'--targetdir=%s/%s-%s-%s' % (opts.configure_dir, product, device_target, opts.configuration),
|
||||
'--abi=%s' % offsets_dumper_abi,
|
||||
'--monodir=%s' % opts.mono_source_root,
|
||||
|
Loading…
Reference in New Issue
Block a user