build: use dictionnary for features instead of configuration_data
This allows us to easily iterate on all features and only deal with bools.
This commit is contained in:
		
							parent
							
								
									2118a3ce47
								
							
						
					
					
						commit
						6f873078d4
					
				|  | @ -33,7 +33,7 @@ if get_option('logind-provider') == 'auto' | ||||||
| 			version: logind_version, | 			version: logind_version, | ||||||
| 		) | 		) | ||||||
| 		if logind.found() | 		if logind.found() | ||||||
| 			conf_data.set10('WLR_HAS_SYSTEMD', true) | 			features += { 'systemd': true } | ||||||
| 		else | 		else | ||||||
| 			logind = dependency('libelogind', | 			logind = dependency('libelogind', | ||||||
| 				required: get_option('logind'), | 				required: get_option('logind'), | ||||||
|  | @ -41,7 +41,7 @@ if get_option('logind-provider') == 'auto' | ||||||
| 				version: logind_version, | 				version: logind_version, | ||||||
| 			) | 			) | ||||||
| 			if logind.found() | 			if logind.found() | ||||||
| 				conf_data.set10('WLR_HAS_ELOGIND', true) | 				features += { 'elogind': true } | ||||||
| 			endif | 			endif | ||||||
| 		endif | 		endif | ||||||
| 		logind_found = logind.found() | 		logind_found = logind.found() | ||||||
|  | @ -53,7 +53,7 @@ else | ||||||
| 		version: logind_version, | 		version: logind_version, | ||||||
| 	) | 	) | ||||||
| 	if logind.found() | 	if logind.found() | ||||||
| 		conf_data.set10('WLR_HAS_' + get_option('logind-provider').to_upper(), true) | 		features += { get_option('logind-provider'): true } | ||||||
| 		logind_found = true | 		logind_found = true | ||||||
| 	endif | 	endif | ||||||
| endif | endif | ||||||
|  | @ -69,5 +69,5 @@ libseat = dependency('libseat', required: get_option('libseat'), version: '>=0.2 | ||||||
| if libseat.found() | if libseat.found() | ||||||
| 	wlr_files += files('libseat.c') | 	wlr_files += files('libseat.c') | ||||||
| 	wlr_deps += libseat | 	wlr_deps += libseat | ||||||
| 	conf_data.set10('WLR_HAS_LIBSEAT', true) | 	features += { 'libseat': true } | ||||||
| endif | endif | ||||||
|  |  | ||||||
|  | @ -35,4 +35,4 @@ wlr_files += files( | ||||||
| 	'output.c', | 	'output.c', | ||||||
| ) | ) | ||||||
| wlr_deps += x11_libs | wlr_deps += x11_libs | ||||||
| conf_data.set10('WLR_HAS_X11_BACKEND', true) | features += { 'x11-backend': true } | ||||||
|  |  | ||||||
|  | @ -5,6 +5,11 @@ version_data.set('WLR_VERSION_MAJOR', version_array[0]) | ||||||
| version_data.set('WLR_VERSION_MINOR', version_array[1]) | version_data.set('WLR_VERSION_MINOR', version_array[1]) | ||||||
| version_data.set('WLR_VERSION_MICRO', version_array[2]) | version_data.set('WLR_VERSION_MICRO', version_array[2]) | ||||||
| 
 | 
 | ||||||
|  | conf_data = configuration_data() | ||||||
|  | foreach name, have : features | ||||||
|  | 	conf_data.set10('WLR_HAS_' + name.underscorify().to_upper(), have) | ||||||
|  | endforeach | ||||||
|  | 
 | ||||||
