1#!/usr/bin/env bash
2
3full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here
4dir=$(dirname "$full_cmd")
5cmd=${full_cmd##*/}
6
7if [ -n "$WORKSPACE" ] && [ -e "$WORKSPACE/Conf/BaseToolsCBinaries" ]
8then
9  exec "$WORKSPACE/Conf/BaseToolsCBinaries/$cmd"
10elif [ -n "$WORKSPACE" ] && [ -e "$EDK_TOOLS_PATH/Source/C" ]
11then
12  if [ ! -e "$EDK_TOOLS_PATH/Source/C/bin/$cmd" ]
13  then
14    echo "BaseTools C Tool binary was not found ($cmd)"
15    echo "You may need to run:"
16    echo "  make -C $EDK_TOOLS_PATH/Source/C"
17  else
18    exec "$EDK_TOOLS_PATH/Source/C/bin/$cmd" "$@"
19  fi
20elif [ -e "$dir/../../Source/C/bin/$cmd" ]
21then
22  exec "$dir/../../Source/C/bin/$cmd" "$@"
23else
24  echo "Unable to find the real '$cmd' to run"
25  echo "This message was printed by"
26  echo "  $0"
27  exit 127
28fi
29
30