This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
xtool.bat
73 lines (64 loc) · 2.14 KB
/
xtool.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@ECHO OFF
REM Copyright 2017 Google Inc.
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
SET DIR=%~dp0
REM ============================================================================
REM Environment Validation
REM ============================================================================
CALL :check_python
IF %_RESULT% NEQ 0 (
ECHO.
ECHO Python 2.7 must be installed and on PATH:
ECHO https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi
GOTO :exit_error
)
REM ============================================================================
REM Trampoline into xtool
REM ============================================================================
%PYTHON_EXE% %DIR%xtool %*
EXIT /b %ERRORLEVEL%
REM ============================================================================
REM Utilities
REM ============================================================================
:check_python
SETLOCAL
SET FOUND_PYTHON_EXE=""
1>NUL 2>NUL CMD /c where python2
IF NOT ERRORLEVEL 1 (
ECHO FOUND PYTHON 2
SET FOUND_PYTHON_EXE=python2
)
IF %FOUND_PYTHON_EXE% EQU "" (
1>NUL 2>NUL CMD /c where python
IF NOT ERRORLEVEL 1 (
SET FOUND_PYTHON_EXE=python
)
)
IF %FOUND_PYTHON_EXE% EQU "" (
ECHO ERROR: no Python executable found on PATH.
ECHO Make sure you can run 'python' or 'python2' in a Command Prompt.
ENDLOCAL & SET _RESULT=1
GOTO :eof
)
CMD /C %FOUND_PYTHON_EXE% -c "import sys; sys.exit(1 if not sys.version_info[:2] == (2, 7) else 0)"
IF %ERRORLEVEL% NEQ 0 (
ECHO ERROR: Python version mismatch - not 2.7
ENDLOCAL & SET _RESULT=1
GOTO :eof
)
ENDLOCAL & (
SET _RESULT=0
SET PYTHON_EXE=%FOUND_PYTHON_EXE%
)
GOTO :eof