]> khamidou — GitHub mirrors - electron.git/commitdiff
Add function to get host_arch
authorCheng Zhao <zcbenz@gmail.com>
Wed, 1 Jul 2015 09:17:44 +0000 (09:17 +0000)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 1 Jul 2015 09:17:44 +0000 (09:17 +0000)
script/lib/util.py
script/update.py

index b67bb8da0da85c9519a1274cb49ab1463d6db30d..a995b605613b2f6c4cbe190f6636db8f0f6eb679 100644 (file)
@@ -3,6 +3,8 @@
 import atexit
 import contextlib
 import errno
+import platform
+import re
 import shutil
 import ssl
 import subprocess
@@ -15,6 +17,29 @@ import zipfile
 
 from config import is_verbose_mode
 
+
+def get_host_arch():
+  """Returns the host architecture with a predictable string."""
+  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'
+
+  return host_arch
+
+
 def tempdir(prefix=''):
   directory = tempfile.mkdtemp(prefix=prefix)
   atexit.register(shutil.rmtree, directory)
index 2a0c044368a247f29f54224ba036f965a973a42c..ac9231c77645d4fc932647f17df356359a863fb9 100755 (executable)
@@ -6,6 +6,7 @@ import subprocess
 import sys
 
 from lib.config import get_target_arch
+from lib.util import get_host_arch
 
 
 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@@ -48,7 +49,7 @@ def run_gyp(target_arch, component):
   defines = [
     '-Dlibchromiumcontent_component={0}'.format(component),
     '-Dtarget_arch={0}'.format(target_arch),
-    '-Dhost_arch=x64',
+    '-Dhost_arch={0}'.format(get_host_arch()),
     '-Dlibrary=static_library',
   ]
   return subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.',