diff --git a/.gitea/toolchains/mingw-w64-x86_64.cmake b/.gitea/toolchains/mingw-w64-x86_64.cmake new file mode 100644 index 0000000000..5fff3da204 --- /dev/null +++ b/.gitea/toolchains/mingw-w64-x86_64.cmake @@ -0,0 +1,27 @@ +# MinGW-w64 toolchain file for cross-compiling to Windows on Linux + +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +# Specify the cross compiler +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# Specify the target environment +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +# Search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# Search for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# Set Windows-specific flags +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") + +# Ensure we're targeting Windows +set(WIN32 TRUE) +set(MINGW TRUE) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index e932568e64..fdae785341 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -7,8 +7,7 @@ on: workflow_dispatch: jobs: - build-linux: - name: Build Linux + build-windows: runs-on: ubuntu-latest steps: @@ -16,278 +15,93 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y \ - autoconf cmake g++ gcc git glslang-tools \ - libglu1-mesa-dev libhidapi-dev libpulse-dev \ - libtool libudev-dev libxcb-icccm4 libxcb-image0 \ - libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 \ - libxcb-xkb1 libxext-dev libxkbcommon-x11-0 \ - mesa-common-dev nasm ninja-build qt6-base-private-dev \ - libmbedtls-dev catch2 libfmt-dev liblz4-dev \ - nlohmann-json3-dev libzstd-dev libssl-dev \ - libavfilter-dev libavcodec-dev libswscale-dev \ - pkg-config zlib1g-dev libva-dev libvdpau-dev \ - qt6-tools-dev libvulkan-dev spirv-tools spirv-headers \ - libusb-1.0-0-dev libxbyak-dev libboost-dev \ - libboost-fiber-dev libboost-context-dev libsdl2-dev \ - libopus-dev vulkan-utility-libraries-dev + build-essential \ + cmake \ + ninja-build \ + ccache \ + git \ + wget \ + python3 \ + python3-pip \ + mingw-w64 \ + wine64 - - name: Configure CMake + # Install CPM dependencies + pip3 install --upgrade pip + + - name: Setup ccache + uses: actions/cache@v4 + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache-windows-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-ccache-windows- + + - name: Setup CPM cache + uses: actions/cache@v4 + with: + path: .cache/cpm + key: ${{ runner.os }}-cpm-${{ hashFiles('**/cpmfile.json') }} + restore-keys: | + ${{ runner.os }}-cpm- + + - name: Install MinGW toolchain run: | - cmake -S . -B build -G "Ninja" \ + # Set up MinGW-w64 for cross-compilation + sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix + sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix + + - name: Configure CMake for Windows + run: | + cmake -S . -B build \ + -G "Ninja" \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/.gitea/toolchains/mingw-w64-x86_64.cmake \ -DYUZU_TESTS=OFF \ - -DENABLE_QT_TRANSLATION=OFF + -DENABLE_QT_TRANSLATION=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build Eden run: | cmake --build build --parallel $(nproc) - - name: Package Artifacts + - name: Prepare artifacts run: | mkdir -p artifacts - cp build/bin/eden artifacts/ || echo "eden not found" - cp build/bin/eden-cmd artifacts/ || echo "eden-cmd not found" - if [ -f artifacts/eden ]; then - chmod +x artifacts/eden - fi - if [ -f artifacts/eden-cmd ]; then - chmod +x artifacts/eden-cmd + + # Copy the built executable + if [ -f build/bin/eden.exe ]; then + cp build/bin/eden.exe artifacts/ fi - # Create version info - echo "Eden Emulator - Linux Build" > artifacts/VERSION.txt - echo "Build Date: $(date)" >> artifacts/VERSION.txt - echo "Commit: $(git rev-parse --short HEAD)" >> artifacts/VERSION.txt + # Copy any additional runtime files + if [ -d build/bin ]; then + find build/bin -name "*.dll" -exec cp {} artifacts/ \; + fi - - name: Create tarball - run: | - cd artifacts - tar -czf ../eden-linux-x64.tar.gz . - cd .. + # Create a version file + echo "Build Date: $(date)" > artifacts/build_info.txt + echo "Commit: ${{ github.sha }}" >> artifacts/build_info.txt + echo "Branch: ${{ github.ref_name }}" >> artifacts/build_info.txt - - name: Upload Linux Build + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: - name: eden-linux-x64 - path: eden-linux-x64.tar.gz + name: eden-windows-${{ github.sha }} + path: artifacts/ retention-days: 30 - build-windows-wine: - name: Build Windows (Wine + MSYS2) - runs-on: ubuntu-latest - timeout-minutes: 180 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Wine and dependencies - run: | - sudo dpkg --add-architecture i386 - sudo mkdir -pm755 /etc/apt/keyrings - sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key - sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources - - sudo apt-get update - sudo apt-get install -y --install-recommends winehq-stable - sudo apt-get install -y wget unzip p7zip-full xvfb cabextract - - wine --version - - - name: Setup Xvfb for headless display - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - sleep 2 - echo "DISPLAY=:99" >> $GITHUB_ENV - - - name: Initialize Wine prefix - run: | - export WINEPREFIX=$HOME/.wine-eden - export WINEARCH=win64 - export WINEDEBUG=-all - wineboot -u - sleep 5 - echo "WINEPREFIX=$HOME/.wine-eden" >> $GITHUB_ENV - echo "WINEARCH=win64" >> $GITHUB_ENV - echo "WINEDEBUG=-all" >> $GITHUB_ENV - - - name: Download and Install MSYS2 - run: | - # Download MSYS2 base - wget https://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20231026.tar.xz - - # Extract to Wine prefix - mkdir -p $WINEPREFIX/drive_c/msys64 - tar -xf msys2-base-x86_64-20231026.tar.xz -C $WINEPREFIX/drive_c/ - - # Setup MSYS2 environment - echo "export MSYS2_PATH_TYPE=inherit" > $WINEPREFIX/drive_c/msys64/etc/profile.d/wine.sh - - ls -la $WINEPREFIX/drive_c/msys64/ - - - name: Initialize MSYS2 in Wine - run: | - # Run MSYS2 bash to initialize - wine $WINEPREFIX/drive_c/msys64/usr/bin/bash.exe -lc "pacman-key --init" || true - sleep 2 - wine $WINEPREFIX/drive_c/msys64/usr/bin/bash.exe -lc "pacman-key --populate msys2" || true - sleep 2 - wine $WINEPREFIX/drive_c/msys64/usr/bin/bash.exe -lc "pacman -Sy --noconfirm" || true - - - name: Install MSYS2 Build Dependencies - run: | - # Install MinGW packages - wine $WINEPREFIX/drive_c/msys64/usr/bin/bash.exe -lc "pacman -S --noconfirm --needed \ - mingw-w64-x86_64-toolchain \ - mingw-w64-x86_64-cmake \ - mingw-w64-x86_64-ninja \ - mingw-w64-x86_64-qt6-base \ - mingw-w64-x86_64-qt6-tools \ - mingw-w64-x86_64-qt6-translations \ - mingw-w64-x86_64-qt6-svg \ - mingw-w64-x86_64-boost \ - mingw-w64-x86_64-fmt \ - mingw-w64-x86_64-lz4 \ - mingw-w64-x86_64-nlohmann-json \ - mingw-w64-x86_64-openssl \ - mingw-w64-x86_64-zlib \ - mingw-w64-x86_64-zstd \ - mingw-w64-x86_64-opus \ - mingw-w64-x86_64-mbedtls \ - mingw-w64-x86_64-libusb \ - mingw-w64-x86_64-SDL2 \ - mingw-w64-x86_64-vulkan-headers \ - mingw-w64-x86_64-vulkan-loader \ - mingw-w64-x86_64-glslang \ - mingw-w64-x86_64-spirv-tools \ - mingw-w64-x86_64-ffmpeg \ - git \ - make \ - autoconf \ - automake \ - libtool \ - patch \ - python" || echo "Some packages may have failed to install" - - - name: Download Vulkan SDK for Windows - run: | - wget https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe -O vulkan-sdk.exe - - # Try silent install - wine vulkan-sdk.exe /S || echo "Vulkan SDK install attempted" - sleep 10 - - - name: Setup build script - run: | - cat > build-eden.sh << 'EOFSCRIPT' - #!/bin/bash - set -e - - export PATH="/c/msys64/mingw64/bin:/c/msys64/usr/bin:$PATH" - export PKG_CONFIG_PATH="/c/msys64/mingw64/lib/pkgconfig" - - cd "$(pwd)" - - mkdir -p build-wine - cd build-wine - - cmake .. \ - -G "Ninja" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="/c/msys64/mingw64" \ - -DYUZU_TESTS=OFF \ - -DENABLE_QT=ON \ - -DENABLE_QT_TRANSLATION=ON \ - -DENABLE_SDL2=ON \ - -DENABLE_WEB_SERVICE=ON \ - -DYUZU_USE_QT_MULTIMEDIA=ON \ - -DENABLE_LIBUSB=ON \ - -DENABLE_OPENSSL=ON \ - -DYUZU_USE_BUNDLED_QT=OFF \ - -DYUZU_USE_BUNDLED_SDL2=OFF \ - -DYUZU_USE_BUNDLED_FFMPEG=OFF \ - -DYUZU_USE_CPM=ON - - ninja -j$(nproc) - EOFSCRIPT - - chmod +x build-eden.sh - - - name: Build Eden in Wine - run: | - # Copy build script to Wine drive - cp build-eden.sh $WINEPREFIX/drive_c/ - - # Copy source to Wine accessible location - rsync -av --exclude='.git' --exclude='build*' ./ $WINEPREFIX/drive_c/eden-src/ - - # Run build - cd $WINEPREFIX/drive_c/eden-src - wine $WINEPREFIX/drive_c/msys64/usr/bin/bash.exe -lc "/c/build-eden.sh" || echo "Build completed with potential errors" - timeout-minutes: 120 - continue-on-error: true - - - name: Package Windows Artifacts - run: | - mkdir -p artifacts-windows - - BUILD_DIR="$WINEPREFIX/drive_c/eden-src/build-wine/bin" - - if [ -d "$BUILD_DIR" ]; then - # Copy executables - find "$BUILD_DIR" -name "*.exe" -exec cp {} artifacts-windows/ \; 2>/dev/null || true - - # Copy DLLs - find "$BUILD_DIR" -name "*.dll" -exec cp {} artifacts-windows/ \; 2>/dev/null || true - - # Copy Qt dependencies if eden.exe exists - if [ -f artifacts-windows/eden.exe ]; then - wine $WINEPREFIX/drive_c/msys64/mingw64/bin/windeployqt.exe artifacts-windows/eden.exe || true - fi - fi - - # Create version info - echo "Eden Emulator - Windows Build (Wine + MSYS2)" > artifacts-windows/VERSION.txt - echo "Build Date: $(date)" >> artifacts-windows/VERSION.txt - echo "Commit: $(git rev-parse --short HEAD)" >> artifacts-windows/VERSION.txt - echo "" >> artifacts-windows/VERSION.txt - echo "Built using:" >> artifacts-windows/VERSION.txt - echo "- Wine (Windows emulation on Linux)" >> artifacts-windows/VERSION.txt - echo "- MSYS2 MinGW-w64 toolchain" >> artifacts-windows/VERSION.txt - echo "- Qt6 for Windows" >> artifacts-windows/VERSION.txt - echo "" >> artifacts-windows/VERSION.txt - echo "Features:" >> artifacts-windows/VERSION.txt - echo "- Qt GUI: Enabled" >> artifacts-windows/VERSION.txt - echo "- SDL2: Enabled" >> artifacts-windows/VERSION.txt - echo "- OpenSSL: Enabled" >> artifacts-windows/VERSION.txt - echo "- Web Services: Enabled" >> artifacts-windows/VERSION.txt - - if [ ! -f artifacts-windows/eden.exe ] && [ ! -f artifacts-windows/eden-cmd.exe ]; then - echo "" >> artifacts-windows/VERSION.txt - echo "BUILD STATUS: FAILED - No executables produced" >> artifacts-windows/VERSION.txt - echo "Check build logs for errors" >> artifacts-windows/VERSION.txt - else - echo "" >> artifacts-windows/VERSION.txt - echo "BUILD STATUS: SUCCESS" >> artifacts-windows/VERSION.txt - fi - - # Create archive - cd artifacts-windows - zip -r ../eden-windows-wine-msys2.zip . - cd .. - continue-on-error: true - - - name: Upload Windows Build - if: always() + - name: Upload executable only uses: actions/upload-artifact@v4 with: - name: eden-windows-wine-msys2 - path: eden-windows-wine-msys2.zip + name: eden-windows-exe + path: artifacts/eden.exe retention-days: 30 + if: success() && hashFiles('artifacts/eden.exe') != '' diff --git a/src/core/internal_network/legacy_online.cpp b/src/core/internal_network/legacy_online.cpp index 6f0c1d70e0..0ac2191791 100644 --- a/src/core/internal_network/legacy_online.cpp +++ b/src/core/internal_network/legacy_online.cpp @@ -127,7 +127,7 @@ void LegacyOnlineService::ServerLoop() { socklen_t client_len = sizeof(client_addr); #endif - ssize_t len = -1; + int len = -1; #ifdef _WIN32 len = recvfrom(static_cast(socket_fd), buffer, sizeof(buffer), 0, (sockaddr*)&client_addr, &client_len); #else @@ -142,7 +142,7 @@ void LegacyOnlineService::ServerLoop() { #ifdef _WIN32 sendto(static_cast(socket_fd), ack_msg, static_cast(strlen(ack_msg)), 0, (sockaddr*)&client_addr, client_len); #else - sendto(static_cast(socket_fd), ack_msg, static_cast(strlen(ack_msg)), 0, (sockaddr*)&client_addr, client_len); + sendto(static_cast(socket_fd), ack_msg, strlen(ack_msg), 0, (sockaddr*)&client_addr, client_len); #endif } else { // Error or closed