Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meson build system support #525

Merged
merged 12 commits into from
Oct 6, 2024
69 changes: 61 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ jobs:
name: >-
CMake build + tests (${{ matrix.image_name }} ${{ matrix.cmake_flags }})
runs-on: ${{ matrix.image_name }}

strategy:
fail-fast: false
matrix:
include:
# Do a regular and a no-libc build for each platform.
- image_name: macOS-latest
- image_name: macOS-latest
- image_name: macos-latest
- image_name: macos-latest
cmake_flags: -DZYAN_NO_LIBC=ON
skip_tests: yes
- image_name: windows-2022
Expand All @@ -39,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with: { submodules: recursive }
- name: Configuring
run: |
Expand All @@ -53,16 +52,70 @@ jobs:
cd build
ctest -C Release --output-on-failure

meson-build-and-tests:
name: >-
Meson build + tests (${{ matrix.platform }}, ${{ matrix.flavor }} ${{ matrix.mode.name }})
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
flavor:
- debug
- release
mode:
- { name: default, args: -Dtests=enabled }
- { name: NO_LIBC, args: -Dnolibc=true }
platform:
- macos-latest
- windows-2022
- ubuntu-22.04
extra_envs:
- {}
include:
# Do a few more specialized configurations.
- platform: ubuntu-22.04
mode:
- name: minimal
args: -Dminimal=enabled -Ddecoder=enabled -Davx512=enabled -Dknc=enabled -Dsegment=enabled -Dtests=enabled
extra_envs: {}
flavor: minsize
exclude:
- platform: macos-latest
mode: { name: NO_LIBC, args: -Dnolibc=true }

steps:
- name: Setup meson
run: |
pipx install meson ninja
- name: Checkout
uses: actions/checkout@v4
with: { submodules: recursive }
- name: Activate MSVC and Configure
if: ${{ matrix.platform == 'windows-2022' }}
env: ${{ matrix.extra_envs }}
run: |
meson setup build-${{ matrix.flavor }} --buildtype=${{ matrix.flavor }} ${{ matrix.mode.args }} --vsenv
- name: Configuring
if: ${{ matrix.platform != 'windows-2022' }}
run: |
meson setup build-${{ matrix.flavor }} --buildtype=${{ matrix.flavor }} ${{ matrix.mode.args }}
- name: Building
run: |
meson compile -C build-${{ matrix.flavor }}
- name: Running tests
run: |
meson test -C build-${{ matrix.flavor }}

msbuild-build:
name: MSBuild build (windows-2022)
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with: { submodules: recursive }
- name: Add msbuild to PATH
uses: microsoft/[email protected]
with: { vs-version: '[17,]' }
with: { vs-version: "[17,]" }
- name: Build user-mode
run: |
cd msvc
Expand All @@ -77,7 +130,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with: { submodules: recursive }
- name: Amalgamating sources
run: |
Expand Down Expand Up @@ -109,7 +162,7 @@ jobs:
dry-run: false
sanitizer: ${{ matrix.sanitizer }}
- name: Upload Crash
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
Expand Down
25 changes: 25 additions & 0 deletions Doxyfile.meson.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@INCLUDE = "@TOP_SRCDIR@/Doxyfile"
PROJECT_NUMBER = @VERSION@
PROJECT_BRIEF = "Zyan Disassembler Library"
OUTPUT_DIRECTORY = "@TOP_BUILDDIR@/doc"
STRIP_FROM_PATH = "@TOP_SRCDIR@"
STRIP_FROM_INC_PATH = "@ZYCORE_INCLUDE_PATH@"
INPUT = "@TOP_SRCDIR@/include" \
"@TOP_SRCDIR@/README.md" \
"@TOP_SRCDIR@/files.dox"
EXAMPLE_PATH = "@TOP_SRCDIR@/examples"
USE_MDFILE_AS_MAINPAGE = "@TOP_SRCDIR@/README.md"
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
INCLUDE_PATH = "@ZYCORE_INCLUDE_PATH@"
PREDEFINED = @PREDEFINED@
EXPAND_AS_DEFINED = ZYAN_BITFIELD
DOT_COMMON_ATTR = "fontname=\"sans-serif\",fontsize=10"
DOT_EDGE_ATTR = "labelfontname=\"sans-serif\",labelfontsize=10"
DOT_IMAGE_FORMAT = svg
INTERACTIVE_SVG = YES
HAVE_DOT = @HAVE_DOT@
DOT_MULTI_TARGETS = @HAVE_DOT_1_8_10@
DOT_PATH = "@DOT_PATH@"
HTML_FORMULA_FORMAT = @HTML_FORMULA_FORMAT@

1 change: 1 addition & 0 deletions assets/version-bump-checklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
- resources/VersionInfo.rc (4 locations)
- include/Zydis/Zydis.h (ZYDIS_VERSION macro)
- create a tagged release of zycore
- sync revision in dependencies/zycore.wrap
- create a tagged release of zydis
10 changes: 10 additions & 0 deletions dependencies/zycore.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[wrap-git]
# This is a fallback for plain clone (no submodules available).
url = https://github.com/zyantific/zycore-c.git
# Sync revision to `git submodule status zycore`.
athre0z marked this conversation as resolved.
Show resolved Hide resolved
# If doing a release for Zydis, sync both to a tagged commit.
revision = 38d4f0285e6157ee840ea82a9b90aba71c8a705d
depth = 1

[provide]
dependency_names = zycore
28 changes: 28 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
examples_req = examples.enabled()

if examples_req
if decoder.enabled() and formatter.enabled()
executable('DisassembleSimple', 'DisassembleSimple.c', dependencies: [zydis_dep])
executable('Disassemble', 'Disassemble.c', dependencies: [zydis_dep])
executable('Formatter01', 'Formatter01.c', dependencies: [zydis_dep])
executable('Formatter02', 'Formatter02.c', dependencies: [zydis_dep])
executable('Formatter03', 'Formatter03.c', dependencies: [zydis_dep])
executable(
'ZydisPerfTest',
'ZydisPerfTest.c',
c_args: host_machine.system() in ['linux', 'freebsd'] ? ['-D_GNU_SOURCE'] : [],
dependencies: [zydis_dep],
)
endif

if encoder.enabled()
executable('EncodeMov', 'EncodeMov.c', dependencies: [zydis_dep])
executable('EncodeFromScratch', 'EncodeFromScratch.c', dependencies: [zydis_dep])
executable('RewriteCode', 'RewriteCode.c', dependencies: [zydis_dep])
endif
endif

summary(
{'examples': examples_req},
section: 'Features',
)
25 changes: 25 additions & 0 deletions man/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ronn_exe = find_program('ronn', required: man)
man_req = ronn_exe.found()

if man_req
man_names = [
'ZydisDisasm.1',
'ZydisInfo.1',
]

foreach page : man_names
custom_target(
page,
input: files(f'@[email protected]'),
command: [ronn_exe, '--roff', '--output-dir', '@OUTDIR@', '@INPUT@'],
output: page,
install: true,
install_dir: datadir / 'man' / 'man1',
)
endforeach
endif

summary(
{'man': man_req},
section: 'Features',
)
Loading
Loading