forked from forknote/cryptonote-generator
-
Notifications
You must be signed in to change notification settings - Fork 7
/
compile.sh
124 lines (98 loc) · 3.65 KB
/
compile.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
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
#! /usr/bin/env bash
# Bash script for change coin files
# Exit immediately if an error occurs, or if an undeclared variable is used
set -o errexit
[ "$OSTYPE" != "win"* ] || die "Windows is not supported"
# Set directory vars
. "vars.cfg"
# Load libs
. "lib/ticktick.sh"
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts "h?f:c:p:" opt; do
case "$opt" in
f) CONFIG_FILE=${OPTARG}
;;
c) COMPILE_ARGS+=${OPTARG}
;;
p) NEW_COIN_PATH=${OPTARG}
;;
esac
done
shift $((OPTIND-1))
if [ -z "${CONFIG_FILE}" ]; then
exit 1
fi
echo "compile:"
echo ${CONFIG_FILE}
echo ${COMPILE_ARGS}
# Set config vars
CONFIG=`cat $CONFIG_FILE`
# File
tickParse "$CONFIG"
daemon_name=``core.daemon_name``
CRYPTONOTE_NAME=``core.CRYPTONOTE_NAME``
BUILD_PATH="${WORK_FOLDERS_PATH}/builds"
MAC_BUILD_NAME="${CRYPTONOTE_NAME}-mac"
LINUX_BUILD_NAME="${CRYPTONOTE_NAME}-linux"
WINDOWS_BUILD_NAME="${CRYPTONOTE_NAME}-windows"
cd ${NEW_COIN_PATH}
rm -rf build; mkdir -p build/release; cd build/release
# Compile!
if [[ "$OSTYPE" == "msys" ]]; then
cmake -DBOOST_ROOT=C:\sdk\boost_1_55_0 -DBOOST_LIBRARYDIR=C:\sdk\boost_1_55_0\lib64-msvc-11.0 -G "Visual Studio 11 Win64" ".."
msbuild.exe Project.sln /p:Configuration=Release ${COMPILE_ARGS}
else
cmake -D STATIC=ON -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=Release ../..
MAKE_STATUS=$( make ${COMPILE_ARGS} )
fi
if [[ $? == "0" ]]; then
echo "Compilation successful"
fi
# Generate genesis
grep -v "GENESIS_COINBASE_TX_HEX" ${NEW_COIN_PATH}/src/cryptonote_config.h > ${NEW_COIN_PATH}/src/cryptonote_config.new
mv ${NEW_COIN_PATH}/src/cryptonote_config.new ${NEW_COIN_PATH}/src/cryptonote_config.h
${NEW_COIN_PATH}/build/release/src/${daemon_name} --print-genesis-tx | grep "GENESIS_COINBASE_TX_HEX" >> ${NEW_COIN_PATH}/src/cryptonote_config.h
echo "New genesis coinbase tx generated. Going to recompile ..."
cd ${NEW_COIN_PATH}/build/release/
# Recompile!
if [[ "$OSTYPE" == "msys" ]]; then
cmake -DBOOST_ROOT=C:\sdk\boost_1_55_0 -DBOOST_LIBRARYDIR=C:\sdk\boost_1_55_0\lib64-msvc-11.0 -G "Visual Studio 11 Win64" ".."
msbuild.exe Project.sln /p:Configuration=Release ${COMPILE_ARGS}
else
cmake -D STATIC=ON -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=Release ../..
MAKE_STATUS=$( make ${COMPILE_ARGS} )
fi
if [[ $? == "0" ]]; then
echo "Recompilation successful"
fi
# Move and zip binaries
case "$OSTYPE" in
msys*) rm -f ${BUILD_PATH}/${WINDOWS_BUILD_NAME}.zip
rm -rf ${BUILD_PATH}/${WINDOWS_BUILD_NAME}
mkdir -p ${BUILD_PATH}/${WINDOWS_BUILD_NAME}
cp ${NEW_COIN_PATH}/build/release/src/${daemon_name} ${BUILD_PATH}/${WINDOWS_BUILD_NAME}
cp ${NEW_COIN_PATH}/build/release/src/simplewallet ${BUILD_PATH}/${WINDOWS_BUILD_NAME}
rm -rf "${NEW_COIN_PATH}/build"
cd ${BUILD_PATH}
zip -r ${WINDOWS_BUILD_NAME}.zip ${WINDOWS_BUILD_NAME}/
;;
darwin*) rm -f ${BUILD_PATH}/${MAC_BUILD_NAME}.zip
rm -rf ${BUILD_PATH}/${MAC_BUILD_NAME}
mkdir -p ${BUILD_PATH}/${MAC_BUILD_NAME}
cp ${NEW_COIN_PATH}/build/release/src/${daemon_name} ${BUILD_PATH}/${MAC_BUILD_NAME}
cp ${NEW_COIN_PATH}/build/release/src/simplewallet ${BUILD_PATH}/${MAC_BUILD_NAME}
rm -rf "${NEW_COIN_PATH}/build"
cd ${BUILD_PATH}
zip -r ${MAC_BUILD_NAME}.zip ${MAC_BUILD_NAME}/
;;
*) rm -r ${BUILD_PATH}/${LINUX_BUILD_NAME}.tar.gz
rm -rf ${BUILD_PATH}/${LINUX_BUILD_NAME}
mkdir -p ${BUILD_PATH}/${LINUX_BUILD_NAME}
cp ${NEW_COIN_PATH}/build/release/src/${daemon_name} ${BUILD_PATH}/${LINUX_BUILD_NAME}
cp ${NEW_COIN_PATH}/build/release/src/simplewallet ${BUILD_PATH}/${LINUX_BUILD_NAME}
rm -rf "${NEW_COIN_PATH}/build"
cd ${BUILD_PATH}
tar -zcvf ${LINUX_BUILD_NAME}.tar.gz ${LINUX_BUILD_NAME}
;;
esac