summaryrefslogtreecommitdiff
path: root/storage/tokudb/scripts/make.mysql.debug.env.bash
blob: b7c270cfbd7fbf40c273fb07a5601f7717f93012 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash

set -e -u

function usage() {
    echo "build a debug mysql in the current directory"
    echo "with default parameters it builds a debug $mysql-$mysql_tree"
    echo "--git_tag=$git_tag"
    echo "--mysql=$mysql --mysql_tree=$mysql_tree"
    echo "--tokudbengine=$tokudbengine --tokudbengine_tree=$tokudbengine_tree"
    echo "--ftindex=$ftindex --ftindex_tree=$ftindex_tree"
    echo "--jemalloc=$jemalloc --jemalloc_tree=$jemalloc_tree"
    echo "--backup=$backup --backup_tree=$backup_tree"
    echo "--cc=$cc --cxx=$cxx"
    echo "--local_cache_dir=$local_cache_dir --local_cache_update=$local_cache_update"
    echo "--cmake_valgrind=$cmake_valgrind --cmake_debug_paranoid=$cmake_debug_paranoid"
}

function github_clone() {
    local repo=
    if [ $# -gt 0 ] ; then repo=$1; shift; else test 0 = 1; return; fi
    local tree=
    if [ $# -gt 0 ] ; then tree=$1; shift; else test 0 = 1; return; fi
    local destdir=
    if [ $# -gt 0 ] ; then destdir=$1; shift; fi
    if [[ -z "$local_cache_dir" ]] ; then
        git clone git@github.com:Tokutek/$repo $destdir
        if [ $? != 0 ] ; then test 0 = 1; return; fi
    else
        if (( "$local_cache_update" )) ; then
            pushd $local_cache_dir/$repo.git
            git fetch --all -f -p -v
            git fetch --all -f -p -v -t
            popd
        fi
        git clone --reference $local_cache_dir/$repo.git git@github.com:Tokutek/$repo $destdir
        if [ $? != 0 ] ; then test 0 = 1; return; fi
    fi

    if [ -z "$destdir" ] ; then pushd $repo; else pushd $destdir; fi
    if [ -z "$git_tag" ] ; then
        if ! git branch | grep "\<$tree\>" > /dev/null && git branch -a | grep "remotes/origin/$tree\>" > /dev/null; then
            git checkout --track origin/$tree
        else
            git checkout $tree
        fi
    else
        git checkout $git_tag
    fi
    if [ $? != 0 ] ; then test 0 = 1; return; fi
    popd
}

# shopt -s compat31 2>/dev/null

git_tag=
mysql=mysql-5.5
mysql_tree=mysql-5.5.35
jemalloc=jemalloc
jemalloc_tree=3.6.0
tokudbengine=tokudb-engine
tokudbengine_tree=master
ftindex=ft-index
ftindex_tree=master
backup=backup-community
backup_tree=master
cc=gcc
cxx=g++
local_cache_dir=
local_cache_update=1
cmake_valgrind=
cmake_debug_paranoid=

while [ $# -ne 0 ] ; do
    arg=$1; shift
    if [[ $arg =~ ^--(.*)=(.*) ]] ; then
        eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]};
    else
        usage; exit 1;
    fi
done

if [[ $mysql =~ ^(.*)-(([0-9]+\.[0-9]+)\.[0-9]+.*)$ ]] ; then
    mysql=${BASH_REMATCH[1]}-${BASH_REMATCH[3]}
    mysql_tree=${BASH_REMATCH[1]}-${BASH_REMATCH[2]}
fi

# setup environment variables
build_dir=$PWD/build
mkdir $build_dir
if [ $? != 0 ] ; then exit 1; fi
install_dir=$PWD/install
mkdir $install_dir
if [ $? != 0 ] ; then exit 1; fi

# checkout the fractal tree
github_clone $ftindex $ftindex_tree

# checkout jemalloc
github_clone $jemalloc $jemalloc_tree

# checkout mysql
github_clone $mysql $mysql_tree $mysql_tree

# checkout the community backup
github_clone $backup $backup_tree

# checkout the tokudb handlerton
github_clone $tokudbengine $tokudbengine_tree

# setup links'
pushd $tokudbengine/storage/tokudb
if [ $? != 0 ] ; then exit 1; fi
ln -s ../../../$ftindex ft-index
if [ $? != 0 ] ; then exit 1; fi
popd
pushd $mysql_tree/storage
if [ $? != 0 ] ; then exit 1; fi
ln -s ../../$tokudbengine/storage/tokudb tokudb
if [ $? != 0 ] ; then exit 1; fi
popd
pushd $mysql_tree
if [ $? != 0 ] ; then exit 1; fi
ln -s ../$backup/backup toku_backup
if [ $? != 0 ] ; then exit 1; fi
popd
pushd $mysql_tree/scripts
if [ $? != 0 ] ; then exit 1; fi
ln ../../$tokudbengine/scripts/tokustat.py
if [ $? != 0 ] ; then exit 1; fi
ln ../../$tokudbengine/scripts/tokufilecheck.py
if [ $? != 0 ] ; then exit 1; fi
popd
if [[ $mysql =~ mariadb ]] || [[ $mysql_tree =~ mariadb ]] ; then
    pushd $mysql_tree/extra
    if [ $? != 0 ] ; then exit 1; fi
    ln -s ../../$jemalloc $jemalloc
    if [ $? != 0 ] ; then exit 1; fi
    popd
else
    pushd $ftindex/third_party
    if [ $? != 0 ] ; then exit 1; fi
    ln -s ../../$jemalloc $jemalloc
    if [ $? != 0 ] ; then exit 1; fi
    popd
fi

pushd $build_dir
if [ $? != 0 ] ; then exit 1; fi
extra_cmake_options="-DCMAKE_LINK_DEPENDS_NO_SHARED=ON"
if (( $cmake_valgrind )) ; then
    extra_cmake_options+=" -DUSE_VALGRIND=ON"
fi
if (( $cmake_debug_paranoid )) ; then
    extra_cmake_options+=" -DTOKU_DEBUG_PARANOID=ON"
fi
CC=$cc CXX=$cxx cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$install_dir -DBUILD_TESTING=OFF $extra_cmake_options ../$mysql_tree
if [ $? != 0 ] ; then exit 1; fi
make -j4 install
if [ $? != 0 ] ; then exit 1; fi
popd

pushd $install_dir
scripts/mysql_install_db --defaults-file=$HOME/$(whoami).cnf
popd