[gnome-weather/wip/christopherdavis/dual-install: 16/18] build: Various port cleanups



commit 1f9b557e0c7d6f6579b2ea7d704264e51d21e982
Author: Christopher Davis <brainblasted disroot org>
Date:   Wed Mar 6 00:41:13 2019 -0500

    build: Various port cleanups
    
    * Use more variables instead of `get_option()`
    * Use `join_paths()` instead of path separators
    * Rename variables
    * Clean up icon handling
    * Remove `message()` calls
    * Remove unused variables
    * Prefer formatting over concatenation

 data/icons/meson.build                     | 31 ++++-----------
 data/meson.build                           | 64 +++++++++++++++---------------
 meson.build                                | 39 +++++-------------
 po/meson.build                             |  2 +-
 src/meson.build                            | 32 +++++++--------
 src/org.gnome.Weather.BackgroundService.in |  6 +--
 src/org.gnome.Weather.in                   |  6 +--
 7 files changed, 73 insertions(+), 107 deletions(-)
---
diff --git a/data/icons/meson.build b/data/icons/meson.build
index 9412fac..0e191eb 100644
--- a/data/icons/meson.build
+++ b/data/icons/meson.build
@@ -1,28 +1,13 @@
-datadir = join_paths(get_option('datadir'), 'icons')
-icondir = join_paths('hicolor', 'scalable', 'apps')
-if get_option('profile') == 'development'
+scalable_icondir = join_paths('hicolor', 'scalable', 'apps')
 install_data (
-  join_paths(icondir, 'org.gnome.Weather.svg'),
-  install_dir: join_paths(datadir, icondir),
-  rename: 'org.gnome.WeatherDevel.svg'
+  join_paths(scalable_icondir, 'org.gnome.Weather.svg'),
+  install_dir: join_paths(weather_datadir, 'icons', scalable_icondir),
+  rename: '@0@.svg'.format(weather_id)
 )
-else
-install_data (
-  join_paths(icondir, 'org.gnome.Weather.svg'),
-  install_dir: join_paths(datadir, icondir)
-)
-endif
 
-icondir = join_paths('hicolor', 'symbolic', 'apps')
-if get_option('profile') == 'development'
-install_data (
-  join_paths(icondir, 'org.gnome.Weather-symbolic.svg'),
-  install_dir: join_paths(datadir, icondir),
-  rename: 'org.gnome.WeatherDevel-symbolic.svg'
-)
-else
+symbolic_icondir = join_paths('hicolor', 'symbolic', 'apps')
 install_data (
-  join_paths(icondir, 'org.gnome.Weather-symbolic.svg'),
-  install_dir: join_paths(datadir, icondir)
+  join_paths(symbolic_icondir, 'org.gnome.Weather-symbolic.svg'),
+  install_dir: join_paths(weather_datadir, 'icons', symbolic_icondir),
+  rename: '@0 -symbolic svg'.format(weather_id)
 )
-endif
diff --git a/data/meson.build b/data/meson.build
index 1273550..5ac2163 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,50 +1,43 @@
 gnome = import('gnome')
 podir = join_paths(meson.source_root(), 'po')
 
-data_conf = configuration_data()
-data_conf.set('APP_ID', application_id)
-data_conf.set('DATA_DIR', DATA_DIR)
-
-message('Compiling resources')
 
 gnome.compile_resources(
-  application_id_stable + '.data',
-  application_id_stable + '.data.gresource.xml',
+  '@0@.data'.format(default_id),
+  '@0  data gresource xml'.format(weather_id),
   gresource_bundle: true,
-  source_dir: '.',
-  install_dir: DATA_DIR,
+  install_dir: weather_pkgdatadir,
   install: true
 )
 
 gnome.compile_resources(
-  application_id_stable + '.BackgroundService.data',
-  application_id_stable + '.BackgroundService.data.gresource.xml',
+  '@0  BackgroundService data'.format(default_id),
+  '@0  BackgroundService data gresource xml'.format(weather_id),
   gresource_bundle: true,
-  source_dir: '.',
-  install_dir: DATA_DIR,
+  install_dir: weather_pkgdatadir,
   install: true
 )
 
 # Installing the schema file
 install_data(
-  application_id_stable + '.gschema.xml',
-  install_dir: 'share/glib-2.0/schemas'
+  default_id + '.gschema.xml',
+  install_dir: join_paths(weather_datadir, 'glib-2.0', 'schemas')
 )
 
 # Building desktop file
 msgfmt = find_program('msgfmt')
 desktop_conf = configuration_data()
