adding Meson in mlx (#186)

This PR adds meson.build support for creating `mlx.wrap` in [meson
wrapdb](https://mesonbuild.com/Wrapdb-projects.html)
This commit is contained in:
2026-01-09 21:57:25 +01:00
committed by GitHub
5 changed files with 226 additions and 1 deletions

43
.github/workflows/linux_meson.yml vendored git.filemode.normal_file
View File

@@ -0,0 +1,43 @@
name: Linux (meson)
on:
repository_dispatch:
types: [create-pull-request]
pull_request:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
arch: [x86_64]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get -y install mesa-common-dev clang libsdl2-2.0-0 libsdl2-dev build-essential libvulkan-dev
- name: Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Meson with pip
run: sudo pip3 install meson
- name: Build with meson
run: |
meson build --prefix=$PWD/ --bindir='' --libdir=''
ninja install -C build

View File

@@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [macOS-latest]
arch: [x86_64]
arch: [x86_64, arm]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"

42
.github/workflows/macos_meson.yml vendored git.filemode.normal_file
View File

@@ -0,0 +1,42 @@
name: macOS (meson)
on:
repository_dispatch:
types: [create-pull-request]
pull_request:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [macOS-latest]
arch: [x86_64, arm]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install system dependencies
run: |
brew install SDL2
- name: Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Meson with pip
run: sudo pip3 install meson
- name: Build with meson
run: |
meson build --prefix=$PWD/ --bindir='' --libdir=''
ninja install -C build

111
meson.build git.filemode.normal_file
View File

@@ -0,0 +1,111 @@
project('MacroLibX',
['c', 'cpp'],
version : '2.2.2',
license : 'MIT',
meson_version : '>= 1.9.0',
default_options : ['warning_level=2', 'optimization=3', 'cpp_std=c++20'])
add_project_arguments('-Wno-error=', language : 'c')
add_project_arguments('-fPIC', language : 'c')
add_project_arguments('-DSDL_MAIN_HANDLED', language : 'c')
if get_option('force_integrated_gpu')
add_project_arguments('-DFORCE_INTEGRATED_GPU', language : 'c')
endif
if get_option('graphics_memory_dump')
add_project_arguments('-DGRAPHICS_MEMORY_DUMP', language : 'c')
endif
if get_option('profiler')
add_project_arguments('-DPROFILER_ENABLED', language : 'c')
endif
if get_option('force_wayland')
add_project_arguments('-DFORCE_WAYLAND', language : 'c')
endif
if get_option('disable_all_safeties')
add_project_arguments('-DDISABLE_ALL_SAFETIES', language : 'c')
endif
includes_directories = [
include_directories('includes'),
include_directories('runtime/Includes'),
include_directories('runtime/Sources'),
include_directories('third_party'),
]
sources = [
files(
'runtime/Sources/Core/Application.cpp',
'runtime/Sources/Core/Bridge.cpp',
'runtime/Sources/Core/EventBus.cpp',
'runtime/Sources/Core/EventListener.cpp',
'runtime/Sources/Core/Fps.cpp',
'runtime/Sources/Core/Graphics.cpp',
'runtime/Sources/Core/Logs.cpp',
'runtime/Sources/Core/Memory.cpp',
'runtime/Sources/Core/Profiler.cpp',
'runtime/Sources/Core/SDLManager.cpp',
'runtime/Sources/Core/UUID.cpp',
'runtime/Sources/Graphics/Font.cpp',
'runtime/Sources/Graphics/Mesh.cpp',
'runtime/Sources/Graphics/PutPixelManager.cpp',
'runtime/Sources/Graphics/Scene.cpp',
'runtime/Sources/Graphics/Sprite.cpp',
'runtime/Sources/Graphics/Text.cpp',
'runtime/Sources/Platform/Inputs.cpp',
'runtime/Sources/Platform/Window.cpp',
'runtime/Sources/Renderer/Pipelines/Graphics.cpp',
'runtime/Sources/Renderer/Pipelines/Shader.cpp',
'runtime/Sources/Renderer/RenderPasses/2DPass.cpp',
'runtime/Sources/Renderer/RenderPasses/FinalPass.cpp',
'runtime/Sources/Renderer/RenderPasses/Passes.cpp',
'runtime/Sources/Renderer/Vulkan/VulkanLoader.cpp',
'runtime/Sources/Renderer/Buffer.cpp',
'runtime/Sources/Renderer/Descriptor.cpp',
'runtime/Sources/Renderer/Image.cpp',
'runtime/Sources/Renderer/Memory.cpp',
'runtime/Sources/Renderer/RenderCore.cpp',
'runtime/Sources/Renderer/Renderer.cpp',
'runtime/Sources/Renderer/SceneRenderer.cpp',
'runtime/Sources/Renderer/Swapchain.cpp'
)
]
mlx_headers = [
'includes/mlx.h',
'includes/mlx_extended.h',
'includes/mlx_profile.h'
]
install_headers(mlx_headers)
deps = [
dependency('sdl2'),
]
libmlx = library('mlx',
sources,
include_directories : includes_directories,
dependencies : deps,
install : true)
libmlx_dep = declare_dependency(
include_directories: includes_directories,
dependencies : deps,
link_with : libmlx)
meson.override_dependency('mlx', libmlx_dep)
# PKG CONFIG GENERATION
pkg_mod = import('pkgconfig')
pkg_mod.generate(
libmlx,
name : 'mlx',
description : 'MacroLibX Library',
version : meson.project_version(),
subdirs : ['.'],
)

29
meson_options.txt git.filemode.normal_file
View File

@@ -0,0 +1,29 @@
option('force_integrated_gpu',
type : 'boolean',
value : false,
description : 'Force the application to use the integrated GPU if available.'
)
option('graphics_memory_dump',
type : 'boolean',
value : false,
description : 'Enable graphics memory dump for debugging purposes.'
)
option('profiler',
type : 'boolean',
value : false,
description : 'Enable profiler for performance analysis.'
)
option('force_wayland',
type : 'boolean',
value : false,
description : 'Force the application to use Wayland display server.'
)
option('disable_all_safeties',
type : 'boolean',
value : false,
description : 'Disable all safety checks in the application.'
)