win_tools.bat 3.18 KB
Newer Older
1 2 3 4 5 6 7 8
@echo off
:: Copyright (c) 2009 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.

:: This script will try to find if svn and python are accessible and it not,
:: it will try to download it and 'install' it in depot_tools.

9 10
:: Sadly, we can't use SETLOCAL here otherwise it ERRORLEVEL is not correctly
:: returned.
11

12
set WIN_TOOLS_ROOT_URL=http://src.chromium.org/svn/trunk/tools
13 14 15 16 17

:: Get absolute root directory (.js scripts don't handle relative paths well).
pushd %~dp0..\..
set WIN_TOOLS_ROOT_DIR=%CD%
popd
18

19 20 21 22 23
if "%1" == "force" (
  set WIN_TOOLS_FORCE=1
  shift /1
)

24
:SVN_CHECK
25
:: If the batch file exists, skip the svn check.
26
if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :PYTHON_CHECK
27
if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL
28
call svn --version 2>nul 1>nul
29 30
if errorlevel 1 goto :SVN_INSTALL
goto :PYTHON_CHECK
31 32


33
:SVN_INSTALL
34 35
echo Installing subversion ...
:: svn is not accessible; check it out and create 'proxy' files.
36
if exist "%~dp0svn.zip" del "%~dp0svn.zip"
37
cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party/svn_bin.zip "%~dp0svn.zip"
38
if errorlevel 1 goto :SVN_FAIL
39 40
:: Cleanup svn directory if it was existing.
if exist "%WIN_TOOLS_ROOT_DIR%\svn\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn"
41 42
if exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn_bin"
:: Will create svn_bin\...
43
cscript //nologo //e:jscript "%~dp0unzip.js" "%~dp0svn.zip" "%WIN_TOOLS_ROOT_DIR%"
44
if errorlevel 1 goto :SVN_FAIL
45
if not exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." goto :SVN_FAIL
46
del "%~dp0svn.zip"
47
:: Create the batch file.
48
call copy /y "%~dp0svn.new.bat" "%WIN_TOOLS_ROOT_DIR%\svn.bat" 1>nul
49
call copy /y "%~dp0svnversion.new.bat" "%WIN_TOOLS_ROOT_DIR%\svnversion.bat" 1>nul
50
goto :PYTHON_CHECK
51 52 53


:SVN_FAIL
54
echo ... Failed to checkout svn automatically.
55 56
echo Please visit http://subversion.tigris.org to download the latest subversion client
echo before continuing.
57 58 59 60 61 62 63 64 65
echo You can also get the "prebacked" version used at %WIN_TOOLS_ROOT_URL%/third_party/
set ERRORLEVEL=1
goto :END


:PYTHON_CHECK
:: If the batch file exists, skip the python check.
set ERRORLEVEL=0
if exist "%WIN_TOOLS_ROOT_DIR%\python.bat" goto :END
66
if "%WIN_TOOLS_FORCE%" == "1" goto :PYTHON_INSTALL
67 68 69 70 71 72
call python --version 2>nul 1>nul
if errorlevel 1 goto :PYTHON_INSTALL

:: We are done.
set ERRORLEVEL=0
goto :END
73 74


75
:PYTHON_INSTALL
76
echo Installing python ...
77
:: Cleanup python directory if it was existing.
78
if exist "%WIN_TOOLS_ROOT_DIR%\python_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\python_bin"
79
call svn co -q %WIN_TOOLS_ROOT_URL%/third_party/python_26 "%WIN_TOOLS_ROOT_DIR%\python_bin"
80 81
if errorlevel 1 goto :PYTHON_FAIL
:: Create the batch file.
82
call copy /y "%~dp0python.new.bat" "%WIN_TOOLS_ROOT_DIR%\python.bat" 1>nul
83 84
set ERRORLEVEL=0
goto :END
85 86 87


:PYTHON_FAIL
88
echo ... Failed to checkout python automatically.
89 90
echo Please visit http://python.org to download the latest python 2.x client before
echo continuing.
91 92 93 94 95 96 97 98 99 100 101 102
echo You can also get the "prebacked" version used at %WIN_TOOLS_ROOT_URL%/third_party/
set ERRORLEVEL=1
goto :END


:returncode
set WIN_TOOLS_ROOT_URL=
set WIN_TOOLS_ROOT_DIR=
exit /b %ERRORLEVEL%

:END
call :returncode %ERRORLEVEL%