2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
import imp
|
|
|
|
import os
|
|
|
|
import sys
|
2018-02-27 17:54:16 +01:00
|
|
|
import subprocess
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
from distutils.version import LooseVersion
|
2018-10-03 19:01:57 +02:00
|
|
|
from SCons.Script import BoolVariable, Dir, Environment, File, SCons, Variables
|
2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
monoreg = imp.load_source('mono_reg_utils', 'modules/mono/mono_reg_utils.py')
|
|
|
|
|
|
|
|
|
2018-05-30 19:11:33 +02:00
|
|
|
def can_build(env, platform):
|
2018-06-26 21:03:42 +02:00
|
|
|
if platform in ['javascript']:
|
2017-10-02 23:24:00 +02:00
|
|
|
return False # Not yet supported
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def is_enabled():
|
|
|
|
# The module is disabled by default. Use module_mono_enabled=yes to enable it.
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
def get_doc_classes():
|
|
|
|
return [
|
|
|
|
'@C#',
|
|
|
|
'CSharpScript',
|
|
|
|
'GodotSharp',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def get_doc_path():
|
|
|
|
return 'doc_classes'
|
|
|
|
|
|
|
|
|
|
|
|
def find_file_in_dir(directory, files, prefix='', extension=''):
|
|
|
|
if not extension.startswith('.'):
|
|
|
|
extension = '.' + extension
|
|
|
|
for curfile in files:
|
|
|
|
if os.path.isfile(os.path.join(directory, prefix + curfile + extension)):
|
|
|
|
return curfile
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
2018-01-12 22:44:22 +01:00
|
|
|
def copy_file(src_dir, dst_dir, name):
|
2017-10-24 22:47:27 +02:00
|
|
|
from shutil import copyfile
|
|
|
|
|
|
|
|
src_path = os.path.join(src_dir, name)
|
|
|
|
dst_path = os.path.join(dst_dir, name)
|
|
|
|
|
|
|
|
if not os.path.isdir(dst_dir):
|
|
|
|
os.mkdir(dst_dir)
|
|
|
|
|
2018-01-12 22:44:22 +01:00
|
|
|
copyfile(src_path, dst_path)
|
2017-10-24 22:47:27 +02:00
|
|
|
|
|
|
|
|
2017-10-02 23:24:00 +02:00
|
|
|
def configure(env):
|
|
|
|
env.use_ptrcall = True
|
2018-06-26 21:03:42 +02:00
|
|
|
env.add_module_version_string('mono')
|
2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
envvars = Variables()
|
|
|
|
envvars.Add(BoolVariable('mono_static', 'Statically link mono', False))
|
2018-10-03 19:01:57 +02:00
|
|
|
envvars.Add(BoolVariable('copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False))
|
2017-10-02 23:24:00 +02:00
|
|
|
envvars.Update(env)
|
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
bits = env['bits']
|
|
|
|
|
2018-10-03 19:01:57 +02:00
|
|
|
tools_enabled = env['tools']
|
2017-10-02 23:24:00 +02:00
|
|
|
mono_static = env['mono_static']
|
2018-10-03 19:01:57 +02:00
|
|
|
copy_mono_root = env['copy_mono_root']
|
2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0']
|
|
|
|
|
|
|
|
if env['platform'] == 'windows':
|
2018-08-14 08:55:37 +02:00
|
|
|
mono_root = ''
|
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
if bits == '32':
|
2017-10-02 23:24:00 +02:00
|
|
|
if os.getenv('MONO32_PREFIX'):
|
|
|
|
mono_root = os.getenv('MONO32_PREFIX')
|
|
|
|
elif os.name == 'nt':
|
2017-10-24 22:47:27 +02:00
|
|
|
mono_root = monoreg.find_mono_root_dir(bits)
|
2017-10-02 23:24:00 +02:00
|
|
|
else:
|
|
|
|
if os.getenv('MONO64_PREFIX'):
|
|
|
|
mono_root = os.getenv('MONO64_PREFIX')
|
|
|
|
elif os.name == 'nt':
|
2017-10-24 22:47:27 +02:00
|
|
|
mono_root = monoreg.find_mono_root_dir(bits)
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
if not mono_root:
|
2017-10-02 23:24:00 +02:00
|
|
|
raise RuntimeError('Mono installation directory not found')
|
|
|
|
|
2018-08-23 23:17:08 +02:00
|
|
|
print('Found Mono root directory: ' + mono_root)
|
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
mono_version = mono_root_try_find_mono_version(mono_root)
|
|
|
|
configure_for_mono_version(env, mono_version)
|
|
|
|
|
2017-10-02 23:24:00 +02:00
|
|
|
mono_lib_path = os.path.join(mono_root, 'lib')
|
|
|
|
|
|
|
|
env.Append(LIBPATH=mono_lib_path)
|
|
|
|
env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0'))
|
|
|
|
|
2018-04-25 21:15:35 +02:00
|
|
|
if mono_static:
|
|
|
|
lib_suffix = Environment()['LIBSUFFIX']
|
2018-06-01 21:45:21 +02:00
|
|
|
|
|
|
|
if env.msvc:
|
|
|
|
mono_static_lib_name = 'libmono-static-sgen'
|
|
|
|
else:
|
|
|
|
mono_static_lib_name = 'libmonosgen-2.0'
|
2018-04-25 21:15:35 +02:00
|
|
|
|
|
|
|
if not os.path.isfile(os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)):
|
|
|
|
raise RuntimeError('Could not find static mono library in: ' + mono_lib_path)
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-05-02 15:19:02 +02:00
|
|
|
if env.msvc:
|
2018-04-25 21:15:35 +02:00
|
|
|
env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix)
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-25 21:15:35 +02:00
|
|
|
env.Append(LINKFLAGS='Mincore' + lib_suffix)
|
|
|
|
env.Append(LINKFLAGS='msvcrt' + lib_suffix)
|
|
|
|
env.Append(LINKFLAGS='LIBCMT' + lib_suffix)
|
|
|
|
env.Append(LINKFLAGS='Psapi' + lib_suffix)
|
|
|
|
else:
|
2018-06-01 21:45:21 +02:00
|
|
|
env.Append(LINKFLAGS=os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix))
|
|
|
|
|
|
|
|
env.Append(LIBS='psapi')
|
|
|
|
env.Append(LIBS='version')
|
2017-10-02 23:24:00 +02:00
|
|
|
else:
|
2018-04-25 21:15:35 +02:00
|
|
|
mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib')
|
|
|
|
|
|
|
|
if not mono_lib_name:
|
|
|
|
raise RuntimeError('Could not find mono library in: ' + mono_lib_path)
|
|
|
|
|
2018-05-02 15:19:02 +02:00
|
|
|
if env.msvc:
|
2018-04-25 21:15:35 +02:00
|
|
|
env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX'])
|
|
|
|
else:
|
|
|
|
env.Append(LIBS=mono_lib_name)
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-25 21:15:35 +02:00
|
|
|
mono_bin_path = os.path.join(mono_root, 'bin')
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-25 21:15:35 +02:00
|
|
|
mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll')
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-25 21:15:35 +02:00
|
|
|
if not mono_dll_name:
|
|
|
|
raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path)
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-25 21:15:35 +02:00
|
|
|
copy_file(mono_bin_path, 'bin', mono_dll_name + '.dll')
|
2017-10-02 23:24:00 +02:00
|
|
|
else:
|
2018-12-22 12:31:43 +01:00
|
|
|
is_apple = (sys.platform == 'darwin' or "osxcross" in env)
|
|
|
|
|
|
|
|
sharedlib_ext = '.dylib' if is_apple else '.so'
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
mono_root = ''
|
2018-01-12 22:44:22 +01:00
|
|
|
mono_lib_path = ''
|
2017-10-24 22:47:27 +02:00
|
|
|
|
|
|
|
if bits == '32':
|
2017-10-02 23:24:00 +02:00
|
|
|
if os.getenv('MONO32_PREFIX'):
|
|
|
|
mono_root = os.getenv('MONO32_PREFIX')
|
|
|
|
else:
|
|
|
|
if os.getenv('MONO64_PREFIX'):
|
|
|
|
mono_root = os.getenv('MONO64_PREFIX')
|
|
|
|
|
2018-12-22 12:31:43 +01:00
|
|
|
if not mono_root and is_apple:
|
2018-08-23 23:17:08 +02:00
|
|
|
# Try with some known directories under OSX
|
|
|
|
hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current', '/usr/local/var/homebrew/linked/mono']
|
|
|
|
for hint_dir in hint_dirs:
|
|
|
|
if os.path.isdir(hint_dir):
|
|
|
|
mono_root = hint_dir
|
|
|
|
break
|
|
|
|
|
2018-05-17 23:40:22 +02:00
|
|
|
# We can't use pkg-config to link mono statically,
|
|
|
|
# but we can still use it to find the mono root directory
|
|
|
|
if not mono_root and mono_static:
|
2018-06-26 21:03:42 +02:00
|
|
|
mono_root = pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext)
|
2018-05-17 23:40:22 +02:00
|
|
|
if not mono_root:
|
|
|
|
raise RuntimeError('Building with mono_static=yes, but failed to find the mono prefix with pkg-config. Specify one manually')
|
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
if mono_root:
|
2018-08-23 23:17:08 +02:00
|
|
|
print('Found Mono root directory: ' + mono_root)
|
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
mono_version = mono_root_try_find_mono_version(mono_root)
|
|
|
|
configure_for_mono_version(env, mono_version)
|
|
|
|
|
2017-10-02 23:24:00 +02:00
|
|
|
mono_lib_path = os.path.join(mono_root, 'lib')
|
|
|
|
|
|
|
|
env.Append(LIBPATH=mono_lib_path)
|
|
|
|
env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0'))
|
|
|
|
|
|
|
|
mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a')
|
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
if not mono_lib:
|
2017-10-02 23:24:00 +02:00
|
|
|
raise RuntimeError('Could not find mono library in: ' + mono_lib_path)
|
|
|
|
|
|
|
|
env.Append(CPPFLAGS=['-D_REENTRANT'])
|
|
|
|
|
|
|
|
if mono_static:
|
|
|
|
mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a')
|
|
|
|
|
2018-12-22 12:31:43 +01:00
|
|
|
if is_apple:
|
2017-10-02 23:24:00 +02:00
|
|
|
env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file])
|
|
|
|
else:
|
2018-10-03 19:01:57 +02:00
|
|
|
env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive'])
|
2017-10-02 23:24:00 +02:00
|
|
|
else:
|
|
|
|
env.Append(LIBS=[mono_lib])
|
|
|
|
|
2018-12-22 12:31:43 +01:00
|
|
|
if is_apple:
|
2017-10-20 18:40:41 +02:00
|
|
|
env.Append(LIBS=['iconv', 'pthread'])
|
2018-10-03 19:01:57 +02:00
|
|
|
else:
|
2017-10-20 18:40:41 +02:00
|
|
|
env.Append(LIBS=['m', 'rt', 'dl', 'pthread'])
|
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
if not mono_static:
|
|
|
|
mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext)
|
|
|
|
|
|
|
|
if not mono_so_name:
|
|
|
|
raise RuntimeError('Could not find mono shared library in: ' + mono_lib_path)
|
|
|
|
|
2018-01-12 22:44:22 +01:00
|
|
|
copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext)
|
2017-10-02 23:24:00 +02:00
|
|
|
else:
|
2018-05-17 23:40:22 +02:00
|
|
|
assert not mono_static
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-08-23 23:17:08 +02:00
|
|
|
# TODO: Add option to force using pkg-config
|
|
|
|
print('Mono root directory not found. Using pkg-config instead')
|
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
mono_version = pkgconfig_try_find_mono_version()
|
|
|
|
configure_for_mono_version(env, mono_version)
|
|
|
|
|
2017-10-14 23:54:23 +02:00
|
|
|
env.ParseConfig('pkg-config monosgen-2 --cflags --libs')
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2017-10-24 22:47:27 +02:00
|
|
|
mono_lib_path = ''
|
|
|
|
mono_so_name = ''
|
|
|
|
|
|
|
|
tmpenv = Environment()
|
2018-02-02 19:17:53 +01:00
|
|
|
tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
|
2017-10-24 22:47:27 +02:00
|
|
|
tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L')
|
|
|
|
|
|
|
|
for hint_dir in tmpenv['LIBPATH']:
|
|
|
|
name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext)
|
|
|
|
if name_found:
|
|
|
|
mono_lib_path = hint_dir
|
|
|
|
mono_so_name = name_found
|
|
|
|
break
|
|
|
|
|
|
|
|
if not mono_so_name:
|
|
|
|
raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH']))
|
|
|
|
|
2018-01-12 22:44:22 +01:00
|
|
|
copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext)
|
2017-10-24 22:47:27 +02:00
|
|
|
|
2017-10-02 23:24:00 +02:00
|
|
|
env.Append(LINKFLAGS='-rdynamic')
|
|
|
|
|
2018-10-03 19:01:57 +02:00
|
|
|
if not tools_enabled:
|
|
|
|
if not mono_root:
|
|
|
|
mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
|
|
|
|
|
|
|
|
make_template_dir(env, mono_root)
|
|
|
|
|
|
|
|
if copy_mono_root:
|
|
|
|
if not mono_root:
|
|
|
|
mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
|
|
|
|
|
|
|
|
if tools_enabled:
|
|
|
|
copy_mono_root_files(env, mono_root)
|
|
|
|
else:
|
|
|
|
print("Ignoring option: 'copy_mono_root'. Only available for builds with 'tools' enabled.")
|
|
|
|
|
|
|
|
|
|
|
|
def make_template_dir(env, mono_root):
|
|
|
|
from shutil import rmtree
|
|
|
|
|
|
|
|
platform = env['platform']
|
|
|
|
target = env['target']
|
|
|
|
|
|
|
|
template_dir_name = ''
|
|
|
|
|
2018-11-08 16:47:15 +01:00
|
|
|
if platform in ['windows', 'osx', 'x11']:
|
2018-10-03 19:01:57 +02:00
|
|
|
template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target)
|
|
|
|
else:
|
|
|
|
assert False
|
|
|
|
|
|
|
|
output_dir = Dir('#bin').abspath
|
|
|
|
template_dir = os.path.join(output_dir, template_dir_name)
|
|
|
|
|
|
|
|
template_mono_root_dir = os.path.join(template_dir, 'Mono')
|
|
|
|
|
|
|
|
if os.path.isdir(template_mono_root_dir):
|
|
|
|
rmtree(template_mono_root_dir) # Clean first
|
|
|
|
|
|
|
|
# Copy etc/mono/
|
|
|
|
|
|
|
|
template_mono_config_dir = os.path.join(template_mono_root_dir, 'etc', 'mono')
|
|
|
|
copy_mono_etc_dir(mono_root, template_mono_config_dir, env['platform'])
|
|
|
|
|
|
|
|
# Copy the required shared libraries
|
|
|
|
|
|
|
|
copy_mono_shared_libs(mono_root, template_mono_root_dir, env['platform'])
|
|
|
|
|
|
|
|
|
|
|
|
def copy_mono_root_files(env, mono_root):
|
|
|
|
from glob import glob
|
|
|
|
from shutil import copy
|
|
|
|
from shutil import rmtree
|
|
|
|
|
|
|
|
if not mono_root:
|
|
|
|
raise RuntimeError('Mono installation directory not found')
|
|
|
|
|
|
|
|
output_dir = Dir('#bin').abspath
|
|
|
|
editor_mono_root_dir = os.path.join(output_dir, 'GodotSharp', 'Mono')
|
|
|
|
|
|
|
|
if os.path.isdir(editor_mono_root_dir):
|
|
|
|
rmtree(editor_mono_root_dir) # Clean first
|
|
|
|
|
|
|
|
# Copy etc/mono/
|
|
|
|
|
|
|
|
editor_mono_config_dir = os.path.join(editor_mono_root_dir, 'etc', 'mono')
|
|
|
|
copy_mono_etc_dir(mono_root, editor_mono_config_dir, env['platform'])
|
|
|
|
|
|
|
|
# Copy the required shared libraries
|
|
|
|
|
|
|
|
copy_mono_shared_libs(mono_root, editor_mono_root_dir, env['platform'])
|
|
|
|
|
|
|
|
# Copy framework assemblies
|
|
|
|
|
|
|
|
mono_framework_dir = os.path.join(mono_root, 'lib', 'mono', '4.5')
|
|
|
|
mono_framework_facades_dir = os.path.join(mono_framework_dir, 'Facades')
|
|
|
|
|
|
|
|
editor_mono_framework_dir = os.path.join(editor_mono_root_dir, 'lib', 'mono', '4.5')
|
|
|
|
editor_mono_framework_facades_dir = os.path.join(editor_mono_framework_dir, 'Facades')
|
|
|
|
|
|
|
|
if not os.path.isdir(editor_mono_framework_dir):
|
|
|
|
os.makedirs(editor_mono_framework_dir)
|
|
|
|
if not os.path.isdir(editor_mono_framework_facades_dir):
|
|
|
|
os.makedirs(editor_mono_framework_facades_dir)
|
|
|
|
|
|
|
|
for assembly in glob(os.path.join(mono_framework_dir, '*.dll')):
|
|
|
|
copy(assembly, editor_mono_framework_dir)
|
|
|
|
for assembly in glob(os.path.join(mono_framework_facades_dir, '*.dll')):
|
|
|
|
copy(assembly, editor_mono_framework_facades_dir)
|
|
|
|
|
|
|
|
|
|
|
|
def copy_mono_etc_dir(mono_root, target_mono_config_dir, platform):
|
|
|
|
from distutils.dir_util import copy_tree
|
|
|
|
from glob import glob
|
|
|
|
from shutil import copy
|
|
|
|
|
|
|
|
if not os.path.isdir(target_mono_config_dir):
|
|
|
|
os.makedirs(target_mono_config_dir)
|
|
|
|
|
|
|
|
mono_etc_dir = os.path.join(mono_root, 'etc', 'mono')
|
|
|
|
if not os.path.isdir(mono_etc_dir):
|
|
|
|
mono_etc_dir = ''
|
|
|
|
etc_hint_dirs = []
|
|
|
|
if platform != 'windows':
|
|
|
|
etc_hint_dirs += ['/etc/mono', '/usr/local/etc/mono']
|
|
|
|
if 'MONO_CFG_DIR' in os.environ:
|
|
|
|
etc_hint_dirs += [os.path.join(os.environ['MONO_CFG_DIR'], 'mono')]
|
|
|
|
for etc_hint_dir in etc_hint_dirs:
|
|
|
|
if os.path.isdir(etc_hint_dir):
|
|
|
|
mono_etc_dir = etc_hint_dir
|
|
|
|
break
|
|
|
|
if not mono_etc_dir:
|
|
|
|
raise RuntimeError('Mono installation etc directory not found')
|
|
|
|
|
|
|
|
copy_tree(os.path.join(mono_etc_dir, '2.0'), os.path.join(target_mono_config_dir, '2.0'))
|
|
|
|
copy_tree(os.path.join(mono_etc_dir, '4.0'), os.path.join(target_mono_config_dir, '4.0'))
|
|
|
|
copy_tree(os.path.join(mono_etc_dir, '4.5'), os.path.join(target_mono_config_dir, '4.5'))
|
|
|
|
copy_tree(os.path.join(mono_etc_dir, 'mconfig'), os.path.join(target_mono_config_dir, 'mconfig'))
|
|
|
|
|
|
|
|
for file in glob(os.path.join(mono_etc_dir, '*')):
|
|
|
|
if os.path.isfile(file):
|
|
|
|
copy(file, target_mono_config_dir)
|
|
|
|
|
|
|
|
|
|
|
|
def copy_mono_shared_libs(mono_root, target_mono_root_dir, platform):
|
|
|
|
from shutil import copy
|
|
|
|
|
|
|
|
if platform == 'windows':
|
|
|
|
target_mono_bin_dir = os.path.join(target_mono_root_dir, 'bin')
|
|
|
|
|
|
|
|
if not os.path.isdir(target_mono_bin_dir):
|
|
|
|
os.makedirs(target_mono_bin_dir)
|
|
|
|
|
|
|
|
copy(os.path.join(mono_root, 'bin', 'MonoPosixHelper.dll'), os.path.join(target_mono_bin_dir, 'MonoPosixHelper.dll'))
|
|
|
|
else:
|
|
|
|
target_mono_lib_dir = os.path.join(target_mono_root_dir, 'lib')
|
|
|
|
|
|
|
|
if not os.path.isdir(target_mono_lib_dir):
|
|
|
|
os.makedirs(target_mono_lib_dir)
|
|
|
|
|
|
|
|
if platform == 'osx':
|
|
|
|
copy(os.path.join(mono_root, 'lib', 'libMonoPosixHelper.dylib'), os.path.join(target_mono_lib_dir, 'libMonoPosixHelper.dylib'))
|
|
|
|
elif platform == 'x11':
|
|
|
|
copy(os.path.join(mono_root, 'lib', 'libmono-btls-shared.so'), os.path.join(target_mono_lib_dir, 'libmono-btls-shared.so'))
|
|
|
|
copy(os.path.join(mono_root, 'lib', 'libMonoPosixHelper.so'), os.path.join(target_mono_lib_dir, 'libMonoPosixHelper.so'))
|
|
|
|
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
def configure_for_mono_version(env, mono_version):
|
|
|
|
if mono_version is None:
|
|
|
|
raise RuntimeError('Mono JIT compiler version not found')
|
2018-08-23 23:17:08 +02:00
|
|
|
print('Found Mono JIT compiler version: ' + str(mono_version))
|
2018-10-03 19:01:57 +02:00
|
|
|
if mono_version >= LooseVersion('5.12.0'):
|
2018-06-26 21:03:42 +02:00
|
|
|
env.Append(CPPFLAGS=['-DHAS_PENDING_EXCEPTIONS'])
|
2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
def pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext):
|
|
|
|
tmpenv = Environment()
|
|
|
|
tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
|
|
|
|
tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L')
|
|
|
|
for hint_dir in tmpenv['LIBPATH']:
|
|
|
|
name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext)
|
|
|
|
if name_found and os.path.isdir(os.path.join(hint_dir, '..', 'include', 'mono-2.0')):
|
|
|
|
return os.path.join(hint_dir, '..')
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
def pkgconfig_try_find_mono_version():
|
2018-08-20 06:42:07 +02:00
|
|
|
from compat import decode_utf8
|
|
|
|
|
2018-06-26 21:03:42 +02:00
|
|
|
lines = subprocess.check_output(['pkg-config', 'monosgen-2', '--modversion']).splitlines()
|
|
|
|
greater_version = None
|
|
|
|
for line in lines:
|
|
|
|
try:
|
2018-08-20 06:42:07 +02:00
|
|
|
version = LooseVersion(decode_utf8(line))
|
2018-06-26 21:03:42 +02:00
|
|
|
if greater_version is None or version > greater_version:
|
|
|
|
greater_version = version
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
return greater_version
|
|
|
|
|
|
|
|
|
|
|
|
def mono_root_try_find_mono_version(mono_root):
|
2018-07-04 16:05:28 +02:00
|
|
|
from compat import decode_utf8
|
|
|
|
|
2018-09-16 15:20:44 +02:00
|
|
|
mono_bin = os.path.join(mono_root, 'bin')
|
|
|
|
if os.path.isfile(os.path.join(mono_bin, 'mono')):
|
|
|
|
mono_binary = os.path.join(mono_bin, 'mono')
|
|
|
|
elif os.path.isfile(os.path.join(mono_bin, 'mono.exe')):
|
|
|
|
mono_binary = os.path.join(mono_bin, 'mono.exe')
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
output = subprocess.check_output([mono_binary, '--version'])
|
2018-07-04 16:05:28 +02:00
|
|
|
first_line = decode_utf8(output.splitlines()[0])
|
2018-06-26 21:03:42 +02:00
|
|
|
try:
|
|
|
|
return LooseVersion(first_line.split()[len('Mono JIT compiler version'.split())])
|
|
|
|
except (ValueError, IndexError):
|
|
|
|
return None
|