[dia: 38/105] #19: Remove code duplication when compiling plugins.



commit d4cfb158ec252dcb60d733ec388db0cced6cce0f
Author: Eduard Nicodei <eddnicodei gmail com>
Date:   Mon Dec 31 10:43:32 2018 +0000

    #19: Remove code duplication when compiling plugins.

 plug-ins/cairo/meson.build | 18 +++---------------
 plug-ins/cgm/meson.build   | 12 +-----------
 plug-ins/drs/meson.build   | 20 +++++++++-----------
 plug-ins/dxf/meson.build   | 17 +++--------------
 plug-ins/hpgl/meson.build  | 16 +---------------
 plug-ins/meson.build       | 19 +++++++++++++++++++
 6 files changed, 36 insertions(+), 66 deletions(-)
---
diff --git a/plug-ins/cairo/meson.build b/plug-ins/cairo/meson.build
index 2473963e..6a40f781 100644
--- a/plug-ins/cairo/meson.build
+++ b/plug-ins/cairo/meson.build
@@ -1,20 +1,8 @@
-plugin_sources = [
+sources = files(
     'diacairo.c',
     'diacairo-interactive.c',
     'diacairo-renderer.c',
     'diacairo-print.c'
-]
-
-shared_library(
-    'cairo_filter',
-    plugin_sources,
-    dependencies : [ libcairo_dep,
-                     libgtk_dep,
-                     libxml_dep,
-                     libm_dep ],
-    include_directories : [ libdia_inc,
-                            configuration_inc ],
-    link_with : [ libdia ],
-    install : true,
-    install_dir : dialibdir
 )
+
+install_plugins_desc += [['cairo_filter', sources, [libcairo_dep]]]
diff --git a/plug-ins/cgm/meson.build b/plug-ins/cgm/meson.build
index 5a22f524..b9aa28dd 100644
--- a/plug-ins/cgm/meson.build
+++ b/plug-ins/cgm/meson.build
@@ -1,11 +1 @@
-shared_library(
-    'cgm_filter',
-    'cgm.c',
-    dependencies : [ libgtk_dep,
-                     libm_dep ],
-    include_directories : [ libdia_inc,
-                            configuration_inc ],
-    link_with : [ libdia ],
-    install : true,
-    install_dir : dialibdir
-)
+install_plugins_desc += [['cgm_filter', files('cgm.c'), []]]
diff --git a/plug-ins/drs/meson.build b/plug-ins/drs/meson.build
index da9dd5bd..481e0010 100644
--- a/plug-ins/drs/meson.build
+++ b/plug-ins/drs/meson.build
@@ -1,19 +1,17 @@
-plugin_sources = [
+sources = files(
     'dia-render-script.c',
     'dia-render-script-import.c',
     'dia-render-script-object.c',
     'dia-render-script-renderer.c'
-]
+)
 
+# Prevent installation - currently a debug tool only
 shared_library(
     'drs_filter',
-    plugin_sources,
-    dependencies : [ libgtk_dep,
-                     libxml_dep,
-                     libm_dep ],
-    include_directories : [ libdia_inc,
-                            configuration_inc ],
-    link_with : [ libdia ],
-    install : false,   # Prevent installation - currently a debug tool only
-    install_dir : dialibdir
+    sources,
+    dependencies: [libgtk_dep, libm_dep, libxml_dep],
+    include_directories: [libdia_inc, configuration_inc],
+    link_with: [libdia],
+    install: false,
+    install_dir: dialibdir
 )
diff --git a/plug-ins/dxf/meson.build b/plug-ins/dxf/meson.build
index 5a20185d..130c7175 100644
--- a/plug-ins/dxf/meson.build
+++ b/plug-ins/dxf/meson.build
@@ -1,19 +1,8 @@
-plugin_sources = [
+sources = files(
        'dxf.c',
        'dxf-export.c',
        'dxf-import.c',
        'autocad_pal.c'
-]
-
-shared_library(
-    'dxf_filter',
-    plugin_sources,
-    dependencies : [ libgtk_dep,
-                     libxml_dep,
-                     libm_dep ],
-    include_directories : [ libdia_inc,
-                            configuration_inc ],
-    link_with : [ libdia ],
-    install : true,
-    install_dir : dialibdir
 )
+
+install_plugins_desc += [['dxf_filter', sources, []]]
diff --git a/plug-ins/hpgl/meson.build b/plug-ins/hpgl/meson.build
index 4f3c352a..2ec01c8f 100644
--- a/plug-ins/hpgl/meson.build
+++ b/plug-ins/hpgl/meson.build
@@ -1,15 +1 @@
-plugin_sources = [
-    'hpgl.c'
-]
-
-shared_library(
-    'hpgl_filter',
-    plugin_sources,
-    dependencies : [ libgtk_dep,
-                     libm_dep ],
-    include_directories : [ libdia_inc,
-                            configuration_inc ],
-    link_with : [ libdia ],
-    install : true,
-    install_dir : dialibdir
-)
+install_plugins_desc += [['hpgl_filter', files('hpgl.c'), []]]
diff --git a/plug-ins/meson.build b/plug-ins/meson.build
index e04bf946..01199799 100644
--- a/plug-ins/meson.build
+++ b/plug-ins/meson.build
@@ -1,3 +1,9 @@
+# First element is plugin name
+# Second is source list
+# Third is additional dependences
+# Fourth is whether to install or not
+install_plugins_desc = []
+
 subdir('cairo')
 subdir('cgm')
 subdir('drs')
@@ -23,3 +29,16 @@ subdir('hpgl')
 #subdir('wpg')
 #subdir('xfig')
 #subdir('xslt')
+
+foreach p : install_plugins_desc
+    message(p[0])
+    shared_library(
+        p[0],
+        p[1],
+        dependencies: [libgtk_dep, libm_dep, libxml_dep] + [p[2]],
+        include_directories: [libdia_inc, configuration_inc],
+        link_with: [libdia],
+        install: true,
+        install_dir: dialibdir
+    )
+endforeach


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