diff --git a/.gitignore b/.gitignore index 6c331cb..ee9bfd8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ compile_flags.txt -obj/ +compile_commands.json +/build diff --git a/hyprload.toml b/hyprload.toml index 2c925a7..ef9f17c 100644 --- a/hyprload.toml +++ b/hyprload.toml @@ -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" ] diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..47734d4 --- /dev/null +++ b/meson.build @@ -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') diff --git a/src/VERSION b/src/VERSION new file mode 100644 index 0000000..ae39fab --- /dev/null +++ b/src/VERSION @@ -0,0 +1 @@ +v0.0.0 diff --git a/src/main.cpp b/src/main.cpp index a46a4d7..d729cc9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,8 @@ #define WLR_USE_UNSTABLE #include "globals.hpp" +// version.hpp will be generated by meson +#include "version.hpp" #include #include diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..901dedc --- /dev/null +++ b/src/meson.build @@ -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) diff --git a/src/version.hpp.in b/src/version.hpp.in new file mode 100644 index 0000000..39fc5b7 --- /dev/null +++ b/src/version.hpp.in @@ -0,0 +1,2 @@ +// "@PLUGIN_VERSION@" will be replaced with the actual version via meson +#define PLUGIN_VERSION "@PLUGIN_VERSION@"