Skip to content

Widnows workflow #113

Description

@wipedlifepotato

For Vade:

name: Build and Cross-compile

on:
  push:
    branches: [main, master]
    tags: ['v*']

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        compiler: [gcc]
    runs-on: ${{ matrix.os }}

    steps:
      # -------------------------------------------------
      # Checkout repository with submodules
      # -------------------------------------------------
      - name: Checkout Repository
        uses: actions/checkout@v3
        with:
          submodules: true

      # -------------------------------------------------
      # Ubuntu dependencies
      # -------------------------------------------------
      - name: Install dependencies (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt update
          sudo apt install --no-install-recommends -y \
            build-essential libboost-all-dev libssl-dev git wget
      # -------------------------------------------------
      # Cache dependencies and build artifacts
      # -------------------------------------------------
      - name: Cache dependencies and build artifacts
        uses: actions/cache@v3
        with:
          path: |
            i2pd/obj/
            i2pd/libi2pd.a
            /mingw64/lib
            /mingw64/include
            /usr/local/lib
            /usr/local/include
            ${{ github.workspace }}/boost_build
          key: deps-${{ runner.os }}-${{ hashFiles('i2pd/**') }}
          restore-keys: |
            deps-${{ runner.os }}-
      # -------------------------------------------------
      # Initialize Git Submodules
      # -------------------------------------------------
      - name: Initialize Git Submodules
        run: git submodule update --init --recursive

      # -------------------------------------------------
      # Build on Ubuntu
      # -------------------------------------------------
      - name: Build Project (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: |
          echo "✅ Building i2pd-tools on Ubuntu"
          make -j$(nproc)
          make stripall
          make builddir
      # -------------------------------------------------
      # Windows – setup MSYS2 + pacman Boost
      # -------------------------------------------------
      - name: Setup MSYS2 (Windows)
        if: matrix.os == 'windows-latest'
        uses: msys2/setup-msys2@v2
        with:
          msystem: MINGW64
          update: true
          install: >-
            git
            base-devel
            mingw-w64-x86_64-gcc
            mingw-w64-x86_64-make
            mingw-w64-x86_64-wget
            mingw-w64-x86_64-openssl
            mingw-w64-x86_64-miniupnpc
            mingw-w64-x86_64-boost
      # -------------------------------------------------
      # Clone and build Boost from GitHub
      # -------------------------------------------------
      - name: Clone and Build Boost from GitHub
        if: matrix.os == 'windows-latest'
        shell: msys2 {0}
        run: |
          cd "${GITHUB_WORKSPACE}"
          echo "✅ Cloning Boost from GitHub"
          git clone --depth=1 https://github.com/boostorg/boost.git boost_src
          cd boost_src
          git submodule update --init --recursive
          ./bootstrap.sh --prefix="${GITHUB_WORKSPACE}/boost_build" --with-libraries=system,program_options,thread
          ./b2 --build-type=complete --with-system --with-program_options --with-thread toolset=gcc threading=multi link=static install --prefix="${GITHUB_WORKSPACE}/boost_build"
          cd ..
      # -------------------------------------------------
      # Setup tmate session
      # -------------------------------------------------
      - name: Setup tmate session
        if: failure()
        uses: mxschmitt/action-tmate@v3

      # -------------------------------------------------
      # Debug: Locate Boost libraries on Windows
      # -------------------------------------------------
      - name: 🔍 Debug — Locate Boost libraries (Windows)
        if: matrix.os == 'windows-latest'
        shell: msys2 {0}
        run: |
          echo "🔍 Searching for Boost libraries across system..."
          echo "-----------------------------------------------"
          SEARCH_PATHS="
          /mingw64/lib
          /mingw64/include
          /mingw32/lib
          /mingw32/include
          /clang64/lib
          /clang64/include
          /usr/lib
          /usr/local/lib
          /usr/include
          /usr/local/include
          ${GITHUB_WORKSPACE}/boost_build/lib
          ${GITHUB_WORKSPACE}/boost_build/include
          ${GITHUB_WORKSPACE}/boost_src/stage/lib
          ${GITHUB_WORKSPACE}/boost_src
          /c/msys64/mingw64/lib
          /c/msys64/mingw32/lib
          /c/msys64/clang64/lib
          "
          for dir in $SEARCH_PATHS; do
            if [ -d "$dir" ]; then
              echo "📂 Searching in: $dir"
              find "$dir" -type f \( -name "libboost*.a" -o -name "libboost*.dll" -o -name "boost*.lib" -o -name "boost*.dll" \) 2>/dev/null || true
            fi
          done
          echo "-----------------------------------------------"
          echo "✅ Done searching for Boost libs"
      # -------------------------------------------------
      # Debug dump on failure
      # -------------------------------------------------
      - name: Upload full debug dump (Windows)
        if: failure() && matrix.os == 'windows-latest'
        uses: actions/upload-artifact@v4
        with:
          name: full-debug-dump-${{ matrix.os }}
          path: |
            .
            i2pd/
            build/
            boost_build/
            C:/msys64/mingw64/lib/
            C:/msys64/mingw64/include/
            C:/msys64/mingw32/lib/
            C:/msys64/mingw32/include/
            C:/msys64/clang64/lib/
            C:/msys64/clang64/include/
            /mingw64/lib/
            /mingw64/include/
            /mingw32/lib/
            /mingw32/include/
            /clang64/lib/
            /clang64/include/
            /usr/local/lib/
            /usr/local/include/
            /usr/lib/
            /usr/include/
            ${{ github.workspace }}
            ${{ github.workspace }}/boost_src/
            ${{ github.workspace }}/boost_build/
            /tmp/
            /var/log/
          retention-days: 3

      # -------------------------------------------------
      # Build Project on Windows
      # -------------------------------------------------
      - name: Build Project (Windows)
        if: matrix.os == 'windows-latest'
        shell: msys2 {0}
        run: |
          cd "${GITHUB_WORKSPACE}"
          echo "✅ Building i2pd-tools on Windows with GitHub Boost"
          export CC=gcc
          export CXX=g++
          export CXXFLAGS="-Os -msse -DWIN32_LEAN_AND_MEAN -DOPENSSL_SUPPRESS_DEPRECATED"
          export LDFLAGS="-L/mingw64/lib -L${GITHUB_WORKSPACE}/boost_build/lib"
          export INCFLAGS="-I/mingw64/include -I${GITHUB_WORKSPACE}/boost_build/include -I${GITHUB_WORKSPACE}/i2pd -I${GITHUB_WORKSPACE}/i2pd/libi2pd"
          export BOOST_SUFFIX=""
          make -j$(nproc) BOOST_SUFFIX="${BOOST_SUFFIX}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" INCFLAGS="${INCFLAGS}"
          make stripall
          make builddir
      # -------------------------------------------------
      # Upload binaries
      # -------------------------------------------------
      - name: Upload binaries
        uses: actions/upload-artifact@v4
        with:
          name: my-binaries-${{ matrix.os }}
          path: build/*

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions