Improve tools/run_dev.sh to allow custom flags It is currently impossible or very hard to run tools/run_dev.sh with a jvm debug port open. With this change, one can simply run 'tools/run_dev.sh --debug' to open the default jvm debug port. Change-Id: Ie3702affb3a7ee604cfa2dca6836135e0e8663b7
diff --git a/Documentation/developer-guide.md b/Documentation/developer-guide.md index 5b64e5e..d36a24d 100644 --- a/Documentation/developer-guide.md +++ b/Documentation/developer-guide.md
@@ -70,6 +70,16 @@ http://localhost:8080/ to view your local copy of gitiles, which will serve any repositories under `/path/to/repositories`. +Passing `--debug` option to `tools/run_dev.sh` will suspend the runtime until a +remote debugger connects to port 5005. If you don't want to suspend the +runtime, make sure to assign value `n` to environment variable +`DEFAULT_JVM_DEBUG_SUSPEND`: + +``` +cd /path/to/repositories # Don't run from the gitiles repo. +export DEFAULT_JVM_DEBUG_SUSPEND=n; /path/to/gitiles/tools/run_dev.sh --debug +``` + To run unit tests, refer to the aforementioned bazel test command. ## Pushing your changes
diff --git a/tools/run_dev.sh b/tools/run_dev.sh index 497e9d3..1f4ed5e 100755 --- a/tools/run_dev.sh +++ b/tools/run_dev.sh
@@ -18,9 +18,18 @@ ROOT="$(cd $(dirname "$0")/..; pwd)" PROPERTIES= -if [ "x$1" != "x" ]; then - PROPERTIES="--jvm_flag=-Dcom.google.gitiles.configPath=$1" -fi + +NUMBER_OF_ARGUMENTS=$# +while test $# -gt 0 +do + case "$1" in + --debug) PROPERTIES="$PROPERTIES --debug" + ;; + *) if [ $NUMBER_OF_ARGUMENTS -eq $# ]; then PROPERTIES="$PROPERTIES --jvm_flag=-Dcom.google.gitiles.configPath=$1"; fi + ;; + esac + shift +done PROPERTIES="$PROPERTIES --jvm_flag=-Dcom.google.gitiles.sourcePath=$ROOT" @@ -29,4 +38,5 @@ bazel build java/com/google/gitiles/dev ) +set -x "$ROOT/bazel-bin/java/com/google/gitiles/dev/dev" $PROPERTIES