From 7c8a7dd54c3fbdc050988ef94ebb0e36646c13bf Mon Sep 17 00:00:00 2001 From: TheTank20 <57580668+thepwrtank18@users.noreply.github.com> Date: Mon, 7 Jul 2025 16:27:04 +0000 Subject: [PATCH] Compile OpenSSL in-action (#134) --- .github/workflows/windows.yml | 125 ++++++++++++++++++++++++++++------ 1 file changed, 105 insertions(+), 20 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 4bbcc24..e6ecbd7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -30,6 +30,7 @@ jobs: build: runs-on: windows-latest strategy: + fail-fast: false matrix: arch: [x64, x86, arm64] steps: @@ -50,6 +51,19 @@ jobs: $env:PATH = 'C:\TDM-GCC-64\bin;' + $env:PATH [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine) + - name: Setup MSYS2 + if: matrix.arch != 'arm64' + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.arch == 'x86' && 'MINGW32' || 'MINGW64' }} + update: true + install: >- + mingw-w64-${{ matrix.arch == 'x86' && 'i686' || 'x86_64' }}-gcc + mingw-w64-${{ matrix.arch == 'x86' && 'i686' || 'x86_64' }}-make + mingw-w64-x86_64-perl + perl + git + - name: Setup MSVC for ARM64 if: matrix.arch == 'arm64' uses: ilammy/msvc-dev-cmd@v1 @@ -59,28 +73,99 @@ jobs: - name: Checkout Source Tree uses: actions/checkout@v4 - - name: Download OpenSSL-TDM release asset - if: matrix.arch != 'arm64' + - name: Cache OpenSSL 3.1.2 (32-bit) + uses: actions/cache/restore@v4 + if: matrix.arch == 'x86' + id: cache-openssl-32 + with: + path: | + ${{ github.workspace }}/OpenSSL-TDM-32 + key: openssl-3.1.2-x86-${{ hashFiles('**/CMakeLists.txt') }} + + - name: Cache OpenSSL 3.1.2 (64-bit) + uses: actions/cache/restore@v4 + if: matrix.arch == 'x64' + id: cache-openssl-64 + with: + path: | + ${{ github.workspace }}/OpenSSL-TDM-64 + key: openssl-3.1.2-x64-${{ hashFiles('**/CMakeLists.txt') }} + + - name: Checkout and Compile OpenSSL 3.1.2 + if: matrix.arch != 'arm64' && steps.cache-openssl-32.outputs.cache-hit != 'true' && steps.cache-openssl-64.outputs.cache-hit != 'true' + shell: msys2 {0} + run: | + # Clone UMSKT's OpenSSL fork + echo "Cloning UMSKT OpenSSL fork..." + git clone https://github.com/UMSKT/openssl.git --depth 1 openssl-3.1.2 + + - name: Checkout and Compile OpenSSL 3.1.2 (32-bit) + if: matrix.arch == 'x86' && steps.cache-openssl-32.outputs.cache-hit != 'true' + shell: msys2 {0} + run: | + # Set up proper MSYS2 environment + export MSYS=winsymlinks:nativestrict + export MSYS2_PATH_TYPE=strict + export LANG=en_US.UTF-8 + export PATH="/usr/bin:/mingw64/bin:$PATH" + export PATH="/c/TDM-GCC-64/bin:$PATH" + export MSYSTEM=MINGW32 + echo "Compiling 32-bit OpenSSL..." + cd openssl-3.1.2 + /usr/bin/perl Configure mingw --prefix=$(cygpath -u "$GITHUB_WORKSPACE")/OpenSSL-TDM-32 --openssldir=$(cygpath -u "$GITHUB_WORKSPACE")/OpenSSL-TDM-32 no-tests no-sse2 no-asm no-threads -DOPENSSL_DEV_NO_ATOMICS -mno-mmx -mno-sse -mno-sse2 -march=i386 + mingw32-make -j + mingw32-make install_sw + cd .. + + - name: Checkout and Compile OpenSSL 3.1.2 (64-bit) + if: matrix.arch == 'x64' && steps.cache-openssl-64.outputs.cache-hit != 'true' + shell: msys2 {0} + run: | + # Set up proper MSYS2 environment + export MSYS=winsymlinks:nativestrict + export MSYS2_PATH_TYPE=strict + export LANG=en_US.UTF-8 + export PATH="/usr/bin:/mingw64/bin:$PATH" + export PATH="/c/TDM-GCC-64/bin:$PATH" + export MSYSTEM=MINGW64 + echo "Compiling 64-bit OpenSSL..." + cd openssl-3.1.2 + /usr/bin/perl Configure mingw64 --prefix=$(cygpath -u "$GITHUB_WORKSPACE")/OpenSSL-TDM-64 --openssldir=$(cygpath -u "$GITHUB_WORKSPACE")/OpenSSL-TDM-64 no-tests no-asm -DOPENSSL_DEV_NO_ATOMICS -mno-mmx + mingw32-make -j + mingw32-make install_sw + cd .. + + - name: Save OpenSSL 3.1.2 (32-bit) + if: matrix.arch == 'x86' && steps.cache-openssl-32.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: | + ${{ github.workspace }}/OpenSSL-TDM-32 + key: openssl-3.1.2-x86-${{ hashFiles('**/CMakeLists.txt') }} + + - name: Save OpenSSL 3.1.2 (64-bit) + if: matrix.arch == 'x64' && steps.cache-openssl-64.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: | + ${{ github.workspace }}/OpenSSL-TDM-64 + key: openssl-3.1.2-x64-${{ hashFiles('**/CMakeLists.txt') }} + + - name: Set OpenSSL Environment (32-bit) + if: matrix.arch == 'x86' shell: pwsh run: | - if ('${{ matrix.arch }}' -eq 'x64') { - $url = "https://github.com/UMSKT/winactiontest/releases/download/openssl/OpenSSL-TDM-64.zip" - $dest = "$env:GITHUB_WORKSPACE/OpenSSL-TDM-64" - $libdir = "lib64" - $cmake_flags = "-m64" - $openssl_root = "$env:GITHUB_WORKSPACE/OpenSSL-TDM-64" - } else { - $url = "https://github.com/UMSKT/winactiontest/releases/download/openssl/OpenSSL-TDM-32.zip" - $dest = "$env:GITHUB_WORKSPACE/OpenSSL-TDM-32" - $libdir = "lib32" - $cmake_flags = "-m32" - $openssl_root = "$env:GITHUB_WORKSPACE/OpenSSL-TDM-32" - } - Invoke-WebRequest -Uri $url -OutFile "OpenSSL-TDM.zip" - Expand-Archive -Path "OpenSSL-TDM.zip" -DestinationPath $env:GITHUB_WORKSPACE - echo "OPENSSL_ROOT=$openssl_root" | Out-File -FilePath $env:GITHUB_ENV -Append - echo "OPENSSL_LIBDIR=$libdir" | Out-File -FilePath $env:GITHUB_ENV -Append - echo "CMAKE_FLAGS=$cmake_flags" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "OPENSSL_ROOT=$env:GITHUB_WORKSPACE/OpenSSL-TDM-32" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "OPENSSL_LIBDIR=lib" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CMAKE_FLAGS=-m32" | Out-File -FilePath $env:GITHUB_ENV -Append + + - name: Set OpenSSL Environment (64-bit) + if: matrix.arch == 'x64' + shell: pwsh + run: | + echo "OPENSSL_ROOT=$env:GITHUB_WORKSPACE/OpenSSL-TDM-64" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "OPENSSL_LIBDIR=lib" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CMAKE_FLAGS=-m64" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Setup vcpkg for ARM64 if: matrix.arch == 'arm64'