[tools][twine] Build twine gem before usage

Signed-off-by: Viacheslav Greshilov <slovaricheg@gmail.com>
This commit is contained in:
Viacheslav Greshilov 2021-07-21 00:13:18 +03:00 committed by Alexander Borsuk
parent 25e8fa67f6
commit 40f936adbd

View file

@ -2,19 +2,47 @@
set -e -u -x
# Use ruby from brew on Mac OS X, because system ruby is outdated/broken/will be removed in future releases.
case $OSTYPE in darwin*)
if [ -x /usr/local/opt/ruby/bin/ruby ]; then
PATH="/usr/local/opt/ruby/bin:$PATH"
elif [ -x /opt/homebrew/opt/ruby/bin/ruby ]; then
PATH="/opt/homebrew/opt/ruby/bin:$PATH"
else
echo 'Please install Homebrew ruby by running "brew install ruby"'
exit -1
fi
case $OSTYPE in
darwin*)
if [ -x /usr/local/opt/ruby/bin/ruby ]; then
PATH="/usr/local/opt/ruby/bin:$PATH"
elif [ -x /opt/homebrew/opt/ruby/bin/ruby ]; then
PATH="/opt/homebrew/opt/ruby/bin:$PATH"
else
echo 'Please install Homebrew ruby by running "brew install ruby"'
exit -1
fi ;;
*)
if [ ! -x "$(which ruby)" ]; then
echo "Please, install ruby (https://www.ruby-lang.org/en/documentation/installation/)"
exit 1
fi ;;
esac
OMIM_PATH="$(dirname "$0")/../.."
TWINE="$OMIM_PATH/tools/twine/twine"
TWINE_SUBMODULE=tools/twine
TWINE_PATH="$OMIM_PATH/$TWINE_SUBMODULE"
if [ ! -e "$TWINE_PATH/twine" ]; then
echo "You need to have twine submodule present to run this script"
echo "Try 'git submodule update --init --recursive'"
exit 1
fi
TWINE_COMMIT="$(git rev-parse HEAD:$TWINE_SUBMODULE)"
TWINE_GEM="twine-$TWINE_COMMIT.gem"
if [ ! -f "$TWINE_PATH/$TWINE_GEM" ] || ! gem list -i twine; then
echo "Building & installing twine gem..."
(
cd $TWINE_PATH \
&& rm -f *.gem \
&& gem build --output $TWINE_GEM \
&& gem install $TWINE_GEM
)
fi
TWINE="$(gem contents twine | grep -m 1 bin/twine)"
STRINGS_PATH="$OMIM_PATH/data/strings"
MERGED_FILE="$(mktemp)"