diff options
Diffstat (limited to 'modules/mono/build_scripts')
-rw-r--r-- | modules/mono/build_scripts/api_solution_build.py | 17 | ||||
-rw-r--r-- | modules/mono/build_scripts/gen_cs_glue_version.py | 20 | ||||
-rw-r--r-- | modules/mono/build_scripts/godot_tools_build.py | 97 | ||||
-rw-r--r-- | modules/mono/build_scripts/make_cs_compressed_header.py | 62 | ||||
-rw-r--r-- | modules/mono/build_scripts/mono_android_config.xml | 28 | ||||
-rw-r--r-- | modules/mono/build_scripts/mono_configure.py | 142 | ||||
-rw-r--r-- | modules/mono/build_scripts/patches/fix-mono-android-tkill.diff | 70 |
7 files changed, 172 insertions, 264 deletions
diff --git a/modules/mono/build_scripts/api_solution_build.py b/modules/mono/build_scripts/api_solution_build.py index 1fe00a3028..639197c285 100644 --- a/modules/mono/build_scripts/api_solution_build.py +++ b/modules/mono/build_scripts/api_solution_build.py @@ -10,10 +10,7 @@ def build_api_solution(source, target, env): module_dir = env['module_dir'] - solution_path = os.path.join(module_dir, 'glue/Managed/Generated/GodotSharp.sln') - - if not os.path.isfile(solution_path): - raise RuntimeError("Godot API solution not found. Did you forget to run '--generate-mono-glue'?") + solution_path = os.path.join(module_dir, 'glue/GodotSharp/GodotSharp.sln') build_config = env['solution_build_config'] @@ -55,12 +52,22 @@ def build(env_mono): 'GodotSharpEditor.dll', 'GodotSharpEditor.pdb', 'GodotSharpEditor.xml' ] + depend_cmd = [] + for build_config in ['Debug', 'Release']: output_dir = Dir('#bin').abspath editor_api_dir = os.path.join(output_dir, 'GodotSharp', 'Api', build_config) targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames] - cmd = env_mono.CommandNoCache(targets, [], build_api_solution, + cmd = env_mono.CommandNoCache(targets, depend_cmd, build_api_solution, module_dir=os.getcwd(), solution_build_config=build_config) env_mono.AlwaysBuild(cmd) + + # Make the Release build of the API solution depend on the Debug build. + # We do this in order to prevent SCons from building them in parallel, + # which can freak out MSBuild. In many cases, one of the builds would + # hang indefinitely requiring a key to be pressed for it to continue. + depend_cmd = cmd + + return depend_cmd diff --git a/modules/mono/build_scripts/gen_cs_glue_version.py b/modules/mono/build_scripts/gen_cs_glue_version.py new file mode 100644 index 0000000000..5d1056c2fc --- /dev/null +++ b/modules/mono/build_scripts/gen_cs_glue_version.py @@ -0,0 +1,20 @@ + +def generate_header(solution_dir, version_header_dst): + import os + latest_mtime = 0 + for root, dirs, files in os.walk(solution_dir, topdown=True): + dirs[:] = [d for d in dirs if d not in ['Generated']] # Ignored generated files + files = [f for f in files if f.endswith('.cs')] + for file in files: + filepath = os.path.join(root, file) + mtime = os.path.getmtime(filepath) + latest_mtime = mtime if mtime > latest_mtime else latest_mtime + + glue_version = int(latest_mtime) # The latest modified time will do for now + + with open(version_header_dst, 'w') as version_header: + version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') + version_header.write('#ifndef CS_GLUE_VERSION_H\n') + version_header.write('#define CS_GLUE_VERSION_H\n\n') + version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n') + version_header.write('\n#endif // CS_GLUE_VERSION_H\n') diff --git a/modules/mono/build_scripts/godot_tools_build.py b/modules/mono/build_scripts/godot_tools_build.py index 35daa6d307..99341c631e 100644 --- a/modules/mono/build_scripts/godot_tools_build.py +++ b/modules/mono/build_scripts/godot_tools_build.py @@ -13,106 +13,27 @@ def build_godot_tools(source, target, env): solution_path = os.path.join(module_dir, 'editor/GodotTools/GodotTools.sln') build_config = 'Debug' if env['target'] == 'debug' else 'Release' - from . solution_builder import build_solution, nuget_restore - nuget_restore(env, solution_path) - build_solution(env, solution_path, build_config) - - # Copy targets - - solution_dir = os.path.abspath(os.path.join(solution_path, os.pardir)) - - src_dir = os.path.join(solution_dir, 'GodotTools', 'bin', build_config) - dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir)) - - if not os.path.isdir(dst_dir): - assert not os.path.isfile(dst_dir) - os.makedirs(dst_dir) - - def copy_target(target_path): - from shutil import copy - filename = os.path.basename(target_path) - copy(os.path.join(src_dir, filename), target_path) - - for scons_target in target: - copy_target(str(scons_target)) - - -def build_godot_tools_project_editor(source, target, env): - # source and target elements are of type SCons.Node.FS.File, hence why we convert them to str - - module_dir = env['module_dir'] - - project_name = 'GodotTools.ProjectEditor' - - csproj_dir = os.path.join(module_dir, 'editor/GodotTools', project_name) - csproj_path = os.path.join(csproj_dir, project_name + '.csproj') - build_config = 'Debug' if env['target'] == 'debug' else 'Release' + # Custom build target to make sure output is always copied to the data dir. + extra_build_args = ['/Target:Build;GodotTools:BuildAlwaysCopyToDataDir'] from . solution_builder import build_solution, nuget_restore - - # Make sure to restore NuGet packages in the project directory for the project to find it - nuget_restore(env, os.path.join(csproj_dir, 'packages.config'), '-PackagesDirectory', - os.path.join(csproj_dir, 'packages')) - - build_solution(env, csproj_path, build_config) - - # Copy targets - - src_dir = os.path.join(csproj_dir, 'bin', build_config) - dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir)) - - if not os.path.isdir(dst_dir): - assert not os.path.isfile(dst_dir) - os.makedirs(dst_dir) - - def copy_target(target_path): - from shutil import copy - filename = os.path.basename(target_path) - copy(os.path.join(src_dir, filename), target_path) - - for scons_target in target: - copy_target(str(scons_target)) - - -def build(env_mono): - assert env_mono['tools'] - - output_dir = Dir('#bin').abspath - editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools') - editor_api_dir = os.path.join(output_dir, 'GodotSharp', 'Api', 'Debug') - - source_filenames = ['GodotSharp.dll', 'GodotSharpEditor.dll'] - sources = [os.path.join(editor_api_dir, filename) for filename in source_filenames] - - target_filenames = [ - 'GodotTools.dll', 'GodotTools.IdeConnection.dll', 'GodotTools.BuildLogger.dll', - 'GodotTools.ProjectEditor.dll', 'DotNet.Glob.dll', 'GodotTools.Core.dll' - ] - - if env_mono['target'] == 'debug': - target_filenames += [ - 'GodotTools.pdb', 'GodotTools.IdeConnection.pdb', 'GodotTools.BuildLogger.pdb', - 'GodotTools.ProjectEditor.pdb', 'GodotTools.Core.pdb' - ] - - targets = [os.path.join(editor_tools_dir, filename) for filename in target_filenames] - - cmd = env_mono.CommandNoCache(targets, sources, build_godot_tools, module_dir=os.getcwd()) - env_mono.AlwaysBuild(cmd) + nuget_restore(env, solution_path) + build_solution(env, solution_path, build_config, extra_build_args) + # No need to copy targets. The GodotTools csproj takes care of copying them. -def build_project_editor_only(env_mono): +def build(env_mono, api_sln_cmd): assert env_mono['tools'] output_dir = Dir('#bin').abspath editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools') - target_filenames = ['GodotTools.ProjectEditor.dll', 'DotNet.Glob.dll', 'GodotTools.Core.dll'] + target_filenames = ['GodotTools.dll'] if env_mono['target'] == 'debug': - target_filenames += ['GodotTools.ProjectEditor.pdb', 'GodotTools.Core.pdb'] + target_filenames += ['GodotTools.pdb'] targets = [os.path.join(editor_tools_dir, filename) for filename in target_filenames] - cmd = env_mono.CommandNoCache(targets, [], build_godot_tools_project_editor, module_dir=os.getcwd()) + cmd = env_mono.CommandNoCache(targets, api_sln_cmd, build_godot_tools, module_dir=os.getcwd()) env_mono.AlwaysBuild(cmd) diff --git a/modules/mono/build_scripts/make_cs_compressed_header.py b/modules/mono/build_scripts/make_cs_compressed_header.py deleted file mode 100644 index ed49db5bb2..0000000000 --- a/modules/mono/build_scripts/make_cs_compressed_header.py +++ /dev/null @@ -1,62 +0,0 @@ - -def generate_header(src, dst, version_dst): - from compat import byte_to_str - - with open(dst, 'w') as header: - header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') - header.write('#ifndef CS_COMPRESSED_H\n') - header.write('#define CS_COMPRESSED_H\n\n') - header.write('#ifdef TOOLS_ENABLED\n\n') - header.write('#include "core/map.h"\n') - header.write('#include "core/ustring.h"\n') - inserted_files = '' - import os - latest_mtime = 0 - cs_file_count = 0 - for root, _, files in os.walk(src): - files = [f for f in files if f.endswith('.cs')] - for file in files: - cs_file_count += 1 - filepath = os.path.join(root, file) - filepath_src_rel = os.path.relpath(filepath, src) - mtime = os.path.getmtime(filepath) - latest_mtime = mtime if mtime > latest_mtime else latest_mtime - with open(filepath, 'rb') as f: - buf = f.read() - decompr_size = len(buf) - import zlib - buf = zlib.compress(buf) - compr_size = len(buf) - name = str(cs_file_count) - header.write('\n') - header.write('// ' + filepath_src_rel + '\n') - header.write('static const int _cs_' + name + '_compressed_size = ' + str(compr_size) + ';\n') - header.write('static const int _cs_' + name + '_uncompressed_size = ' + str(decompr_size) + ';\n') - header.write('static const unsigned char _cs_' + name + '_compressed[] = { ') - for i, buf_idx in enumerate(range(compr_size)): - if i > 0: - header.write(', ') - header.write(byte_to_str(buf[buf_idx])) - header.write(' };\n') - inserted_files += '\tr_files.insert("' + filepath_src_rel.replace('\\', '\\\\') + '", ' \ - 'GodotCsCompressedFile(_cs_' + name + '_compressed_size, ' \ - '_cs_' + name + '_uncompressed_size, ' \ - '_cs_' + name + '_compressed));\n' - header.write('\nstruct GodotCsCompressedFile\n' '{\n' - '\tint compressed_size;\n' '\tint uncompressed_size;\n' '\tconst unsigned char* data;\n' - '\n\tGodotCsCompressedFile(int p_comp_size, int p_uncomp_size, const unsigned char* p_data)\n' - '\t{\n' '\t\tcompressed_size = p_comp_size;\n' '\t\tuncompressed_size = p_uncomp_size;\n' - '\t\tdata = p_data;\n' '\t}\n' '\n\tGodotCsCompressedFile() {}\n' '};\n' - '\nvoid get_compressed_files(Map<String, GodotCsCompressedFile>& r_files)\n' '{\n' + inserted_files + '}\n' - ) - header.write('\n#endif // TOOLS_ENABLED\n') - header.write('\n#endif // CS_COMPRESSED_H\n') - - glue_version = int(latest_mtime) # The latest modified time will do for now - - with open(version_dst, 'w') as version_header: - version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') - version_header.write('#ifndef CS_GLUE_VERSION_H\n') - version_header.write('#define CS_GLUE_VERSION_H\n\n') - version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n') - version_header.write('\n#endif // CS_GLUE_VERSION_H\n') diff --git a/modules/mono/build_scripts/mono_android_config.xml b/modules/mono/build_scripts/mono_android_config.xml new file mode 100644 index 0000000000..e79670afd2 --- /dev/null +++ b/modules/mono/build_scripts/mono_android_config.xml @@ -0,0 +1,28 @@ +<configuration> + <dllmap wordsize="32" dll="i:cygwin1.dll" target="/system/lib/libc.so" /> + <dllmap wordsize="64" dll="i:cygwin1.dll" target="/system/lib64/libc.so" /> + <dllmap wordsize="32" dll="libc" target="/system/lib/libc.so" /> + <dllmap wordsize="64" dll="libc" target="/system/lib64/libc.so" /> + <dllmap wordsize="32" dll="intl" target="/system/lib/libc.so" /> + <dllmap wordsize="64" dll="intl" target="/system/lib64/libc.so" /> + <dllmap wordsize="32" dll="libintl" target="/system/lib/libc.so" /> + <dllmap wordsize="64" dll="libintl" target="/system/lib64/libc.so" /> + <dllmap dll="MonoPosixHelper" target="libMonoPosixHelper.so" /> + <dllmap dll="System.Native" target="libmono-native.so" /> + <dllmap wordsize="32" dll="i:msvcrt" target="/system/lib/libc.so" /> + <dllmap wordsize="64" dll="i:msvcrt" target="/system/lib64/libc.so" /> + <dllmap wordsize="32" dll="i:msvcrt.dll" target="/system/lib/libc.so" /> + <dllmap wordsize="64" dll="i:msvcrt.dll" target="/system/lib64/libc.so" /> + <dllmap wordsize="32" dll="sqlite" target="/system/lib/libsqlite.so" /> + <dllmap wordsize="64" dll="sqlite" target="/system/lib64/libsqlite.so" /> + <dllmap wordsize="32" dll="sqlite3" target="/system/lib/libsqlite.so" /> + <dllmap wordsize="64" dll="sqlite3" target="/system/lib64/libsqlite.so" /> + <dllmap wordsize="32" dll="liblog" target="/system/lib/liblog.so" /> + <dllmap wordsize="64" dll="liblog" target="/system/lib64/liblog.so" /> + <dllmap dll="i:kernel32.dll"> + <dllentry dll="__Internal" name="CopyMemory" target="mono_win32_compat_CopyMemory"/> + <dllentry dll="__Internal" name="FillMemory" target="mono_win32_compat_FillMemory"/> + <dllentry dll="__Internal" name="MoveMemory" target="mono_win32_compat_MoveMemory"/> + <dllentry dll="__Internal" name="ZeroMemory" target="mono_win32_compat_ZeroMemory"/> + </dllmap> +</configuration> diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index 4c1ebd8d74..033c467da9 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -44,9 +44,33 @@ def copy_file(src_dir, dst_dir, name): copy(src_path, dst_dir) +def is_desktop(platform): + return platform in ['windows', 'osx', 'x11', 'server', 'uwp', 'haiku'] + + +def is_unix_like(platform): + return platform in ['osx', 'x11', 'server', 'android', 'haiku'] + + +def module_supports_tools_on(platform): + return platform not in ['android', 'javascript'] + + +def find_wasm_src_dir(mono_root): + hint_dirs = [ + os.path.join(mono_root, 'src'), + os.path.join(mono_root, '../src'), + ] + for hint_dir in hint_dirs: + if os.path.isfile(os.path.join(hint_dir, 'driver.c')): + return hint_dir + return '' + + def configure(env, env_mono): bits = env['bits'] is_android = env['platform'] == 'android' + is_javascript = env['platform'] == 'javascript' tools_enabled = env['tools'] mono_static = env['mono_static'] @@ -63,17 +87,21 @@ def configure(env, env_mono): env_mono.Append(CPPDEFINES=['NO_PENDING_EXCEPTIONS']) if is_android and not env['android_arch'] in android_arch_dirs: - raise RuntimeError('This module does not support for the specified \'android_arch\': ' + env['android_arch']) + raise RuntimeError('This module does not support the specified \'android_arch\': ' + env['android_arch']) - if is_android and tools_enabled: - # TODO: Implement this. We have to add the data directory to the apk, concretely the Api and Tools folders. - raise RuntimeError('This module does not currently support building for android with tools enabled') + if tools_enabled and not module_supports_tools_on(env['platform']): + # TODO: + # Android: We have to add the data directory to the apk, concretely the Api and Tools folders. + raise RuntimeError('This module does not currently support building for this platform with tools enabled') if is_android and mono_static: - # When static linking and doing something that requires libmono-native, we get a dlopen error as libmono-native seems to depend on libmonosgen-2.0 - raise RuntimeError('Linking Mono statically is not currently supported on Android') + # Android: When static linking and doing something that requires libmono-native, we get a dlopen error as libmono-native seems to depend on libmonosgen-2.0 + raise RuntimeError('Statically linking Mono is not currently supported on this platform') - if (os.getenv('MONO32_PREFIX') or os.getenv('MONO64_PREFIX')) and not mono_prefix: + if is_javascript: + mono_static = True + + if not mono_prefix and (os.getenv('MONO32_PREFIX') or os.getenv('MONO64_PREFIX')): print("WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead") if env['platform'] == 'windows': @@ -92,9 +120,9 @@ def configure(env, env_mono): env.Append(LIBPATH=mono_lib_path) env_mono.Prepend(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) - if mono_static: - lib_suffix = Environment()['LIBSUFFIX'] + lib_suffix = Environment()['LIBSUFFIX'] + if mono_static: if env.msvc: mono_static_lib_name = 'libmono-static-sgen' else: @@ -116,13 +144,13 @@ def configure(env, env_mono): env.Append(LIBS=['psapi']) env.Append(LIBS=['version']) else: - mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib') + mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension=lib_suffix) if not mono_lib_name: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) if env.msvc: - env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX']) + env.Append(LINKFLAGS=mono_lib_name + lib_suffix) else: env.Append(LIBS=[mono_lib_name]) @@ -143,7 +171,7 @@ def configure(env, env_mono): mono_lib_path = '' mono_so_name = '' - if not mono_root and is_android: + if not mono_root and (is_android or is_javascript): raise RuntimeError("Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter") if not mono_root and is_apple: @@ -167,7 +195,7 @@ def configure(env, env_mono): mono_lib_path = os.path.join(mono_root, 'lib') - env.Append(LIBPATH=mono_lib_path) + env.Append(LIBPATH=[mono_lib_path]) env_mono.Prepend(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') @@ -178,12 +206,37 @@ def configure(env, env_mono): env_mono.Append(CPPDEFINES=['_REENTRANT']) if mono_static: + env.Append(LINKFLAGS=['-rdynamic']) + mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') if is_apple: env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) else: + assert is_desktop(env['platform']) or is_android or is_javascript env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive']) + + if is_javascript: + env.Append(LIBS=['mono-icall-table', 'mono-native', 'mono-ilgen', 'mono-ee-interp']) + + wasm_src_dir = os.path.join(mono_root, 'src') + if not os.path.isdir(wasm_src_dir): + raise RuntimeError('Could not find mono wasm src directory') + + # Ideally this should be defined only for 'driver.c', but I can't fight scons for another 2 hours + env_mono.Append(CPPDEFINES=['CORE_BINDINGS']) + + env_mono.add_source_files(env.modules_sources, [ + os.path.join(wasm_src_dir, 'driver.c'), + os.path.join(wasm_src_dir, 'zlib-helper.c'), + os.path.join(wasm_src_dir, 'corebindings.c') + ]) + + env.Append(LINKFLAGS=[ + '--js-library', os.path.join(wasm_src_dir, 'library_mono.js'), + '--js-library', os.path.join(wasm_src_dir, 'binding_support.js'), + '--js-library', os.path.join(wasm_src_dir, 'dotnet_support.js') + ]) else: env.Append(LIBS=[mono_lib]) @@ -191,6 +244,8 @@ def configure(env, env_mono): env.Append(LIBS=['iconv', 'pthread']) elif is_android: pass # Nothing + elif is_javascript: + env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) else: env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) @@ -228,21 +283,23 @@ def configure(env, env_mono): libs_output_dir = get_android_out_dir(env) if is_android else '#bin' copy_file(mono_lib_path, libs_output_dir, 'lib' + mono_so_name + sharedlib_ext) - env.Append(LINKFLAGS='-rdynamic') - - if not tools_enabled and not is_android: - if not mono_root: - mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() + if not tools_enabled: + if is_desktop(env['platform']): + if not mono_root: + mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() - make_template_dir(env, mono_root) - elif not tools_enabled and is_android: - # Compress Android Mono Config - from . import make_android_mono_config - config_file_path = os.path.join(mono_root, 'etc', 'mono', 'config') - make_android_mono_config.generate_compressed_config(config_file_path, 'mono_gd/') + make_template_dir(env, mono_root) + elif is_android: + # Compress Android Mono Config + from . import make_android_mono_config + module_dir = os.getcwd() + config_file_path = os.path.join(module_dir, 'build_scripts', 'mono_android_config.xml') + make_android_mono_config.generate_compressed_config(config_file_path, 'mono_gd/') - # Copy the required shared libraries - copy_mono_shared_libs(env, mono_root, None) + # Copy the required shared libraries + copy_mono_shared_libs(env, mono_root, None) + elif is_javascript: + pass # No data directory for this platform if copy_mono_root: if not mono_root: @@ -251,7 +308,7 @@ def configure(env, env_mono): if tools_enabled: copy_mono_root_files(env, mono_root) else: - print("Ignoring option: 'copy_mono_root'. Only available for builds with 'tools' enabled.") + print("Ignoring option: 'copy_mono_root'; only available for builds with 'tools' enabled.") def make_template_dir(env, mono_root): @@ -262,10 +319,9 @@ def make_template_dir(env, mono_root): template_dir_name = '' - if platform in ['windows', 'osx', 'x11', 'android']: - template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target) - else: - assert False + assert is_desktop(platform) + + template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target) output_dir = Dir('#bin').abspath template_dir = os.path.join(output_dir, template_dir_name) @@ -278,7 +334,7 @@ def make_template_dir(env, mono_root): # 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_mono_etc_dir(mono_root, template_mono_config_dir, platform) # Copy the required shared libraries @@ -371,30 +427,38 @@ def copy_mono_shared_libs(env, mono_root, target_mono_root_dir): platform = env['platform'] if platform == 'windows': + src_mono_bin_dir = os.path.join(mono_root, 'bin') 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'), target_mono_bin_dir) + mono_posix_helper_name = find_file_in_dir(src_mono_bin_dir, ['MonoPosixHelper', 'libMonoPosixHelper'], extension='.dll') + copy(os.path.join(src_mono_bin_dir, mono_posix_helper_name + '.dll'), os.path.join(target_mono_bin_dir, 'MonoPosixHelper.dll')) + + # For newer versions + btls_dll_path = os.path.join(src_mono_bin_dir, 'libmono-btls-shared.dll') + if os.path.isfile(btls_dll_path): + copy(btls_dll_path, target_mono_bin_dir) else: target_mono_lib_dir = get_android_out_dir(env) if platform == 'android' else os.path.join(target_mono_root_dir, 'lib') if not os.path.isdir(target_mono_lib_dir): os.makedirs(target_mono_lib_dir) + lib_file_names = [] if platform == 'osx': - # TODO: Make sure nothing is missing - copy(os.path.join(mono_root, 'lib', 'libMonoPosixHelper.dylib'), target_mono_lib_dir) - elif platform == 'x11' or platform == 'android': + lib_file_names = [lib_name + '.dylib' for lib_name in [ + 'libmono-btls-shared', 'libmono-native-compat', 'libMonoPosixHelper' + ]] + elif is_unix_like(platform): lib_file_names = [lib_name + '.so' for lib_name in [ 'libmono-btls-shared', 'libmono-ee-interp', 'libmono-native', 'libMonoPosixHelper', 'libmono-profiler-aot', 'libmono-profiler-coverage', 'libmono-profiler-log', 'libMonoSupportW' ]] - for lib_file_name in lib_file_names: - copy_if_exists(os.path.join(mono_root, 'lib', lib_file_name), target_mono_lib_dir) - + for lib_file_name in lib_file_names: + copy_if_exists(os.path.join(mono_root, 'lib', lib_file_name), target_mono_lib_dir) def pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext): tmpenv = Environment() diff --git a/modules/mono/build_scripts/patches/fix-mono-android-tkill.diff b/modules/mono/build_scripts/patches/fix-mono-android-tkill.diff deleted file mode 100644 index 05f8dcadcc..0000000000 --- a/modules/mono/build_scripts/patches/fix-mono-android-tkill.diff +++ /dev/null @@ -1,70 +0,0 @@ -diff --git a/libgc/include/private/gcconfig.h b/libgc/include/private/gcconfig.h -index e2bdf13ac3e..f962200ba4e 100644 ---- a/libgc/include/private/gcconfig.h -+++ b/libgc/include/private/gcconfig.h -@@ -2255,6 +2255,14 @@ - # define GETPAGESIZE() getpagesize() - # endif - -+#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \ -+ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \ -+ || defined(ARM32) || defined(I386) /* but not x32 */) -+ /* tkill() exists only on arm32/mips(32)/x86. */ -+ /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */ -+# define USE_TKILL_ON_ANDROID -+#endif -+ - # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4) - /* OS has SVR4 generic features. Probably others also qualify. */ - # define SVR4 -diff --git a/libgc/pthread_stop_world.c b/libgc/pthread_stop_world.c -index f93ce26b562..4a49a6d578c 100644 ---- a/libgc/pthread_stop_world.c -+++ b/libgc/pthread_stop_world.c -@@ -336,7 +336,7 @@ void GC_push_all_stacks() - pthread_t GC_stopping_thread; - int GC_stopping_pid; - --#ifdef HOST_ANDROID -+#ifdef USE_TKILL_ON_ANDROID - static - int android_thread_kill(pid_t tid, int sig) - { -diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c -index ad9b8823f8f..3542b32b540 100644 ---- a/mono/metadata/threads.c -+++ b/mono/metadata/threads.c -@@ -77,8 +77,12 @@ mono_native_thread_join_handle (HANDLE thread_handle, gboolean close_handle); - #include <zircon/syscalls.h> - #endif - --#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) --#define USE_TKILL_ON_ANDROID 1 -+#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \ -+ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \ -+ || defined(ARM32) || defined(I386) /* but not x32 */) -+ /* tkill() exists only on arm32/mips(32)/x86. */ -+ /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */ -+# define USE_TKILL_ON_ANDROID - #endif - - #ifdef HOST_ANDROID -diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c -index 3e4bf93de5f..79c9f731fe7 100644 ---- a/mono/utils/mono-threads-posix.c -+++ b/mono/utils/mono-threads-posix.c -@@ -31,8 +31,12 @@ - - #include <errno.h> - --#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) --#define USE_TKILL_ON_ANDROID 1 -+#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \ -+ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \ -+ || defined(ARM32) || defined(I386) /* but not x32 */) -+ /* tkill() exists only on arm32/mips(32)/x86. */ -+ /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */ -+# define USE_TKILL_ON_ANDROID - #endif - - #ifdef USE_TKILL_ON_ANDROID |