[gnome-photos/wip/rishi/split-private-library: 2/2] build: Split some code into a private shared library



commit 4f51f779fba027ba55baa38e04b8e0d78168cc71
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Oct 3 08:44:37 2018 +0200

    build: Split some code into a private shared library
    
    The overall idea is to start adding unit tests, wherever possible.
    Putting the tested code in a private library makes it accessible from
    test cases because they can link to it.
    
    Subsequent commits will add a new codec API for GeglBuffer. It will be
    very important to have unit tests for those code paths because:
      * That code will be inherently testable and tests are great.
      * That code is likely to be security sensitive, will handle all
        sorts of dodgy input from untrusted sources, and written using
        very old APIs with brittle error handling.
    
    This is a step towards that.
    
    A private shared library seems better than a private static archive
    because the most easily testable code paths are shared across the main
    application and the thumbnailer. Therefore, the assumption is that the
    benefits of sharing that code across both processes outweigh the
    drawbacks of having to resolve symbols from yet another shared library
    on startup. However, this is just an assumption. There's no data
    behind it.
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/63

 meson.build     |   1 +
 src/Makefile.am | 162 ++++++++++++++++++++++++++++----------------------------
 src/meson.build |  44 ++++++++++++---
 3 files changed, 119 insertions(+), 88 deletions(-)
---
diff --git a/meson.build b/meson.build
index 633cf56a..3f6e1552 100644
--- a/meson.build
+++ b/meson.build
@@ -13,6 +13,7 @@ photos_libexecdir = join_paths(photos_prefix, get_option('libexecdir'))
 photos_localedir = join_paths(photos_prefix, get_option('localedir'))
 
 photos_docdir = join_paths(photos_datadir, 'doc', meson.project_name())
+photos_libdir = join_paths(photos_prefix, get_option('libdir'), meson.project_name())
 
 photos_installed_test_metadir = join_paths(photos_datadir, 'installed-tests', meson.project_name())
 photos_installed_test_execdir = join_paths(photos_libexecdir, 'installed-tests', meson.project_name())
diff --git a/src/Makefile.am b/src/Makefile.am
index 94d7e940..06b5b3e8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,14 +1,90 @@
+pkglib_LTLIBRARIES = libgnome-photos.la
+
 bin_PROGRAMS = gnome-photos
 
 libexec_PROGRAMS = gnome-photos-thumbnailer
 
