Mac install protobuf

2017-06-04  本文已影响97人  滴滴时光
#!/usr/bin/env bash

# Usage: sudo ./install_protobuf.sh

warn () {
    echo "$*"
}

die () {
    echo "$*"
    exit 1
}

echo "git clone git@github.com:google/protobuf.git" 

git clone git@github.com:google/protobuf.git

if [[ $? -ne 0 ]]; then
  die "fetch protobuf source code failed."
fi

cd protobuf

if [[ $? -ne 0 ]]; then
  die "cd protobuf failed."
fi

./autogen.sh
./configure

make

if [[ $? -ne 0 ]]; then
  die "make failed."
fi

make check

if [[ $? -ne 0 ]]; then
  die "make check faild."
fi

sudo make install

if [[ $? -ne 0 ]]; then
  die "sudo make install failed."
fi

# Refresh shared library cache
sudo ldconfig 

echo "begin build python lib"

cd python

python --version
protoc --version

python setup.py build --cpp_implementation

if [[ $? -ne 0 ]]; then
    die "python setup.py build --cpp_implementation failed."
fi

python setup.py test --cpp_implementation

if [[ $? -ne 0 ]]; then
    die "python setup.py test --cpp_implementation failed."
fi

python setup.py install --cpp_implementation

if [[ $? -eq 0 ]]; then 
    echo "Done"
fi
上一篇 下一篇

猜你喜欢

热点阅读