[libgweather/ebassi/gtk4: 10/28] build: Use idiomatic Meson




commit ee13e2cc0ce5616bc6fecf51b03ba772e8d9f551
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Oct 7 17:24:26 2021 +0100

    build: Use idiomatic Meson
    
    Break declarations over multiple lines; use trailing commas; use path
    separators instead of join_paths(); use consistent spacing/indentation.

 data/meson.build        |  4 +--
 doc/meson.build         | 19 +++++++-------
 libgweather/meson.build | 70 +++++++++++++++++++++++++++++++------------------
 meson.build             | 38 ++++++++++++++++++---------
 schemas/meson.build     | 24 +++++++++--------
 5 files changed, 94 insertions(+), 61 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index dd04c1b0..a0f2bc44 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -25,10 +25,10 @@ endif
 # The generated file is architecture dependent (i.e. host endianness)
 locations_bin = custom_target('locations-db',
   command: [gen_locations_variant, '@INPUT@', '@OUTPUT@' ],
-  install: true,
-  install_dir: pkglibdir,
   input: files('Locations.xml'),
   output: '@BASENAME@.bin',
+  install: true,
+  install_dir: pkglibdir,
 )
 
 install_data('Locations.xml',
diff --git a/doc/meson.build b/doc/meson.build
index c2308cc9..b4b32cd2 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -1,21 +1,20 @@
-
 version_conf = configuration_data()
 version_conf.set('LIBGWEATHER_VERSION', meson.project_version())
 configure_file(input: 'version.xml.in', output: 'version.xml', configuration: version_conf)
 
 glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
-glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
+glib_docpath = glib_prefix / 'share/gtk-doc/html'
 
 gtk_prefix = dependency('gtk+-3.0').get_pkgconfig_variable('prefix')
-gtk_docpath = join_paths(gtk_prefix, 'share', 'gtk-doc', 'html')
+gtk_docpath = gtk_prefix / 'share/gtk-doc/html'
 
-docpath = join_paths(datadir, 'gtk-doc', 'html')
+docpath = datadir / 'gtk-doc/html'
 
 gnome.gtkdoc('libgweather',
   main_xml: 'libgweather-docs.xml',
-  src_dir: ['libgweather'],
+  src_dir: include_directories('../libgweather'),
   dependencies: libgweather_dep,
-  gobject_typesfile: [join_paths(meson.current_source_dir(), 'libgweather.types')],
+  gobject_typesfile: 'libgweather.types',
   ignore_headers: [
     'gweather-enum-types.h',
     'gweather-parser.h',
@@ -27,10 +26,10 @@ gnome.gtkdoc('libgweather',
   ],
   fixxref_args: [
     '--html-dir=@0@'.format(docpath),
-    '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
-    '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
-    '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
-    '--extra-dir=@0@'.format(join_paths(gtk_docpath, 'gtk')),
+    '--extra-dir=@0@'.format(glib_docpath / 'glib'),
+    '--extra-dir=@0@'.format(glib_docpath /'gobject'),
+    '--extra-dir=@0@'.format(glib_docpath / 'gio'),
+    '--extra-dir=@0@'.format(gtk_docpath / 'gtk'),
   ],
   install: true,
 )
diff --git a/libgweather/meson.build b/libgweather/meson.build
index 8199c773..c941a911 100644
--- a/libgweather/meson.build
+++ b/libgweather/meson.build
@@ -6,13 +6,13 @@ add_project_arguments([
 ], language: 'c')
 
 header_subdir = 'libgweather-3.0/libgweather'
-libgweather_map = join_paths(meson.current_source_dir(), 'libgweather.map')
+libgweather_map = meson.current_source_dir() / 'libgweather.map'
 link_depends = []
 link_args = []
 
 if c_compiler.has_link_argument('-Wl,--version-script,' + libgweather_map)
-        link_depends += libgweather_map
-        link_args += ['-Wl,--version-script,' + libgweather_map]
+  link_depends += libgweather_map
+  link_args += ['-Wl,--version-script,' + libgweather_map]
 endif
 
 versionconf = configuration_data()
@@ -25,7 +25,7 @@ configure_file(
   output: 'gweather-version.h',
   configuration: versionconf,
   install: true,
-  install_dir: join_paths(includedir, header_subdir),
+  install_dir: includedir / header_subdir,
 )
 
 gweather_new_headers = [
@@ -37,12 +37,15 @@ gweather_new_headers = [
   'gweather-weather.h',
   'gweather-enums.h'
 ]
+
 gweather_enum_types = gnome.mkenums('gweather-enum-types',
   sources: gweather_new_headers,
   c_template: 'gweather-enum-types.c.tmpl',
   h_template: 'gweather-enum-types.h.tmpl',
   install_header: true,
-  install_dir: join_paths(includedir, header_subdir))
+  install_dir: includedir / header_subdir,
+)
+
 install_headers(gweather_new_headers,
   subdir: header_subdir)
 
@@ -60,7 +63,9 @@ gweather_c_sources = [
   'gweather-location.c',
   'gweather-timezone.c',
   'gweather-location-entry.c',
-  'gweather-timezone-menu.c']
+  'gweather-timezone-menu.c',
+]
+
 introspection_sources = gweather_c_sources + gweather_new_headers
 
 lib_libgweather = shared_library('gweather-3',
@@ -105,44 +110,57 @@ if enable_vala
     sources: gweather_gir[0],
     packages: ['gobject-2.0', 'gtk+-3.0'],
     metadata_dirs: '.',
-    install: true
+    install: true,
   )
 endif
 
-test_cargs = ['-DTEST_LOCATIONS="@0@"'.format(locations_bin.full_path()),
-              '-DSCHEMASDIR="@0@/schemas"'.format(meson.source_root()),
-              '-DSCHEMAS_BUILDDIR="@0@/schemas"'.format(meson.build_root())]
+test_cargs = [
+  '-DTEST_LOCATIONS="@0@"'.format(locations_bin.full_path()),
+  '-DSCHEMASDIR="@0@/schemas"'.format(meson.source_root()),
+  '-DSCHEMAS_BUILDDIR="@0@/schemas"'.format(meson.build_root()),
+]
 
 executable('test_locations',
-  ['test_locations.c'],
+  sources: ['test_locations.c'],
   c_args: test_cargs,
   dependencies: libgweather_dep,
-  install: false)
+  install: false,
+)
+
 executable('test_locations_utc',
-  ['test_locations_utc.c'],
+  sources: ['test_locations_utc.c'],
   c_args: test_cargs,
   dependencies: libgweather_dep,
-  install: false)
+  install: false,
+)
 
