Add option to flash images from differen out directory
am: dc91c89

* commit 'dc91c89d6d0253dec1ef3ed5cfb63a5695d76d77':
  Add option to flash images from differen out directory

Change-Id: I62a6d038550d74f9930e791954d78f570b9375a3
diff --git a/installer/flash-all.sh b/installer/flash-all.sh
index ae54514..076b580 100755
--- a/installer/flash-all.sh
+++ b/installer/flash-all.sh
@@ -10,7 +10,7 @@
     echo "device: $1 does not exist"
     exit
 fi
-
+DEVICE_PORT=${1}
 PTABLE=ptable-aosp-8g.img
 if [ $# -gt 1 ]
   then
@@ -22,11 +22,34 @@
 
 INSTALLER_DIR="`dirname $0`"
 ANDROID_TOP=${INSTALLER_DIR}/../../../../
-python ${INSTALLER_DIR}/hisi-idt.py --img1=${INSTALLER_DIR}/l-loader.bin -d ${1}
+
+#get out directory path
+while [ $# -ne 0 ]; do
+    case "$1" in
+        --out) OUT_IMGDIR=$2;shift;
+    esac
+    shift
+done
+
+if [ -z $OUT_IMGDIR ]; then
+    if [ ! -z $ANDROID_PRODUCT_OUT ]; then
+        OUT_IMGDIR=${ANDROID_PRODUCT_OUT}
+    else
+        OUT_IMGDIR="${ANDROID_TOP}/out/target/product/hikey"
+    fi
+fi
+
+if [ ! -d $OUT_IMGDIR ]; then
+    echo "error in locating out directory, check if it exist"
+    exit
+fi
+echo "android out dir:$OUT_IMGDIR"
+
+python ${INSTALLER_DIR}/hisi-idt.py --img1=${INSTALLER_DIR}/l-loader.bin -d ${DEVICE_PORT}
 fastboot flash ptable ${INSTALLER_DIR}/${PTABLE}
 fastboot flash fastboot ${INSTALLER_DIR}/fip.bin
 fastboot flash nvme ${INSTALLER_DIR}/nvme.img
-fastboot flash boot ${ANDROID_TOP}/out/target/product/hikey/boot_fat.uefi.img
-fastboot flash system ${ANDROID_TOP}/out/target/product/hikey/system.img
-fastboot flash cache ${ANDROID_TOP}/out/target/product/hikey/cache.img
-fastboot flash userdata ${ANDROID_TOP}/out/target/product/hikey/userdata.img
+fastboot flash boot ${OUT_IMGDIR}/boot_fat.uefi.img
+fastboot flash system ${OUT_IMGDIR}/system.img
+fastboot flash cache ${OUT_IMGDIR}/cache.img
+fastboot flash userdata ${OUT_IMGDIR}/userdata.img