[gvfs] build: Make use of dictionaries to gain readibility



commit a60d8c0987914213f2e69f760b15500a10c3adb4
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Tue Dec 18 12:09:48 2018 +0100

    build: Make use of dictionaries to gain readibility
    
    The set of daemons is a large list of executables to be built. To
    ease its build an array of arrays was created, but this harms
    readibility.
    
    This has been improved by the use of the new dictionary types[0] and
    the possibility of using a dictionary as a parameter in target
    objects[1].
    
    The individual dependencies have been moved directly to the new
    dictionary because it remains clear their meaning.
    
    [0] http://mesonbuild.com/Release-notes-for-0-47-0.html#new-builtin-object-type-dictionary
    [1] http://mesonbuild.com/Release-notes-for-0-49-0.html#can-specify-keyword-arguments-with-a-dictionary

 daemon/meson.build | 103 ++++++++++++++++-------------------------------------
 1 file changed, 31 insertions(+), 72 deletions(-)
---
diff --git a/daemon/meson.build b/daemon/meson.build
index 9c402d22..0ce0c204 100644
--- a/daemon/meson.build
+++ b/daemon/meson.build
@@ -156,15 +156,13 @@ mounts = []
 schema_data = []
 convert_data = []
 
-sources = files('gvfsbackendlocaltest.c')
-
 cflags = [
   '-DBACKEND_HEADER=gvfsbackendlocaltest.h',
   '-DDEFAULT_BACKEND_TYPE=localtest',
   '-DBACKEND_TYPES="localtest", G_VFS_TYPE_BACKEND_LOCALTEST,',
 ]
 
