Skip to content

Commit 93a758a

Browse files
authored
Merge pull request #4189 from masatake/units-meson--config
Units(Meson): add a case testing extracting config variables
2 parents c8b8337 + d86b627 commit 93a758a

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--sort=no
2+
--map-Meson=+.meson
3+
--fields=+K
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
systemd input.meson /^project('systemd', 'c',$/;" project
2+
project_major_version input.meson /^project_major_version = meson.project_version().split('.')[0].split('~')[0]$/;" variable
3+
project_minor_version input.meson /^ project_minor_version = meson.project_version().split('.')[-1].split('~')[0]$/;" variable
4+
project_minor_version input.meson /^ project_minor_version = '0'$/;" variable
5+
libsystemd_version input.meson /^libsystemd_version = '0.39.0'$/;" variable
6+
libudev_version input.meson /^libudev_version = '1.7.9'$/;" variable
7+
conf input.meson /^conf = configuration_data()$/;" cfgdata
8+
PROJECT_URL input.meson /^conf.set_quoted('PROJECT_URL', 'https:\/\/systemd.io\/')$/;" cfgvar cfgdata:conf
9+
PROJECT_VERSION input.meson /^conf.set('PROJECT_VERSION', project_major_version,$/;" cfgvar cfgdata:conf
10+
PROJECT_VERSION_FULL input.meson /^conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project ver/;" cfgvar cfgdata:conf
11+
conf2 input.meson /^conf2 = configuration_data()$/;" cfgdata
12+
PROJECT_URL_ALT input.meson /^conf2.set_quoted('PROJECT_URL_ALT', 'https:\/\/systemd.io\/')$/;" cfgvar cfgdata:conf2
13+
project_source_root input.meson /^project_source_root = meson.current_source_dir()$/;" variable
14+
project_build_root input.meson /^project_build_root = meson.current_build_dir()$/;" variable
15+
relative_source_path input.meson /^relative_source_path = run_command('realpath',$/;" variable
16+
RELATIVE_SOURCE_PATH input.meson /^conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)$/;" cfgvar cfgdata:conf
17+
BUILD_MODE_DEVELOPER input.meson /^conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',$/;" cfgvar cfgdata:conf
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# Taken from meson.build of systemd
3+
#
4+
5+
# SPDX-License-Identifier: LGPL-2.1-or-later
6+
7+
project('systemd', 'c',
8+
version : files('meson.version'),
9+
license : 'LGPLv2+',
10+
default_options: [
11+
'c_std=gnu11',
12+
'prefix=/usr',
13+
'sysconfdir=/etc',
14+
'localstatedir=/var',
15+
'warning_level=2',
16+
],
17+
meson_version : '>= 0.60.0',
18+
)
19+
20+
project_major_version = meson.project_version().split('.')[0].split('~')[0]
21+
if meson.project_version().contains('.')
22+
project_minor_version = meson.project_version().split('.')[-1].split('~')[0]
23+
else
24+
project_minor_version = '0'
25+
endif
26+
27+
libsystemd_version = '0.39.0'
28+
libudev_version = '1.7.9'
29+
30+
conf = configuration_data()
31+
conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
32+
conf.set('PROJECT_VERSION', project_major_version,
33+
description : 'Numerical project version (used where a simple number is expected)')
34+
conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version')
35+
36+
conf2 = configuration_data()
37+
conf2.set_quoted('PROJECT_URL_ALT', 'https://systemd.io/')
38+
39+
# This is to be used instead of meson.source_root(), as the latter will return
40+
# the wrong result when systemd is being built as a meson subproject
41+
project_source_root = meson.current_source_dir()
42+
project_build_root = meson.current_build_dir()
43+
relative_source_path = run_command('realpath',
44+
'--relative-to=@0@'.format(project_build_root),
45+
project_source_root,
46+
check : true).stdout().strip()
47+
conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
48+
49+
conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
50+
description : 'tailor build to development or release builds')

0 commit comments

Comments
 (0)