Additional parameter options for building Tulsi

Allows users to specify where Tulsi should be unzipped to after install using the `-d` option and allows them to specify the Bazel path to use with the `-b` option

Closes https://github.com/bazelbuild/tulsi/pull/151.

PiperOrigin-RevId: 315557493
diff --git a/.bazelrc b/.bazelrc
index fe92af6..ab068fb 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1,6 +1,5 @@
 build --cpu=darwin_x86_64
 build --apple_platform_type=macos
-build --xcode_version=11.3.1
 
 # Disable the Swift compilation worker when running integration tests, since it
 # requires the protobuf dependency which is infeasible to get working on Bazel.
diff --git a/README.md b/README.md
index 938fd80..b04e6e3 100644
--- a/README.md
+++ b/README.md
@@ -9,11 +9,11 @@
 
 ## Building and installing
 
-1.  Check `.bazelrc` to see if the Xcode version used by Tulsi is installed
-    locally. If it isn't, feel free to remove the `--xcode_version` flag or
-    modify it as you wish, but note that Tulsi may not build correctly with
-    different versions of Xcode.
-1.  Run `build_and_run.sh`. This will install Tulsi.app inside ~/Applications.
+Run `build_and_run.sh`. This will install Tulsi.app inside `$HOME/Applications` by default. See below for supported options:
+
+* `-b`: Bazel binary that Tulsi should use to build and install the app (Default is `bazel`)
+* `-d`: The folder where to install the Tulsi app into (Default is `$HOME/Applications`)
+* `-x`: The Xcode version Tulsi should be built for (Default is `11.3.1`)
 
 
 ## Notes
diff --git a/build_and_run.sh b/build_and_run.sh
index d124e4c..c208db1 100755
--- a/build_and_run.sh
+++ b/build_and_run.sh
@@ -21,11 +21,34 @@
 
 set -eu
 
-readonly unzip_dir="${1:-$HOME/Applications}"
+unzip_dir="$HOME/Applications"
+bazel_path="bazel"
+xcode_version="11.3.1"
+
+while getopts ":b:d:x:h" opt; do
+  case ${opt} in
+    h)
+      echo "Usage:"
+      echo "    ./build_and_run -h          Display this help message."
+      echo "    ./build_and_run -b PATH     Bazel binary used to build Tulsi"
+      echo "    ./build_and_run -d PATH     Intall Tulsi App at the provided path"
+      echo "    ./build_and_run -x VERSION  Xcode version Tulsi should be built for"
+      exit 0
+      ;;
+    b) bazel_path=$OPTARG;;
+    d) unzip_dir=$OPTARG;;
+    x) xcode_version=$OPTARG;;
+    ?)
+      echo "Invalid Option: -$OPTARG" 1>&2
+      exit 1
+      ;;
+  esac
+done
+shift $((OPTIND -1))
 
 # build it
-bazel build //:tulsi --use_top_level_targets_for_symlinks
+$bazel_path build //:tulsi --use_top_level_targets_for_symlinks --xcode_version=$xcode_version
 # unzip it
-unzip -oq $(bazel info workspace)/bazel-bin/tulsi.zip -d "$unzip_dir"
+unzip -oq $("$bazel_path" info workspace)/bazel-bin/tulsi.zip -d "$unzip_dir"
 # run it
 open "$unzip_dir/Tulsi.app"