From 6c897756b6340d098f50eeb0da0d39abda87fdda Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 25 Nov 2022 17:36:24 +0100 Subject: [PATCH] build: use a configuration file for internal features This avoids re-building the whole project when switching one Meson option. This shrinks down the compiler invocation command line, making it more readable and making it easier to inspect which flags are passed in (the generated file can be opened). Additionally this is more consistent with our external feature handling, which uses already. --- include/backend/x11.h | 10 ++++++---- include/meson.build | 8 ++++++++ include/xwayland/xwm.h | 4 +++- meson.build | 8 +------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/backend/x11.h b/include/backend/x11.h index 9c0c1a4d..704d48f1 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -9,10 +9,6 @@ #include #include -#if HAS_XCB_ERRORS -#include -#endif - #include #include #include @@ -21,6 +17,12 @@ #include #include +#include "config.h" + +#if HAS_XCB_ERRORS +#include +#endif + #define XCB_EVENT_RESPONSE_TYPE_MASK 0x7f struct wlr_x11_backend; diff --git a/include/meson.build b/include/meson.build index 358aada8..bc91a766 100644 --- a/include/meson.build +++ b/include/meson.build @@ -30,3 +30,11 @@ install_subdir('wlr', install_dir: get_option('includedir'), exclude_files: exclude_files, ) + +foreach name, have : internal_features + internal_config.set10('HAS_' + name.underscorify().to_upper(), have) +endforeach +wlr_files += configure_file( + output: 'config.h', + configuration: internal_config, +) diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h index 391e09ab..7ed97b15 100644 --- a/include/xwayland/xwm.h +++ b/include/xwayland/xwm.h @@ -5,10 +5,12 @@ #include #include #include +#include "config.h" +#include "xwayland/selection.h" + #if HAS_XCB_ERRORS #include #endif -#include "xwayland/selection.h" /* This is in xcb/xcb_event.h, but pulling xcb-util just for a constant * others redefine anyway is meh diff --git a/meson.build b/meson.build index fc3f88af..0a584621 100644 --- a/meson.build +++ b/meson.build @@ -99,6 +99,7 @@ internal_features = { 'xcb-errors': false, 'egl': false, } +internal_config = configuration_data() wayland_project_options = ['tests=false', 'documentation=false'] wayland_server = dependency('wayland-server', @@ -158,13 +159,6 @@ subdir('xwayland') subdir('include') -foreach name, have : internal_features - add_project_arguments( - '-DHAS_@0@=@1@'.format(name.underscorify().to_upper(), have.to_int()), - language: 'c', - ) -endforeach - wlr_inc = include_directories('include') proto_inc = include_directories('protocol')