summaryrefslogtreecommitdiff
path: root/envsetup.sh
diff options
context:
space:
mode:
authorChris Gross <chrisgross@google.com>2020-11-05 04:50:04 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-11-05 04:50:04 +0000
commit784d0566cc2ee33399cd5bf5fb1edb6ccc743431 (patch)
treec750fd6dc7d37aadf5df14986f8ad1a93a0b14b1 /envsetup.sh
parent536db6efc0cf0a4c8df34edb8fd79fd362cf6a62 (diff)
parent238f582bcd0dc52753c719ee8f3fde599ed1ff41 (diff)
Merge "Merge SP1A.201015.001" into s-keystone-qcom-dev
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh85
1 files changed, 76 insertions, 9 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 78d57fc24f..c1b8f204c7 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -34,6 +34,7 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y
- gomod: Go to the directory containing a module.
- pathmod: Get the directory containing a module.
- refreshmod: Refresh list of modules for allmod/gomod/pathmod.
+- syswrite: Remount partitions (e.g. system.img) as writable, rebooting if necessary.
Environment options:
- SANITIZE_HOST: Set to 'address' to use ASAN for all host modules.
@@ -317,6 +318,59 @@ function setpaths()
#export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
}
+function abazel()
+{
+ local T="$(gettop)"
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return
+ fi
+
+ case $(uname -s) in
+ Darwin)
+ ANDROID_BAZEL_PATH="${T}/prebuilts/bazel/darwin-x86_64/bazel"
+ ANDROID_BAZELRC_PATH="${T}/build/bazel/darwin.bazelrc"
+ ANDROID_BAZEL_JDK_PATH="${T}/prebuilts/jdk/jdk11/darwin-x86"
+ ;;
+ Linux)
+ ANDROID_BAZEL_PATH="${T}/prebuilts/bazel/linux-x86_64/bazel"
+ ANDROID_BAZELRC_PATH="${T}/build/bazel/linux.bazelrc"
+ ANDROID_BAZEL_JDK_PATH="${T}/prebuilts/jdk/jdk11/linux-x86"
+ ;;
+ *)
+ ANDROID_BAZEL_PATH=
+ ANDROID_BAZELRC_PATH=
+ ANDROID_BAZEL_JDK_PATH=
+ ;;
+ esac
+
+ if [ -n "$ANDROID_BAZEL_PATH" -a -f "$ANDROID_BAZEL_PATH" ]; then
+ export ANDROID_BAZEL_PATH
+ else
+ echo "Couldn't locate Bazel binary"
+ return
+ fi
+
+ if [ -n "$ANDROID_BAZELRC_PATH" -a -f "$ANDROID_BAZELRC_PATH" ]; then
+ export ANDROID_BAZELRC_PATH
+ else
+ echo "Couldn't locate bazelrc file for Bazel"
+ return
+ fi
+
+ if [ -n "$ANDROID_BAZEL_JDK_PATH" -a -d "$ANDROID_BAZEL_JDK_PATH" ]; then
+ export ANDROID_BAZEL_JDK_PATH
+ else
+ echo "Couldn't locate JDK to use for Bazel"
+ return
+ fi
+
+ echo "WARNING: Bazel support for the Android Platform is experimental and is undergoing development."
+ echo "WARNING: Currently, build stability is not guaranteed. Thank you."
+ echo
+ "${ANDROID_BAZEL_PATH}" --server_javabase="${ANDROID_BAZEL_JDK_PATH}" --bazelrc="${ANDROID_BAZELRC_PATH}" "$@"
+}
+
function printconfig()
{
local T=$(gettop)
@@ -355,7 +409,7 @@ function should_add_completion() {
function addcompletions()
{
- local T dir f
+ local f=
# Keep us from trying to run in something that's neither bash nor zsh.
if [ -z "$BASH_VERSION" -a -z "$ZSH_VERSION" ]; then
@@ -769,7 +823,7 @@ function gettop
local TOPFILE=build/make/core/envsetup.mk
if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
# The following circumlocution ensures we remove symlinks from TOP.
- (cd $TOP; PWD= /bin/pwd)
+ (cd "$TOP"; PWD= /bin/pwd)
else
if [ -f $TOPFILE ] ; then
# The following circumlocution (repeated below as well) ensures
@@ -779,13 +833,13 @@ function gettop
else
local HERE=$PWD
local T=
- while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
+ while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do
\cd ..
T=`PWD= /bin/pwd -P`
done
- \cd $HERE
+ \cd "$HERE"
if [ -f "$T/$TOPFILE" ]; then
- echo $T
+ echo "$T"
fi
fi
fi
@@ -858,6 +912,18 @@ function qpid() {
fi
}
+# syswrite - disable verity, reboot if needed, and remount image
+#
+# Easy way to make system.img/etc writable
+function syswrite() {
+ adb wait-for-device && adb root || return 1
+ if [[ $(adb disable-verity | grep "reboot") ]]; then
+ echo "rebooting"
+ adb reboot && adb wait-for-device && adb root || return 1
+ fi
+ adb wait-for-device && adb remount || return 1
+}
+
# coredump_setup - enable core dumps globally for any process
# that has the core-file-size limit set correctly
#
@@ -1650,25 +1716,26 @@ function validate_current_shell() {
# This allows loading only approved vendorsetup.sh files
function source_vendorsetup() {
unset VENDOR_PYTHONPATH
+ local T="$(gettop)"
allowed=
- for f in $(find -L device vendor product -maxdepth 4 -name 'allowed-vendorsetup_sh-files' 2>/dev/null | sort); do
+ for f in $(cd "$T" && find -L device vendor product -maxdepth 4 -name 'allowed-vendorsetup_sh-files' 2>/dev/null | sort); do
if [ -n "$allowed" ]; then
echo "More than one 'allowed_vendorsetup_sh-files' file found, not including any vendorsetup.sh files:"
echo " $allowed"
echo " $f"
return
fi
- allowed="$f"
+ allowed="$T/$f"
done
allowed_files=
[ -n "$allowed" ] && allowed_files=$(cat "$allowed")
for dir in device vendor product; do
- for f in $(test -d $dir && \
+ for f in $(cd "$T" && test -d $dir && \
find -L $dir -maxdepth 4 -name 'vendorsetup.sh' 2>/dev/null | sort); do
if [[ -z "$allowed" || "$allowed_files" =~ $f ]]; then
- echo "including $f"; . "$f"
+ echo "including $f"; . "$T/$f"
else
echo "ignoring $f, not in $allowed"
fi