2020-10-13 14:55:07 +02:00
|
|
|
#!/usr/bin/env python3
|
2019-11-10 04:58:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main(raw_args):
|
|
|
|
import cmd_utils
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
from os_utils import get_emsdk_root
|
|
|
|
|
|
|
|
parser = cmd_utils.build_arg_parser(description='Apply patches to the Mono source tree')
|
|
|
|
|
|
|
|
default_help = 'default: %(default)s'
|
|
|
|
|
|
|
|
mono_sources_default = os.environ.get('MONO_SOURCE_ROOT', '')
|
|
|
|
|
|
|
|
if mono_sources_default:
|
|
|
|
parser.add_argument('--mono-sources', default=mono_sources_default, help=default_help)
|
|
|
|
else:
|
|
|
|
parser.add_argument('--mono-sources', required=True)
|
|
|
|
|
|
|
|
args = parser.parse_args(raw_args)
|
|
|
|
|
|
|
|
this_script_dir = os.path.dirname(os.path.realpath(__file__))
|
2019-12-04 15:15:25 +01:00
|
|
|
patches_dir = os.path.join(this_script_dir, 'files', 'patches')
|
2019-11-10 04:58:04 +01:00
|
|
|
|
|
|
|
mono_source_root = args.mono_sources
|
|
|
|
|
|
|
|
patches = [
|
2020-01-21 15:17:08 +01:00
|
|
|
'fix-mono-android-tkill.diff',
|
2020-01-29 12:27:35 +01:00
|
|
|
'mono-dbg-agent-clear-tls-instead-of-abort.diff',
|
2020-03-11 01:23:59 +01:00
|
|
|
'bcl-profile-platform-override.diff',
|
2021-01-06 16:40:04 +01:00
|
|
|
'mono_ios_asl_log_deprecated.diff',
|
|
|
|
'wasm_m2n_trampolines_hook.diff',
|
2019-11-10 04:58:04 +01:00
|
|
|
]
|
|
|
|
|
2020-04-16 15:28:25 +02:00
|
|
|
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']
|
|
|
|
|
2019-11-10 04:58:04 +01:00
|
|
|
from subprocess import Popen
|
2020-04-06 14:51:14 +02:00
|
|
|
from sys import exit
|
2019-11-10 04:58:04 +01:00
|
|
|
for patch in patches:
|
2020-04-06 14:51:14 +02:00
|
|
|
patch_cmd = 'patch -N -p1 < %s' % os.path.join(patches_dir, patch)
|
|
|
|
print('Running: %s' % patch_cmd)
|
|
|
|
proc = Popen('bash -c \'%s; exit $?\'' % patch_cmd, cwd=mono_source_root, shell=True)
|
|
|
|
exit_code = proc.wait()
|
|
|
|
if exit_code != 0:
|
|
|
|
exit('patch exited with error code: %s' % exit_code)
|
2019-11-10 04:58:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from sys import argv
|
|
|
|
main(argv[1:])
|