From 80701514cd85f4a0b784a46d7c9c0a63aa8013de Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 8 Aug 2026 12:51:04 +0200 Subject: [PATCH] Add support for Windows builds in the ci --- .github/workflows/ci.yml | 73 +++++++++++++++++++++++++++++++++++++++- meson.build | 27 +++++++++++++-- src/main.c | 1 - 3 files changed, 96 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 207e11c..d40d0a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,6 +110,69 @@ jobs: if-no-files-found: error archive: false + windows: + name: Build Windows package + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: 3.12.x + + - name: Setup MSVC + uses: TheMrMilchmann/setup-msvc-dev@v4 + with: + arch: x64 + + - name: Install build dependencies + run: python -m pip install meson ninja + + - name: Install radare2 + id: r2 + uses: radareorg/github-actions@v3 + + - name: Configure + run: meson setup build-windows --buildtype=release -Dplugins=enabled + + - name: Build + run: meson compile -C build-windows + + - name: Test + run: meson test -C build-windows --print-errorlogs + + - name: Package Windows build + id: package + shell: pwsh + run: | + $project = meson introspect build-windows --projectinfo | ConvertFrom-Json + $package = "r2unity-$($project.version)-w64" + $files = @( + "build-windows\r2unity.exe", + "build-windows\core_r2unity.dll", + "build-windows\bin_r2unity.dll" + ) + New-Item -ItemType Directory -Path $package | Out-Null + foreach ($file in $files) { + if (-not (Test-Path $file)) { + throw "Missing Windows build output: $file" + } + Copy-Item $file -Destination $package + } + $archive = "$package.zip" + Compress-Archive -Path "$package\*" -DestinationPath $archive -Force + "archive=$archive" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + + - name: Upload Windows package artifact + uses: actions/upload-artifact@v7 + with: + name: windows-package + path: ${{ steps.package.outputs.archive }} + if-no-files-found: error + release: name: Publish release if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} @@ -117,6 +180,7 @@ jobs: - build - meson - debian + - windows runs-on: ubuntu-latest permissions: contents: write @@ -126,13 +190,19 @@ jobs: with: fetch-depth: 0 - - name: Download artifacts + - name: Download Debian package artifact uses: actions/download-artifact@v8 with: pattern: '*.deb' path: dist/artifacts merge-multiple: true + - name: Download Windows package artifact + uses: actions/download-artifact@v8 + with: + name: windows-package + path: dist/artifacts + - name: Generate release notes run: ./release.sh notes > release-notes.md @@ -147,3 +217,4 @@ jobs: fail_on_unmatched_files: true files: | dist/artifacts/*.deb + dist/artifacts/*.zip diff --git a/meson.build b/meson.build index f026897..cc46295 100644 --- a/meson.build +++ b/meson.build @@ -17,8 +17,26 @@ add_project_arguments( language: 'c', ) -r_util_dep = dependency('r_util') -r_bin_dep = dependency('r_bin') +r2 = find_program('r2', required: true) +r2_cflags = run_command(r2, '-H', 'R2_CFLAGS', check: true).stdout().strip().split() +r2_ldflags = run_command(r2, '-H', 'R2_LDFLAGS', check: true).stdout().strip().split() +r2_libs = run_command(r2, '-H', 'R2_LIBS', check: true).stdout().strip().split() +r2_fallback_dep = declare_dependency( + compile_args: r2_cflags, + link_args: r2_ldflags + r2_libs, +) + +# Windows release ZIPs are relocatable and are not registered with pkg-config. +# Fall back to the paths reported by r2 when pkg-config cannot find its SDK. +r_util_dep = dependency('r_util', required: false) +if not r_util_dep.found() + r_util_dep = r2_fallback_dep +endif + +r_bin_dep = dependency('r_bin', required: false) +if not r_bin_dep.found() + r_bin_dep = r2_fallback_dep +endif conf = configuration_data() conf.set_quoted('R2UNITY_VERSION', meson.project_version()) @@ -48,7 +66,10 @@ test('r2unity-help', r2unity, args: ['-h']) test('r2unity-version', r2unity, args: ['-v']) plugins_opt = get_option('plugins') -r_core_dep = dependency('r_core', required: plugins_opt) +r_core_dep = dependency('r_core', required: false) +if not r_core_dep.found() and not plugins_opt.disabled() + r_core_dep = r2_fallback_dep +endif build_plugins = plugins_opt.enabled() or ( plugins_opt.auto() and r_core_dep.found() and r_bin_dep.found() ) diff --git a/src/main.c b/src/main.c index 939c227..5288d3e 100644 --- a/src/main.c +++ b/src/main.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include "lib/lib.h"