From a5bec845691b95c7b7299f0fd5bfc5fbd016c7fd Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Mon, 3 Apr 2017 11:37:35 +0300 Subject: [PATCH] [bootstrap] Move bitness detection logic into Python Bug: 703064 Change-Id: I319e89a43533b86c0eedff56fec2665fa13e728c Reviewed-on: https://chromium-review.googlesource.com/466006 Commit-Queue: Robbie Iannucci Reviewed-by: Robbie Iannucci --- bootstrap/win/git_bootstrap.py | 11 +++++++++-- bootstrap/win/win_tools.bat | 11 +---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bootstrap/win/git_bootstrap.py b/bootstrap/win/git_bootstrap.py index bf780ccf7..5c1fd59c9 100644 --- a/bootstrap/win/git_bootstrap.py +++ b/bootstrap/win/git_bootstrap.py @@ -6,6 +6,7 @@ import argparse import fnmatch import logging import os +import platform import shutil import subprocess import sys @@ -26,6 +27,11 @@ def _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(): """Returns git version that should be installed.""" if os.path.exists(os.path.join(ROOT_DIR, '.git_bleeding_edge')): @@ -148,8 +154,9 @@ def install_git(args, git_version, git_directory): def main(argv): parser = argparse.ArgumentParser() - parser.add_argument('--bits', type=int, choices=(32,64), default=64, - help='Bitness of the client to install.') + parser.add_argument('--bits', type=int, choices=(32,64), + help='Bitness of the client to install. Default on this' + ' system: %(default)s', default=get_os_bitness()) parser.add_argument('--cipd-client', help='Path to CIPD client binary. default: %(default)s', default=os.path.join(ROOT_DIR, 'cipd'+BAT_EXT)) diff --git a/bootstrap/win/win_tools.bat b/bootstrap/win/win_tools.bat index abcbcebce..1701aa4e9 100644 --- a/bootstrap/win/win_tools.bat +++ b/bootstrap/win/win_tools.bat @@ -58,16 +58,7 @@ set ERRORLEVEL=1 goto :END :GIT_CHECK - -:: 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%" +"%WIN_TOOLS_ROOT_DIR%\python.bat" "%~dp0git_bootstrap.py" goto :END :returncode