-desktop_conf.set('APP_ID', application_id)
+desktop_conf.set('APP_ID', weather_id)
 desktop = custom_target(
   'desktop-file',
   input: configure_file(
-    input: '@0  desktop in in'.format(application_id_stable),
-    output: '@0  desktop in'.format(application_id_stable),
+    input: '@0  desktop in in'.format(default_id),
+    output: '@0  desktop in'.format(default_id),
     configuration: desktop_conf,
   ),
-  output: '@0@.desktop'.format(application_id),
+  output: '@0@.desktop'.format(weather_id),
   install: true,
-  install_dir: join_paths(get_option('datadir'), 'applications'),
+  install_dir: join_paths(weather_datadir, 'applications'),
   command: [msgfmt, '--desktop',
     '--template', '@INPUT@', '-d', podir, '-o', '@OUTPUT@',
     '--keyword=X-Geoclue-Reason',
@@ -58,7 +51,7 @@ if desktop_file_validate.found()
   test (
     'Validate desktop file',
     desktop_file_validate,
-    args: join_paths(meson.current_build_dir(), application_id + '.desktop')
+    args: join_paths(meson.current_build_dir(), weather_id + '.desktop')
   )
 endif
 
@@ -66,8 +59,8 @@ endif
 appdata_conf = configuration_data()
 appdata = i18n.merge_file(
   'appdata',
-  input: application_id_stable + '.appdata.xml.in',
-  output: application_id + '.appdata.xml',
+  input: '@0  appdata xml in'.format(default_id),
+  output: '@0  appdata xml'.format(weather_id),
   install: true,
   install_dir: join_paths(join_paths('share'), 'metainfo'),
   po_dir: join_paths(meson.source_root(), 'po')
@@ -84,26 +77,31 @@ if appstream_util.found()
   )
 endif
 
+service_conf = configuration_data()
+service_conf.set('APP_ID', weather_id)
+service_conf.set('DATA_DIR', weather_pkgdatadir)
+weather_servicedir = join_paths(weather_datadir, 'dbus-1', 'services')
+
 configure_file(
-  input: application_id_stable + '.service.in',
-  output: application_id + '.service',
-  configuration: data_conf,
+  input: '@0  service in'.format(default_id),
+  output: '@0@.service'.format(weather_id),
+  configuration: service_conf,
   install: true,
-  install_dir: join_paths(get_option('datadir'), 'dbus-1', 'services')
+  install_dir: weather_servicedir
 )
 
 configure_file(
-  input: application_id_stable + '.BackgroundService.service.in',
-  output: application_id + '.BackgroundService.service',
-  configuration: data_conf,
+  input: '@0  BackgroundService service in'.format(default_id),
+  output: '@0@.BackgroundService.service'.format(weather_id),
+  configuration: service_conf,
   install: true,
-  install_dir: join_paths(get_option('datadir'), 'dbus-1', 'services')
+  install_dir: weather_servicedir
 )
 
 # Search Provider
 install_data(
-  application_id_stable + '.search-provider.ini',
-  install_dir: 'share/gnome-shell/search-providers'
+  default_id + '.search-provider.ini',
+  install_dir: join_paths(weather_datadir, 'gnome-shell', 'search-providers')
 )
 
 subdir('icons')
diff --git a/meson.build b/meson.build
index 203e331..a6ad692 100644
--- a/meson.build
+++ b/meson.build
@@ -4,13 +4,9 @@ project('gnome-weather', 'c',
   license: 'GPL2+'
 )
 
-prefix = get_option('prefix')
 i18n = import('i18n')
 gnome = import('gnome')
-application_id = 'org.gnome.Weather'
-application_id_stable = 'org.gnome.Weather'
 
-message('Looking for dependencies')
 dependency('glib-2.0')
 dependency('gobject-introspection-1.0', version: '>=1.35.9')
 dependency('gtk+-3.0', version :'>=3.20')
@@ -18,12 +14,6 @@ dependency('gjs-1.0', version: '>= 1.50.0')
 dependency('geoclue-2.0', version: '>= 0.12.99')
 dependency('gweather-3.0', version: '>= 3.28')
 
-env = environment()
-
-EXTENSION_DIR = join_paths(get_option('prefix'), get_option('libdir'), meson.project_name())
-DATA_DIR = join_paths(get_option('prefix'), get_option('datadir'), application_id)
-BIN_DIR = join_paths(get_option('prefix'), get_option('bindir'))
-
 # Profiles
 if get_option('profile') == 'development'
   profile = 'Devel'
@@ -33,22 +23,15 @@ else
   name_suffix = ''
 endif
 
-conf = configuration_data()
-conf.set('PACKAGE_URL', 'https://gitlab.gnome.org/GNOME/gnome-weather')
-conf.set('DATA_DIR', DATA_DIR)
+default_id = 'org.gnome.Weather'
+weather_id = default_id + profile
 
-if get_option('profile') == 'development'
-  conf.set('VERSION', ''.join([run_command(['git', 'describe', '--long', '--tags']).stdout(), 
get_option('profile')]))
-else
-  conf.set('VERSION', meson.project_version())
-endif
-
-conf.set_quoted('PROFILE', profile)
-
-if get_option('profile') == 'development'
-  application_id = 'org.gnome.WeatherDevel'
-endif
-conf.set('APP_ID', application_id)
+weather_prefix = get_option('prefix')
+weather_libdir = join_paths(weather_prefix, get_option('libdir'))
+weather_extensiondir = join_paths(weather_libdir, meson.project_name())
+weather_datadir = join_paths(weather_prefix, get_option('datadir'))
+weather_pkgdatadir = join_paths(weather_datadir, weather_id)
+weather_bindir = join_paths(weather_prefix, get_option('bindir'))
 
 subdir('data')
 subdir('po')
@@ -57,7 +40,7 @@ subdir('tests')
 
 meson.add_install_script(
   'meson_post_install.py',
-  join_paths(get_option('prefix'), get_option('datadir')),
-  DATA_DIR,
-  BIN_DIR,
+  weather_datadir,
+  weather_pkgdatadir,
+  weather_bindir,
 )
diff --git a/po/meson.build b/po/meson.build
index 5d0af17..bc3b1ec 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -1,3 +1,3 @@
 message('Update translations')
-i18n.gettext(application_id, preset: 'glib',
+i18n.gettext(weather_id, preset: 'glib',
              args: [ '--keyword=X-Geoclue-Reason' ])
diff --git a/src/meson.build b/src/meson.build
index b63ea62..c52cf7f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,40 +1,40 @@
 source_conf = configuration_data()
 source_conf.set('GJS', find_program('gjs').path())
-source_conf.set('DATA_DIR', DATA_DIR)
-source_conf.set('PACKAGE_VERSION', meson.project_version())
-source_conf.set('libdir', EXTENSION_DIR)
-source_conf.set('prefix', prefix)
+source_conf.set('VERSION', meson.project_version())
+source_conf.set('APP_ID', weather_id)
+source_conf.set('libdir', weather_extensiondir)
+source_conf.set('prefix', weather_prefix)
 
 application = configure_file(
-  input: application_id_stable + '.in',
-  output: application_id,
+  input: '@0@.in'.format(default_id),
+  output: weather_id,
   configuration: source_conf,
   install: true,
-  install_dir: DATA_DIR
+  install_dir: weather_pkgdatadir
 )
 
 configure_file(
-  input: application_id_stable + '.BackgroundService.in',
-  output: application_id + '.BackgroundService',
+  input: '@0  BackgroundService in'.format(default_id),
+  output: '@0@.BackgroundService'.format(weather_id),
   configuration: source_conf,
   install: true,
-  install_dir: DATA_DIR
+  install_dir: weather_pkgdatadir
 )
 
 application_sources = gnome.compile_resources(
-  application_id_stable + '.src',
-  application_id_stable + '.src.gresource.xml',
+  '@0@.src'.format(default_id),
+  '@0  src gresource xml'.format(default_id),
   gresource_bundle: true,
   install: true,
-  install_dir: DATA_DIR
+  install_dir: weather_pkgdatadir
 )
 
 gnome.compile_resources(
-  application_id_stable + '.BackgroundService.src',
-  application_id_stable + '.BackgroundService.src.gresource.xml',
+  '@0  BackgroundService src'.format(default_id),
+  '@0  BackgroundService src gresource xml'.format(default_id),
   gresource_bundle: true,
   install: true,
-  install_dir: DATA_DIR
+  install_dir: weather_pkgdatadir
 )
 
 run_target('run',
diff --git a/src/org.gnome.Weather.BackgroundService.in b/src/org.gnome.Weather.BackgroundService.in
index 4b966dd..e4029f6 100755
--- a/src/org.gnome.Weather.BackgroundService.in
+++ b/src/org.gnome.Weather.BackgroundService.in
@@ -1,6 +1,6 @@
 #!@GJS@
-imports.package.init({ name: "org.gnome.Weather",
-                        version: "@PACKAGE_VERSION@",
+imports.package.init({ name: "@APP_ID",
+                        version: "@VERSION@",
                         prefix: "@prefix@",
                         libdir: "@libdir@" });
-imports.package.run(imports.service.main);
\ No newline at end of file
+imports.package.run(imports.service.main);
diff --git a/src/org.gnome.Weather.in b/src/org.gnome.Weather.in
index ffcb925..9c26b18 100755
--- a/src/org.gnome.Weather.in
+++ b/src/org.gnome.Weather.in
@@ -1,6 +1,6 @@
 #!@GJS@
-imports.package.init({ name: "org.gnome.Weather",
-                        version: "@PACKAGE_VERSION@",
+imports.package.init({ name: "@APP_ID@",
+                        version: "@VERSION@",
                         prefix: "@prefix@",
                         libdir: "@libdir@" });
-imports.package.run(imports.app.main);
\ No newline at end of file
+imports.package.run(imports.app.main);


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