From 9b1d2d6388a8f3a54029f0466f68b45e9cccb026 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Mon, 9 Feb 2026 20:36:33 -0500 Subject: [PATCH] Build: Fix static lib packaging for Zlib/Zstd (Win/Mac/Linux) --- .gitea/workflows/build.yaml | 112 ++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 24 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 6ba941ebf..b606df642 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Build Wownero Core (Portable Mac Fix) +name: Build Wownero Core (Windows Filename Fix) on: push: branches: [ master, main ] @@ -29,15 +29,18 @@ jobs: run: echo "192.168.88.230 git.such.software" >> /etc/hosts - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + token: ${{ secrets.GITHUB_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git URLs run: | - rm -rf * git config --global --add safe.directory '*' git config --global url."http://oauth2:${GITHUB_TOKEN}@git.such.software:3000/Builds/RandomWOW.git".insteadOf "https://codeberg.org/wownero/RandomWOW" git config --global url."http://oauth2:${GITHUB_TOKEN}@git.such.software:3000/Builds/wownero.git".insteadOf "https://codeberg.org/wownero/wownero.git" - git clone http://oauth2:$GITHUB_TOKEN@git.such.software:3000/${{ github.repository }}.git . - git submodule update --init --recursive - name: Download macOS SDK if: contains(matrix.target, 'apple') @@ -52,16 +55,17 @@ jobs: tar -xf cmake.tar.gz echo "$(pwd)/cmake-3.28.1-linux-x86_64/bin" >> $GITHUB_PATH + # ----------------------------------------------------------------------- + # 1. BUILD CONFIGURATION + # ----------------------------------------------------------------------- - name: Sanitize Makefiles (Stable + Mac Compat) run: | - # 1. RESTORE UPSTREAM FILES curl -L -o contrib/depends/funcs.mk https://codeberg.org/wownero/wownero/raw/branch/master/contrib/depends/funcs.mk curl -L -o contrib/depends/packages/packages.mk https://codeberg.org/wownero/wownero/raw/branch/master/contrib/depends/packages/packages.mk - # 2. INJECT ZLIB/ZSTD (Safe Append) sed -i 's/^packages :=.*/packages := boost openssl expat libusb hidapi protobuf libiconv sodium zeromq unbound zlib zstd/' contrib/depends/packages/packages.mk - # 3. GENERATE ZLIB.MK + # GENERATE ZLIB.MK cat <<'EOF' > contrib/depends/packages/zlib.mk package=zlib $(package)_version=1.3.1 @@ -83,7 +87,7 @@ jobs: EOF sed -i 's/^ /\t/' contrib/depends/packages/zlib.mk - # 4. GENERATE ZSTD.MK + # GENERATE ZSTD.MK cat <<'EOF' > contrib/depends/packages/zstd.mk package=zstd $(package)_version=1.5.5 @@ -100,8 +104,7 @@ jobs: EOF sed -i 's/^ /\t/' contrib/depends/packages/zstd.mk - # 5. GENERATE BOOST.MK (Standard Mac Config) - # We use runtime-link=shared for Darwin because that is the robust way to build portable Mac binaries. + # GENERATE BOOST.MK cat <<'EOF' > contrib/depends/packages/boost.mk package=boost $(package)_version=1.90.0 @@ -116,17 +119,13 @@ jobs: $(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 $(package)_config_opts_linux=threadapi=pthread runtime-link=static - - # Darwin uses shared runtime (system libc++). This is standard for portable static libs. $(package)_config_opts_darwin=target-os=darwin runtime-link=shared - $(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static $(package)_config_opts_x86_64_mingw32=address-model=64 $(package)_config_opts_i686_mingw32=address-model=32 $(package)_config_opts_i686_linux=address-model=32 architecture=x86 $(package)_config_opts_x86_64_darwin=address-model=64 - # MACOS ARM FIX $(package)_config_opts_aarch64_darwin=address-model=64 architecture=arm binary-format=mach-o abi=aapcs $(package)_toolset_$(host_os)=gcc @@ -162,20 +161,12 @@ jobs: PREFIX=$(pwd)/contrib/depends/${{ matrix.target }} mkdir build && cd build - # Fix strptime export CXXFLAGS="-D_GNU_SOURCE" export CFLAGS="-D_GNU_SOURCE" - # DEFAULT FLAGS STATIC_RUNTIME="ON" - - # MAC SPECIFIC FIX: - # If we are building for Apple, relax the static runtime requirement. - # This allows CMake to accept the libraries we just built. - # The result IS STILL A PORTABLE BINARY (Boost is static, Runtime is System). if [[ "${{ matrix.target }}" == *"apple"* ]]; then STATIC_RUNTIME="OFF" - # Also nuking 'locale' requirement to bypass the build failure perl -pi -e 's/locale//g' ../CMakeLists.txt perl -pi -e 's/locale//g' ../external/monero/CMakeLists.txt fi @@ -188,15 +179,88 @@ jobs: make -j$(nproc) + # ----------------------------------------------------------------------- + # 2. FAIL-SAFE (Mkdir Fixed + Windows Name Fix) + # ----------------------------------------------------------------------- + - name: Ensure Static Libs Exist + run: | + # ABSOLUTE PATHS to prevent cp errors + LIB_DIR="$(pwd)/contrib/depends/${{ matrix.target }}/lib" + INC_DIR="$(pwd)/contrib/depends/${{ matrix.target }}/include" + TOOLCHAIN="$(pwd)/contrib/depends/${{ matrix.target }}/share/toolchain.cmake" + + # Create dirs + mkdir -p "$LIB_DIR" + mkdir -p "$INC_DIR" + + # 1. CHECK ZSTD + if [ ! -f "$LIB_DIR/libzstd.a" ]; then + echo "Zstd missing! Activating Fail-Safe Build..." + mkdir -p temp_zstd && cd temp_zstd + curl -L -o zstd.tar.gz https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz + tar -xf zstd.tar.gz && cd zstd-1.5.5/build/cmake + + cmake . -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \ + -DCMAKE_INSTALL_PREFIX="$(pwd)/../../inst" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF \ + -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_TESTS=OFF + make -j$(nproc) + + # Zstd naming is usually consistent, but let's be safe + if [ -f lib/libzstd.a ]; then + cp lib/libzstd.a "$LIB_DIR/" + elif [ -f lib/libzstdstatic.a ]; then + cp lib/libzstdstatic.a "$LIB_DIR/libzstd.a" + fi + + cp ../../lib/zstd.h "$INC_DIR/" + cd ../../.. + fi + + # 2. CHECK ZLIB + if [ ! -f "$LIB_DIR/libz.a" ]; then + echo "Zlib missing! Activating Fail-Safe Build..." + mkdir -p temp_zlib && cd temp_zlib + curl -L -o zlib.tar.gz https://zlib.net/zlib-1.3.1.tar.gz + tar -xf zlib.tar.gz && cd zlib-1.3.1 + + cmake . -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \ + -DCMAKE_INSTALL_PREFIX="$(pwd)/inst" \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF + make -j$(nproc) + + # WINDOWS FIX: Check for libzlibstatic.a + if [ -f libz.a ]; then + cp libz.a "$LIB_DIR/" + elif [ -f libzlibstatic.a ]; then + echo "Detected Windows naming (libzlibstatic.a). Renaming to libz.a..." + cp libzlibstatic.a "$LIB_DIR/libz.a" + fi + + cp zlib.h "$INC_DIR/" + cp zconf.h "$INC_DIR/" + cd ../.. + fi + - name: Package Artifacts run: | LIB_DIR="contrib/depends/${{ matrix.target }}/lib" INC_DIR="contrib/depends/${{ matrix.target }}/include" mkdir -p output/lib output/include output/bin - find build/bin -type f -exec cp {} output/bin/ \; - cp $LIB_DIR/*.a output/lib/ + + find build/bin -type f -exec cp -v {} output/bin/ \; + cp -v $LIB_DIR/*.a output/lib/ + + # Final Verification + ls -l output/lib/libz*.a + if [ ! -f output/lib/libzstd.a ]; then echo "FATAL: libzstd.a missing"; exit 1; fi + if [ ! -f output/lib/libz.a ]; then echo "FATAL: libz.a missing"; exit 1; fi + cp -r src output/include/wownero-src cp -r $INC_DIR/* output/include/ + tar -czf wownero-core-${{ matrix.target }}.tar.gz -C output . - name: Upload Artifact