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



commit ea732ad2a6a098ea52e35f98e80a43959c74cd25
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Sep 25 09:21:23 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 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 | 24 ++++++++++++------------
 src/meson.build | 32 +++++++++++++++++++++++++++++---
 3 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index 3ff4f6aa..d838a8ec 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 1ebaf665..1702208c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,12 +5,21 @@ bin_PROGRAMS = gnome-photos
 libexec_PROGRAMS = gnome-photos-thumbnailer
 
 libgnome_photos_la_SOURCES = \
+       photos-debug.c \
+       photos-debug.h \
+       photos-error.c \
+       photos-error.h \
+       photos-operation-svg-multiply.c \
+       photos-operation-svg-multiply.h \
        photos-quarks.c \
        photos-quarks.h \
        $(NULL)
 
 libgnome_photos_la_CPPFLAGS = \
+       $(BABL_CFLAGS) \
+       $(GEGL_CFLAGS) \
        $(GLIB_CFLAGS) \
+       $(GOBJECT_CFLAGS) \
        $(NULL)
 
 libgnome_photos_la_LDFLAGS = \
@@ -19,7 +28,10 @@ libgnome_photos_la_LDFLAGS = \
        $(NULL)
 
 libgnome_photos_la_LIBADD = \
+       $(BABL_LIBS) \
+       $(GEGL_LIBS) \
        $(GLIB_LIBS) \
+       $(GOBJECT_LIBS) \
        $(NULL)
 
 gnome_photos_built_sources = \
@@ -76,8 +88,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 \
@@ -94,8 +104,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 \
@@ -187,8 +195,6 @@ gnome_photos_SOURCES = \
        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 \
@@ -387,10 +393,6 @@ 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-glib.c \
@@ -414,8 +416,6 @@ gnome_photos_thumbnailer_SOURCES = \
        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 \
diff --git a/src/meson.build b/src/meson.build
index 961558a3..3b532453 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,6 +1,31 @@
-common_sources = files(
+sources = files(
   'photos-debug.c',
   'photos-error.c',
+  'photos-operation-svg-multiply.c',
+  'photos-quarks.c',
+)
+
+deps = [
+  babl_dep,
+  gegl_dep,
+  glib_dep,
+  gobject_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 = files(
   'photos-gegl.c',
   'photos-glib.c',
   'photos-jpeg-count.c',
@@ -12,10 +37,8 @@ common_sources = files(
   'photos-operation-jpg-guess-sizes.c',
   'photos-operation-png-guess-sizes.c',
   'photos-operation-saturation.c',
-  'photos-operation-svg-multiply.c',
   'photos-pipeline.c',
   'photos-png-count.c',
-  'photos-quarks.c',
 )
 
 enum_headers = files(
@@ -64,6 +87,7 @@ common_deps = [
   gio_unix_dep,
   glib_dep,
   libdazzle_dep,
+  libgnome_photos_dep,
   libjpeg_dep,
   libpng_dep,
   m_dep,
@@ -375,6 +399,7 @@ executable(
   c_args: cflags,
   install: true,
   install_dir: photos_bindir,
+  install_rpath: photos_libdir,
 )
 
 sources = common_sources + files(
@@ -391,4 +416,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]