Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: python_runner.sh

Issue 1415993003: Generalize python_git_runner for use in non-git scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « python_git_runner.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 ## This file is designed to be sourced from a bash script whose name takes the 5 ## This file is designed to be sourced from a bash script whose name takes the
6 ## form 'git-sub-command'. This script will then instead invoke 6 ## form 'command-name'. This script will then instead invoke
7 ## '[depot_tools]/git_sub_command.py' correctly under mingw as well 7 ## '[depot_tools]/command_name.py' correctly under mingw as well
8 ## as posix-ey systems, passing along all other command line flags. 8 ## as posix-ey systems, passing along all other command line flags.
9 9
10 ## Example: 10 ## Example:
11 ## echo ". python_git_runner.sh" > git-foo-command 11 ## echo ". python_runner.sh" > git-foo-command
12 ## ./git-foo-command #=> runs `python git_foo_command.py` 12 ## ./git-foo-command #=> runs `python git_foo_command.py`
13 13
14 ## Constants 14 ## Constants
15 PYTHONDONTWRITEBYTECODE=1 15 PYTHONDONTWRITEBYTECODE=1
16 16
17 ## "Input parameters". 17 ## "Input parameters".
18 # If set before the script is sourced, then we'll use the pre-set values. 18 # If set before the script is sourced, then we'll use the pre-set values.
19 # 19 #
20 # SCRIPT defaults to the basename of $0, with dashes replaced with underscores 20 # SCRIPT defaults to the basename of $0, with dashes replaced with underscores
21 21
22 if [[ $OSTYPE = msys ]] 22 DEPOT_TOOLS="${0%/*}"
23 then 23 # Sometimes commands will run with no path (e.g. a git command run from within
24 DEPOT_TOOLS="${0%\\*}" 24 # the depot_tools dir itself). In that case, treat it like it was run like:
25 BASENAME="${0##*\\}" 25 # "./command"
26 else 26 if [[ "$DEPOT_TOOLS" = "$0" ]]; then
27 DEPOT_TOOLS="${0%/*}" 27 DEPOT_TOOLS="."
28 BASENAME="${0##*/}"
29 fi 28 fi
29 BASENAME="${0##*/}"
30 SCRIPT="${SCRIPT-${BASENAME//-/_}.py}" 30 SCRIPT="${SCRIPT-${BASENAME//-/_}.py}"
31 31
32 if [[ -e "$DEPOT_TOOLS/python.bat" && $OSTYPE = msys ]]; then 32 if [[ -e "$DEPOT_TOOLS/python.bat" && $OSTYPE = msys ]]; then
33 cmd.exe //c "$DEPOT_TOOLS\\python.bat" "$DEPOT_TOOLS\\$SCRIPT" "$@" 33 cmd.exe //c "$DEPOT_TOOLS\\python.bat" "$DEPOT_TOOLS\\$SCRIPT" "$@"
34 else 34 else
35 exec "$DEPOT_TOOLS/$SCRIPT" "$@" 35 exec "$DEPOT_TOOLS/$SCRIPT" "$@"
36 fi 36 fi
OLDNEW
« no previous file with comments | « python_git_runner.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698