-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sh
executable file
·62 lines (51 loc) · 1.48 KB
/
build.sh
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
#! /bin/bash
print_usage(){
echo "usage:"
echo "$ ./build.sh bos.cdt # compile with bos.cdt"
echo "$ ./build.sh eosio.cdt # compile with eosio.cdt"
echo ""
echo "If deploy them on a hub chain, you need to compile with the hub protocol."
echo "$ ./build.sh bos.cdt HUB_PROTOCOL=ON"
echo "$ ./build.sh eosio.cdt HUB_PROTOCOL=ON"
}
eosio_cdt_version=1.5
bos_cdt_version=3.0.1
if [ $# -gt 2 ];then
echo "too much arguments" && exit 0
fi
if [ "$1" == "bos.cdt" ];then
cdt_version=${bos_cdt_version}
elif [ "$1" == "eosio.cdt" ];then
cdt_version=${eosio_cdt_version}
else
print_usage && exit 0
fi
ARCH=$( uname )
unset set_tag
replace_in_file(){
if [ "$ARCH" == "Darwin" ]; then
sed -i '' "s/$1/$2/g" ./CMakeLists.txt
else
sed -i "s/$1/$2/g" ./CMakeLists.txt
fi
}
sed 's/set(EOSIO_CDT_VERSION_MIN.*/set(EOSIO_CDT_VERSION_MIN '${cdt_version}')/g' ./CMakeLists_gen.txt > CMakeLists.txt
replace_in_file "set(EOSIO_CDT_VERSION_SOFT_MAX.*" 'set(EOSIO_CDT_VERSION_SOFT_MAX '${cdt_version}')'
if [ $# -eq 2 ];then
if [ "$2" == "HUB_PROTOCOL=ON" ];then
replace_in_file "HUB_PROTOCOL_SWITCH" "add_definitions(-DHUB)"
else
echo "unknown parameter: " $2 && exit 0
fi
else
replace_in_file "HUB_PROTOCOL_SWITCH" ""
fi
printf "\t=========== building ibc_contracts ===========\n\n"
RED='\033[0;31m'
NC='\033[0m'
CORES=`getconf _NPROCESSORS_ONLN`
mkdir -p build
pushd build &> /dev/null
cmake ../
make -j${CORES}
popd &> /dev/null