Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Misc updates #469

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion _cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
# endif
#endif

#if defined (_WIN32) && !defined(_SSIZE_T_DECLARED) && !defined(_ssize_t) && !defined(ssize_t)
#if defined(_WIN64)
typedef __int64 ssize_t;
#else
typedef long ssize_t;
#endif
#endif

#include "ccan_config.h"
#endif /*LIBWALLYCORE_CONFIG_H*/
#endif /* LIBWALLYCORE_CONFIG_H */
17 changes: 17 additions & 0 deletions contrib/Dockerfile_bookworm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Dockerfile for wally builds on Debain bookworm (stable).
# build from this directory with e.g:
# docker buildx build --platform linux/arm64,linux/amd64 -f Dockerfile_bullseye -t greenaddress/wallycore:bookworm .
#
# Note that to build both platforms you need to:
# apt install qemu-user-static binfmt-support
#
FROM debian:bookworm@sha256:10901ccd8d249047f9761845b4594f121edef079cfd8224edebd9ea726f0a7f6
WORKDIR /root
COPY bookworm_deps.sh ./deps.sh
COPY requirements.txt ./contrib/requirements.txt
ARG TARGETARCH
ENV TARGETARCH=${TARGETARCH}
ENV JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-${TARGETARCH}
RUN ./deps.sh && rm ./deps.sh
ENV ANDROID_NDK=/opt/android-ndk-r26b
4 changes: 3 additions & 1 deletion contrib/Dockerfile_bullseye
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#
# Dockerfile for wally builds.
# Dockerfile for wally builds on Debain bullseye (oldstable).
# build from this directory with e.g:
# DOCKER_BUILDKIT=1 docker build . -t greenaddress/wallycore -f Dockerfile_bullseye
# and for linux/arm64:
# DOCKER_BUILDKIT=1 docker build . -t greenaddress/wallycore -f Dockerfile_bullseye --platform linux/arm64 --build-arg TARGETARCH=arm64
#
FROM debian:bullseye@sha256:01559430c84e6bc864bed554345d1bfbfa94ac108ab68f39915cae34604b15c3
WORKDIR /root
Expand Down
85 changes: 85 additions & 0 deletions contrib/bookworm_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#! /usr/bin/env bash
# Install required dependencies for building wally
# Options:
# -e : Don't install emsdk (used for JS builds)
# -j : Don't install Java SDK (used for Java builds)
# -n : Don't install Android NDK (used for Android builds)
# -w : Don't install MinGW (used for Windows cross compiles)
set -e

skip_emsdk=
skip_ndk=
skip_java=
skip_windows=
while getopts enjw name
do
case $name in
e) skip_emsdk=1;;
n) skip_ndk=1;;
j) skip_java=1;;
w) skip_windows=1;;
*) echo "Invalid flag"; exit 1;;
esac
done
shift $(($OPTIND - 1))

apt update -qq
apt upgrade -yqq

java_packages=
if [ -z "$skip_java" ]; then
java_packages="openjdk-17-jdk openjdk-17-jre"
fi
windows_packages=
if [ -z "$skip_windows" ]; then
windows_packages="g++-mingw-w64-x86-64"
fi
apt install --no-install-recommends unzip autoconf automake autotools-dev pkg-config build-essential libtool python3{,-dev,-pip,-virtualenv} python{,-dev}-is-python3 clang{,-format,-tidy} git swig curl cmake libssl-dev libtool-bin $java_packages curl $windows_packages valgrind jq -yqq

if [ -z "$skip_java" ]; then
update-java-alternatives -s $(basename ${JAVA_HOME})
fi

# Note --break-system-packages to allow installing our requirements system-wide
pip install valgrind-codequality -r contrib/requirements.txt --break-system-packages

pushd /opt

if [ -z "$skip_ndk" ]; then
curl -L -o ndk.zip https://dl.google.com/android/repository/android-ndk-r26b-linux.zip
echo "ad73c0370f0b0a87d1671ed2fd5a9ac9acfd1eb5c43a7fbfbd330f85d19dd632 ndk.zip" | shasum -a 256 -c
unzip ndk.zip
rm ndk.zip
fi

if [ -z "$skip_emsdk" ]; then
# Install node 20
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install nodejs -yqq
# Install emsdk
git clone https://github.com/emscripten-core/emsdk
cd emsdk
EMSDK_VERSION=3.1.52
if [ "${TARGETARCH}" = "arm64" ]; then
# very few versions of emsdk are available for linux-arm64
# https://github.com/emscripten-core/emsdk/issues/547
EMSDK_VERSION=3.1.33
fi
./emsdk install ${EMSDK_VERSION}
./emsdk activate ${EMSDK_VERSION}
# Force emsdk to use the installed node version instead of its own
sed -i "s/^NODE_JS = .*$/NODE_JS = 'node'/g" /opt/emsdk/.emscripten
# Make emsdk commands available
source ./emsdk_env.sh
fi

if [ -f /.dockerenv ]; then
# Installing dependencies into a docker image.
# Purge uneeded files to keep the image as small as possible.
apt remove --purge curl unzip -yqq
apt -yqq autoremove
apt -yqq clean
rm -rf /var/lib/apt/lists/* /var/cache/* /tmp/* /usr/share/locale/* /usr/share/man /usr/share/doc /lib/xtables/libip6* /root/.cache
fi

popd
8 changes: 6 additions & 2 deletions src/amalgamation/windows_config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

#define HAVE_UNALIGNED_ACCESS 1

#if (!defined(_SSIZE_T_DECLARED)) && (!defined(_ssize_t)) && (!defined(ssize_t))
#define ssize_t long long
#if defined (_WIN32) && !defined(_SSIZE_T_DECLARED) && !defined(_ssize_t) && !defined(ssize_t)
#if defined(_WIN64)
typedef __int64 ssize_t;
#else
typedef long ssize_t;
#endif
#endif

#include "ccan_config.h"
Expand Down
10 changes: 6 additions & 4 deletions src/ctest/_CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ target_include_directories(test_bech32 PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(test_bech32 PRIVATE wallycore)
add_test(test_bech32 test_bech32)

add_executable(test_clear test_clear.c)
target_include_directories(test_clear PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(test_clear PRIVATE wallycore pthread)
add_test(test_clear test_clear)
if(NOT WIN32)
add_executable(test_clear test_clear.c)
target_include_directories(test_clear PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(test_clear PRIVATE wallycore pthread)
add_test(test_clear test_clear)
endif()

add_executable(test_coinselection test_coinselection.c)
target_include_directories(test_coinselection PRIVATE ${CMAKE_BINARY_DIR})
Expand Down