From cdc91e8df639f4f8225056688c0e3501bec37b5f Mon Sep 17 00:00:00 2001 From: Ergys Dona Date: Fri, 1 Oct 2021 15:21:22 +0200 Subject: [PATCH] Add global option --arch Allows to specify a custom architecture target. Useful for arm64-based Apple computers, until all used native libraries are released for arm64. Example usage: mx --arch amd64 ... --- mx.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mx.py b/mx.py index 8b236896..4b8da0c6 100755 --- a/mx.py +++ b/mx.py @@ -581,6 +581,7 @@ def __init__(self, parents=None): "projects and store it in the given . If is 'default', the compilation database will " "be stored in the parent directory of the repository containing the primary suite. This option " "can also be configured using the MX_COMPDB environment variable. Use --compdb none to disable.") + self.add_argument('--arch', action='store', dest='arch', help='force use of the specified architecture') if not is_windows(): # Time outs are (currently) implemented with Unix specific functionality @@ -679,6 +680,10 @@ def _parse_cmd_line(self, opts, firstParse): except IOError as e: abort('Error opening {} specified by --exec-log: {}'.format(opts.exec_log, e)) + system_arch = platform.uname()[4] + if opts.arch and opts.arch != system_arch: + warn('overriding detected architecture ({}) with {}'.format(system_arch, opts.arch)) + else: parser = ArgParser(parents=[self]) parser.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') @@ -3835,6 +3840,9 @@ def _separatedCygpathW2U(p): return os.pathsep.join(map(_cygpathW2U, p.split(';'))) def get_arch(): + return _opts.arch if _opts.arch else _get_real_arch() + +def _get_real_arch(): machine = platform.uname()[4] if machine in ['aarch64']: return 'aarch64'