2024-03-08 23:43:34 +01:00
|
|
|
#!/bin/bash
|
2024-04-01 08:51:37 +02:00
|
|
|
|
2024-07-30 17:46:55 +02:00
|
|
|
cd "$(realpath $(dirname $0))"
|
|
|
|
|
|
2024-08-12 15:12:37 +02:00
|
|
|
proccount=1
|
|
|
|
|
if [[ "x$(uname)" == "xDarwin" ]];
|
|
|
|
|
then
|
|
|
|
|
proccount=$(sysctl -n hw.physicalcpu)
|
|
|
|
|
elif [[ "x$(uname)" == "xLinux" ]];
|
|
|
|
|
then
|
|
|
|
|
proccount=$(nproc)
|
|
|
|
|
fi
|
|
|
|
|
|
2024-04-01 08:51:37 +02:00
|
|
|
function verbose_copy() {
|
|
|
|
|
echo "==> cp $1 $2"
|
|
|
|
|
cp $1 $2
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 23:43:34 +01:00
|
|
|
set -e
|
2024-03-26 19:34:04 +01:00
|
|
|
repo=$1
|
|
|
|
|
if [[ "x$repo" == "x" ]];
|
|
|
|
|
then
|
2025-01-04 09:02:44 +01:00
|
|
|
echo "Usage: $0 monero/wownero/zano $(gcc -dumpmachine) -j$proccount"
|
2024-03-26 19:34:04 +01:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2025-01-04 09:02:44 +01:00
|
|
|
if [[ "x$repo" != "xwownero" && "x$repo" != "xmonero" && "x$repo" != "xzano" ]];
|
2024-03-26 19:34:04 +01:00
|
|
|
then
|
2025-01-04 09:02:44 +01:00
|
|
|
echo "Usage: $0 monero/wownero/zano $(gcc -dumpmachine) -j$proccount"
|
|
|
|
|
echo "Invalid target given"
|
2024-12-04 10:22:48 -05:00
|
|
|
exit 1
|
2024-03-26 19:34:04 +01:00
|
|
|
fi
|
2024-03-08 23:43:34 +01:00
|
|
|
|
2024-03-26 19:34:04 +01:00
|
|
|
if [[ ! -d "$repo" ]]
|
|
|
|
|
then
|
|
|
|
|
echo "no '$repo' directory found. clone with --recursive or run:"
|
|
|
|
|
echo "$ git submodule init && git submodule update --force";
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
HOST_ABI="$2"
|
2024-03-08 23:43:34 +01:00
|
|
|
if [[ "x$HOST_ABI" == "x" ]];
|
|
|
|
|
then
|
2024-08-12 15:12:37 +02:00
|
|
|
echo "Usage: $0 monero/wownero $(gcc -dumpmachine) -j$proccount"
|
2024-03-08 23:43:34 +01:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2024-03-26 19:34:04 +01:00
|
|
|
NPROC="$3"
|
2024-03-08 23:43:34 +01:00
|
|
|
|
|
|
|
|
if [[ "x$NPROC" == "x" ]];
|
|
|
|
|
then
|
2024-08-12 15:12:37 +02:00
|
|
|
echo "Usage: $0 monero/wownero $(gcc -dumpmachine) -j$proccount"
|
2024-03-08 23:43:34 +01:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2024-03-10 02:22:11 +01:00
|
|
|
cd $(dirname $0)
|
|
|
|
|
WDIR=$PWD
|
2024-12-04 10:22:48 -05:00
|
|
|
pushd contrib/depends
|
2025-01-04 09:02:44 +01:00
|
|
|
if [[ -d $HOST_ABI ]];
|
|
|
|
|
then
|
|
|
|
|
echo "Not building depends, directory exists"
|
|
|
|
|
else
|
|
|
|
|
env -i PATH="$PATH" CC=gcc CXX=g++ make "$NPROC" HOST="$HOST_ABI"
|
|
|
|
|
fi
|
2024-03-08 23:43:34 +01:00
|
|
|
popd
|
|
|
|
|
|
2024-04-02 00:14:52 +02:00
|
|
|
buildType=Debug
|
2024-03-22 18:38:27 +01:00
|
|
|
|
feat: split MONERO and WOWNERO prefixed functions
So basically: when we open the .so file, we define some
symbols, and it appears that if we load something else,
with the same symbols, under the same thread we cause
some funky behaviour - like calling function a wownero
function MONERO_Wallet_address() resulting in a monero
address being generated.
Needless to say, this is undesired, and a blocker for
https://github.com/cypherstack/stack_wallet/pull/818
I'm afraid that this may not solve all of our issues (but
will solve some significant roadblocks), because of the
"genesis block" issue, as output of
nm -gDC release/wownero/x86_64-linux-gnu_libwallet2_api_c.so | grep genesis
indicate that these functions may share *something* in
common across both WOW and XMR libraries.
In a case in which this fix won't be sufficient, I think that
the way forward would be to close the dynamic libraries,
but before we do that I want to check if maybe there is
a change to run multiple wallets at once.
2024-03-31 09:19:47 +02:00
|
|
|
pushd ${repo}_libwallet2_api_c
|
2024-03-26 19:34:04 +01:00
|
|
|
rm -rf build/${HOST_ABI} || true
|
|
|
|
|
mkdir -p build/${HOST_ABI} -p
|
2025-01-04 09:02:44 +01:00
|
|
|
if [[ "$repo" == "zano" ]];
|
|
|
|
|
then
|
|
|
|
|
EXTRA_CMAKE_FLAGS="-DCAKEWALLET=ON"
|
|
|
|
|
fi
|
2024-04-02 17:09:22 +02:00
|
|
|
pushd build/${HOST_ABI}
|
2025-01-04 09:02:44 +01:00
|
|
|
cmake -DCMAKE_TOOLCHAIN_FILE=$PWD/../../../contrib/depends/${HOST_ABI}/share/toolchain.cmake $EXTRA_CMAKE_FLAGS -DUSE_DEVICE_TREZOR=OFF -DMONERO_FLAVOR=$repo -DCMAKE_BUILD_TYPE=Debug -DHOST_ABI=${HOST_ABI} ../..
|
2024-12-04 10:22:48 -05:00
|
|
|
make $NPROC
|
2024-04-02 17:09:22 +02:00
|
|
|
popd
|
2024-03-26 19:34:04 +01:00
|
|
|
popd
|
2024-03-22 14:21:57 +01:00
|
|
|
|
2024-03-26 19:34:04 +01:00
|
|
|
mkdir -p release/$repo 2>/dev/null || true
|
|
|
|
|
pushd release/$repo
|
|
|
|
|
APPENDIX=""
|
|
|
|
|
if [[ "${HOST_ABI}" == "x86_64-w64-mingw32" || "${HOST_ABI}" == "i686-w64-mingw32" ]];
|
|
|
|
|
then
|
2024-12-04 10:22:48 -05:00
|
|
|
echo "TODO: check if it's still needed"
|
2024-03-26 19:34:04 +01:00
|
|
|
APPENDIX="${APPENDIX}dll"
|
2024-12-04 10:22:48 -05:00
|
|
|
# cp ../../$repo/build/${HOST_ABI}/external/polyseed/libpolyseed.${APPENDIX} ${HOST_ABI}_libpolyseed.${APPENDIX}
|
|
|
|
|
# rm ${HOST_ABI}_libpolyseed.${APPENDIX}.xz || true
|
|
|
|
|
# xz -e ${HOST_ABI}_libpolyseed.${APPENDIX}
|
2025-02-04 18:22:07 +01:00
|
|
|
elif [[ "${HOST_ABI}" == "x86_64-apple-darwin11" || "${HOST_ABI}" == "aarch64-apple-darwin11" || "${HOST_ABI}" == "host-apple-darwin" || "${HOST_ABI}" == "x86_64-host-apple-darwin" || "${HOST_ABI}" == "aarch64-apple-darwin" || "${HOST_ABI}" == "x86_64-apple-darwin" || "${HOST_ABI}" == "host-apple-ios" || "${HOST_ABI}" == "aarch64-apple-ios" || "${HOST_ABI}" == "aarch64-apple-iossimulator" ]];
|
2024-03-28 02:08:12 +01:00
|
|
|
then
|
|
|
|
|
APPENDIX="${APPENDIX}dylib"
|
2024-03-26 19:34:04 +01:00
|
|
|
else
|
|
|
|
|
APPENDIX="${APPENDIX}so"
|
|
|
|
|
fi
|
2025-02-04 18:22:07 +01:00
|
|
|
xz -ek ../../${repo}_libwallet2_api_c/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}
|
feat: split MONERO and WOWNERO prefixed functions
So basically: when we open the .so file, we define some
symbols, and it appears that if we load something else,
with the same symbols, under the same thread we cause
some funky behaviour - like calling function a wownero
function MONERO_Wallet_address() resulting in a monero
address being generated.
Needless to say, this is undesired, and a blocker for
https://github.com/cypherstack/stack_wallet/pull/818
I'm afraid that this may not solve all of our issues (but
will solve some significant roadblocks), because of the
"genesis block" issue, as output of
nm -gDC release/wownero/x86_64-linux-gnu_libwallet2_api_c.so | grep genesis
indicate that these functions may share *something* in
common across both WOW and XMR libraries.
In a case in which this fix won't be sufficient, I think that
the way forward would be to close the dynamic libraries,
but before we do that I want to check if maybe there is
a change to run multiple wallets at once.
2024-03-31 09:19:47 +02:00
|
|
|
mv ../../${repo}_libwallet2_api_c/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}.xz ${HOST_ABI}_libwallet2_api_c.${APPENDIX}.xz
|
2024-03-26 19:34:04 +01:00
|
|
|
# Extra libraries
|
|
|
|
|
if [[ "$HOST_ABI" == "x86_64-w64-mingw32" || "$HOST_ABI" == "i686-w64-mingw32" ]];
|
|
|
|
|
then
|
|
|
|
|
cp /usr/${HOST_ABI}/lib/libwinpthread-1.dll ${HOST_ABI}_libwinpthread-1.dll
|
|
|
|
|
rm ${HOST_ABI}_libwinpthread-1.dll.xz || true
|
2025-02-04 18:22:07 +01:00
|
|
|
xz -ek ${HOST_ABI}_libwinpthread-1.dll
|
2024-03-26 19:34:04 +01:00
|
|
|
####
|
2024-04-29 12:22:49 +02:00
|
|
|
cp /usr/lib/gcc/${HOST_ABI}/*-posix/libssp-0.dll ${HOST_ABI}_libssp-0.dll
|
2024-03-26 19:34:04 +01:00
|
|
|
rm ${HOST_ABI}_libssp-0.dll.xz || true
|
2025-02-04 18:22:07 +01:00
|
|
|
xz -ek ${HOST_ABI}_libssp-0.dll
|
2024-03-26 19:34:04 +01:00
|
|
|
fi
|
2024-04-27 19:17:40 +02:00
|
|
|
popd
|