+libgnome_photos_la_built_sources = \
+       photos-enums-gegl.c \
+       photos-enums-gegl.h \
+       photos-resources-gegl.c \
+       photos-resources-gegl.h \
+       $(NULL)
+
+nodist_libgnome_photos_la_SOURCES = \
+       $(libgnome_photos_la_built_sources) \
+       $(NULL)
+
+libgnome_photos_la_SOURCES = \
+       photos-debug.c \
+       photos-debug.h \
+       photos-error.c \
+       photos-error.h \
+       photos-gegl.c \
+       photos-gegl.h \
+       photos-jpeg-count.c \
+       photos-jpeg-count.h \
+       photos-operation-insta-common.h \
+       photos-operation-insta-curve.c \
+       photos-operation-insta-curve.h \
+       photos-operation-insta-filter.c \
+       photos-operation-insta-filter.h \
+       photos-operation-insta-hefe.c \
+       photos-operation-insta-hefe.h \
+       photos-operation-insta-hefe-curve.c \
+       photos-operation-insta-hefe-curve.h \
+       photos-operation-insta-hefe-vignette.c \
+       photos-operation-insta-hefe-vignette.h \
+       photos-operation-jpg-guess-sizes.c \
+       photos-operation-jpg-guess-sizes.h \
+       photos-operation-png-guess-sizes.c \
+       photos-operation-png-guess-sizes.h \
+       photos-operation-saturation.c \
+       photos-operation-saturation.h \
+       photos-operation-svg-multiply.c \
+       photos-operation-svg-multiply.h \
+       photos-pipeline.c \
+       photos-pipeline.h \
+       photos-png-count.c \
+       photos-png-count.h \
+       photos-quarks.c \
+       photos-quarks.h \
+       $(NULL)
+
+libgnome_photos_la_CPPFLAGS = \
+       $(BABL_CFLAGS) \
+       $(DAZZLE_CFLAGS) \
+       $(GDK_PIXBUF_CFLAGS) \
+       $(GEGL_CFLAGS) \
+       $(GIO_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       $(GOBJECT_CFLAGS) \
+       $(PNG_CFLAGS) \
+       $(NULL)
+
+libgnome_photos_la_LDFLAGS = \
+       $(WARN_LDFLAGS) \
+       -avoid-version \
+       $(NULL)
+
+libgnome_photos_la_LIBADD = \
+       $(BABL_LIBS) \
+       $(DAZZLE_LIBS) \
+       $(GEGL_LIBS) \
+       $(GDK_PIXBUF_LIBS) \
+       $(GIO_LIBS) \
+       $(GLIB_LIBS) \
+       $(GOBJECT_LIBS) \
+       $(JPEG_LIBS) \
+       $(PNG_LIBS) \
+       $(LIBM) \
+       $(NULL)
+
 gnome_photos_built_sources = \
        photos-about-data.c \
        photos-about-data.h \
        photos-enums.c \
        photos-enums.h \
-       photos-enums-gegl.c \
-       photos-enums-gegl.h \
        photos-dleyna-renderer-device.c \
        photos-dleyna-renderer-device.h \
        photos-dleyna-renderer-manager.c \
@@ -23,8 +99,6 @@ gnome_photos_built_sources = \
        photos-mpris-player.h \
        photos-resources.c \
        photos-resources.h \
-       photos-resources-gegl.c \
-       photos-resources-gegl.h \
        photos-shell-search-provider2.c \
        photos-shell-search-provider2.h \
        photos-thumbnailer-dbus.c \
@@ -56,8 +130,6 @@ gnome_photos_SOURCES = \
        photos-create-collection-icon-job.h \
        photos-create-collection-job.c \
        photos-create-collection-job.h \
-       photos-debug.c \
-       photos-debug.h \
        photos-delete-item-job.c \
        photos-delete-item-job.h \
        photos-delete-notification.c \
@@ -74,8 +146,6 @@ gnome_photos_SOURCES = \
        photos-done-notification.h \
        photos-dropdown.c \
        photos-dropdown.h \
-       photos-error.c \
-       photos-error.h \
        photos-export-dialog.c \
        photos-export-dialog.h \
        photos-export-notification.c \
@@ -104,8 +174,6 @@ gnome_photos_SOURCES = \
        photos-filterable.h \
        photos-flickr-item.c \
        photos-flickr-item.h \
-       photos-gegl.c \
-       photos-gegl.h \
        photos-gesture-zoom.c \
        photos-gesture-zoom.h \
        photos-glib.c \
@@ -122,8 +190,6 @@ gnome_photos_SOURCES = \
        photos-indexing-notification.h \
        photos-item-manager.c \
        photos-item-manager.h \
-       photos-jpeg-count.c \
-       photos-jpeg-count.h \
        photos-local-item.c \
        photos-local-item.h \
        photos-main-toolbar.c \
@@ -150,25 +216,6 @@ gnome_photos_SOURCES = \
        photos-offset-overview-controller.h \
        photos-offset-search-controller.c \
        photos-offset-search-controller.h \
-       photos-operation-insta-common.h \
-       photos-operation-insta-curve.c \
-       photos-operation-insta-curve.h \
-       photos-operation-insta-filter.c \
-       photos-operation-insta-filter.h \
-       photos-operation-insta-hefe.c \
-       photos-operation-insta-hefe.h \
-       photos-operation-insta-hefe-curve.c \
-       photos-operation-insta-hefe-curve.h \
-       photos-operation-insta-hefe-vignette.c \
-       photos-operation-insta-hefe-vignette.h \
-       photos-operation-jpg-guess-sizes.c \
-       photos-operation-jpg-guess-sizes.h \
-       photos-operation-png-guess-sizes.c \
-       photos-operation-png-guess-sizes.h \
-       photos-operation-saturation.c \
-       photos-operation-saturation.h \
-       photos-operation-svg-multiply.c \
-       photos-operation-svg-multiply.h \
        photos-organize-collection-dialog.c \
        photos-organize-collection-dialog.h \
        photos-organize-collection-model.c \
@@ -177,10 +224,6 @@ gnome_photos_SOURCES = \
        photos-organize-collection-view.h \
        photos-overview-searchbar.c \
        photos-overview-searchbar.h \
-       photos-pipeline.c \
-       photos-pipeline.h \
-       photos-png-count.c \
-       photos-png-count.h \
        photos-preview-nav-buttons.c \
        photos-preview-nav-buttons.h \
        photos-preview-view.c \
@@ -195,8 +238,6 @@ gnome_photos_SOURCES = \
        photos-print-setup.h \
        photos-properties-dialog.c \
        photos-properties-dialog.h \
-       photos-quarks.c \
-       photos-quarks.h \
        photos-query.c \
        photos-query.h \
        photos-query-builder.h \
@@ -348,18 +389,13 @@ gnome_photos_LDADD = \
        $(GRILO_LIBS) \
        $(GTK_LIBS) \
        $(GTK_UNIX_PRINT_LIBS) \
-       $(JPEG_LIBS) \
-       $(PNG_LIBS) \
        $(TRACKER_LIBS) \
        $(LIBM) \
        $(top_builddir)/subprojects/libgd/libgd.la \
+       libgnome-photos.la \
        $(NULL)
 
 gnome_photos_thumbnailer_built_sources = \
-       photos-enums-gegl.c \
-       photos-enums-gegl.h \
-       photos-resources-gegl.c \
-       photos-resources-gegl.h \
        photos-thumbnailer-dbus.c \
        photos-thumbnailer-dbus.h \
        $(NULL)
@@ -369,41 +405,8 @@ nodist_gnome_photos_thumbnailer_SOURCES = \
        $(NULL)
 
 gnome_photos_thumbnailer_SOURCES = \
-       photos-debug.c \
-       photos-debug.h \
-       photos-error.c \
-       photos-error.h \
-       photos-gegl.c \
-       photos-gegl.h \
-       photos-jpeg-count.c \
-       photos-jpeg-count.h \
-       photos-operation-insta-common.h \
-       photos-operation-insta-curve.c \
-       photos-operation-insta-curve.h \
-       photos-operation-insta-filter.c \
-       photos-operation-insta-filter.h \
-       photos-operation-insta-hefe.c \
-       photos-operation-insta-hefe.h \
-       photos-operation-insta-hefe-curve.c \
-       photos-operation-insta-hefe-curve.h \
-       photos-operation-insta-hefe-vignette.c \
-       photos-operation-insta-hefe-vignette.h \
-       photos-operation-jpg-guess-sizes.c \
-       photos-operation-jpg-guess-sizes.h \
-       photos-operation-png-guess-sizes.c \
-       photos-operation-png-guess-sizes.h \
-       photos-operation-saturation.c \
-       photos-operation-saturation.h \
-       photos-operation-svg-multiply.c \
-       photos-operation-svg-multiply.h \
-       photos-pipeline.c \
-       photos-pipeline.h \
        photos-pixbuf.c \
        photos-pixbuf.h \
-       photos-png-count.c \
-       photos-png-count.h \
-       photos-quarks.c \
-       photos-quarks.h \
        photos-thumbnailer.c \
        photos-thumbnailer.h \
        photos-thumbnailer-main.c \
@@ -411,7 +414,6 @@ gnome_photos_thumbnailer_SOURCES = \
 
 gnome_photos_thumbnailer_CPPFLAGS = \
        -DPACKAGE_LOCALE_DIR=\""${datadir}/locale"\" \
-       $(BABL_CFLAGS) \
        $(DAZZLE_CFLAGS) \
        $(GDK_PIXBUF_CFLAGS) \
        $(GEGL_CFLAGS) \
@@ -426,21 +428,19 @@ gnome_photos_thumbnailer_LDFLAGS = \
        $(NULL)
 
 gnome_photos_thumbnailer_LDADD = \
-       $(BABL_LIBS) \
        $(DAZZLE_LIBS) \
        $(GEGL_LIBS) \
        $(GDK_PIXBUF_LIBS) \
        $(GIO_LIBS) \
        $(GLIB_LIBS) \
        $(GOBJECT_LIBS) \
-       $(JPEG_LIBS) \
-       $(PNG_LIBS) \
-       $(LIBM) \
+       libgnome-photos.la \
        $(NULL)
 
 BUILT_SOURCES = \
        $(gnome_photos_built_sources) \
        $(gnome_photos_thumbnailer_built_sources) \
+       $(libgnome_photos_la_built_sources) \
        $(NULL)
 
 EXTRA_DIST = \
diff --git a/src/meson.build b/src/meson.build
index 9cb0dd83..ac2a782a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,4 +1,4 @@
-common_sources = files(
+sources = files(
   'photos-debug.c',
   'photos-error.c',
   'photos-gegl.c',
@@ -23,7 +23,7 @@ enum_headers = files(
 
 enum = 'photos-enums-gegl'
 
-common_sources += gnome.mkenums(
+sources += gnome.mkenums(
   enum,
   sources: enum_headers,
   c_template: enum + '.c.template',
@@ -32,7 +32,7 @@ common_sources += gnome.mkenums(
 
 resource_data = files('../data/vignette.png')
 
-common_sources += gnome.compile_resources(
+sources += gnome.compile_resources(
   'photos-resources-gegl',
   'photos-gegl.gresource.xml',
   source_dir: '.',
@@ -41,6 +41,35 @@ common_sources += gnome.compile_resources(
   export: true,
 )
 
+deps = [
+  babl_dep,
+  gegl_dep,
+  gdk_pixbuf_dep,
+  gio_dep,
+  gio_unix_dep,
+  glib_dep,
+  gobject_dep,
+  libdazzle_dep,
+  libjpeg_dep,
+  libpng_dep,
+  m_dep,
+]
+
+libgnome_photos = shared_library(
+  meson.project_name(),
+  sources,
+  dependencies: deps,
+  include_directories: top_inc,
+  install: true,
+  install_dir: photos_libdir,
+)
+
+libgnome_photos_dep = declare_dependency(
+  link_with: libgnome_photos,
+)
+
+common_sources = []
+
 thumbnailer_dbus = 'photos-thumbnailer-dbus'
 
 common_sources += gnome.gdbus_codegen(
@@ -56,7 +85,6 @@ common_sources += gnome.gdbus_codegen(
 )
 
 common_deps = [
-  babl_dep,
   gdk_pixbuf_dep,
   gegl_dep,
   gio_dep,
@@ -64,9 +92,7 @@ common_deps = [
   glib_dep,
   gobject_dep,
   libdazzle_dep,
-  libjpeg_dep,
-  libpng_dep,
-  m_dep,
+  libgnome_photos_dep,
 ]
 
 sources = common_sources + files(
@@ -348,6 +374,7 @@ sources += gnome.gdbus_codegen(
 )
 
 deps = common_deps + [
+  babl_dep,
   cairo_dep,
   geocode_glib_dep,
   gexiv_dep,
@@ -359,6 +386,7 @@ deps = common_deps + [
   libgd_dep,
   libgdata_dep,
   libgfgraph_dep,
+  m_dep,
   tracker_control_dep,
   tracker_sparql_dep,
 ]
@@ -376,6 +404,7 @@ executable(
   c_args: cflags,
   install: true,
   install_dir: photos_bindir,
+  install_rpath: photos_libdir,
 )
 
 sources = common_sources + files(
@@ -392,4 +421,5 @@ executable(
   c_args: cflags,
   install: true,
   install_dir: photos_libexecdir,
+  install_rpath: photos_libdir,
 )


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