diff --git a/_cmake/config.h.in b/_cmake/config.h.in index d295a82dd..692b63e81 100644 --- a/_cmake/config.h.in +++ b/_cmake/config.h.in @@ -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 */ diff --git a/contrib/Dockerfile_bookworm b/contrib/Dockerfile_bookworm new file mode 100644 index 000000000..7f2b2cd4e --- /dev/null +++ b/contrib/Dockerfile_bookworm @@ -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 diff --git a/contrib/Dockerfile_bullseye b/contrib/Dockerfile_bullseye index 019643101..d1c848485 100644 --- a/contrib/Dockerfile_bullseye +++ b/contrib/Dockerfile_bullseye @@ -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 diff --git a/contrib/bookworm_deps.sh b/contrib/bookworm_deps.sh new file mode 100755 index 000000000..7f7ea0191 --- /dev/null +++ b/contrib/bookworm_deps.sh @@ -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 diff --git a/src/amalgamation/windows_config/config.h b/src/amalgamation/windows_config/config.h index 454a73eca..fbb95f1fd 100644 --- a/src/amalgamation/windows_config/config.h +++ b/src/amalgamation/windows_config/config.h @@ -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" diff --git a/src/ctest/_CMakeLists.txt b/src/ctest/_CMakeLists.txt index 785081d84..a8214bdea 100644 --- a/src/ctest/_CMakeLists.txt +++ b/src/ctest/_CMakeLists.txt @@ -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})