add meson infra

This commit is contained in:
Ching Pei Yang 2024-10-09 16:45:51 +02:00
parent 90283112bf
commit e8903702b3
No known key found for this signature in database
GPG Key ID: 062FBBCE1D0C5DD9
7 changed files with 56 additions and 4 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
compile_flags.txt
obj/
compile_commands.json
/build

View File

@ -1,10 +1,14 @@
[example]
description = "Example plugin"
version = "1.0.0"
author = "YOU"
## NOTE: version is omitted here because I don't like having multiple places
## to update the version string. Feel free to add it back in.
#
# version = "v0.0.0"
[example.build]
output = "example.so"
output = "build/src/example.so"
steps = [
"make all",
"meson setup build",
"meson compile -Cbuild"
]

18
meson.build Normal file
View File

@ -0,0 +1,18 @@
project('example', 'cpp', 'c',
# we always take the VERSION file as the single source of truth
version: run_command('cat', join_paths(meson.project_source_root(), 'VERSION'), check: true).stdout().strip(),
default_options: ['buildtype=release'],
)
cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.has_argument('-std=c++23')
add_global_arguments('-std=c++23', language: 'cpp')
elif cpp_compiler.has_argument('-std=c++2b')
add_global_arguments('-std=c++2b', language: 'cpp')
else
error('Could not configure current C++ compiler (' + cpp_compiler.get_id() + ' ' + cpp_compiler.version() + ') with required C++ standard (C++23)')
endif
hyprland_headers = dependency('hyprland')
subdir('src')

1
src/VERSION Normal file
View File

@ -0,0 +1 @@
v0.0.0

View File

@ -1,6 +1,8 @@
#define WLR_USE_UNSTABLE
#include "globals.hpp"
// version.hpp will be generated by meson
#include "version.hpp"
#include <hyprland/src/Window.hpp>
#include <hyprland/src/Compositor.hpp>

24
src/meson.build Normal file
View File

@ -0,0 +1,24 @@
subdir('gestures')
configure_file(
input: 'version.hpp.in',
output: 'version.hpp',
configuration: {
'PLUGIN_VERSION': meson.project_version()
}
)
shared_module('example',
'main.cpp',
cpp_args: ['-DWLR_USE_UNSTABLE'],
link_with: [gestures],
# sometimes you need to add other hyprland dependencies yourself
dependencies: [
dependency('pixman-1'),
dependency('libinput'),
dependency('wayland-server'),
dependency('xkbcommon'),
dependency('libdrm'),
hyprland_headers
],
install: true)

2
src/version.hpp.in Normal file
View File

@ -0,0 +1,2 @@
// "@PLUGIN_VERSION@" will be replaced with the actual version via meson
#define PLUGIN_VERSION "@PLUGIN_VERSION@"