diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1438408 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,511 @@ +name: Build + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + inputs: + force: + description: 'Force new release' + type: boolean + +jobs: + msys2: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + sys: mingw64 + env: x86_64 + - os: windows-2022 + sys: ucrt64 + env: ucrt-x86_64 + - os: windows-11-arm + sys: clangarm64 + env: clang-aarch64 + steps: + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + id: msys2 + with: + msystem: ${{ matrix.sys }} + update: true + install: >- + autoconf-wrapper + autogen + automake-wrapper + bison + compression + diffutils + libtool + m4 + make + patch + re2c + texinfo + texinfo-tex + + mingw-w64-${{ matrix.env }}-curl + mingw-w64-${{ matrix.env }}-gcc + mingw-w64-${{ matrix.env }}-make + mingw-w64-${{ matrix.env }}-pkgconf + mingw-w64-${{ matrix.env }}-libmangle-git + mingw-w64-${{ matrix.env }}-tools-git + + mingw-w64-${{ matrix.env }}-gdbm + mingw-w64-${{ matrix.env }}-gmp + mingw-w64-${{ matrix.env }}-libffi + mingw-w64-${{ matrix.env }}-libyaml + mingw-w64-${{ matrix.env }}-openssl + mingw-w64-${{ matrix.env }}-ragel + mingw-w64-${{ matrix.env }}-readline + + - name: Archive MSYS2 + run: | + cd "${env:MSYS2_LOCATION}" + 7z a "${env:GITHUB_WORKSPACE}\msys2-${{ matrix.sys }}.7z" + env: + MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }} + + - name: Upload MSYS2 + uses: actions/upload-artifact@v4 + with: + name: msys2-${{ matrix.sys }} + path: msys2-${{ matrix.sys }}.7z + compression-level: 0 + if-no-files-found: error + + - name: Download MSYS2 Package Cache + run: pacman -Qq | xargs pacman -Sw --noconfirm + shell: msys2 {0} + + - name: Archive MSYS2 Package Cache + run: | + cd "${env:MSYS2_LOCATION}\var\cache\pacman\pkg" + 7z a "${env:GITHUB_WORKSPACE}\msys2-${{ matrix.sys }}-var-cache-pacman-pkg.7z" + env: + MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }} + + - name: Upload MSYS2 Package Cache + uses: actions/upload-artifact@v4 + with: + name: msys2-${{ matrix.sys }}-var-cache-pacman-pkg + path: msys2-${{ matrix.sys }}-var-cache-pacman-pkg.7z + compression-level: 0 + if-no-files-found: error + + - name: Create MSYS2 Package List + run: pacman -Q | tee msys2-${{ matrix.sys }}.packages.txt + shell: msys2 {0} + + - name: Upload MSYS2 Package List + uses: actions/upload-artifact@v4 + with: + name: msys2-${{ matrix.sys }}-packages-txt + path: msys2-${{ matrix.sys }}.packages.txt + if-no-files-found: error + + msys2-extra: + needs: [msys2] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + sys: mingw64 + env: x86_64 + variant: -mingw-w64@r688-gcc@14-openssl@1.1 + install: >- + crt-git-12.0.0.r688.g6b2176247-1 + headers-git-12.0.0.r688.g6b2176247-1 + libmangle-git-12.0.0.r688.g6b2176247-1 + libwinpthread-git-12.0.0.r688.g6b2176247-1 + tools-git-12.0.0.r688.g6b2176247-1 + winpthreads-git-12.0.0.r688.g6b2176247-1 + gcc-14.2.0-3 + gcc-libs-14.2.0-3 + openssl-1.1.1.w-1 + - os: windows-2022 + sys: ucrt64 + env: ucrt-x86_64 + variant: -mingw-w64@r688-gcc@14 + install: >- + crt-git-12.0.0.r688.g6b2176247-1 + headers-git-12.0.0.r688.g6b2176247-1 + libmangle-git-12.0.0.r688.g6b2176247-1 + libwinpthread-git-12.0.0.r688.g6b2176247-1 + tools-git-12.0.0.r688.g6b2176247-1 + winpthreads-git-12.0.0.r688.g6b2176247-1 + gcc-14.2.0-3 + gcc-libs-14.2.0-3 + - os: windows-2022 + sys: ucrt64 + env: ucrt-x86_64 + variant: -mingw-w64@r688-gcc@14-openssl@1.1 + install: >- + crt-git-12.0.0.r688.g6b2176247-1 + headers-git-12.0.0.r688.g6b2176247-1 + libmangle-git-12.0.0.r688.g6b2176247-1 + libwinpthread-git-12.0.0.r688.g6b2176247-1 + tools-git-12.0.0.r688.g6b2176247-1 + winpthreads-git-12.0.0.r688.g6b2176247-1 + gcc-14.2.0-3 + gcc-libs-14.2.0-3 + openssl-1.1.1.w-1 + - os: windows-11-arm + sys: clangarm64 + env: clang-aarch64 + variant: -mingw-w64@r688 + install: >- + crt-git-12.0.0.r688.g6b2176247-1 + headers-git-12.0.0.r688.g6b2176247-1 + libmangle-git-12.0.0.r688.g6b2176247-1 + libwinpthread-git-12.0.0.r688.g6b2176247-1 + tools-git-12.0.0.r688.g6b2176247-1 + winpthreads-git-12.0.0.r688.g6b2176247-1 + steps: + - name: Download MSYS2 + uses: actions/download-artifact@v4 + with: + name: msys2-${{ matrix.sys }} + + - name: Setup MSYS2 + id: msys2 + run: | + 7z x msys2-${{ matrix.sys }}.7z "-o${env:RUNNER_TEMP}\msys64" + + md ${env:RUNNER_TEMP}\setup-msys2 + echo @" + @echo off + setlocal + set CHERE_INVOKING=1 + IF NOT DEFINED MSYSTEM set MSYSTEM=$("${{ matrix.sys }}".ToUpper()) + IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=minimal + ${env:RUNNER_TEMP}\msys64\usr\bin\bash.exe -leo pipefail %* + "@ | tee ${env:RUNNER_TEMP}\setup-msys2\msys2.cmd + echo "${env:RUNNER_TEMP}\setup-msys2" | Tee-Object -FilePath "${env:GITHUB_PATH}" -Encoding UTF8 + + echo "msys2-location=${env:RUNNER_TEMP}\msys64" | Tee-Object -FilePath "${env:GITHUB_OUTPUT}" -Append -Encoding UTF8 + + - name: Download + run: | + foreach ($pkg in (-split $env:INSTALL)) { + gh release download msys2-packages --repo ${{ github.repository }} --pattern "${pkg}*" --pattern "mingw-w64-${{ matrix.env }}-${pkg}*" + if (!$?) { exit 1 } + } + Get-ChildItem + env: + GH_TOKEN: ${{ github.token }} + INSTALL: ${{ matrix.install }} + + - name: Trust ri2 package signing key + if: contains(matrix.install, 'openssl-1.1') + run: | + pacman-key --recv-keys 79D1D4E12FF93365DEAA8DCEF98B8484BE8BF1C5 + pacman-key --lsign-key 79D1D4E12FF93365DEAA8DCEF98B8484BE8BF1C5 + shell: msys2 {0} + + - name: Backup openssl dll/cnf files + if: contains(matrix.install, 'openssl-1.1') + run: pacman -Qql mingw-w64-${{ matrix.env }}-openssl | grep '/bin/[^/]\+\.dll$\|/etc/ssl/[^/]\+\.cnf$' | xargs -- tar -cvf openssl.orig.tar -PC / -- + shell: msys2 {0} + + - name: Install + run: find . -name '*.pkg.*' -not -name '*.sig' -print0 | xargs -0 -- pacman -Udd --noconfirm + shell: msys2 {0} + + - name: Restore openssl dll/cnf files + if: contains(matrix.install, 'openssl-1.1') + run: tar -xvf openssl.orig.tar -PC / + shell: msys2 {0} + + - name: Archive MSYS2 + run: | + cd "${env:MSYS2_LOCATION}" + 7z a "${env:GITHUB_WORKSPACE}\msys2-${{ matrix.sys }}${{ matrix.variant }}.7z" + env: + MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }} + + - name: Upload MSYS2 + uses: actions/upload-artifact@v4 + with: + name: msys2-${{ matrix.sys }}${{ matrix.variant }} + path: msys2-${{ matrix.sys }}${{ matrix.variant }}.7z + compression-level: 0 + if-no-files-found: error + + - name: Create MSYS2 Package List + run: pacman -Q | tee msys2-${{ matrix.sys }}${{ matrix.variant }}.packages.txt + shell: msys2 {0} + + - name: Upload MSYS2 Package List + uses: actions/upload-artifact@v4 + with: + name: msys2-${{ matrix.sys }}${{ matrix.variant }}-packages-txt + path: msys2-${{ matrix.sys }}${{ matrix.variant }}.packages.txt + if-no-files-found: error + + vcpkg: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + triplet: x64-windows + - os: windows-11-arm + triplet: arm64-windows + steps: + - name: Update vcpkg + run: | + cd "${env:VCPKG_INSTALLATION_ROOT}" + git fetch --depth 1 origin HEAD + git reset --hard FETCH_HEAD + .\bootstrap-vcpkg.bat + + - name: Create vcpkg.json + run: | + echo @' + { + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "dependencies": [ + "gmp", + "libyaml", + "libffi", + "pkgconf", + "openssl", + "readline-win32", + "zlib" + ] + } + '@ | Tee-Object -FilePath vcpkg.json -Encoding UTF8 + + - name: Dry Run + run: vcpkg install --dry-run | Tee-Object -FilePath vcpkg-install.log -Encoding UTF8 + + - name: Cache + uses: actions/cache@v4 + with: + path: vcpkg_binary_cache + key: ${{ runner.os }}-${{ runner.arch }}-vcpkg-${{ hashFiles('vcpkg-install.log') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-vcpkg- + + - name: Install + run: vcpkg install + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg_binary_cache,readwrite + + - name: Export + run: | + vcpkg export --raw --output vcpkg --output-dir=$pwd + cd vcpkg + 7z a ..\vcpkg-${{ matrix.triplet }}.7z installed + + - name: Upload vcpkg Export + uses: actions/upload-artifact@v4 + with: + name: vcpkg-${{ matrix.triplet }} + path: vcpkg-${{ matrix.triplet }}.7z + compression-level: 0 + if-no-files-found: error + + - name: Create vcpkg Package List + run: vcpkg list | Tee-Object -FilePath "vcpkg-${{ matrix.triplet }}.packages.txt" -Encoding UTF8 + + - name: Upload vcpkg Package List + uses: actions/upload-artifact@v4 + with: + name: vcpkg-${{ matrix.triplet }}-packages-txt + path: vcpkg-${{ matrix.triplet }}.packages.txt + if-no-files-found: error + + test: + needs: [msys2, msys2-extra, vcpkg] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + ruby-version: '3.0' + sys: mingw64 + variant: -mingw-w64@r688-gcc@14-openssl@1.1 + - os: windows-2022 + ruby-version: '3.1' + sys: ucrt64 + variant: -mingw-w64@r688-gcc@14-openssl@1.1 + - os: windows-2022 + ruby-version: '3.2.8' + sys: ucrt64 + variant: -mingw-w64@r688-gcc@14 + - os: windows-2022 + ruby-version: head + sys: ucrt64 + - os: windows-11-arm + ruby-version: '3.4.3' + sys: clangarm64 + variant: -mingw-w64@r688 + - os: windows-11-arm + ruby-version: head + sys: clangarm64 + - os: windows-2022 + ruby-version: mswin + sys: ucrt64 + triplet: x64-windows + vcvars: vcvars64.bat + # - os: windows-11-arm + # ruby-version: mswin + # sys: clangarm64 + # triplet: arm64-windows + # vcvars: vcvarsarm64.bat + steps: + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler: none + windows-toolchain: none + + - name: Download vcpkg + if: matrix.ruby-version == 'mswin' + uses: actions/download-artifact@v4 + with: + name: vcpkg-${{ matrix.triplet }} + + - name: Install vcpkg + if: matrix.ruby-version == 'mswin' + run: 7z x vcpkg-${{ matrix.triplet }}.7z "-o${env:VCPKG_INSTALLATION_ROOT}" + + - name: Setup MSVC + if: matrix.ruby-version == 'mswin' + run: | + ruby -r json -e @' + vcvars = File.join(`vswhere -latest -property installationPath`.rstrip, "VC/Auxiliary/Build/${{ matrix.vcvars }}").tr(File::SEPARATOR, File::ALT_SEPARATOR) + JSON + .parse(`"#{vcvars}" >NUL && ruby -r json -e "puts JSON.fast_generate(ENV.to_h)"`) + .each do |name, value| + if name == "Path" + warn "#{name}=#{value}" + File.open(ENV["GITHUB_PATH"], "a+") do |file| + value + .gsub("#{File::PATH_SEPARATOR}#{ENV["Path"]}", "") + .split(File::PATH_SEPARATOR) + .reverse_each do |path| + file.puts path + end + end + elsif ENV[name] != value + puts "#{name}=#{value}" + end + end + puts "MAKE=nmake.exe" + '@ | Tee-Object -FilePath "${env:GITHUB_ENV}" -Append -Encoding UTF8 + + - name: Download MSYS2 + uses: actions/download-artifact@v4 + with: + name: msys2-${{ matrix.sys }}${{ matrix.variant }} + + - name: Setup MSYS2 + id: msys2 + run: | + $rubyPrefix = ruby -e 'puts RbConfig::TOPDIR.tr(File::SEPARATOR, File::ALT_SEPARATOR)' + 7z x msys2-${{ matrix.sys }}${{ matrix.variant }}.7z "-o${env:RUNNER_TEMP}\msys64" + New-Item -ItemType Junction -Path "${rubyPrefix}\msys64" -value "${env:RUNNER_TEMP}\msys64" + echo "msys2-location=${rubyPrefix}\msys64" | Tee-Object -FilePath "${env:GITHUB_OUTPUT}" -Append -Encoding UTF8 + + - name: Setup PATH + run: | + echo "${env:MSYS2_LOCATION}\usr\bin" | Tee-Object -FilePath "${env:GITHUB_PATH}" -Append -Encoding UTF8 + echo "${env:MSYS2_LOCATION}\${{ matrix.sys }}\bin" | Tee-Object -FilePath "${env:GITHUB_PATH}" -Append -Encoding UTF8 + env: + MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }} + + - name: Enable ridk + if: matrix.ruby-version != 'mswin' + run: | + ruby -r json -e @' + JSON + .parse(`ridk.cmd enable >NUL && ruby -r json -e "puts JSON.fast_generate(ENV.to_h)"`) + .each do |name, value| + puts "#{name}=#{value}" if name != 'Path' && ENV[name] != value + end + '@ | Tee-Object -FilePath "${env:GITHUB_ENV}" -Append -Encoding UTF8 + + - name: OpenSSL compiled version + run: ruby -r openssl -e 'puts OpenSSL::OPENSSL_VERSION' + + - name: OpenSSL loaded version + run: ruby -r openssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION' + + - name: OpenSSL test + run: ruby -r open-uri -e 'puts URI.open("https://rubygems.org/") { |f| f.read(1024) }' + + - name: C extension test + run: gem install --platform ruby date fiddle openssl psych && ruby -r date -r fiddle -r openssl -r psych -e exit + + changelog: + needs: [msys2, msys2-extra, vcpkg] + runs-on: ubuntu-latest + outputs: + diff: ${{ steps.diff.outputs.diff }} + changelog: ${{ steps.changelog.outputs.changelog }} + steps: + - name: Download Latest Release + run: | + mkdir a + cd a + gh release download --repo ${{ github.repository }} --pattern '*.packages.txt' || true + env: + GH_TOKEN: ${{ github.token }} + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: b + pattern: '*-packages-txt' + merge-multiple: true + + - name: Diff + id: diff + run: echo "diff=$(diff -qr a b &>/dev/null && echo false || echo true)" | tee -a "$GITHUB_OUTPUT" + + - name: Changelog + id: changelog + run: | + { echo '``` diff'; diff -rNU0 a b || true; echo '```'; } | tee CHANGELOG.md + echo "changelog=$(base64 -w0 - - mswin vcpkg tools - #env: - # FORCE_UPDATE: true - runs-on: windows-2022 - strategy: - fail-fast: false - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: mswin - timeout-minutes: 5 - - - name: update vcpkg installation - run: | - $env:VCPKG_ROOT = $env:VCPKG_INSTALLATION_ROOT - echo "::group::————————————— git pull —————————————" - cd $env:VCPKG_INSTALLATION_ROOT - # --depth=1 may cause 'fatal: refusing to merge unrelated histories' - git pull --no-tags -q --depth=1000 - echo ::endgroup:: - echo "`n———————————— commit info ————————————" - git log -1 --pretty=format:'%H %cs%n%n' - ./bootstrap-vcpkg.bat - timeout-minutes: 15 - - - name: Update mswin tools 7z and Upload - run: ruby create_mswin_pkg.rb - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - timeout-minutes: 30 diff --git a/.github/workflows/windows-build-tools.yml b/.github/workflows/windows-build-tools.yml deleted file mode 100644 index e43486c..0000000 --- a/.github/workflows/windows-build-tools.yml +++ /dev/null @@ -1,147 +0,0 @@ -name: Windows MSYS2 Build Tools - -on: - push: - branches: - - '*' - schedule: - - cron: '30 0,6,12,18 * * *' - workflow_dispatch: - -jobs: - msys2: - name: >- - ${{ matrix.name }} tools - #env: - # FORCE_UPDATE: true - permissions: - contents: write - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - { os: windows-2022, ruby: ucrt, name: msys2 } - - { os: windows-11-arm, ruby: 3.4, name: msys2-arm64 } - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Copy msys2 files to temp dir - run: | - if (Test-Path -LiteralPath C:\msys64 -PathType Container) { - $temp = $env:RUNNER_TEMP - md $temp\msys64 - # copy current msys2 to temp folder, needed to determine what files to include - # in zip file (only newer files) - xcopy C:\msys64 $temp\msys64 /s /q - } - timeout-minutes: 15 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - timeout-minutes: 7 - - - name: Update msys2 tools 7z and Upload - run: ruby create_msys2_pkg.rb ${{ matrix.name }} - env: - GITHUB_TOKEN: ${{ github.token }} - timeout-minutes: 10 - - gcc-mingw: - if: ${{ always() }} - needs: msys2 - name: >- - ${{ matrix.gcc }} gcc - #env: - # FORCE_UPDATE: true - permissions: - contents: write - runs-on: windows-2022 - strategy: - fail-fast: false - matrix: - include: - - { gcc: mingw64 , ruby: '3.0' } - - { gcc: mingw64-3.0, ruby: mingw } - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - timeout-minutes: 7 - - - name: Update ${{ matrix.gcc }} gcc 7z and Upload - run: ruby create_gcc_pkg.rb ${{ matrix.gcc }} - env: - GITHUB_TOKEN: ${{ github.token }} - timeout-minutes: 13 - - gcc-ucrt: - if: ${{ always() }} - needs: msys2 - name: >- - ${{ matrix.gcc }} gcc - #env: - # FORCE_UPDATE: true - permissions: - contents: write - runs-on: windows-2022 - strategy: - fail-fast: false - matrix: - include: - - { gcc: ucrt64 , ruby: 3.1 } - - { gcc: ucrt64-3.0 , ruby: ucrt } - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - timeout-minutes: 7 - - - name: Update ${{ matrix.gcc }} gcc 7z and Upload - run: ruby create_gcc_pkg.rb ${{ matrix.gcc }} - env: - GITHUB_TOKEN: ${{ github.token }} - timeout-minutes: 13 - - gcc-clangarm64: - if: ${{ always() }} - needs: msys2 - name: >- - ${{ matrix.gcc }} gcc - #env: - # FORCE_UPDATE: true - permissions: - contents: write - runs-on: windows-11-arm - strategy: - fail-fast: false - matrix: - include: - - { gcc: clangarm64-3.0 , ruby: 3.4 } - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - timeout-minutes: 7 - - - name: Update ${{ matrix.gcc }} gcc 7z and Upload - run: ruby create_gcc_pkg.rb ${{ matrix.gcc }} - env: - GITHUB_TOKEN: ${{ github.token }} - timeout-minutes: 13 - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e175137..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Logs -logs -*.log - -/scratch - -notes.txt diff --git a/LICENSE b/LICENSE index 18fca39..acbabf4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2022 MSP-Greg +Copyright (c) 2025 なつき Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c111c52..e9007f5 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,35 @@ # setup-msys2-gcc -### Purpose +[![Build](https://github.com/ruby/setup-msys2-gcc/actions/workflows/build.yml/badge.svg)](https://github.com/ruby/setup-msys2-gcc/actions/workflows/build.yml) This repo packages the build tools needed to compile c and c++ source when using Windows Rubies with GitHub Actions. -### General +## Release Assets -Publicly available Windows Rubies are built with the [MSYS2](https://github.com/msys2) system, -which provides a bash shell, compilers and tools, and various packages. Windows Rubies 2.4 thru -3.0 use the MSYS2 tools refered to as 'mingw64', which compile using legacy Windows libraries. -Windows Rubies 3.1 and later use 'ucrt64', which use newer Windows libraries. +The code installs the MSYS2 and vcpkg packages with GitHub Actions. If any packages have been +updated since the latest release, it creates a new release and uploads all packages. -Below summarizes the default MSYS2 installations on Actions Windows images: +See [`windows-toolchain.json`](./windows-toolchain.json). -| Actions
Image | MSYS
Base | MSYS
Build Tools | mingw64
gcc & tools | mingw64
packages | ucrt64
gcc & tools | ucrt64
packages | -|--------------------|:--------------:|:--------------------:|:-----------------------:|:--------------------:|:----------------------:|:-------------------:| -| **11-arm** | No | No | No | No | No | No | -| **2022 and later** | Yes | No | No | No | No | No | -| **2016, 2019** | Yes | Yes | Yes | Some | No | No | +## Dependency Pinning -### Notes +### MSYS2 -Eight package files are stored in a GitHub release, and are used by -[ruby/setup-ruby](https://github.com/ruby/setup-ruby). They are: +> [!NOTE] +> Installed packages are archived in `msys2-*-var-cache-pacman-pkg.7z` in case downgrade is needed. -* **`msys2.7z`** The base msys2 installation on Actions Windows images contains a minimal -set of bash tools, and no shared build tools. Code updates the MSYS2 files, and saves only -updated files to the 7z. All Ruby Windows x64 releases from version 2.4 and later use these -tools. +If a specific version of a dependency is needed: -* **`msys2-arm64.7z`** The base msys2 installation on Actions Windows images contains a minimal -set of bash tools, and no shared build tools. Code saves complate base MSYS2 files to the 7z. -All Ruby Windows arm64 releases from version 3.4 and later use these tools. +- Upload packages to [msys2-packages](https://github.com/ruby/setup-msys2-gcc/releases/tag/msys2-packages). +- Update `msys2-extra` matrix job. +- Update `windows-toolchain.json` if needed. +- Update [ruby/setup-ruby](https://github.com/ruby/setup-ruby) if needed. -* **`mingw64.7z`** This contains the mingw64 gcc chain and any packages needed to build -Ruby. This has OpenSSL 1.1.1 installed, as of 26-Apr-2024, 1.1.1.w. Normal Ruby Windows -releases from version 2.4 thru 3.0 use these tools. +### vcpkg -* **`mingw64-3.0.7z`** This contains the mingw64 gcc chain and any packages needed to build -Ruby. The MSYS2 OpenSSL 3.y.z package is installed. The mingw Ruby master build is the -only build that uses this. +If a specific version of a dependency is needed: -* **`ucrt64.7z`** This contains the ucrt64 gcc chain and any packages needed to build -Ruby. This has OpenSSL 1.1.1 installed, as of 26-Apr-2024, 1.1.1.w. Ruby version 3.1 is -the only release that uses this. - -* **`ucrt64-3.0.7z`** This contains the ucrt64 gcc chain and any packages needed to build -Ruby. The MSYS2 OpenSSL 3.y.z package is installed. Ruby 3.2, head, & ucrt builds use this. - -* **`clangarm64-3.0.7z`** This contains the clangarm64 gcc chain and any packages needed to build -Ruby. The MSYS2 OpenSSL 3.y.z package is installed. Ruby 3.4 and head builds on windows arm64 -use this. - -* **`mswin.7z`** This contains files needed to compile Windows Ruby mswin builds. It contains -libffi, libyaml, openssl, readline, and zlib, built with the Microsoft vcpkg system. This -contains OpenSSL 3.0.z. - -The code installs the packages with [ruby/setup-ruby](https://github.com/ruby/setup-ruby), -then updates the MSYS2 and vcpkg packages. If any packages have been updated, it creates -a new 7z file and updates the package in the release. +- Update `vcpkg.json` defined in the `vcpkg` matrix job. +- Update `windows-toolchain.json` if needed. +- Update [ruby/setup-ruby](https://github.com/ruby/setup-ruby) if needed. diff --git a/common.rb b/common.rb deleted file mode 100644 index 3729f3c..0000000 --- a/common.rb +++ /dev/null @@ -1,358 +0,0 @@ -# frozen_string_literal: true - -# 25-Dec-2022 Actions cron jobs stop if repo has no commits for 60 days. - -require 'json' -require 'net/http' -require 'uri' - -module Common - # Generic constants - USER_REPO = ENV['GITHUB_REPOSITORY'] - TOKEN = ENV['GITHUB_TOKEN'] - BUILD_NUMBER = ENV['GITHUB_RUN_NUMBER'] - - GH_NAME = "#{USER_REPO}-actions" - GH_API = 'api.github.com' - GH_UPLOAD = 'uploads.github.com' - - TEMP = ENV.fetch('RUNNER_TEMP') { ENV.fetch('RUNNER_WORKSPACE') { ENV['TEMP'] } } - - SEVEN = "C:\\Program Files\\7-Zip\\7z" - - DASH = ENV['GITHUB_ACTIONS'] ? "\u2500".dup.force_encoding('utf-8') : 151.chr - LINE = DASH * 40 - GRN = "\e[92m" - RED = "\e[91m" - YEL = "\e[93m" - RST = "\e[0m" - END_GROUP = "##[endgroup]\n" - - # Repo specific constants - TAG = 'msys2-gcc-pkgs' # GitHub release tag - MSYS2_ROOT = 'C:/msys64' - PACMAN = 'C:/msys64/usr/bin/pacman.exe' - BASH = 'C:/msys64/usr/bin/bash.exe' - - def gh_api_graphql(http, query) - body = {} - body["query"] = query - - req = Net::HTTP::Post.new '/gh_api_graphql' - req['Authorization'] = "Bearer #{TOKEN}" - req['Accept'] = 'application/json' - req['Content-Type'] = 'application/json' - req.body = JSON.generate body - resp = http.request req - - if resp.code == '200' - body = resp.body - JSON.parse body, symbolize_names: true - else - STDOUT.syswrite "resp.code #{resp.code}\n" - end - end - - def gh_api_http - Net::HTTP.start(GH_API, 443, :use_ssl => true) do |http| - yield http - end - end - - def gh_upload_http - Net::HTTP.start(GH_UPLOAD, 443, :use_ssl => true) do |http| - yield http - end - end - - def set_v3_common_headers(req, connection: nil) - req['User-Agent'] = GH_NAME - req['Authorization'] = "Bearer #{TOKEN}" - req['Accept'] = 'application/vnd.github+json' # old 'application/vnd.github.v3+json' - req['X-GitHub-Api-Version'] = '2022-11-28' - req['Connection'] = 'close' if connection == 'close' - end - - def gh_api_v3_get(http, user_repo, suffix, connection: nil) - req = Net::HTTP::Get.new "/repos/#{user_repo}/#{suffix}" - set_v3_common_headers req, connection: connection - resp = http.request req - resp.code == '200' ? JSON.parse(resp.body) : resp - end - - def gh_api_v3_patch(http, user_repo, suffix, hsh, connection: nil) - req = Net::HTTP::Patch.new "/repos/#{user_repo}/#{suffix}" - set_v3_common_headers req, connection: connection - req['Content-Type'] = 'application/json; charset=utf-8' - req.body = JSON.generate hsh - - resp = http.request req - resp.code == '200' ? JSON.parse(resp.body) : resp - end - - def gh_api_v3_delete(http, user_repo, suffix, connection: nil) - req = Net::HTTP::Delete.new "/repos/#{user_repo}/#{suffix}" - set_v3_common_headers req, connection: connection - resp = http.request req - resp.code == '204' ? nil : resp - end - - def gh_api_v3_upload(http, user_repo, suffix, file, connection: nil) - unless File.exist?(file) && File.readable?(file) - STDOUT.syswrite "#{RED}File #{file} doesn't exist or isn't readable#{RST}\n" - exit 1 - end - - req = Net::HTTP::Post.new "/repos/#{user_repo}/#{suffix}" - set_v3_common_headers req, connection: connection - req['Content-Type'] = 'application/x-7z-compressed' - req['Content-Length'] = File.size file - io = File.open file, mode: 'rb' - req.body_stream = io - resp = http.request req - io.close unless io.closed? - resp.code == '201' ? JSON.parse(resp.body) : resp - end - - def response_ok(response_obj, msg, actions_group: false) - if response_obj.is_a? Net::HTTPResponse - out_str = (actions_group ? END_GROUP : '').dup - out_str << "#{RED}HTTP Error - #{msg} - #{response_obj.code} #{response_obj.message}#{RST}\n" - if (body = response_obj['body']) - out_str << "#{JSON.parse(body)}\n" - end - STDOUT.syswrite "#{out_str}\n" - false - else - true - end - end - - def download(uri_s, file) - retry_max = 3 - retries = 0 - uri = URI uri_s - redirect = nil - begin - Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| - http.verify_mode = OpenSSL::SSL::VERIFY_PEER - req = Net::HTTP::Get.new uri.request_uri - http.request req do |resp| - req['Connection'] = 'close' - case resp - when Net::HTTPSuccess then - File.open file, 'wb' do |io| - resp.read_body do |chunk| - io.write chunk - end - end - when Net::HTTPRedirection then - redirect = resp['location'] - warn "redirected to #{URI(redirect).host}" - else - puts "Unknown issue connecting to:\n#{uri}\nCode: #{resp.code} Class: #{resp.class}" - resp.value - end - end - end - rescue Errno::ECONNRESET => e - if retries > retry_max - raise e - else - puts "Retry" - retries += 1 - sleep 2 - retry - end - end - download(redirect, file) if redirect - rescue => e - STDOUT.syswrite "\nCannot connect to:\n#{uri.host}\n#{uri.request_uri}\n#{File.basename file}\n\n" - raise e - end - - def upload_7z_update(pkg_name, time) - resp_obj = nil - body = nil - release_id = nil - old_asset_exists = nil - new_asset_exists = nil - current_asset_id = nil - updated_asset_id = nil - - STDOUT.syswrite "##[group]#{YEL}Upload #{pkg_name}.7z file & update release notes#{RST}\n" - - # get release info - gh_api_http do |http| - resp_obj = gh_api_v3_get http, USER_REPO, "releases/tags/#{TAG}", - connection: 'close' - - break unless response_ok resp_obj, 'GET - release info response', actions_group: true - - release_id = resp_obj['id'] - assets = resp_obj['assets'] - - old_asset_exists = assets.any? { |asset| asset['name'] == "#{pkg_name}_old.7z" } - new_asset_exists = assets.any? { |asset| asset['name'] == "#{pkg_name}_new.7z" } - - asset_obj = assets.find { |asset| asset['name'] == "#{pkg_name}.7z" } - current_asset_id = asset_obj['id'] if asset_obj - end - - exit 1 if resp_obj.is_a? Net::HTTPResponse - - if old_asset_exists - STDOUT.syswrite "#{END_GROUP}#{RED}old asset #{pkg_name}_old.7z exists#{RST}\n" - exit 1 - end - - if new_asset_exists - STDOUT.syswrite "#{END_GROUP}#{RED}new asset #{pkg_name}_new.7z exists#{RST}\n" - exit 1 - end - - # Upload new 7z package - gh_upload_http do |http| - time_start = Process.clock_gettime Process::CLOCK_MONOTONIC - - resp_obj = gh_api_v3_upload http, USER_REPO, - "releases/#{release_id}/assets?label=&name=#{pkg_name}_new.7z", "#{pkg_name}.7z", - connection: 'close' - - break unless response_ok resp_obj, 'POST - upload new 7z package', actions_group: true - - updated_asset_id = resp_obj['id'] - - ttl_time = format '%5.2f', (Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start).round(2) - STDOUT.syswrite "Upload time: #{ttl_time} secs\n" - end - - exit 1 if resp_obj.is_a? Net::HTTPResponse - - unless updated_asset_id - STDOUT.syswrite "#{END_GROUP}#{RED}updated_asset_id not found#{RST}\n" - exit 1 - end - - sleep 5.0 - - # Flip names and update release notes (body) - gh_api_http do |http| - time_start = Process.clock_gettime Process::CLOCK_MONOTONIC - - if current_asset_id - resp_obj = gh_api_v3_patch http, USER_REPO, "releases/assets/#{current_asset_id}", {'name' => "#{pkg_name}_old.7z"} - break unless response_ok resp_obj, 'PATCH - rename current asset to old', actions_group: true - end - - resp_obj = gh_api_v3_patch http, USER_REPO, "releases/assets/#{updated_asset_id}", {'name' => "#{pkg_name}.7z"} - break unless response_ok resp_obj, 'PATCH - rename updated asset to current', actions_group: true - - ttl_time = format '%5.2f', (Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start).round(2) - STDOUT.syswrite "Rename time: #{ttl_time} secs\n" - - if current_asset_id - resp_obj = gh_api_v3_delete http, USER_REPO, "releases/assets/#{current_asset_id}" - break unless response_ok resp_obj, 'DELETE - remove old asset', actions_group: true - end - - resp_obj = gh_api_v3_get http, USER_REPO, "releases/#{release_id}" - break unless response_ok resp_obj, 'GET - release notes response', actions_group: true - body = resp_obj['body'] - - # update package info in release notes - h = {'body' => update_release_notes(body, pkg_name, time)} - resp_obj = gh_api_v3_patch http, USER_REPO, "releases/#{release_id}", h, - connection: 'close' - break unless response_ok resp_obj, 'PATCH - update release notes with date/build number', actions_group: true - end - - exit 1 if resp_obj.is_a? Net::HTTPResponse - - Net::HTTP.start('github.com', 443, :use_ssl => true) do |http| - req = Net::HTTP::Head.new "/#{USER_REPO}/releases/download/#{TAG}/#{pkg_name}.7z" - resp = http.request req - if resp.code == '302' - STDOUT.syswrite "##[endgroup]\n\n#{GRN}HTTP HEAD request #{pkg_name}.7z test - #{resp.code} #{resp.message}#{RST}\n" - else - STDOUT.syswrite "##[endgroup]\n\n#{RED}HTTP HEAD request #{pkg_name}.7z test - #{resp.code} #{resp.message}#{RST}\n" - end - end - end - - def update_release_notes(old_body, name, time) - old_body.sub(/(^\| +\*\*#{name}\*\* +\|).+/) { - "#{$1} #{time} | #{BUILD_NUMBER.rjust 6} |" - } - end - - def gpg_conf_key_server(old_uri, new_uri) - fn = "#{MSYS2_ROOT}/etc/pacman.d/gnupg/gpg.conf" - str = File.binread fn - if str.include? old_uri - str.sub! old_uri, new_uri - File.binwrite fn, str - STDOUT.syswrite "\ngpg.conf - changed '#{old_uri}' to '#{new_uri}'" - end - end - - def refresh_keys - STDOUT.syswrite "\n##[group]#{YEL}#{LINE} Refresh keys#{RST}\n" - gpg_conf_key_server 'keyserver.ubuntu.com', 'keys.openpgp.org' - - str = '' - cmd = "#{BASH} -c \"pacman-key --refresh-keys\"" - - IO.popen(cmd, err: [:child, :out]) { |io| str = io.read } - - system 'taskkill /f /fi "MODULES eq msys-2.0.dll"' - - STDOUT.syswrite "#{str}\n#{END_GROUP}" - - str.match?(/new signatures:|signatures cleaned:/) ? true : nil - end - - def pacman_syuu(ignore = nil) - - usr_bin = "#{MSYS2_ROOT}/usr/bin" - - exit 1 unless system "#{usr_bin}/sed -i 's/^CheckSpace/#CheckSpace/g' C:/msys64/etc/pacman.conf" - - ignore = ignore ? "--ignore #{ignore}" : nil - - cmd = "#{PACMAN} -Syuu --disable-download-timeout --noconfirm #{ignore}" - - exec_check 'Updating all installed packages', cmd, false - system 'taskkill /f /fi "MODULES eq msys-2.0.dll"' - STDOUT.syswrite END_GROUP - - exec_check 'Updating all installed packages (2nd pass)', cmd, false - system 'taskkill /f /fi "MODULES eq msys-2.0.dll"' - STDOUT.syswrite END_GROUP - - refresh_keys - end - - # logs message and runs cmd, checking for error - def exec_check(msg, cmd, write_group_end = true) - STDOUT.syswrite "\n##[group]#{YEL}#{LINE} #{msg}#{RST}\n" - exit 1 unless system cmd - STDOUT.syswrite END_GROUP if write_group_end - end - - def log_array_2_column(ary, wid, hdr) - pad = (wid - hdr.length - 5)/2 - - hdr_pad = pad > 0 ? "#{DASH * pad} #{hdr} #{DASH * pad}" : hdr - - STDOUT.syswrite "\n#{YEL}#{hdr_pad.ljust wid}#{hdr_pad}#{RST}\n" - - mod = ary.length % 2 - split = ary.length/2 - offset = split + mod - (0...split).each do - |i| STDOUT.syswrite "#{ary[i].ljust wid}#{ary[i + offset]}\n" - end - STDOUT.syswrite "#{ary[split]}\n" if mod == 1 - end -end diff --git a/create_gcc_pkg.rb b/create_gcc_pkg.rb deleted file mode 100644 index d0227ee..0000000 --- a/create_gcc_pkg.rb +++ /dev/null @@ -1,294 +0,0 @@ -# frozen_string_literal: true - -# Original code by MSP-Greg -# This script creates 7z files of the mingw64 and ucrt64 MSYS2 gcc tool chains -# for use with GitHub Actions. Since these files are installed on the Actions -# Windows runner's hard drive, smaller zip files speed up the installation. -# Hence, many of the 'doc' related files in the 'share' folder are removed. - -# OpenSSL - There are comments and code lines that are commented out. The archives -# may need to have one version of OpenSSL fully installed, and if that version -# differs from the current MSYS2 version, the OpenSSL files needed to run (not build) -# the MSYS2 utilities need to remain. They should be from the most recent version -# that MSYS2 uses. -# -# This means there are files that are not associated with an installed package, -# so the code gets more complex, and some code is just needed for the transition. - -require 'fileutils' -require_relative 'common' - -module CreateMingwGCC - class << self - - include Common - - TAR_DIR = "#{TEMP}/msys64" - - SYNC = 'var/lib/pacman/sync' - LOCAL = 'var/lib/pacman/local' - - PKG_NAME = ARGV[0].downcase - - PKG_DIR, PKG_PRE = - case PKG_NAME[/\A[^-]+/] - when 'ucrt64' - ['ucrt64', 'mingw-w64-ucrt-x86_64-'] - when 'mingw64' - ['mingw64', 'mingw-w64-x86_64-'] - when 'mingw32' - ['mingw32', 'mingw-w64-i686-'] - when 'clangarm64' - ['clangarm64', 'mingw-w64-clang-aarch64-'] - else - STDOUT.syswrite "Invalid package type, must be ucrt64, mingw64, mingw32, or clangarm64\n" - exit 1 - end - - MSYS2_PKG = "#{MSYS2_ROOT}/#{PKG_DIR}" - - SSL_1_DLLS = if PKG_DIR == 'clangarm64' - %w[bin/libcrypto-1_1.dll bin/libssl-1_1.dll] - else - %w[bin/libcrypto-1_1-x64.dll bin/libssl-1_1-x64.dll] - end - - SSL_3_SAVE_FILES = if PKG_DIR == 'clangarm64' - %w[bin/libcrypto-3.dll bin/libssl-3.dll etc/ssl/openssl.cnf] - else - %w[bin/libcrypto-3-x64.dll bin/libssl-3-x64.dll etc/ssl/openssl.cnf] - end - - def add_ri2_key - # appveyor ri2 package signing key - key = 'F98B8484BE8BF1C5' - exec_check "pacman-key --init", "bash.exe -c \"pacman-key --init\"" - exec_check "Get RI2 Key" , "bash.exe -c \"pacman-key --recv-keys #{key}\"" - exec_check "Sign RI2 Key", "bash.exe -c \"pacman-key --lsign-key #{key}\"", false - end - - def gcc_downgrade - ['gcc-libs', 'gcc'].each do |base| - pkg_name = "#{base}-#{@gcc}-any.pkg.tar.zst" - pkg = "https://github.com/ruby/setup-msys2-gcc/releases/download/msys2-packages/#{PKG_PRE}#{pkg_name}" - pkg_sig = "#{pkg}.sig" - - download pkg , "./#{PKG_PRE}#{pkg_name}" - download pkg_sig, "./#{PKG_PRE}#{pkg_name}.sig" - - # install package - exec_check "Install #{base}-#{@gcc} Downgrade", "pacman.exe -Udd --noconfirm --noprogressbar #{PKG_PRE}#{pkg_name}" - end - end - - def openssl_downgrade - add_ri2_key - - pkg_name = "openssl-1.1.1.w-1-any.pkg.tar.zst" - pkg = "https://github.com/ruby/setup-msys2-gcc/releases/download/msys2-packages/#{PKG_PRE}#{pkg_name}" - pkg_sig = "#{pkg}.sig" - - # save previous dll files so we can copy back into folder - SSL_3_SAVE_FILES.each { |fn| FileUtils.cp "#{MSYS2_PKG}/#{fn}", "." } - - download pkg , "./#{PKG_PRE}#{pkg_name}" - download pkg_sig, "./#{PKG_PRE}#{pkg_name}.sig" - - STDOUT.syswrite END_GROUP - - # install package - exec_check "Install OpenSSL Downgrade", "pacman.exe -Udd --noconfirm --noprogressbar #{PKG_PRE}#{pkg_name}" - - # copy previous dlls back into MSYS2 folder - SSL_3_SAVE_FILES.each { |fn| FileUtils.cp_r File.basename(fn) , "#{MSYS2_PKG}/#{fn}" } - openssl_copy_cert_files - end - - # as of Jan-2023, not used, save for future use - def openssl_upgrade - add_ri2_key - - pkg_name = "openssl-3.0.7-1-any.pkg.tar.zst" - pkg = "https://github.com/oneclick/rubyinstaller2-packages/releases/download/ci.ri2/#{PKG_PRE}#{pkg_name}" - pkg_sig = "#{pkg}.sig" - - # save previous dll files so we can copy back into folder - SSL_1_DLLS.each { |fn| FileUtils.cp "#{MSYS2_PKG}/#{fn}", "." } - - download pkg , "./#{PKG_PRE}#{pkg_name}" - download pkg_sig, "./#{PKG_PRE}#{pkg_name}.sig" - - # install package - exec_check "Install OpenSSL Upgrade", "pacman.exe -Udd --noconfirm --noprogressbar #{PKG_PRE}#{pkg_name}" - - # copy previous dlls back into MSYS2 folder - SSL_1_DLLS.each { |fn| FileUtils.cp_r File.basename(fn) , "#{MSYS2_PKG}/#{fn}" } - end - - # Below files are part of the 'ca-certificates' package, they are not - # included in the openssl package - # This is needed due to MSYS2 OpenSSL 1.1.1 using 'ssl', and the 3.0 version - # using 'etc/ssl'. - def openssl_copy_cert_files - new_dir = "#{MSYS2_PKG}/ssl" - old_dir = "#{MSYS2_PKG}/etc/ssl" - unless Dir.exist? "#{new_dir}/certs" - FileUtils.mkdir_p "#{new_dir}/certs" - end - %w[cert.pem certs/ca-bundle.crt certs/ca-bundle.trust.crt].each do |fn| - if File.exist?("#{old_dir}/#{fn}") && !File.exist?("#{new_dir}/#{fn}") - FileUtils.cp "#{old_dir}/#{fn}", "#{new_dir}/#{fn}" - end - end - end - - def install_gcc - - @gcc = PKG_DIR == 'clangarm64' ? nil : '14.2.0-3' - - args = '--noconfirm --noprogressbar --needed' - - # zlib required by gcc, gdbm for older Rubies - base_gcc = @gcc ? - %w[make pkgconf libmangle-git tools-git curl] : - %w[make pkgconf libmangle-git tools-git gcc curl] - - base_ruby = PKG_NAME.end_with?('-3.0') ? - %w[gdbm gmp libffi libyaml openssl ragel readline] : - %w[gdbm gmp libffi libyaml openssl ragel readline] - - pkgs = (base_gcc + base_ruby).unshift('').join " #{PKG_PRE}" - - unless PKG_NAME.end_with? '-3.0' - SSL_3_SAVE_FILES.each do |fn| - FileUtils.remove_file "#{MSYS2_PKG}/#{fn}" if File.exist? "#{MSYS2_PKG}/#{fn}" - end - end - - # May not be needed, but... - # Note that OpenSSL may need to be ignored - if PKG_NAME.end_with?('-3.0') - pacman_syuu - else - pacman_syuu - end - - gcc_downgrade if @gcc - - exec_check "Updating the following #{PKG_PRE[0..-2]} packages:#{RST}\n" \ - "#{YEL}#{(base_gcc + base_ruby).join ' '}", - "#{PACMAN} -S #{args} #{pkgs}" - - if PKG_NAME.end_with? '-3.0' - SSL_1_DLLS.each do |fn| - FileUtils.remove_file("#{MSYS2_PKG}/#{fn}") if File.exist?("#{MSYS2_PKG}/#{fn}") - end - else - openssl_downgrade - end - end - - # copies needed files from C:/msys64 to TEMP - def copy_to_temp - Dir.chdir TEMP do - FileUtils.mkdir_p "msys64/#{SYNC}" - FileUtils.mkdir_p "msys64/#{LOCAL}" - end - - Dir.chdir "#{MSYS2_ROOT}/#{SYNC}" do - FileUtils.cp "#{PKG_DIR}.db", "#{TAR_DIR}/#{SYNC}" - FileUtils.cp "#{PKG_DIR}.db.sig", "#{TAR_DIR}/#{SYNC}" - end - - ary = Dir.glob "#{PKG_PRE}*", base: "#{MSYS2_ROOT}/#{LOCAL}" - - local = "#{TAR_DIR}/#{LOCAL}" - - Dir.chdir "#{MSYS2_ROOT}/#{LOCAL}" do - ary.each { |dir| FileUtils.copy_entry dir, "#{local}/#{dir}" } - end - - FileUtils.copy_entry "#{MSYS2_ROOT}/#{PKG_DIR}", "#{TAR_DIR}/#{PKG_DIR}" - end - - # removes files contained in 'share' folder to reduce 7z file size - def clean_package - share = "#{TAR_DIR}/#{PKG_DIR}/share" - - Dir.chdir "#{share}/doc" do - ary = Dir.glob "*" - ary.each { |dir| FileUtils.remove_dir dir } - end - - Dir.chdir "#{share}/info" do - ary = Dir.glob "*.gz" - ary.each { |file| FileUtils.remove_file file } - end - - Dir.chdir "#{share}/man" do - ary = Dir.glob "**/*.gz" - ary.each { |file| FileUtils.remove_file file } - end - - # remove entries in 'files' file so updates won't log warnings - Dir.chdir "#{TAR_DIR}/#{LOCAL}" do - ary = Dir.glob "#{PKG_PRE}*/files" - ary.each do |fn| - File.open(fn, mode: 'r+b') { |f| - str = f.read - f.truncate 0 - f.rewind - str.gsub!(/^#{PKG_DIR}\/share\/doc\/\S+\s*/m , '') - str.gsub!(/^#{PKG_DIR}\/share\/info\/\S+\s*/m, '') - str.gsub!(/^#{PKG_DIR}\/share\/man\/\S+\s*/m , '') - f.write "#{str.strip}\n\n" - } - end - end - end - - def run - current_pkgs = %x[#{PACMAN} -Q].split("\n").select { |l| l.start_with? PKG_PRE } - - # exec_check "Removing #{PKG_PRE}dlfcn", - # "#{PACMAN} -R --noconfirm --noprogressbar #{PKG_PRE}dlfcn" - - install_gcc - - time = Time.now.utc.strftime '%Y-%m-%d %H:%M:%S UTC' - - updated_pkgs = %x[#{PACMAN} -Q].split("\n").select { |l| l.start_with? PKG_PRE } - - # log current packages - log_array_2_column updated_pkgs.map { |el| el.sub PKG_PRE, ''}, 48, - "Installed #{PKG_PRE[0..-2]} Packages" - - if (current_pkgs == updated_pkgs) && !ENV.key?('FORCE_UPDATE') - STDOUT.syswrite "\n** No update to #{PKG_DIR} gcc tools needed **\n\n" - exit 0 - else - STDOUT.syswrite "\n#{GRN}** Creating and Uploading #{PKG_DIR} gcc tools 7z **#{RST}\n\n" - end - - exec_check "Remove all uninstalled packages" , "#{BASH} -c \"paccache -r -f -u -k0\"" - exec_check "Keep the newest for all other packages" , "#{BASH} -c \"paccache -r -f -k1\"" - exec_check "Remove all cached packages" , "#{PACMAN} -Scc --noconfirm" - - copy_to_temp - - clean_package - - # create 7z file - STDOUT.syswrite "##[group]#{YEL}Create #{PKG_NAME} 7z file#{RST}\n" - tar_path = "#{Dir.pwd}\\#{PKG_NAME}.7z".gsub '/', '\\' - Dir.chdir TAR_DIR do - exit 1 unless system "\"#{SEVEN}\" a #{tar_path}" - end - STDOUT.syswrite "##[endgroup]\n" - - upload_7z_update PKG_NAME, time - end - end -end - -CreateMingwGCC.run diff --git a/create_mswin_pkg.rb b/create_mswin_pkg.rb deleted file mode 100644 index eed7e4d..0000000 --- a/create_mswin_pkg.rb +++ /dev/null @@ -1,120 +0,0 @@ -# frozen_string_literal: true - -# Original code by MSP-Greg -# This script creates a 7z file using `vcpkg export` for use with Ruby mswin -# builds in GitHub Actions. - -require 'fileutils' -require_relative 'common' - -module CreateMswin - class << self - - include Common - - PACKAGES = 'pkgconf gmp libffi libyaml openssl readline-win32 zlib' - PKG_DEPENDS = 'vcpkg-cmake vcpkg-cmake-config vcpkg-cmake-get-vars vcpkg-tool-meson' - - PKG_NAME = 'mswin' - - EXPORT_DIR = "#{TEMP}".gsub "\\", '/' - - VCPKG = ENV.fetch 'VCPKG_INSTALLATION_ROOT', 'C:/vcpkg' - - OPENSSL_PKG = 'packages/openssl_x64-windows' - - def copy_ssl_files - # Locations for vcpkg OpenSSL build - # X509::DEFAULT_CERT_FILE C:\vcpkg\packages\openssl_x64-windows/cert.pem - # X509::DEFAULT_CERT_DIR C:\vcpkg\packages\openssl_x64-windows/certs - # Config::DEFAULT_CONFIG_FILE C:\vcpkg\packages\openssl_x64-windows/openssl.cnf - - vcpkg_u = VCPKG.gsub "\\", '/' - - # make certs dir - export_ssl_path = "#{EXPORT_DIR}/#{PKG_NAME}/#{OPENSSL_PKG}" - FileUtils.mkdir_p "#{export_ssl_path}/certs" - - # updating OpenSSL package may overwrite cert.pem - cert_path = "#{RbConfig::TOPDIR}/ssl/cert.pem" - - if File.readable? cert_path - vcpkg_ssl_path = "#{vcpkg_u}/#{OPENSSL_PKG}" - unless Dir.exist? vcpkg_ssl_path - FileUtils.mkdir_p vcpkg_ssl_path - end - IO.copy_stream cert_path, "#{vcpkg_ssl_path}/cert.pem" - IO.copy_stream cert_path, "#{export_ssl_path}/cert.pem" - end - - # copy openssl.cnf file - conf_path = "#{vcpkg_u}/installed/x64-windows/tools/openssl/openssl.cnf" - if File.readable? conf_path - IO.copy_stream conf_path, "#{export_ssl_path}/openssl.cnf" - end - end - - def generate_package_files - ENV['VCPKG_ROOT'] = VCPKG - - Dir.chdir VCPKG do |d| - - install_info = %x(./vcpkg install #{PACKAGES} --triplet=x64-windows --dry-run) - - installed_packages = install_info.include?('The following packages will be built and installed') - - exec_check "Installing #{PACKAGES}", - "./vcpkg install #{PACKAGES} --triplet=x64-windows" - - update_info = %x(./vcpkg update) - if !installed_packages && update_info.include?('No packages need updating') && !ENV.key?('FORCE_UPDATE') - STDOUT.syswrite "\n#{GRN}No packages need updating#{RST}\n\n" - exit 0 - else - STDOUT.syswrite "\n#{YEL}#{LINE} Updates needed#{RST}\n#{update_info}" - end - - exec_check "Upgrading #{PACKAGES}", - "./vcpkg upgrade #{PACKAGES} #{PKG_DEPENDS} --triplet=x64-windows --no-dry-run" - - exec_check "Removing outdated packages", - "./vcpkg remove --outdated --recurse" - - exec_check "Package List", - "./vcpkg list" - - exec_check "Exporting package files from vcpkg", - "./vcpkg export --triplet=x64-windows #{PACKAGES} --raw --output=#{PKG_NAME} --output-dir=#{EXPORT_DIR}" - end - - # remove tracked files - Dir.chdir "#{EXPORT_DIR}/#{PKG_NAME}" do - FileUtils.remove_dir 'scripts', true - end - - vcpkg_u = VCPKG.gsub "\\", '/' - - # vcpkg/installed/status contains a list of installed packages - status_path = 'installed/vcpkg/status' - IO.copy_stream "#{vcpkg_u}/#{status_path}", "#{EXPORT_DIR}/#{PKG_NAME}/#{status_path}" - end - - def run - generate_package_files - - copy_ssl_files - - # create 7z archive file - tar_path = "#{__dir__}\\#{PKG_NAME}.7z".gsub '/', '\\' - - Dir.chdir("#{EXPORT_DIR}/#{PKG_NAME}") do - exec_check "Creating 7z file", "\"#{SEVEN}\" a #{tar_path}" - end - - time = Time.now.utc.strftime '%Y-%m-%d %H:%M:%S UTC' - upload_7z_update PKG_NAME, time - end - end -end - -CreateMswin.run diff --git a/create_msys2_pkg.rb b/create_msys2_pkg.rb deleted file mode 100644 index 98b42fc..0000000 --- a/create_msys2_pkg.rb +++ /dev/null @@ -1,147 +0,0 @@ -# frozen_string_literal: true - -# Original code by MSP-Greg -# This script creates a 7z file of the MSYS2 base tools (located in usr/bin) -# for use with GitHub Actions. Since these files are installed on the Actions -# Windows runner's hard drive, smaller zip files speed up the installation. -# Hence, many of the 'doc' related files in the 'share' folder are removed. - -require 'fileutils' -require_relative 'common' - -module CreateMSYS2Tools - class << self - - include Common - - TEMP = ENV.fetch('RUNNER_TEMP') { ENV.fetch('RUNNER_WORKSPACE') { ENV['TEMP'] } } - ORIG_MSYS2 = "#{TEMP}/msys64".gsub '\\', '/' - - SYNC = 'var/lib/pacman/sync' - LOCAL = 'var/lib/pacman/local' - CACHE = 'var/cache/pacman/pkg' - - MSYS2_PKG = case RUBY_PLATFORM - when 'aarch64-mingw-ucrt' - "#{MSYS2_ROOT}/clangarm64" - when /ucrt$/ - "#{MSYS2_ROOT}/ucrt64" - else - "#{MSYS2_ROOT}/mingw64" - end - - PKG_NAME = ARGV[0].downcase - - SSL_3_SAVE_FILES = %w[ - bin/libcrypto-3-x64.dll - bin/libssl-3-x64.dll - etc/ssl/openssl.cnf - ] - - def update_msys2 - - SSL_3_SAVE_FILES.each do |fn| - FileUtils.remove_file "#{MSYS2_PKG}/#{fn}" if File.exist? "#{MSYS2_PKG}/#{fn}" - end - - updated_keys = pacman_syuu - - pkgs = 'autoconf-wrapper autogen automake-wrapper bison diffutils libtool m4 make patch re2c texinfo texinfo-tex compression' - exec_check "Install MSYS2 Packages#{RST}\n#{YEL}#{pkgs}", - "#{PACMAN} -S --noconfirm --needed --noprogressbar #{pkgs}" - updated_keys - end - - def remove_non_msys2 - dirs = %w[clang32 clang64 clangarm64 mingw32 mingw64 ucrt64] - Dir.chdir MSYS2_ROOT do |d| - dirs.each { |dir_name| FileUtils.rm_rf dir_name } - end - - dir = "#{MSYS2_ROOT}/#{LOCAL}" - Dir.chdir dir do |d| - del_dirs = Dir['mingw*'] - del_dirs.each { |dir_name| FileUtils.rm_rf dir_name } - end - end - - # remove files from 7z that are identical to Windows image - def remove_duplicate_files - files = Dir.glob('**/*', base: MSYS2_ROOT).reject { |fn| fn.start_with? LOCAL } - - removed_files = 0 - - Dir.chdir MSYS2_ROOT do |d| - files.each do |fn| - old_fn = "#{ORIG_MSYS2}/#{fn}" - if File.exist?(old_fn) && File.mtime(fn) == File.mtime(old_fn) - removed_files += 1 - File.delete fn - end - end - end - STDOUT.syswrite "Removed #{removed_files} files\n" - end - - # remove unneeded database files - def clean_database(pre) - dir = "#{MSYS2_ROOT}/#{SYNC}" - files = Dir.glob('*', base: dir).reject { |fn| fn.start_with? pre } - Dir.chdir(dir) do - files.each { |fn| File.delete fn } - end - end - - # remove downloaded packages and their '.sig' files - def clean_packages - dir = "#{MSYS2_ROOT}/#{CACHE}" - files = Dir.glob('*.*', base: dir) - Dir.chdir(dir) do - files.each do |fn| - next unless File.file? fn - File.delete fn - end - end - end - - def run - current_pkgs = %x[#{PACMAN} -Q].split("\n").reject { |l| l.start_with? 'mingw-w64-' } - - updated_keys = update_msys2 - - updated_pkgs = %x[#{PACMAN} -Q].split("\n").reject { |l| l.start_with? 'mingw-w64-' } - - time = Time.now.utc.strftime '%Y-%m-%d %H:%M:%S UTC' - - log_array_2_column updated_pkgs, 48, "Installed MSYS2 Packages" - - if current_pkgs == updated_pkgs && !updated_keys && !ENV.key?('FORCE_UPDATE') - STDOUT.syswrite "\n** No update to MSYS2 tools needed **\n\n" - exit 0 - else - STDOUT.syswrite "\n#{GRN}** Creating and Uploading MSYS update 7z **#{RST}\n\n" - end - - exec_check "Remove all uninstalled packages" , "#{BASH} -c \"paccache -r -f -u -k0\"" - exec_check "Keep the newest for all other packages" , "#{BASH} -c \"paccache -r -f -k1\"" - exec_check "Remove all cached packages" , "#{PACMAN} -Scc --noconfirm" - - remove_non_msys2 - remove_duplicate_files if File.exist?(ORIG_MSYS2) - clean_database 'msys' - clean_packages - - # create 7z file - STDOUT.syswrite "##[group]#{YEL}Create msys2 7z file#{RST}\n" - tar_path = "#{Dir.pwd}\\#{PKG_NAME}.7z".gsub '/', '\\' - Dir.chdir MSYS2_ROOT do - exit 1 unless system "\"#{SEVEN}\" a #{tar_path}" - end - STDOUT.syswrite "##[endgroup]\n" - - upload_7z_update PKG_NAME, time - end - end -end - -CreateMSYS2Tools.run diff --git a/windows-toolchain.json b/windows-toolchain.json new file mode 100644 index 0000000..5f0abc0 --- /dev/null +++ b/windows-toolchain.json @@ -0,0 +1,86 @@ +[ + { + "name": "msys1-mingw64", + "href": "https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe", + "platform": "x64-mingw32", + "required_ruby_version": [ + ["< 2.4.dev"] + ] + }, + { + "name": "msys2-clangarm64", + "href": "msys2-clangarm64.7z", + "platform": "aarch64-mingw-ucrt", + "required_ruby_version": [ + [">= 3.4.4"] + ] + }, + { + "name": "msys2-clangarm64-mingw-w64@r688", + "href": "msys2-clangarm64-mingw-w64@r688.7z", + "platform": "aarch64-mingw-ucrt", + "required_ruby_version": [ + [">= 3.4.dev", "< 3.4.4"] + ] + }, + { + "name": "msys2-ucrt64", + "href": "msys2-ucrt64.7z", + "platform": "x64-mingw-ucrt", + "required_ruby_version": [ + [">= 3.4.4"], + [">= 3.3.9", "< 3.4.dev"], + [">= 3.2.9", "< 3.3.dev"] + ] + }, + { + "name": "msys2-ucrt64-mingw-w64@r688-gcc@14", + "href": "msys2-ucrt64-mingw-w64@r688-gcc@14.7z", + "platform": "x64-mingw-ucrt", + "required_ruby_version": [ + [">= 3.4.dev", "< 3.4.4"], + [">= 3.3.dev", "< 3.3.9"], + [">= 3.2.dev", "< 3.2.9"] + ] + }, + { + "name": "msys2-ucrt64-mingw-w64@r688-gcc@14-openssl@1.1", + "href": "msys2-ucrt64-mingw-w64@r688-gcc@14-openssl@1.1.7z", + "platform": "x64-mingw-ucrt", + "required_ruby_version": [ + [">= 3.1.dev", "< 3.2.dev"] + ] + }, + { + "name": "msys2-mingw64", + "href": "msys2-mingw64.7z", + "platform": "x64-mingw32", + "required_ruby_version": [ + [">= 3.5.dev"] + ] + }, + { + "name": "msys2-mingw64-mingw-w64@r688-gcc@14-openssl@1.1", + "href": "msys2-mingw64-mingw-w64@r688-gcc@14-openssl@1.1.7z", + "platform": "x64-mingw32", + "required_ruby_version": [ + [">= 2.4.dev", "< 3.1.dev"] + ] + }, + { + "name": "vcpkg-arm64-windows", + "href": "vcpkg-arm64-windows.7z", + "platform": "aarch64-mswin64", + "required_ruby_version": [ + [">= 3.5.dev"] + ] + }, + { + "name": "vcpkg-x64-windows", + "href": "vcpkg-x64-windows.7z", + "platform": "x64-mswin64", + "required_ruby_version": [ + [">= 2.0.dev"] + ] + } +]