From b77db58cbdfb4cbff5e2bd321453835f29165f02 Mon Sep 17 00:00:00 2001 From: Martin Brabham Date: Fri, 5 Feb 2016 15:59:21 -0500 Subject: Implement 'mmap' command Change-Id: I029da8a8421bea2b628b4025f9f2d6f749436c7b --- envsetup.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index 6bd6c61..c62a57f 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -11,6 +11,7 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y To limit the modules being built use the syntax: mmm dir/:target1,target2. - mma: Builds all of the modules in the current directory, and their dependencies. - mmp: Builds all of the modules in the current directory and pushes them to the device. +- mmap: Builds all of the modules in the current directory, and its dependencies, then pushes the package to the device. - mmmp: Builds all of the modules in the supplied directories and pushes them to the device. - mmma: Builds all of the modules in the supplied directories, and their dependencies. - mms: Short circuit builder. Quickly re-build the kernel, rootfs, boot and system images @@ -2337,6 +2338,7 @@ EOF alias mmp='dopush mm' alias mmmp='dopush mmm' +alias mmap='dopush mma' alias mkap='dopush mka' alias cmkap='dopush cmka' -- cgit v1.1 From 695992cade21415f7fb056c7ec129a02ab673afb Mon Sep 17 00:00:00 2001 From: Khalid Zubair Date: Mon, 8 Feb 2016 16:27:55 -0800 Subject: envsetup: add function to detect shell Add a function to detect shell, other functions can now use this to handle shell specific behavior. Change-Id: I4aabc0068e836c5433053b144d163fb0ed49f752 --- envsetup.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index c62a57f..35dc8e1 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -2457,16 +2457,25 @@ function make() mk_timer $(get_make_command) "$@" } -if [ "x$SHELL" != "x/bin/bash" ]; then +function __detect_shell() { case `ps -o command -p $$` in *bash*) + echo bash ;; *zsh*) + echo zsh ;; *) - echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results" + echo unknown + return 1 ;; esac + return +} + + +if ! __detect_shell > /dev/null; then + echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results" fi # Execute the contents of any vendorsetup.sh files we can find. -- cgit v1.1 From 01da99759fbdb950338883d7d2f5fb2bf0dcc423 Mon Sep 17 00:00:00 2001 From: Khalid Zubair Date: Mon, 8 Feb 2016 16:54:01 -0800 Subject: envsetup: cmgerrit: fix for zsh zsh does not define $FUNCNAME, define it for zsh when necessary. Change-Id: I097d3e572b18c84d953ca03b3714271d1d2fd5c3 --- envsetup.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index 35dc8e1..eeb6534 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1831,6 +1831,12 @@ function makerecipe() { } function cmgerrit() { + + if [ "$(__detect_shell)" == "zsh" ]; then + # zsh does not define FUNCNAME, derive from funcstack + local FUNCNAME=$funcstack[1] + fi + if [ $# -eq 0 ]; then $FUNCNAME help return 1 -- cgit v1.1 From 521aa1e2e6d1ef35e0051d4cc76f4b2c91577212 Mon Sep 17 00:00:00 2001 From: Khalid Zubair Date: Thu, 11 Feb 2016 14:34:12 -0800 Subject: envesetup: mmm/mmma: fix for zsh Fix broken argument handling due to differnt word-splitting behavior in zsh [1]. Zsh arrays should be explicitly defined. - [1] http://zsh.sourceforge.net/FAQ/zshfaq03.html Change-Id: Ic299c1952384001e374c64caebbb23e9792fddf2 --- envsetup.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index eeb6534..3384211 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -902,8 +902,15 @@ function mmm() local ARGS= local DIR TO_CHOP local GET_INSTALL_PATH= - local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') - local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') + + if [ "$(__detect_shell)" == "zsh" ]; then + set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') + set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') + else + local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') + local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') + fi + for DIR in $DIRS ; do MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` if [ "$MODULES" = "" ]; then @@ -966,8 +973,13 @@ function mmma() local T=$(gettop) local DRV=$(getdriver $T) if [ "$T" ]; then - local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') - local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') + if [ "$(__detect_shell)" == "zsh" ]; then + set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') + set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') + else + local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') + local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') + fi local MY_PWD=`PWD= /bin/pwd` if [ "$MY_PWD" = "$T" ]; then MY_PWD= -- cgit v1.1 From 5771f5d99ed66ab1a06ae6edd8561248a1e1f9c5 Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Tue, 1 Mar 2016 10:27:51 -0800 Subject: build: better compatibility between zsh shells Handle equals expansion in zsh http://www.zsh.org/mla/users/2011/msg00160.html Change-Id: I2b0cb23991aa88c3fa2c4dce00f7c3a673176e0a Signed-off-by: Roman Birg --- envsetup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index 3384211..77f7096 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -903,7 +903,7 @@ function mmm() local DIR TO_CHOP local GET_INSTALL_PATH= - if [ "$(__detect_shell)" == "zsh" ]; then + if [ "$(__detect_shell)" = "zsh" ]; then set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') else @@ -973,7 +973,7 @@ function mmma() local T=$(gettop) local DRV=$(getdriver $T) if [ "$T" ]; then - if [ "$(__detect_shell)" == "zsh" ]; then + if [ "$(__detect_shell)" = "zsh" ]; then set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') else @@ -1833,7 +1833,7 @@ function makerecipe() { repo forall -c ' - if [ "$REPO_REMOTE" == "github" ] + if [ "$REPO_REMOTE" = "github" ] then pwd cmremote @@ -1844,7 +1844,7 @@ function makerecipe() { function cmgerrit() { - if [ "$(__detect_shell)" == "zsh" ]; then + if [ "$(__detect_shell)" = "zsh" ]; then # zsh does not define FUNCNAME, derive from funcstack local FUNCNAME=$funcstack[1] fi @@ -2239,7 +2239,7 @@ function dopush() echo "Device Found." fi - if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD") || [ "$FORCE_PUSH" == "true" ]; + if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD") || [ "$FORCE_PUSH" = "true" ]; then # retrieve IP and PORT info if we're using a TCP connection TCPIPPORT=$(adb devices | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+[^0-9]+' \ -- cgit v1.1 From cbf9692a7105b7876d88aa1aa3fd53506e300300 Mon Sep 17 00:00:00 2001 From: Khalid Zubair Date: Wed, 2 Mar 2016 14:01:45 -0800 Subject: envsetup: fix mm under zsh Fix a word splitting issue in zsh. Instead of building a duplicate ARGS array for the !GET-INSTALL-PATH case, leave it untouched. For the GET-INSTALL-PATH case, modify the argument list as needed. Change-Id: I902ff1bc7a53e7afa8c4737d4208592ac18f95d7 --- envsetup.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index 77f7096..446947f 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -865,7 +865,6 @@ function mm() local M=$(findmakefile) local MODULES= local GET_INSTALL_PATH= - local ARGS= # Remove the path to top as the makefilepath needs to be relative local M=`echo $M|sed 's:'$T'/::'` if [ ! "$T" ]; then @@ -882,12 +881,12 @@ function mm() done if [ -n "$GET_INSTALL_PATH" ]; then MODULES= - ARGS=GET-INSTALL-PATH + # set all args to 'GET-INSTALL-PATH' + set -- GET-INSTALL-PATH else MODULES=all_modules - ARGS=$@ fi - ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS + ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES "$@" fi fi } -- cgit v1.1