Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
detect_host_arch.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2014 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Outputs host CPU architecture in format recognized by gyp."""
6
7import platform
8import re
9import sys
10
11
13 """Returns the host architecture with a predictable string."""
14 host_arch = platform.machine()
15
16 # Convert machine type to format recognized by gyp.
17 if re.match(r'i.86', host_arch) or host_arch == 'i86pc':
18 host_arch = 'ia32'
19 elif host_arch in ['x86_64', 'amd64']:
20 host_arch = 'x64'
21 elif host_arch.startswith('arm'):
22 host_arch = 'arm'
23 elif host_arch.startswith('aarch64'):
24 host_arch = 'arm64'
25 elif host_arch.startswith('mips'):
26 host_arch = 'mips'
27 elif host_arch.startswith('ppc'):
28 host_arch = 'ppc'
29 elif host_arch.startswith('s390'):
30 host_arch = 's390'
31
32 # platform.machine is based on running kernel. It's possible to use 64-bit
33 # kernel with 32-bit userland, e.g. to give linker slightly more memory.
34 # Distinguish between different userland bitness by querying
35 # the python binary.
36 if host_arch == 'x64' and platform.architecture()[0] == '32bit':
37 host_arch = 'ia32'
38 if host_arch == 'arm64' and platform.architecture()[0] == '32bit':
39 host_arch = 'arm'
40
41 return host_arch
42
43
44def DoMain(_):
45 """Hook to be called from gyp without starting a separate python
46 interpreter."""
47 return HostArch()
48
49
50if __name__ == '__main__':
51 print(DoMain([]))
void print(void *str)
Definition bridge.cpp:126