diff options
author | Kristina Chodorow <kchodorow@google.com> | 2015-05-18 15:30:30 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2015-05-18 20:02:10 +0000 |
commit | 45a24691406c683cfab5bed30f25de8ef2a8300b (patch) | |
tree | dd68d4b3aecc2af7030c7b16cf411e8bc473f5a0 /compile.sh | |
parent | ec1d70e8dbdd66fca0b2f4b8f062d062dad23270 (diff) |
Set up pkg path for the fetch and query commands in .bazelrc
Fixes #192.
--
MOS_MIGRATED_REVID=93890217
Diffstat (limited to 'compile.sh')
-rwxr-xr-x | compile.sh | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/compile.sh b/compile.sh index 076224a3ce..4bafe268cb 100755 --- a/compile.sh +++ b/compile.sh @@ -62,7 +62,7 @@ function fail() { function log() { if [[ -z "${QUIETMODE}" ]]; then - echo "$1" >&2 + echo -e "$1" >&2 fi } @@ -485,21 +485,25 @@ if [[ $PLATFORM == "darwin" ]]; then fi # Create a bazelrc file with the base_workspace directory in the package path. -package_path="build --package_path %workspace%:$base_workspace" +bazelrc='build --package_path %workspace%:'${base_workspace} +bazelrc="${bazelrc}"$'\nfetch --package_path %workspace%:'${base_workspace} +bazelrc="${bazelrc}"$'\nquery --package_path %workspace%:'${base_workspace} if [ -z "${HOME-}" ]; then warning="No \$HOME variable set, cannot write .bazelrc file." warning="$warning Consider adding $base_workspace to your package path" log $warning elif [ ! -f $HOME/.bazelrc ]; then log "Creating a .bazelrc pointing to $base_workspace" - cat > $HOME/.bazelrc <<EOF -$package_path -EOF + echo "$bazelrc" > $HOME/.bazelrc else - warning="You already have a .bazelrc. please modify it to add " - warning="$warning $base_workspace to your build package path." - old_line=$(fgrep "build --package_path " ~/.bazelrc) || true - [[ $package_path != $old_line ]] && log "$warning" + while read rcline; do + if ! grep -q "$rcline" $HOME/.bazelrc; then + warning="You already have a .bazelrc. Make sure it contains the " + warning="$warning following package paths:\n$bazelrc" + log "$warning" + break + fi + done <<< "$bazelrc" fi # Run "bazel fetch" to bring in the JDK (so users don't have to). |