-exe = executable('test_libgweather',
-  ['test_libgweather.c'],
-  c_args: test_cargs,
-  dependencies: libgweather_dep,
-  install: false)
-test('test_libgweather', exe, depends: [locations_bin])
+test('test_libgweather',
+  executable('test_libgweather',
+    sources: ['test_libgweather.c'],
+    c_args: test_cargs,
+    dependencies: libgweather_dep,
+    install: false,
+  ),
+  depends: [locations_bin],
+)
 
 executable('test_metar',
-  ['test_metar.c', gweather_c_sources],
+  sources: ['test_metar.c', gweather_c_sources],
   c_args: test_cargs,
   dependencies: libgweather_dep,
-  install: false)
+  install: false,
+)
+
 executable('test_sun_moon',
-  ['test_sun_moon.c', 'weather-sun.c', 'weather-moon.c'],
+  sources: ['test_sun_moon.c', 'weather-sun.c', 'weather-moon.c'],
   c_args: test_cargs,
   dependencies: libgweather_dep,
-  install: false)
+  install: false,
+)
+
 executable('test_weather',
-  ['test_weather.c'],
+  sources: ['test_weather.c'],
   c_args: test_cargs,
   dependencies: libgweather_dep,
-  install: false)
+  install: false,
+)
diff --git a/meson.build b/meson.build
index 0c1714b4..5aac43f2 100644
--- a/meson.build
+++ b/meson.build
@@ -32,14 +32,15 @@ i18n = import('i18n')
 
 prefix = get_option('prefix')
 