-programs += [['gvfsd-localtest', sources, [], cflags]]
+programs += [['gvfsd-localtest', {'sources': files('gvfsbackendlocaltest.c'), 'c_args': cflags}]]
 mounts += ['localtest']
 
 sources = files(
@@ -183,13 +181,9 @@ cflags = [
   '-DMAX_JOB_THREADS=10',
 ]
 
-programs += [['gvfsd-ftp', sources, [], cflags]]
+programs += [['gvfsd-ftp', {'sources': sources, 'c_args': cflags}]]
 mounts += ['ftp', 'ftps', 'ftpis']
 
-sources = files('gvfsbackendtrash.c')
-
-deps = [libtrash_dep]
-
 cflags = [
   '-DBACKEND_HEADER=gvfsbackendtrash.h',
   '-DDEFAULT_BACKEND_TYPE=trash',
@@ -197,11 +191,9 @@ cflags = [
   '-DMAX_JOB_THREADS=10',
 ]
 
-programs += [['gvfsd-trash', sources, deps, cflags]]
+programs += [['gvfsd-trash', {'sources': files('gvfsbackendtrash.c'), 'dependencies': [libtrash_dep], 
'c_args': cflags}]]
 mounts += ['trash']
 
-sources = files('gvfsbackendrecent.c')
-
 cflags = [
   '-DBACKEND_HEADER=gvfsbackendrecent.h',
   '-DDEFAULT_BACKEND_TYPE=recent',
@@ -210,11 +202,9 @@ cflags = [
   '-DMAX_JOB_THREADS=10',
 ]
 
-programs += [['gvfsd-recent', sources, [], cflags]]
+programs += [['gvfsd-recent', {'sources': files('gvfsbackendrecent.c'), 'c_args': cflags}]]
 mounts += ['recent']
 
-sources = files('gvfsbackendcomputer.c')
-
 cflags = [
   '-DBACKEND_HEADER=gvfsbackendcomputer.h',
   '-DDEFAULT_BACKEND_TYPE=computer',
@@ -223,11 +213,9 @@ cflags = [
   '-DMAX_JOB_THREADS=1',
 ]
 
-programs += [['gvfsd-computer', sources, [gio_unix_dep], cflags]]
+programs += [['gvfsd-computer', {'sources': files('gvfsbackendcomputer.c'), 'dependencies': [gio_unix_dep], 
'c_args': cflags}]]
 mounts += ['computer']
 
-sources = files('gvfsbackendnetwork.c')
-
 cflags = [
   '-DBACKEND_HEADER=gvfsbackendnetwork.h',
   '-DDEFAULT_BACKEND_TYPE=network',
@@ -236,11 +224,9 @@ cflags = [
   '-DMAX_JOB_THREADS=1',
 ]
 
-programs += [['gvfsd-network', sources, [], cflags]]
+programs += [['gvfsd-network', {'sources': files('gvfsbackendnetwork.c'), 'c_args': cflags}]]
 mounts += ['network']
 
-sources = files('gvfsbackendburn.c')
-
 cflags = [
   '-DBACKEND_HEADER=gvfsbackendburn.h',
   '-DDEFAULT_BACKEND_TYPE=burn',
@@ -248,7 +234,7 @@ cflags = [
   '-DMAX_JOB_THREADS=1',
 ]
 
-programs += [['gvfsd-burn', sources, [gio_unix_dep], cflags]]
+programs += [['gvfsd-burn', {'sources': files('gvfsbackendburn.c'), 'dependencies': [gio_unix_dep], 
'c_args': cflags}]]
 mounts += ['burn']
 
 if enable_sftp
@@ -270,15 +256,13 @@ if enable_sftp
     '-DSSH_PROGRAM="@0@"'.format(ssh.path()),
   ]
 
-  programs += [['gvfsd-sftp', sources, deps, cflags]]
+  programs += [['gvfsd-sftp', {'sources': sources, 'dependencies': deps, 'c_args': cflags}]]
   mounts += ['sftp']
 endif
 
 if enable_samba
   sources = files('gvfsbackendsmb.c')
 
-  deps = [smbclient_dep]
-
   cflags = [
     '-DBACKEND_HEADER=gvfsbackendsmb.h',
     '-DDEFAULT_BACKEND_TYPE=smb',
@@ -286,13 +270,11 @@ if enable_samba
     '-DMAX_JOB_THREADS=1',
   ]
 
-  programs += [['gvfsd-smb', sources, deps, cflags]]
+  programs += [['gvfsd-smb', {'sources': sources, 'dependencies': [smbclient_dep], 'c_args': cflags}]]
   mounts += ['smb']
   schema_data += files('org.gnome.system.smb.gschema.xml')
   convert_data += files('gvfs-smb.convert')
 
-  sources += files('gvfsbackendsmbbrowse.c')
-
   cflags = [
     '-DBACKEND_HEADER=gvfsbackendsmbbrowse.h',
     '-DDEFAULT_BACKEND_TYPE=smb-network',
@@ -301,13 +283,11 @@ if enable_samba
     '-DMOUNTABLE_DBUS_NAME=' + gvfs_namespace + '.mountpoint_smb_browse',
   ]
 
-  programs += [['gvfsd-smb-browse', sources, deps, cflags]]
+  programs += [['gvfsd-smb-browse', {'sources': sources + files('gvfsbackendsmbbrowse.c'), 'dependencies': 
[smbclient_dep], 'c_args': cflags}]]
   mounts += ['smb-browse']
 endif
 
 if enable_dnssd
-  sources = files('gvfsbackenddnssd.c')
-
   deps = [
     avahi_client_dep,
     avahi_glib_dep,
@@ -322,17 +302,13 @@ if enable_dnssd
     '-DMOUNTABLE_DBUS_NAME=' + gvfs_namespace + '.mountpoint_dnssd',
   ]
 
-  programs += [['gvfsd-dnssd', sources, deps, cflags]]
+  programs += [['gvfsd-dnssd', {'sources': files('gvfsbackenddnssd.c'), 'dependencies': deps, 'c_args': 
cflags}]]
   mounts += ['dns-sd']
   schema_data += files('org.gnome.system.dns_sd.gschema.xml')
   convert_data += files('gvfs-dns-sd.convert')
 endif
 
 if enable_archive
-  sources = files('gvfsbackendarchive.c')
-
-  deps = [libarchive_dep]
-
   cflags = [
     '-DBACKEND_HEADER=gvfsbackendarchive.h',
     '-DDEFAULT_BACKEND_TYPE=archive',
@@ -341,13 +317,11 @@ if enable_archive
     '-DBACKEND_USES_GVFS=1',
   ]
 
-  programs += [['gvfsd-archive', sources, deps, cflags]]
+  programs += [['gvfsd-archive', {'sources': files('gvfsbackendarchive.c'), 'dependencies': 
[libarchive_dep], 'c_args': cflags}]]
   mounts += ['archive']
 endif
 
 if enable_cdda
-  sources = files('gvfsbackendcdda.c')
-
   deps = [
     gudev_dep,
     libcdio_paranoia_dep,
@@ -360,13 +334,11 @@ if enable_cdda
     '-DMAX_JOB_THREADS=1',
   ]
 
-  programs += [['gvfsd-cdda', sources, deps, cflags]]
+  programs += [['gvfsd-cdda', {'sources': files('gvfsbackendcdda.c'), 'dependencies': deps, 'c_args': 
cflags}]]
   mounts += ['cdda']
 endif
 
 if enable_admin
-  sources = files('gvfsbackendadmin.c')
-
   deps = [
     libcap_dep,
     polkit_gobject_dep,
@@ -379,7 +351,7 @@ if enable_admin
     '-DMOUNTABLE_DBUS_NAME=' + gvfs_namespace + '.mountpoint_admin',
   ]
 
-  programs += [['gvfsd-admin', sources, deps, cflags]]
+  programs += [['gvfsd-admin', {'sources': files('gvfsbackendadmin.c'), 'dependencies': deps, 'c_args': 
cflags}]]
   mounts += ['admin']
 
   policy = gvfs_namespace + '.file-operations.policy'
@@ -406,8 +378,6 @@ if enable_admin
 endif
 
 if enable_google
-  sources = files('gvfsbackendgoogle.c')
-
   deps = [
     goa_dep,
     libgdata_dep,
@@ -419,13 +389,11 @@ if enable_google
     '-DBACKEND_TYPES="google-drive", G_VFS_TYPE_BACKEND_GOOGLE,',
   ]
 
-  programs += [['gvfsd-google', sources, deps, cflags]]
+  programs += [['gvfsd-google', {'sources': files('gvfsbackendgoogle.c'), 'dependencies': deps, 'c_args': 
cflags}]]
   mounts += ['google']
 endif
 
 if enable_gphoto2
-  sources = files('gvfsbackendgphoto2.c')
-
   deps = [
     gio_unix_dep,
     libgphoto2_dep,
@@ -439,13 +407,11 @@ if enable_gphoto2
     '-DMAX_JOB_THREADS=1',
   ]
 
-  programs += [['gvfsd-gphoto2', sources, deps, cflags]]
+  programs += [['gvfsd-gphoto2', {'sources': files('gvfsbackendgphoto2.c'), 'dependencies': deps, 'c_args': 
cflags}]]
   mounts += ['gphoto2']
 endif
 
 if enable_mtp
-  sources = files('gvfsbackendmtp.c')
-
   deps = [
     libgvfscommon_gphoto2_dep,
     libmtp_dep
@@ -462,7 +428,7 @@ if enable_mtp
     deps += libusb_dep
   endif
 
-  programs += [['gvfsd-mtp', sources, deps, cflags]]
+  programs += [['gvfsd-mtp', {'sources': files('gvfsbackendmtp.c'), 'dependencies': deps, 'c_args': cflags}]]
   mounts += ['mtp']
 endif
 
@@ -485,11 +451,9 @@ if enable_http
     '-DMOUNTABLE_DBUS_NAME=' + gvfs_namespace + '.mountpoint_http',
   ]
 
-  programs += [['gvfsd-http', sources, deps, cflags]]
+  programs += [['gvfsd-http', {'sources': sources, 'dependencies': deps, 'c_args': cflags}]]
   mounts += ['http']
 
-  sources = sources + files('gvfsbackenddav.c')
-
   cflags = [
     '-DBACKEND_HEADER=gvfsbackenddav.h',
     '-DDEFAULT_BACKEND_TYPE=dav',
@@ -506,13 +470,11 @@ if enable_http
     cflags += '-DBACKEND_TYPES="dav", G_VFS_TYPE_BACKEND_DAV,'
   endif
 
-  programs += [['gvfsd-dav', sources, deps, cflags]]
+  programs += [['gvfsd-dav', {'sources': sources + files('gvfsbackenddav.c'), 'dependencies': deps, 
'c_args': cflags}]]
   mounts += ['dav']
 endif
 
 if enable_afc
-  sources = files('gvfsbackendafc.c')
-
   deps = [
     libimobiledevice_dep,
     libplist_dep,
@@ -526,7 +488,7 @@ if enable_afc
     '-DBACKEND_USES_GVFS=1',
   ]
 
-  programs += [['gvfsd-afc', sources, deps, cflags]]
+  programs += [['gvfsd-afc', {'sources': files('gvfsbackendafc.c'), 'dependencies': deps, 'c_args': cflags}]]
   mounts += ['afc']
 endif
 
@@ -539,8 +501,6 @@ if enable_afp
     'gvfsafpvolume.c',
   )
 
-  sources = common_sources + files('gvfsbackendafp.c')
-
   deps = []
   if enable_gcrypt
     deps += libgcrypt_dep
@@ -553,11 +513,9 @@ if enable_afp
     '-DMAX_JOB_THREADS=1',
   ]
 
-  programs += [['gvfsd-afp', sources, deps, cflags]]
+  programs += [['gvfsd-afp', {'sources': common_sources + files('gvfsbackendafp.c'), 'dependencies': deps, 
'c_args': cflags}]]
   mounts += ['afp']
 
-  sources = common_sources + files('gvfsbackendafpbrowse.c')
-
   cflags = [
     '-DBACKEND_HEADER=gvfsbackendafpbrowse.h',
     '-DDEFAULT_BACKEND_TYPE=afp-server',
@@ -565,15 +523,11 @@ if enable_afp
     '-DMAX_JOB_THREADS=1',
   ]
 
-  programs += [['gvfsd-afp-browse', sources, deps, cflags]]
+  programs += [['gvfsd-afp-browse', {'sources': common_sources + files('gvfsbackendafpbrowse.c'), 
'dependencies': deps, 'c_args': cflags}]]
   mounts += ['afp-browse']
 endif
 
 if enable_nfs
-  sources = files('gvfsbackendnfs.c')
-
-  deps = [libnfs_dep]
-
   cflags = [
     '-DBACKEND_HEADER=gvfsbackendnfs.h',
     '-DDEFAULT_BACKEND_TYPE=nfs',
@@ -581,17 +535,22 @@ if enable_nfs
     '-DMAX_JOB_THREADS=1',
   ]
 
-  programs += [['gvfsd-nfs', sources, deps, cflags]]
+  programs += [['gvfsd-nfs', {'sources': files('gvfsbackendnfs.c'), 'dependencies': [libnfs_dep], 'c_args': 
cflags}]]
   mounts += ['nfs']
 endif
 
 foreach program: programs
+  options = program[1]
+  kwargs = {
+    'sources': daemon_main_sources + options.get('sources', []),
+    'dependencies': [libgvfsdaemon_dep] + options.get('dependencies', []),
+    'c_args': options.get('c_args', ''),
+  }
+
   executable(
     program[0],
-    daemon_main_sources + program[1],
     include_directories: top_inc,
-    dependencies: [libgvfsdaemon_dep] + program[2],
-    c_args: program[3],
+    kwargs: kwargs,
     install: true,
     install_rpath: gvfs_rpath,
     install_dir: gvfs_libexecdir,


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