Commit 1e48eb52 authored by Martin Cífka's avatar Martin Cífka
Browse files

script.sh fix

parent ab620b9a
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -2,11 +2,10 @@
set -euo pipefail

outfile="miphoto-exec"
usage=$(echo -e "Usage: run.sh [OPTIONS] \n\t-b\tbuild \n\t-r\tcopy to camera and run \n\t-d DIR\tdirectory with .cpp and .h files")
usage=$(echo -e "Usage: run.sh [OPTIONS] \n\t-b\tbuild \n\t-r\tcopy to camera and run")

build=false
run=false
dir="."

if [ $# -eq 0 ]; then
    echo "$usage"
@@ -14,14 +13,12 @@ if [ $# -eq 0 ]; then
fi


while getopts "brd:" opt; do
while getopts "br" opt; do
  case ${opt} in
    b ) build=true
      ;;
    r ) run=true
      ;;
	d ) dir="$OPTARG"
	  ;;
    \? ) echo "$usage"; exit 1;
      ;;
  esac
@@ -32,11 +29,10 @@ done


if [ "$build" = true ] ; then
	sources=$(ls "$dir/"*.cpp 2>/dev/null) || (echo "No .cpp files found" && exit 1)
	headers=$(ls "$dir/"*.h 2>/dev/null) || true
	sources=$(ls *.cpp 2>/dev/null | tr '\r\n' ' ') || (echo "No .cpp files found" && exit 1)

    sudo docker build -t mi_camera_sdk .
    sudo docker run -it --rm -v "$PWD":/workdir mi_camera_sdk bash -c "arm-linux-gnueabihf-c++ -o /workdir/$outfile $sources"
    sudo docker run -it --rm -v "$PWD":/workdir mi_camera_sdk bash -c "arm-linux-gnueabihf-c++ -std=c++11 -o /workdir/$outfile $sources"
    echo -e "\n"
fi