Skip to content

Commit

Permalink
Add darwin build release script (#799)
Browse files Browse the repository at this point in the history
* add darwin build release script

* add hidden-import for cluster manager in darwin build

* print git branch correctly if checkout to a tag head

Co-authored-by: Tong Zhigao <[email protected]>
  • Loading branch information
birdstorm and solotzg authored Jun 28, 2020
1 parent 1d7117f commit 7e091ba
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ build_docker
docker/builder/tics
release-centos7/tiflash
release-centos7/build-release
release-darwin/tiflash
release-darwin/build-release
tests/docker/data
tests/docker/log
tests/fullstack-test/dml/dml_gen/*
Expand Down
4 changes: 2 additions & 2 deletions cluster_manage/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else
fi

git_hash=`git log -1 --format="%H"`
git_branch=`git symbolic-ref --short HEAD`
git_branch=`git symbolic-ref -q --short HEAD || git describe --tags --exact-match`
version_file='version.py'
git_hash_info="git_hash = '$git_hash'"
overwrite="true"
Expand All @@ -49,4 +49,4 @@ echo "Cluster Manager Version Info"
cat $version_file
echo ""

pyinstaller flash_cluster_manager.py -y
pyinstaller flash_cluster_manager.py -y --hidden-import pkg_resources.py2_warn
2 changes: 1 addition & 1 deletion release-centos7/build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SRCPATH=$(cd ${SCRIPTPATH}/../..; pwd -P)

install_dir="$SRCPATH/release-centos7/tiflash"
if [[ -d "$install_dir" ]]; then rm -rf "$install_dir"/*; else mkdir -p "$install_dir"; fi
if [[ -d "$install_dir" ]]; then rm -rf "${install_dir:?}"/*; else mkdir -p "$install_dir"; fi

${SCRIPTPATH}/build-tiflash-proxy.sh
${SCRIPTPATH}/build-cluster-manager.sh
Expand Down
13 changes: 13 additions & 0 deletions release-darwin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
The executable files are located in `tiflash` dir.

# Deploy Enviroument Requirements

Following OS are tested OK

* MacOS Catalina 10.15.5+

**NOTE** XCode version should be at least XCode 11

Your system needs to install

* python 3.7
12 changes: 12 additions & 0 deletions release-darwin/build/build-cluster-manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -ueox pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SRCPATH=${1:-$(cd $SCRIPTPATH/../..; pwd -P)}

install_dir="$SRCPATH/release-darwin/tiflash"

cd ${SRCPATH}/cluster_manage
./release.sh
cp -r dist/flash_cluster_manager "$install_dir/flash_cluster_manager"
13 changes: 13 additions & 0 deletions release-darwin/build/build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -ueox pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SRCPATH=${1:-$(cd $SCRIPTPATH/../..; pwd -P)}

install_dir="$SRCPATH/release-darwin/tiflash"
if [ -d "$install_dir" ]; then rm -rf "${install_dir:?}"/*; else mkdir -p "$install_dir"; fi

$SCRIPTPATH/build-tiflash-proxy.sh
$SCRIPTPATH/build-cluster-manager.sh
$SCRIPTPATH/build-tiflash-release.sh
10 changes: 10 additions & 0 deletions release-darwin/build/build-tiflash-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -ueox pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SRCPATH=${1:-$(cd $SCRIPTPATH/../..; pwd -P)}
PATH=$PATH:/root/.cargo/bin

cd ${SRCPATH}/contrib/tiflash-proxy
make release
53 changes: 53 additions & 0 deletions release-darwin/build/build-tiflash-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

set -ueo pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SRCPATH=${1:-$(cd $SCRIPTPATH/../..; pwd -P)}
NPROC=${NPROC:-$(sysctl -n hw.physicalcpu || grep -c ^processor /proc/cpuinfo)}
CMAKE_BUILD_TYPE="RELWITHDEBINFO"
ENABLE_EMBEDDED_COMPILER="FALSE"

install_dir="$SRCPATH/release-darwin/tiflash"

if [ -d "$SRCPATH/contrib/kvproto" ]; then
cd "$SRCPATH/contrib/kvproto"
rm -rf cpp/kvproto
./scripts/generate_cpp.sh
cd -
fi

if [ -d "$SRCPATH/contrib/tipb" ]; then
cd "$SRCPATH/contrib/tipb"
rm -rf cpp/tipb
./generate-cpp.sh
cd -
fi

rm -rf ${SRCPATH}/libs/libtiflash-proxy
mkdir -p ${SRCPATH}/libs/libtiflash-proxy
ln -s ${SRCPATH}/contrib/tiflash-proxy/target/release/libtiflash_proxy.dylib ${SRCPATH}/libs/libtiflash-proxy/libtiflash_proxy.dylib

build_dir="$SRCPATH/release-darwin/build-release"
rm -rf $build_dir && mkdir -p $build_dir && cd $build_dir

cmake "$SRCPATH" \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DENABLE_EMBEDDED_COMPILER=$ENABLE_EMBEDDED_COMPILER \
-DENABLE_ICU=OFF \
-DENABLE_MYSQL=OFF \
-Wno-dev

make -j $NPROC

cp -f "$build_dir/dbms/src/Server/tiflash" "$install_dir/tiflash"
cp -f "${SRCPATH}/libs/libtiflash-proxy/libtiflash_proxy.dylib" "$install_dir/libtiflash_proxy.dylib"

FILE="$install_dir/tiflash"
otool -L "$FILE"
cd "$install_dir"
# remove .dylib dependency built in other directories
otool -L ${FILE} | egrep -v "$(otool -D ${FILE})" | egrep -v "/(usr/lib|System)" | grep -o "/.*\.dylib" | while read; do
install_name_tool -change $REPLY @executable_path/"$(basename ${REPLY})" $FILE;
done
otool -L "$FILE"
16 changes: 16 additions & 0 deletions release-darwin/prepare-environments/prepare-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -ueox pipefail

brew install python
# you might need to run with sudo
pip3 install \
pybind11 \
pyinstaller \
dnspython \
uri \
requests \
urllib3 \
toml \
setuptools \
etcd3

0 comments on commit 7e091ba

Please sign in to comment.