Skip to content

Commit

Permalink
Add logic to buckw to update buck and build it if needed (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
kageiit authored Jul 10, 2017
1 parent bc0e08b commit 469c870
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .buckversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bd7dec472d385279ea961789eaf72bc655ca9213
f685044b764341d952491529c167403e3c3adba6
22 changes: 21 additions & 1 deletion buckw
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##
## Buck wrapper script to invoke okbuck when needed, before running buck
##
## Created by OkBuck Gradle Plugin on : Wed Apr 19 21:13:00 PDT 2017
## Created by OkBuck Gradle Plugin on : Mon Jul 10 10:22:56 PDT 2017
##
#########################################################################

Expand Down Expand Up @@ -162,6 +162,26 @@ setupBuckBinary ( ) {
cd -
fi
# Check for current buck version
BUCK_VERSION=$(cat .buckversion)
if [[ ! -z "$BUCK_VERSION" ]]; then
pushd "$BUCK_HOME" >/dev/null
CURRENT_BUCK_VERSION=$(git rev-parse HEAD)
if [[ "$BUCK_VERSION" != "$CURRENT_BUCK_VERSION" ]]; then
info "BUCK VERSION IS AT $CURRENT_BUCK_VERSION , BUT IT SHOULD BE $BUCK_VERSION. UPDATING BUCK"
git clean -fdx --quiet && git reset --hard --quiet && git fetch --all && git checkout "$BUCK_VERSION" --quiet
fi
popd >/dev/null
fi
# Build buck if needed
if [[ ! -f "$BUCK_HOME/build/successful-build" ]]; then
echo "Buck does not appear to have been built -- building Buck!"
pushd "$BUCK_HOME" >/dev/null
mkdir -p build && ant > build/ant.log && success "BUCK BUILT SUCCESFULLY" || die "FAILED TO BUILD BUCK"
popd >/dev/null
fi
BUCK_BINARY="$BUCK_HOME/bin/buck"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,26 @@ setupBuckBinary ( ) {
cd -
fi
# Check for current buck version
BUCK_VERSION=$(cat .buckversion)
if [[ ! -z "$BUCK_VERSION" ]]; then
pushd "$BUCK_HOME" >/dev/null
CURRENT_BUCK_VERSION=$(git rev-parse HEAD)
if [[ "$BUCK_VERSION" != "$CURRENT_BUCK_VERSION" ]]; then
info "BUCK VERSION IS AT $CURRENT_BUCK_VERSION , BUT IT SHOULD BE $BUCK_VERSION. UPDATING BUCK"
git clean -fdx --quiet && git reset --hard --quiet && git fetch --all && git checkout "$BUCK_VERSION" --quiet
fi
popd >/dev/null
fi
# Build buck if needed
if [[ ! -f "$BUCK_HOME/build/successful-build" ]]; then
echo "Buck does not appear to have been built -- building Buck!"
pushd "$BUCK_HOME" >/dev/null
mkdir -p build && ant > build/ant.log && success "BUCK BUILT SUCCESFULLY" || die "FAILED TO BUILD BUCK"
popd >/dev/null
fi
BUCK_BINARY="$BUCK_HOME/bin/buck"
fi
}
Expand Down

0 comments on commit 469c870

Please sign in to comment.