Chromium Code Reviews| Index: build/detect_host_arch.py |
| diff --git a/build/detect_host_arch.py b/build/detect_host_arch.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..754a12e3f4a8c938e70941cf5c5c19671861d7eb |
| --- /dev/null |
| +++ b/build/detect_host_arch.py |
| @@ -0,0 +1,32 @@ |
| +#!/usr/bin/env python |
|
Marc-Antoine Ruel (Google)
2014/01/31 14:47:47
Please rename this script to make this clear this
Paweł Hajdan Jr.
2014/01/31 15:44:04
Done.
|
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
|
Marc-Antoine Ruel (Google)
2014/01/31 14:47:47
"""Outputs 'ia32' or 'x64' representing the userla
Paweł Hajdan Jr.
2014/01/31 15:44:04
There's more than bitness so I just wrote about CP
M-A Ruel
2014/01/31 16:04:58
What about arm64?
Paweł Hajdan Jr.
2014/01/31 16:08:35
It just mirrors the previous logic from gyp - anyo
|
| +import platform |
| +import re |
| +import sys |
| + |
|
Marc-Antoine Ruel (Google)
2014/01/31 14:47:47
2 lines
Paweł Hajdan Jr.
2014/01/31 15:44:04
Done.
|
| +def main(): |
| + host_arch = platform.machine() |
| + |
| + # Convert machine type to format recognized by gyp. |
| + if re.match(r'i.86', host_arch) or host_arch == 'i86pc': |
| + host_arch = 'ia32' |
| + elif host_arch in ['x86_64', 'amd64']: |
| + host_arch = 'x64' |
| + elif host_arch.startswith('arm'): |
| + host_arch = 'arm' |
| + |
| + # platform.machine is based on running kernel. It's possible to use 64-bit |
| + # kernel with 32-bit userland, e.g. to give linker slightly more memory. |
| + # Distinguish between different userland bitness by querying |
| + # the python binary. |
| + if host_arch == 'x64' and platform.architecture()[0] == '32bit': |
| + host_arch = 'ia32' |
| + |
| + print host_arch |
| + return 0 |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |