Skip to content

Commit af05f5b

Browse files
committed
Add function to get host_arch
1 parent 1b3a843 commit af05f5b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

script/lib/util.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import atexit
44
import contextlib
55
import errno
6+
import platform
7+
import re
68
import shutil
79
import ssl
810
import subprocess
@@ -15,6 +17,29 @@
1517

1618
from config import is_verbose_mode
1719

20+
21+
def get_host_arch():
22+
"""Returns the host architecture with a predictable string."""
23+
host_arch = platform.machine()
24+
25+
# Convert machine type to format recognized by gyp.
26+
if re.match(r'i.86', host_arch) or host_arch == 'i86pc':
27+
host_arch = 'ia32'
28+
elif host_arch in ['x86_64', 'amd64']:
29+
host_arch = 'x64'
30+
elif host_arch.startswith('arm'):
31+
host_arch = 'arm'
32+
33+
# platform.machine is based on running kernel. It's possible to use 64-bit
34+
# kernel with 32-bit userland, e.g. to give linker slightly more memory.
35+
# Distinguish between different userland bitness by querying
36+
# the python binary.
37+
if host_arch == 'x64' and platform.architecture()[0] == '32bit':
38+
host_arch = 'ia32'
39+
40+
return host_arch
41+
42+
1843
def tempdir(prefix=''):
1944
directory = tempfile.mkdtemp(prefix=prefix)
2045
atexit.register(shutil.rmtree, directory)

script/update.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77

88
from lib.config import get_target_arch
9+
from lib.util import get_host_arch
910

1011

1112
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@@ -48,7 +49,7 @@ def run_gyp(target_arch, component):
4849
defines = [
4950
'-Dlibchromiumcontent_component={0}'.format(component),
5051
'-Dtarget_arch={0}'.format(target_arch),
51-
'-Dhost_arch=x64',
52+
'-Dhost_arch={0}'.format(get_host_arch()),
5253
'-Dlibrary=static_library',
5354
]
5455
return subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.',

0 commit comments

Comments
 (0)