diff --git a/.gitignore b/.gitignore index 2fb6793d7ab..a2fea1c77d9 100644 --- a/.gitignore +++ b/.gitignore @@ -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/* diff --git a/cluster_manage/release.sh b/cluster_manage/release.sh index c29542e46eb..19fb3e4a90f 100755 --- a/cluster_manage/release.sh +++ b/cluster_manage/release.sh @@ -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" @@ -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 diff --git a/release-centos7/build/build-release.sh b/release-centos7/build/build-release.sh index a6018bfc4ef..a334d8d92a5 100755 --- a/release-centos7/build/build-release.sh +++ b/release-centos7/build/build-release.sh @@ -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 diff --git a/release-darwin/README.md b/release-darwin/README.md new file mode 100644 index 00000000000..45d693909e6 --- /dev/null +++ b/release-darwin/README.md @@ -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 diff --git a/release-darwin/build/build-cluster-manager.sh b/release-darwin/build/build-cluster-manager.sh new file mode 100755 index 00000000000..048b4bdfdda --- /dev/null +++ b/release-darwin/build/build-cluster-manager.sh @@ -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" diff --git a/release-darwin/build/build-release.sh b/release-darwin/build/build-release.sh new file mode 100755 index 00000000000..8a5465827c6 --- /dev/null +++ b/release-darwin/build/build-release.sh @@ -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 diff --git a/release-darwin/build/build-tiflash-proxy.sh b/release-darwin/build/build-tiflash-proxy.sh new file mode 100755 index 00000000000..e1e2ba8df56 --- /dev/null +++ b/release-darwin/build/build-tiflash-proxy.sh @@ -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 diff --git a/release-darwin/build/build-tiflash-release.sh b/release-darwin/build/build-tiflash-release.sh new file mode 100755 index 00000000000..0d25cbf61cf --- /dev/null +++ b/release-darwin/build/build-tiflash-release.sh @@ -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" diff --git a/release-darwin/prepare-environments/prepare-python.sh b/release-darwin/prepare-environments/prepare-python.sh new file mode 100755 index 00000000000..2d735df7499 --- /dev/null +++ b/release-darwin/prepare-environments/prepare-python.sh @@ -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