|
|
|
# Copyright 2015 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 file is designed to be sourced from a bash script whose name takes the
|
|
|
|
## form 'command-name'. This script will then instead invoke
|
|
|
|
## '[depot_tools]/command_name.py' correctly under mingw as well
|
|
|
|
## as posix-ey systems, passing along all other command line flags.
|
|
|
|
|
|
|
|
## Example:
|
|
|
|
## echo ". python_runner.sh" > git-foo-command
|
|
|
|
## ./git-foo-command #=> runs `python git_foo_command.py`
|
|
|
|
|
|
|
|
## Constants
|
|
|
|
PYTHONDONTWRITEBYTECODE=1; export PYTHONDONTWRITEBYTECODE
|
|
|
|
|
|
|
|
## "Input parameters".
|
|
|
|
# If set before the script is sourced, then we'll use the pre-set values.
|
|
|
|
#
|
|
|
|
# SCRIPT defaults to the basename of $0, with dashes replaced with underscores
|
|
|
|
|
|
|
|
# "$0" can have several different formats depending on how the script was called
|
|
|
|
# and the environment being used, including having different formats even in the
|
|
|
|
# same environment (e.g. in msys, 'git cl' causes $0 to have a Windows-style
|
|
|
|
# path, but calling 'git-cl' results in a POSIX-style path), so don't assume a
|
|
|
|
# particular format.
|
|
|
|
# First try to split it using Windows format ...
|
|
|
|
DEPOT_TOOLS="${0%\\*}"
|
|
|
|
if [[ "$DEPOT_TOOLS" = "$0" ]]; then
|
|
|
|
# If that didn't work, try POSIX format ...
|
|
|
|
DEPOT_TOOLS="${0%/*}"
|
|
|
|
if [[ "$DEPOT_TOOLS" = "$0" ]]; then
|
|
|
|
# Sometimes commands will run with no path (e.g. a git command run from
|
|
|
|
# within the depot_tools dir itself). In that case, treat it as if run like:
|
|
|
|
# "./command"
|
|
|
|
DEPOT_TOOLS="."
|
|
|
|
BASENAME="$0"
|
|
|
|
else
|
|
|
|
BASENAME="${0##*/}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
BASENAME="${0##*\\}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
SCRIPT="${SCRIPT-${BASENAME//-/_}.py}"
|
|
|
|
|
|
|
|
# Ensure that "depot_tools" is somewhere in PATH so this tool can be used
|
|
|
|
# standalone, but allow other PATH manipulations to take priority.
|
|
|
|
PATH=$PATH:$DEPOT_TOOLS
|
|
|
|
|
|
|
|
if [[ $GCLIENT_PY3 = 1 ]]; then
|
|
|
|
# Explicitly run on Python 3
|
|
|
|
vpython3 "$DEPOT_TOOLS/$SCRIPT" "$@"
|
|
|
|
elif [[ $GCLIENT_PY3 = 0 ]]; then
|
|
|
|
# Explicitly run on Python 2
|
|
|
|
vpython "$DEPOT_TOOLS/$SCRIPT" "$@"
|
|
|
|
elif [[ $(uname -s) = MINGW* || $(uname -s) = CYGWIN* ]]; then
|
|
|
|
# Run on Python 2 on Windows for now, allows default to be flipped.
|
Revert "Reland "depot_tools: Run using Python 3 by default.""
This reverts commit e9013eeb3d1d026d72549dea78dbba2a95ad8d5d.
Reason for revert: https://crbug.com/1064547
Original change's description:
> Reland "depot_tools: Run using Python 3 by default."
>
> This is a reland of 01ed358917aa9f9f6314414ba3bb5e808bdedca2
>
> * python_runner.sh, gclient, roll-dep and fetch will call vpython
> (instead of vpython3) when running on Windows under git-bash.
> * vpython3 now detects when running on Windows under git-bash and
> executes vpython3.bat instead.
> * vpython3.bat calls python3.exe directly instead of calling python3.bat.
>
> Original change's description:
> > depot_tools: Run using Python 3 by default.
> >
> > Run gclient, roll-dep, fetch and custom git commands (i.e. git-cl, git-rebase-update, git-new-branch, etc.)
> > using vpython3 by default.
> >
> > Change-Id: I4eecddafa6ca4c5f82ec097615c79d2a741613e7
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2113550
> > Reviewed-by: Anthony Polito <apolito@google.com>
> > Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
>
> Change-Id: I9829141d7ea26a67e655264430151f493e73a930
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2118418
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Anthony Polito <apolito@google.com>
TBR=ehmaldonado@chromium.org,ajp@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
Change-Id: Ia382d6e4e330f5a7a7a62e4d369c3fa16fc17333
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2120956
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
5 years ago
|
|
|
vpython "$DEPOT_TOOLS/$SCRIPT" "$@"
|
|
|
|
else
|
|
|
|
# Run on Python 3, allows default to be flipped.
|
|
|
|
vpython3 "$DEPOT_TOOLS/$SCRIPT" "$@"
|
|
|
|
fi
|