-bindir = join_paths(prefix, get_option('bindir'))
-datadir = join_paths(prefix, get_option('datadir'))
-libdir = join_paths(prefix, get_option('libdir'))
-includedir = join_paths(prefix, get_option('includedir'))
-libexecdir = join_paths(prefix, get_option('libexecdir'))
-sysconfdir = join_paths(prefix, get_option('sysconfdir'))
-pkgdatadir = join_paths(datadir, 'libgweather')
-pkglibdir = join_paths(libdir, 'libgweather')
+bindir = prefix / get_option('bindir')
+datadir = prefix / get_option('datadir')
+libdir = prefix / get_option('libdir')
+includedir = prefix / get_option('includedir')
+libexecdir = prefix / get_option('libexecdir')
+sysconfdir = prefix / get_option('sysconfdir')
+
+pkgdatadir = datadir / 'libgweather'
+pkglibdir = libdir / 'libgweather'
 
 glib_req_version = '>= 2.44.0'
 gtk_req_version = '>= 3.13.5'
@@ -47,16 +48,29 @@ libsoup_req_version = '>= 2.44.0'
 libxml_req_version = '>= 2.6.0'
 
 c_compiler = meson.get_compiler('c')
+
 gtk_dep = dependency('gtk+-3.0', version: gtk_req_version)
 glib_dep = dependency('gio-2.0', version: glib_req_version)
 libsoup_dep = dependency('libsoup-2.4', version: libsoup_req_version)
 libxml_dep = dependency('libxml-2.0', version: libxml_req_version)
 geocode_glib_dep = dependency('geocode-glib-1.0')
 math_dep = c_compiler.find_library('m', required : false)
-deps_libgweather = [math_dep, gtk_dep, glib_dep, libsoup_dep, libxml_dep, geocode_glib_dep]
+deps_libgweather = [
+  math_dep,
+  gtk_dep,
+  glib_dep,
+  libsoup_dep,
+  libxml_dep,
+  geocode_glib_dep,
+]
 
 pylint = find_program('pylint-3', 'pylint3', 'pylint', required: false)
-pylint_flags = ['-d', 'C0111', '-d', 'W0511', '-d', 'F0401', '-d', 'C0326' ]
+pylint_flags = [
+  '-d', 'C0111',
+  '-d', 'W0511',
+  '-d', 'F0401',
+  '-d', 'C0326',
+]
 
 config_h = configuration_data()
 GETTEXT_PACKAGE = 'libgweather-3.0'
@@ -90,10 +104,10 @@ configure_file(
 if get_option('glade_catalog') == 'false'
   enable_glade_catalog = false
 else
-  glade_dep = dependency('gladeui-2.0', required: (get_option('glade_catalog') == 'true'))
+  glade_dep = dependency('gladeui-2.0', required: get_option('glade_catalog') == 'true')
   enable_glade_catalog = glade_dep.found()
   if enable_glade_catalog
-    glade_catalogdir = join_paths(datadir, 'glade', 'catalogs')
+    glade_catalogdir = datadir / 'glade/catalogs'
   endif
 endif
 
diff --git a/schemas/meson.build b/schemas/meson.build
index d7f341c2..677e4ef5 100644
--- a/schemas/meson.build
+++ b/schemas/meson.build
@@ -1,14 +1,16 @@
-gsettingsdir = join_paths(datadir, 'glib-2.0', 'schemas')
+gsettingsdir = datadir / 'glib-2.0/schemas'
 install_data('org.gnome.GWeather.gschema.xml',
-             install_dir : gsettingsdir)
+  install_dir: gsettingsdir,
+)
 
 gnome.mkenums('org.gnome.GWeather.enums.xml',
-              comments: '<!-- @comment@ -->',
-              fhead: '<schemalist>',
-              vhead: '<@type@ id="org.gnome.GWeather.@EnumName@">',
-              vprod: '<value nick="@valuenick@" value="@valuenum@"/>',
-              vtail: '</@type@>',
-              ftail: '</schemalist>',
-              sources: ['../libgweather/gweather-enums.h'],
-              install_header: true,
-              install_dir: gsettingsdir)
+  comments: '<!-- @comment@ -->',
+  fhead: '<schemalist>',
+  vhead: '<@type@ id="org.gnome.GWeather.@EnumName@">',
+  vprod: '<value nick="@valuenick@" value="@valuenum@"/>',
+  vtail: '</@type@>',
+  ftail: '</schemalist>',
+  sources: ['../libgweather/gweather-enums.h'],
+  install_header: true,
+  install_dir: gsettingsdir,
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]