view misc/mymake.sh @ 558:9a961c5ba31c

Improve performance by eliminating unnecessary checks for file existing.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Wed, 16 Oct 2013 18:57:50 +0300
parents f57d4fb7d7c5
children 204a1812d0d9
line wrap: on
line source

#!/bin/bash

shopt -s extglob

opt=
for (( i=2; i <= ${#@}; i++ )); do
  if [[ ${@:$i-1:1} = -f ]]; then
    fname=${@:$i:1}
    break;
  fi
done

execute() {
  echo "** cd $PWD"
  echo "**" "$@"
  exec "$@"
}

dir="$PWD"
while [[ -n "$dir" ]]; do
  cd "$dir"
  if [[ $fname == *[mM]ake* ]]; then
    if [[ -f "$dir"/"$fname" ]]; then
      execute make "$@"
    fi
  fi
  if [[ -f "$dir"/Makefile ]]; then
    execute make "$@"
  fi
  if [[ -f "$dir"/build.xml ]]; then
    execute ant -e "$@"
  fi
  if [[ -f "$dir"/pom.xml ]]; then
    execute mvn "$@"
  fi
  dir=${dir%/*}
done

echo "Doesn't found any build scripts."
exit 1