2016-05-17 15:03:59 +02:00
|
|
|
#!/bin/bash
|
2016-10-09 20:49:56 +02:00
|
|
|
MONERO_URL=https://github.com/monero-project/monero.git
|
|
|
|
MONERO_BRANCH=master
|
2017-01-16 21:30:29 +01:00
|
|
|
|
|
|
|
pushd $(pwd)
|
|
|
|
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
source $ROOT_DIR/utils.sh
|
|
|
|
|
|
|
|
INSTALL_DIR=$ROOT_DIR/wallet
|
|
|
|
MONERO_DIR=$ROOT_DIR/monero
|
|
|
|
BUILD_LIBWALLET=false
|
|
|
|
|
|
|
|
# init and update monero submodule
|
|
|
|
if [ ! -d $MONERO_DIR/src ]; then
|
|
|
|
git submodule init monero
|
|
|
|
fi
|
2017-05-06 13:23:45 +02:00
|
|
|
git submodule update --remote
|
2018-03-31 10:19:58 +02:00
|
|
|
git -C $MONERO_DIR fetch
|
2019-08-06 22:00:43 +02:00
|
|
|
git -C $MONERO_DIR checkout origin/master
|
2017-01-16 21:30:29 +01:00
|
|
|
|
|
|
|
# get monero core tag
|
2018-10-24 21:27:52 +02:00
|
|
|
pushd $MONERO_DIR
|
2017-01-16 21:30:29 +01:00
|
|
|
get_tag
|
2018-10-24 21:27:52 +02:00
|
|
|
popd
|
2017-01-16 21:30:29 +01:00
|
|
|
# create local monero branch
|
|
|
|
git -C $MONERO_DIR checkout -B $VERSIONTAG
|
|
|
|
|
|
|
|
# Merge monero PR dependencies
|
|
|
|
|
|
|
|
# Workaround for git username requirements
|
|
|
|
# Save current user settings and revert back when we are done with merging PR's
|
2017-01-30 23:33:04 +01:00
|
|
|
OLD_GIT_USER=$(git -C $MONERO_DIR config --local user.name)
|
2017-01-16 21:30:29 +01:00
|
|
|
OLD_GIT_EMAIL=$(git -C $MONERO_DIR config --local user.email)
|
|
|
|
git -C $MONERO_DIR config user.name "Monero GUI"
|
|
|
|
git -C $MONERO_DIR config user.email "gui@monero.local"
|
|
|
|
# check for PR requirements in most recent commit message (i.e requires #xxxx)
|
|
|
|
for PR in $(git log --format=%B -n 1 | grep -io "requires #[0-9]*" | sed 's/[^0-9]*//g'); do
|
|
|
|
echo "Merging monero push request #$PR"
|
|
|
|
# fetch pull request and merge
|
|
|
|
git -C $MONERO_DIR fetch origin pull/$PR/head:PR-$PR
|
|
|
|
git -C $MONERO_DIR merge --quiet PR-$PR -m "Merge monero PR #$PR"
|
|
|
|
BUILD_LIBWALLET=true
|
|
|
|
done
|
|
|
|
|
|
|
|
# revert back to old git config
|
2017-01-30 23:33:04 +01:00
|
|
|
$(git -C $MONERO_DIR config user.name "$OLD_GIT_USER")
|
2017-01-16 21:30:29 +01:00
|
|
|
$(git -C $MONERO_DIR config user.email "$OLD_GIT_EMAIL")
|
|
|
|
|
2018-11-27 06:37:22 +01:00
|
|
|
git -C $MONERO_DIR submodule init
|
|
|
|
git -C $MONERO_DIR submodule update
|
|
|
|
|
2017-01-16 21:30:29 +01:00
|
|
|
# Build libwallet if it doesnt exist
|
|
|
|
if [ ! -f $MONERO_DIR/lib/libwallet_merged.a ]; then
|
|
|
|
echo "libwallet_merged.a not found - Building libwallet"
|
|
|
|
BUILD_LIBWALLET=true
|
|
|
|
# Build libwallet if no previous version file exists
|
|
|
|
elif [ ! -f $MONERO_DIR/version.sh ]; then
|
|
|
|
echo "monero/version.h not found - Building libwallet"
|
|
|
|
BUILD_LIBWALLET=true
|
|
|
|
## Compare previously built version with submodule + merged PR's version.
|
|
|
|
else
|
|
|
|
source $MONERO_DIR/version.sh
|
|
|
|
# compare submodule version with latest build
|
|
|
|
pushd "$MONERO_DIR"
|
|
|
|
get_tag
|
|
|
|
popd
|
|
|
|
echo "latest libwallet version: $GUI_MONERO_VERSION"
|
|
|
|
echo "Installed libwallet version: $VERSIONTAG"
|
|
|
|
# check if recent
|
|
|
|
if [ "$VERSIONTAG" != "$GUI_MONERO_VERSION" ]; then
|
|
|
|
echo "Building new libwallet version $GUI_MONERO_VERSION"
|
|
|
|
BUILD_LIBWALLET=true
|
|
|
|
else
|
|
|
|
echo "latest libwallet ($GUI_MONERO_VERSION) is already built. Remove monero/lib/libwallet_merged.a to force rebuild"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BUILD_LIBWALLET" != true ]; then
|
2018-07-19 22:06:48 +02:00
|
|
|
exit 0
|
2017-01-16 21:30:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "GUI_MONERO_VERSION=\"$VERSIONTAG\"" > $MONERO_DIR/version.sh
|
|
|
|
|
|
|
|
## Continue building libwallet
|
2016-12-22 10:10:03 +01:00
|
|
|
|
|
|
|
# default build type
|
2016-10-06 23:46:42 +02:00
|
|
|
BUILD_TYPE=$1
|
|
|
|
if [ -z $BUILD_TYPE ]; then
|
2016-12-22 10:10:03 +01:00
|
|
|
BUILD_TYPE=release
|
|
|
|
fi
|
|
|
|
|
2018-12-17 22:10:21 +01:00
|
|
|
BUILD_TREZOR_FLAGS=" -DUSE_DEVICE_TREZOR=ON"
|
|
|
|
if [ "$BUILD_TREZOR" == false ]; then
|
|
|
|
BUILD_TREZOR_FLAGS=" -DUSE_DEVICE_TREZOR=OFF"
|
|
|
|
fi
|
2019-03-15 14:21:37 +01:00
|
|
|
BUILD_TREZOR_FLAGS=" -DUSE_DEVICE_TREZOR_UDP_RELEASE=ON ${BUILD_TREZOR_FLAGS}"
|
2018-12-17 22:10:21 +01:00
|
|
|
|
2016-12-22 10:10:03 +01:00
|
|
|
STATIC=false
|
2017-01-01 05:55:49 +01:00
|
|
|
ANDROID=false
|
2016-12-22 10:10:03 +01:00
|
|
|
if [ "$BUILD_TYPE" == "release" ]; then
|
|
|
|
echo "Building libwallet release"
|
|
|
|
CMAKE_BUILD_TYPE=Release
|
|
|
|
elif [ "$BUILD_TYPE" == "release-static" ]; then
|
|
|
|
echo "Building libwallet release-static"
|
|
|
|
CMAKE_BUILD_TYPE=Release
|
|
|
|
STATIC=true
|
2017-01-01 05:55:49 +01:00
|
|
|
elif [ "$BUILD_TYPE" == "release-android" ]; then
|
|
|
|
echo "Building libwallet release-static for ANDROID"
|
|
|
|
CMAKE_BUILD_TYPE=Release
|
|
|
|
STATIC=true
|
|
|
|
ANDROID=true
|
|
|
|
elif [ "$BUILD_TYPE" == "debug-android" ]; then
|
|
|
|
echo "Building libwallet debug-static for ANDROID"
|
|
|
|
CMAKE_BUILD_TYPE=Debug
|
|
|
|
STATIC=true
|
|
|
|
ANDROID=true
|
2016-12-22 10:10:03 +01:00
|
|
|
elif [ "$BUILD_TYPE" == "debug" ]; then
|
|
|
|
echo "Building libwallet debug"
|
|
|
|
CMAKE_BUILD_TYPE=Debug
|
2017-05-30 18:29:26 +02:00
|
|
|
STATIC=true
|
2016-12-22 10:10:03 +01:00
|
|
|
else
|
2017-01-01 05:55:49 +01:00
|
|
|
echo "Valid build types are release, release-static, release-android, debug-android and debug"
|
2016-12-22 10:10:03 +01:00
|
|
|
exit 1;
|
2016-10-06 23:46:42 +02:00
|
|
|
fi
|
2016-12-22 10:10:03 +01:00
|
|
|
|
|
|
|
|
2016-09-19 15:45:34 +02:00
|
|
|
echo "cleaning up existing monero build dir, libs and includes"
|
2017-11-08 10:49:31 +01:00
|
|
|
rm -fr $MONERO_DIR/build
|
2016-09-19 15:45:34 +02:00
|
|
|
rm -fr $MONERO_DIR/lib
|
|
|
|
rm -fr $MONERO_DIR/include
|
2016-12-09 09:42:12 +01:00
|
|
|
rm -fr $MONERO_DIR/bin
|
|
|
|
|
2016-08-24 20:31:43 +02:00
|
|
|
|
2018-03-03 23:56:38 +01:00
|
|
|
mkdir -p $MONERO_DIR/build/$BUILD_TYPE
|
|
|
|
pushd $MONERO_DIR/build/$BUILD_TYPE
|
2016-05-17 15:03:59 +02:00
|
|
|
|
2016-09-22 20:39:43 +02:00
|
|
|
# reusing function from "utils.sh"
|
|
|
|
platform=$(get_platform)
|
2016-11-23 22:30:36 +01:00
|
|
|
# default make executable
|
|
|
|
make_exec="make"
|
2016-12-22 10:10:03 +01:00
|
|
|
|
|
|
|
## OS X
|
2016-09-22 20:39:43 +02:00
|
|
|
if [ "$platform" == "darwin" ]; then
|
|
|
|
echo "Configuring build for MacOS.."
|
2016-12-22 10:10:03 +01:00
|
|
|
if [ "$STATIC" == true ]; then
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
else
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
## LINUX 64
|
2016-12-15 14:56:33 +01:00
|
|
|
elif [ "$platform" == "linux64" ]; then
|
2016-12-21 07:23:05 +01:00
|
|
|
echo "Configuring build for Linux x64"
|
2017-01-01 05:55:49 +01:00
|
|
|
if [ "$ANDROID" == true ]; then
|
|
|
|
echo "Configuring build for Android on Linux host"
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="armv7-a" -D ANDROID=true -D BUILD_GUI_DEPS=ON -D USE_LTO=OFF -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2017-01-01 05:55:49 +01:00
|
|
|
elif [ "$STATIC" == true ]; then
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
else
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
## LINUX 32
|
2016-12-15 14:56:33 +01:00
|
|
|
elif [ "$platform" == "linux32" ]; then
|
2016-12-21 07:23:05 +01:00
|
|
|
echo "Configuring build for Linux i686"
|
2016-12-22 10:10:03 +01:00
|
|
|
if [ "$STATIC" == true ]; then
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
else
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
fi
|
|
|
|
|
2017-01-27 18:10:08 +01:00
|
|
|
## LINUX ARMv7
|
|
|
|
elif [ "$platform" == "linuxarmv7" ]; then
|
|
|
|
echo "Configuring build for Linux armv7"
|
|
|
|
if [ "$STATIC" == true ]; then
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2017-01-27 18:10:08 +01:00
|
|
|
else
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2017-01-27 18:10:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
## LINUX other
|
2016-12-21 07:23:05 +01:00
|
|
|
elif [ "$platform" == "linux" ]; then
|
|
|
|
echo "Configuring build for Linux general"
|
2016-12-22 10:10:03 +01:00
|
|
|
if [ "$STATIC" == true ]; then
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
else
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
## Windows 64
|
|
|
|
## Windows is always static to work outside msys2
|
2016-09-22 20:39:43 +02:00
|
|
|
elif [ "$platform" == "mingw64" ]; then
|
2016-07-01 14:02:19 +02:00
|
|
|
# Do something under Windows NT platform
|
2016-09-22 20:39:43 +02:00
|
|
|
echo "Configuring build for MINGW64.."
|
2016-12-18 14:07:02 +01:00
|
|
|
BOOST_ROOT=/mingw64/boost
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BOOST_ROOT="$BOOST_ROOT" -D ARCH="x86-64" -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" -G "MSYS Makefiles" -D CMAKE_TOOLCHAIN_FILE=../../cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys64 ../..
|
2016-12-22 10:10:03 +01:00
|
|
|
|
|
|
|
## Windows 32
|
2016-09-22 20:39:43 +02:00
|
|
|
elif [ "$platform" == "mingw32" ]; then
|
2016-07-01 14:02:19 +02:00
|
|
|
# Do something under Windows NT platform
|
2016-09-22 20:39:43 +02:00
|
|
|
echo "Configuring build for MINGW32.."
|
2016-12-18 14:07:02 +01:00
|
|
|
BOOST_ROOT=/mingw32/boost
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D Boost_DEBUG=ON -D BOOST_ROOT="$BOOST_ROOT" -D ARCH="i686" -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" -G "MSYS Makefiles" -D CMAKE_TOOLCHAIN_FILE=../../cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys32 ../..
|
2016-11-23 22:30:36 +01:00
|
|
|
make_exec="mingw32-make"
|
2016-09-22 20:39:43 +02:00
|
|
|
else
|
2017-01-27 18:10:08 +01:00
|
|
|
echo "Unknown platform, configuring general build"
|
|
|
|
if [ "$STATIC" == true ]; then
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2017-01-27 18:10:08 +01:00
|
|
|
else
|
2018-12-17 22:10:21 +01:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON $BUILD_TREZOR_FLAGS -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
|
2017-01-27 18:10:08 +01:00
|
|
|
fi
|
2016-07-01 14:02:19 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-16 21:30:29 +01:00
|
|
|
# set CPU core count
|
|
|
|
# thanks to SO: http://stackoverflow.com/a/20283965/4118915
|
|
|
|
if test -z "$CPU_CORE_COUNT"; then
|
|
|
|
CPU_CORE_COUNT=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
|
|
|
|
fi
|
2016-05-17 15:03:59 +02:00
|
|
|
|
2016-12-09 09:42:12 +01:00
|
|
|
# Build libwallet_merged
|
2018-03-03 23:56:38 +01:00
|
|
|
pushd $MONERO_DIR/build/$BUILD_TYPE/src/wallet
|
2016-11-23 22:30:36 +01:00
|
|
|
eval $make_exec version -C ../..
|
|
|
|
eval $make_exec -j$CPU_CORE_COUNT
|
|
|
|
eval $make_exec install -j$CPU_CORE_COUNT
|
2016-05-17 15:03:59 +02:00
|
|
|
popd
|
2016-09-03 12:06:44 +02:00
|
|
|
|
2016-12-09 09:42:12 +01:00
|
|
|
# Build monerod
|
2016-12-09 11:12:53 +01:00
|
|
|
# win32 need to build daemon manually with msys2 toolchain
|
2017-01-01 05:55:49 +01:00
|
|
|
if [ "$platform" != "mingw32" ] && [ "$ANDROID" != true ]; then
|
2018-03-03 23:56:38 +01:00
|
|
|
pushd $MONERO_DIR/build/$BUILD_TYPE/src/daemon
|
2016-12-09 11:12:53 +01:00
|
|
|
eval make -j$CPU_CORE_COUNT
|
2016-12-22 10:10:03 +01:00
|
|
|
eval make install -j$CPU_CORE_COUNT
|
2016-12-09 11:12:53 +01:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2017-02-07 20:10:17 +01:00
|
|
|
# build install epee
|
2018-03-03 23:56:38 +01:00
|
|
|
eval make -C $MONERO_DIR/build/$BUILD_TYPE/contrib/epee all install
|
2017-02-07 20:10:17 +01:00
|
|
|
|
2017-05-06 17:11:15 +02:00
|
|
|
# install easylogging
|
2018-03-03 23:56:38 +01:00
|
|
|
eval make -C $MONERO_DIR/build/$BUILD_TYPE/external/easylogging++ all install
|
2017-02-07 20:10:17 +01:00
|
|
|
|
2018-03-07 01:01:53 +01:00
|
|
|
# install lmdb
|
|
|
|
eval make -C $MONERO_DIR/build/$BUILD_TYPE/external/db_drivers/liblmdb all install
|
|
|
|
|
2018-03-03 23:57:18 +01:00
|
|
|
# Install libunbound
|
2018-11-12 00:42:45 +01:00
|
|
|
if [ -d $MONERO_DIR/build/$BUILD_TYPE/external/unbound ]; then
|
|
|
|
echo "Installing libunbound..."
|
|
|
|
pushd $MONERO_DIR/build/$BUILD_TYPE/external/unbound
|
|
|
|
# no need to make, it was already built as dependency for libwallet
|
|
|
|
# make -j$CPU_CORE_COUNT
|
|
|
|
$make_exec install -j$CPU_CORE_COUNT
|
|
|
|
popd
|
|
|
|
fi
|
2016-09-03 12:06:44 +02:00
|
|
|
|
2017-01-01 05:55:49 +01:00
|
|
|
popd
|