| conf_h = configure_file( | conf_h = configure_file( | ||||||
| 	input: 'config.h.in', | 	input: 'config.h.in', | ||||||
| 	output: 'config.h', | 	output: 'config.h', | ||||||
|  |  | ||||||
							
								
								
									
										32
									
								
								meson.build
								
								
								
								
							
							
						
						
									
										32
									
								
								meson.build
								
								
								
								
							|  | @ -79,15 +79,16 @@ else | ||||||
| 	) | 	) | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| conf_data = configuration_data() | features = { | ||||||
| conf_data.set10('WLR_HAS_SYSTEMD', false) | 	'systemd': false, | ||||||
| conf_data.set10('WLR_HAS_ELOGIND', false) | 	'elogind': false, | ||||||
| conf_data.set10('WLR_HAS_LIBSEAT', false) | 	'libseat': false, | ||||||
| conf_data.set10('WLR_HAS_X11_BACKEND', false) | 	'x11-backend': false, | ||||||
| conf_data.set10('WLR_HAS_XWAYLAND', false) | 	'xwayland': false, | ||||||
| conf_data.set10('WLR_HAS_XCB_ERRORS', false) | 	'xcb-errors': false, | ||||||
| conf_data.set10('WLR_HAS_XCB_ICCCM', false) | 	'xcb-icccm': false, | ||||||
| conf_data.set10('WLR_HAS_XDG_FOREIGN', false) | 	'xdg-foreign': false, | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| wayland_server = dependency('wayland-server', version: '>=1.19') | wayland_server = dependency('wayland-server', version: '>=1.19') | ||||||
| wayland_client = dependency('wayland-client') | wayland_client = dependency('wayland-client') | ||||||
|  | @ -107,7 +108,7 @@ if not get_option('xdg-foreign').disabled() | ||||||
| 	uuid = dependency('uuid', required: false) | 	uuid = dependency('uuid', required: false) | ||||||
| 	uuid_create = cc.has_function('uuid_create') | 	uuid_create = cc.has_function('uuid_create') | ||||||
| 	if uuid.found() or uuid_create | 	if uuid.found() or uuid_create | ||||||
| 		conf_data.set10('WLR_HAS_XDG_FOREIGN', true) | 		features += { 'xdg-foreign': true } | ||||||
| 	elif get_option('xdg-foreign').enabled() | 	elif get_option('xdg-foreign').enabled() | ||||||
| 		error('Missing dependency uuid and uuid_create function not available ' + | 		error('Missing dependency uuid and uuid_create function not available ' + | ||||||
| 				'cannot build with xdg-foreign support') | 				'cannot build with xdg-foreign support') | ||||||
|  | @ -165,16 +166,7 @@ wlroots = declare_dependency( | ||||||
| 
 | 
 | ||||||
| meson.override_dependency('wlroots', wlroots) | meson.override_dependency('wlroots', wlroots) | ||||||
| 
 | 
 | ||||||
| summary({ | summary(features, bool_yn: true) | ||||||
| 	'systemd': conf_data.get('WLR_HAS_SYSTEMD', 0) == 1, |  | ||||||
| 	'elogind': conf_data.get('WLR_HAS_ELOGIND', 0) == 1, |  | ||||||
| 	'libseat': conf_data.get('WLR_HAS_LIBSEAT', 0) == 1, |  | ||||||
| 	'xwayland': conf_data.get('WLR_HAS_XWAYLAND', 0) == 1, |  | ||||||
| 	'x11-backend': conf_data.get('WLR_HAS_X11_BACKEND', 0) == 1, |  | ||||||
| 	'xcb-icccm': conf_data.get('WLR_HAS_XCB_ICCCM', 0) == 1, |  | ||||||
| 	'xcb-errors': conf_data.get('WLR_HAS_XCB_ERRORS', 0) == 1, |  | ||||||
| 	'xdg-foreign': conf_data.get('WLR_HAS_XDG_FOREIGN', 0) == 1, |  | ||||||
| }, bool_yn: true) |  | ||||||
| 
 | 
 | ||||||
| if get_option('examples') | if get_option('examples') | ||||||
| 	subdir('examples') | 	subdir('examples') | ||||||
|  |  | ||||||
|  | @ -67,7 +67,7 @@ wlr_files += files( | ||||||
| 	'wlr_xdg_output_v1.c', | 	'wlr_xdg_output_v1.c', | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| if conf_data.get('WLR_HAS_XDG_FOREIGN', 0) == 1 | if features.get('xdg-foreign') | ||||||
| 	wlr_files += files( | 	wlr_files += files( | ||||||
| 		'wlr_xdg_foreign_v1.c', | 		'wlr_xdg_foreign_v1.c', | ||||||
| 		'wlr_xdg_foreign_v2.c', | 		'wlr_xdg_foreign_v2.c', | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ wlr_files += files( | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if conf_data.get('WLR_HAS_XDG_FOREIGN', 0) == 1 | if features.get('xdg-foreign') | ||||||
| 	if uuid.found() | 	if uuid.found() | ||||||
| 		wlr_deps += uuid | 		wlr_deps += uuid | ||||||
| 		add_project_arguments('-DHAS_LIBUUID=1', language: 'c') | 		add_project_arguments('-DHAS_LIBUUID=1', language: 'c') | ||||||
|  |  | ||||||
|  | @ -45,7 +45,7 @@ foreach lib, desc : xwayland_optional | ||||||
| 	) | 	) | ||||||
| 	if dep.found() | 	if dep.found() | ||||||
| 		xwayland_libs += dep | 		xwayland_libs += dep | ||||||
| 		conf_data.set10('WLR_HAS_' + lib.underscorify().to_upper(), true) | 		features += { lib: true } | ||||||
| 	endif | 	endif | ||||||
| endforeach | endforeach | ||||||
| 
 | 
 | ||||||
|  | @ -60,4 +60,4 @@ wlr_files += files( | ||||||
| 	'xwm.c', | 	'xwm.c', | ||||||
| ) | ) | ||||||
| wlr_deps += xwayland_libs | wlr_deps += xwayland_libs | ||||||
| conf_data.set10('WLR_HAS_XWAYLAND', true) | features += { 'xwayland': true } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue