Prevent PYTHONPATH from accumulatively growing.

After running "lunch" multiple times, the global variable
PYTHONPATH grows larger and larger with repetively content.
This patch is to prevent PYTHONPATH from prepending redundant path.

Bug: b/121110600

Test: $ source build/envsetup.sh && lunch
      $ echo $PYTHONPATH | sed 's/:/\n/g'
      $ lunch; lunch
      $ echo $PYTHONPATH | sed 's/:/\n/g' # not growing.

Change-Id: Ifc36d071fb63bb1494bb0a94fdff477a41708c74
This commit is contained in:
Jim Tang 2018-12-17 15:21:53 +08:00
parent 4bc5c8fed5
commit 22f4c322d6
1 changed files with 8 additions and 1 deletions

View File

@ -266,7 +266,14 @@ function setpaths()
fi
export PATH=$ANDROID_BUILD_PATHS$PATH
export PYTHONPATH=$T/development/python-packages:$PYTHONPATH
# out with the duplicate old
if [ -n $ANDROID_PYTHONPATH ]; then
export PYTHONPATH=${PYTHONPATH//$ANDROID_PYTHONPATH/}
fi
# and in with the new
export ANDROID_PYTHONPATH=$T/development/python-packages:
export PYTHONPATH=$ANDROID_PYTHONPATH$PYTHONPATH
export ANDROID_JAVA_HOME=$(get_abs_build_var ANDROID_JAVA_HOME)
export JAVA_HOME=$ANDROID_JAVA_HOME