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

Side by Side Diff: python_runner.sh

Issue 1411793006: 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, 1 month 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
(Empty)
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
3 # found in the LICENSE file.
4
5 ## This file is designed to be sourced from a bash script whose name takes the
6 ## form 'command-name'. This script will then instead invoke
7 ## '[depot_tools]/command_name.py' correctly under mingw as well
8 ## as posix-ey systems, passing along all other command line flags.
9
10 ## Example:
11 ## echo ". python_runner.sh" > git-foo-command
12 ## ./git-foo-command #=> runs `python git_foo_command.py`
13
14 ## Constants
15 PYTHONDONTWRITEBYTECODE=1
16
17 ## "Input parameters".
18 # If set before the script is sourced, then we'll use the pre-set values.
19 #
20 # SCRIPT defaults to the basename of $0, with dashes replaced with underscores
21
22 # "$0" can have several different formats depending on how the script was called
23 # and the environment being used, including having different formats even in the
24 # same environment (e.g. in msys, 'git cl' causes $0 to have a Windows-style
25 # path, but calling 'git-cl' results in a POSIX-style path), so don't assume a
26 # particular format.
27 # First try to split it using Windows format ...
28 DEPOT_TOOLS="${0%\\*}"
29 if [[ "$DEPOT_TOOLS" = "$0" ]]; then
30 # If that didn't work, try POSIX format ...
31 DEPOT_TOOLS="${0%/*}"
32 if [[ "$DEPOT_TOOLS" = "$0" ]]; then
33 # Sometimes commands will run with no path (e.g. a git command run from
34 # within the depot_tools dir itself). In that case, treat it as if run like:
35 # "./command"
36 DEPOT_TOOLS="."
37 BASENAME="$0"
38 else
39 BASENAME="${0##*/}"
40 fi
41 else
42 BASENAME="${0##*\\}"
43 fi
44 SCRIPT="${SCRIPT-${BASENAME//-/_}.py}"
45
46 if [[ -e "$DEPOT_TOOLS/python.bat" && $OSTYPE = msys ]]; then
47 cmd.exe //c "$DEPOT_TOOLS\\python.bat" "$DEPOT_TOOLS\\$SCRIPT" "$@"
48 else
49 exec "$DEPOT_TOOLS/$SCRIPT" "$@"
50 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