Commit a5bec845 authored by anatoly techtonik's avatar anatoly techtonik Committed by Commit Bot

[bootstrap] Move bitness detection logic into Python

Bug: 703064

Change-Id: I319e89a43533b86c0eedff56fec2665fa13e728c
Reviewed-on: https://chromium-review.googlesource.com/466006
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
parent 3721ee91
...@@ -6,6 +6,7 @@ import argparse ...@@ -6,6 +6,7 @@ import argparse
import fnmatch import fnmatch
import logging import logging
import os import os
import platform
import shutil import shutil
import subprocess import subprocess
import sys import sys
...@@ -26,6 +27,11 @@ def _check_call(argv, **kwargs): ...@@ -26,6 +27,11 @@ def _check_call(argv, **kwargs):
subprocess.check_call(argv, **kwargs) subprocess.check_call(argv, **kwargs)
def get_os_bitness():
"""Returns bitness of operating system as int."""
return 64 if platform.machine().endswith('64') else 32
def get_target_git_version(): def get_target_git_version():
"""Returns git version that should be installed.""" """Returns git version that should be installed."""
if os.path.exists(os.path.join(ROOT_DIR, '.git_bleeding_edge')): if os.path.exists(os.path.join(ROOT_DIR, '.git_bleeding_edge')):
...@@ -148,8 +154,9 @@ def install_git(args, git_version, git_directory): ...@@ -148,8 +154,9 @@ def install_git(args, git_version, git_directory):
def main(argv): def main(argv):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--bits', type=int, choices=(32,64), default=64, parser.add_argument('--bits', type=int, choices=(32,64),
help='Bitness of the client to install.') help='Bitness of the client to install. Default on this'
' system: %(default)s', default=get_os_bitness())
parser.add_argument('--cipd-client', parser.add_argument('--cipd-client',
help='Path to CIPD client binary. default: %(default)s', help='Path to CIPD client binary. default: %(default)s',
default=os.path.join(ROOT_DIR, 'cipd'+BAT_EXT)) default=os.path.join(ROOT_DIR, 'cipd'+BAT_EXT))
......
...@@ -58,16 +58,7 @@ set ERRORLEVEL=1 ...@@ -58,16 +58,7 @@ set ERRORLEVEL=1
goto :END goto :END
:GIT_CHECK :GIT_CHECK
"%WIN_TOOLS_ROOT_DIR%\python.bat" "%~dp0git_bootstrap.py"
:: must explicitly use FIND_EXE to prevent this from grabbing e.g. gnuwin32 or
:: msys versions.
set FIND_EXE=%SYSTEMROOT%\System32\find.exe
:: Check to see if we're on a 32 or 64 bit system
:: (parens) are necessary, otherwise batch puts an extra space after 32.
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | %FIND_EXE% /i "x86" > NUL && (set OS_BITS=32) || (set OS_BITS=64)
"%WIN_TOOLS_ROOT_DIR%\python.bat" "%~dp0git_bootstrap.py" --bits "%OS_BITS%"
goto :END goto :END
:returncode :returncode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment