Skip to content

Units(Meson): add a case testing extracting config variables #4189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Units/parser-meson.r/config.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--map-Meson=+.meson
--fields=+K
17 changes: 17 additions & 0 deletions Units/parser-meson.r/config.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
systemd input.meson /^project('systemd', 'c',$/;" project
project_major_version input.meson /^project_major_version = meson.project_version().split('.')[0].split('~')[0]$/;" variable
project_minor_version input.meson /^ project_minor_version = meson.project_version().split('.')[-1].split('~')[0]$/;" variable
project_minor_version input.meson /^ project_minor_version = '0'$/;" variable
libsystemd_version input.meson /^libsystemd_version = '0.39.0'$/;" variable
libudev_version input.meson /^libudev_version = '1.7.9'$/;" variable
conf input.meson /^conf = configuration_data()$/;" cfgdata
PROJECT_URL input.meson /^conf.set_quoted('PROJECT_URL', 'https:\/\/systemd.io\/')$/;" cfgvar cfgdata:conf
PROJECT_VERSION input.meson /^conf.set('PROJECT_VERSION', project_major_version,$/;" cfgvar cfgdata:conf
PROJECT_VERSION_FULL input.meson /^conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project ver/;" cfgvar cfgdata:conf
conf2 input.meson /^conf2 = configuration_data()$/;" cfgdata
PROJECT_URL_ALT input.meson /^conf2.set_quoted('PROJECT_URL_ALT', 'https:\/\/systemd.io\/')$/;" cfgvar cfgdata:conf2
project_source_root input.meson /^project_source_root = meson.current_source_dir()$/;" variable
project_build_root input.meson /^project_build_root = meson.current_build_dir()$/;" variable
relative_source_path input.meson /^relative_source_path = run_command('realpath',$/;" variable
RELATIVE_SOURCE_PATH input.meson /^conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)$/;" cfgvar cfgdata:conf
BUILD_MODE_DEVELOPER input.meson /^conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',$/;" cfgvar cfgdata:conf
50 changes: 50 additions & 0 deletions Units/parser-meson.r/config.d/input.meson
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Taken from meson.build of systemd
#

# SPDX-License-Identifier: LGPL-2.1-or-later

project('systemd', 'c',
version : files('meson.version'),
license : 'LGPLv2+',
default_options: [
'c_std=gnu11',
'prefix=/usr',
'sysconfdir=/etc',
'localstatedir=/var',
'warning_level=2',
],
meson_version : '>= 0.60.0',
)

project_major_version = meson.project_version().split('.')[0].split('~')[0]
if meson.project_version().contains('.')
project_minor_version = meson.project_version().split('.')[-1].split('~')[0]
else
project_minor_version = '0'
endif

libsystemd_version = '0.39.0'
libudev_version = '1.7.9'

conf = configuration_data()
conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
conf.set('PROJECT_VERSION', project_major_version,
description : 'Numerical project version (used where a simple number is expected)')
conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version')

conf2 = configuration_data()
conf2.set_quoted('PROJECT_URL_ALT', 'https://systemd.io/')

# This is to be used instead of meson.source_root(), as the latter will return
# the wrong result when systemd is being built as a meson subproject
project_source_root = meson.current_source_dir()
project_build_root = meson.current_build_dir()
relative_source_path = run_command('realpath',
'--relative-to=@0@'.format(project_build_root),
project_source_root,
check : true).stdout().strip()
conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)

conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
description : 'tailor build to development or release builds')
Loading