[gnome-photos/sam/tracker3: 18/27] Move application code into a helper library
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/sam/tracker3: 18/27] Move application code into a helper library
- Date: Thu, 13 Aug 2020 00:11:03 +0000 (UTC)
commit 6056d28f183b42489b0f7681455f836ac292a78c
Author: Sam Thursfield <sam afuera me uk>
Date: Wed May 27 20:39:03 2020 +0200
Move application code into a helper library
This allows us to test more of the application code with unit tests.
I have taken a simple approach of moving everything into the shared
library. This does mean that the thumbnailer and the test processes
have an increased number of shared library dependencies.
Before:
$ ldd src/gnome-photos-thumbnailer|wc -l
73
$ ldd src/gnome-photos-thumbnailer|wc -l
120
Loading the thumbnailer process after doing 'sudo sh -c 'echo 2 > /proc/sys/vm/drop_caches'
changed from 00.05 seconds to 00.07 seconds, in an unscientific test
that I did.
src/meson.build | 293 ++++++++++++++++--------------------
src/photos-enums-gegl.c.template | 51 -------
src/photos-enums-gegl.h.template | 34 -----
src/photos-enums.c.template | 1 +
src/photos-gegl.gresource.xml | 6 -
src/photos-operation-insta-curve.c | 2 +-
src/photos-operation-insta-filter.c | 2 +-
src/photos.gresource.xml | 4 +
tests/unit/meson.build | 13 +-
9 files changed, 139 insertions(+), 267 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index bc134b8d..eb538a87 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,120 +1,15 @@
libgnome_photos_built_headers = []
sources = files(
- 'photos-debug.c',
- 'photos-error.c',
- 'photos-gegl.c',
- 'photos-glib.c',
- 'photos-jpeg-count.c',
- 'photos-operation-insta-clarendon.c',
- 'photos-operation-insta-curve.c',
- 'photos-operation-insta-filter.c',
- 'photos-operation-insta-hefe.c',
- 'photos-operation-insta-hefe-curve.c',
- 'photos-operation-insta-hefe-vignette.c',
- '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',
-)
-
-thumbnailer_dbus = 'photos-thumbnailer-dbus'
-
-libgnome_photos_built_sources_gdbus = gnome.gdbus_codegen(
- thumbnailer_dbus,
- thumbnailer_dbus + '.xml',
- interface_prefix: photos_namespace + '.',
- namespace: 'Photos',
- annotations: [
- [photos_namespace + '.Thumbnailer', 'org.gtk.GDBus.C.Name', 'ThumbnailerDBus'],
- [photos_namespace + '.Thumbnailer.GenerateThumbnail()[pipeline_uris]', 'org.gtk.GDBus.C.ForceGVariant',
'true'],
- ],
- autocleanup: 'all',
-)
-
-libgnome_photos_built_headers += libgnome_photos_built_sources_gdbus[1]
-sources += libgnome_photos_built_sources_gdbus
-
-enum_headers = files(
- 'photos-operation-insta-common.h',
-)
-
-enum = 'photos-enums-gegl'
-
-libgnome_photos_built_sources_enums = gnome.mkenums(
- enum,
- sources: enum_headers,
- c_template: enum + '.c.template',
- h_template: enum + '.h.template',
-)
-
-libgnome_photos_built_headers += libgnome_photos_built_sources_enums[1]
-sources += libgnome_photos_built_sources_enums
-
-resource_data = files('../data/vignette.png')
-
-libgnome_photos_built_sources_resources = gnome.compile_resources(
- 'photos-resources-gegl',
- 'photos-gegl.gresource.xml',
- source_dir: '.',
- c_name: 'photos_gegl',
- dependencies: resource_data,
- export: true,
-)
-
-libgnome_photos_built_headers += libgnome_photos_built_sources_resources[1]
-sources += libgnome_photos_built_sources_resources
-
-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, sources: libgnome_photos_built_headers)
-
-common_sources = []
-
-common_deps = [
- gdk_pixbuf_dep,
- gegl_dep,
- gio_dep,
- gio_unix_dep,
- glib_dep,
- gobject_dep,
- libdazzle_dep,
- libgnome_photos_dep,
-]
-
-sources = common_sources + files(
'photos-application.c',
+ 'photos-base-item.c',
'photos-base-manager.c',
'photos-base-model.c',
- 'photos-base-item.c',
'photos-camera-cache.c',
'photos-collection-icon-watcher.c',
'photos-create-collection-icon-job.c',
'photos-create-collection-job.c',
+ 'photos-debug.c',
'photos-delete-item-job.c',
'photos-delete-notification.c',
'photos-device-item.c',
@@ -123,13 +18,14 @@ sources = common_sources + files(
'photos-dlna-renderers-manager.c',
'photos-done-notification.c',
'photos-dropdown.c',
- 'photos-export-dialog.c',
- 'photos-export-notification.c',
- 'photos-edit-palette.c',
'photos-edit-palette-row.c',
+ 'photos-edit-palette.c',
'photos-embed.c',
'photos-empty-results-box.c',
'photos-error-box.c',
+ 'photos-error.c',
+ 'photos-export-dialog.c',
+ 'photos-export-notification.c',
'photos-facebook-item.c',
'photos-fetch-collection-state-job.c',
'photos-fetch-collections-job.c',
@@ -137,16 +33,20 @@ sources = common_sources + files(
'photos-fetch-metas-job.c',
'photos-filterable.c',
'photos-flickr-item.c',
+ 'photos-gegl.c',
'photos-gesture-zoom.c',
+ 'photos-glib.c',
'photos-google-item.c',
- 'photos-image-view.c',
'photos-image-view-helper.c',
+ 'photos-image-view.c',
'photos-import-dialog.c',
'photos-indexing-notification.c',
'photos-item-manager.c',
+ 'photos-jpeg-count.c',
'photos-local-item.c',
'photos-main-toolbar.c',
'photos-main-window.c',
+ 'photos-main.c',
'photos-media-server-item.c',
'photos-model-button.c',
'photos-notification-manager.c',
@@ -157,10 +57,22 @@ sources = common_sources + files(
'photos-offset-import-controller.c',
'photos-offset-overview-controller.c',
'photos-offset-search-controller.c',
+ 'photos-operation-insta-clarendon.c',
+ 'photos-operation-insta-curve.c',
+ 'photos-operation-insta-filter.c',
+ 'photos-operation-insta-hefe-curve.c',
+ 'photos-operation-insta-hefe-vignette.c',
+ 'photos-operation-insta-hefe.c',
+ 'photos-operation-jpg-guess-sizes.c',
+ 'photos-operation-png-guess-sizes.c',
+ 'photos-operation-saturation.c',
+ 'photos-operation-svg-multiply.c',
'photos-organize-collection-dialog.c',
'photos-organize-collection-model.c',
'photos-organize-collection-view.c',
'photos-overview-searchbar.c',
+ 'photos-pipeline.c',
+ 'photos-png-count.c',
'photos-preview-nav-buttons.c',
'photos-preview-view.c',
'photos-print-notification.c',
@@ -168,43 +80,44 @@ sources = common_sources + files(
'photos-print-preview.c',
'photos-print-setup.c',
'photos-properties-dialog.c',
- 'photos-query.c',
+ 'photos-quarks.c',
'photos-query-builder.c',
+ 'photos-query.c',
'photos-remote-display-manager.c',
'photos-removable-device-widget.c',
'photos-removable-devices-button.c',
'photos-search-context.c',
'photos-search-controller.c',
- 'photos-search-match.c',
'photos-search-match-manager.c',
+ 'photos-search-match.c',
'photos-search-provider.c',
- 'photos-search-type.c',
'photos-search-type-manager.c',
+ 'photos-search-type.c',
'photos-searchbar.c',
'photos-selection-controller.c',
'photos-selection-toolbar.c',
'photos-set-collection-job.c',
'photos-share-dialog.c',
'photos-share-notification.c',
- 'photos-share-point.c',
'photos-share-point-email.c',
'photos-share-point-google.c',
'photos-share-point-manager.c',
'photos-share-point-online.c',
+ 'photos-share-point.c',
'photos-single-item-job.c',
- 'photos-source.c',
'photos-source-manager.c',
'photos-source-notification.c',
+ 'photos-source.c',
'photos-sparql-template.c',
'photos-spinner-box.c',
'photos-thumbnail-factory.c',
- 'photos-tool.c',
'photos-tool-colors.c',
- 'photos-tool-crop.c',
'photos-tool-crop-helper.c',
+ 'photos-tool-crop.c',
'photos-tool-enhance.c',
'photos-tool-filter-button.c',
'photos-tool-filters.c',
+ 'photos-tool.c',
'photos-tracker-change-event.c',
'photos-tracker-change-monitor.c',
'photos-tracker-collection-view-controller.c',
@@ -213,57 +126,49 @@ sources = common_sources + files(
'photos-tracker-favorites-controller.c',
'photos-tracker-import-controller.c',
'photos-tracker-overview-controller.c',
- 'photos-tracker-search-controller.c',
'photos-tracker-queue.c',
+ 'photos-tracker-search-controller.c',
'photos-update-mtime-job.c',
'photos-utils.c',
'photos-view-container.c',
'photos-zoom-controls.c',
- 'photos-main.c',
)
-photos_generate_about = find_program('photos-generate-about')
-
-about_header = 'photos-about-data.h'
+thumbnailer_dbus = 'photos-thumbnailer-dbus'
-sources += custom_target(
- about_header,
- output: about_header,
- capture: true,
- command: [photos_generate_about, '--header'],
+libgnome_photos_built_sources_gdbus = gnome.gdbus_codegen(
+ thumbnailer_dbus,
+ thumbnailer_dbus + '.xml',
+ interface_prefix: photos_namespace + '.',
+ namespace: 'Photos',
+ annotations: [
+ [photos_namespace + '.Thumbnailer', 'org.gtk.GDBus.C.Name', 'ThumbnailerDBus'],
+ [photos_namespace + '.Thumbnailer.GenerateThumbnail()[pipeline_uris]', 'org.gtk.GDBus.C.ForceGVariant',
'true'],
+ ],
+ autocleanup: 'all',
)
-about_source = 'photos-about-data.c'
-
-sources += custom_target(
- about_source,
- output: about_source,
- capture: true,
- command: [photos_generate_about, '--body', artists, authors],
-)
+libgnome_photos_built_headers += libgnome_photos_built_sources_gdbus[1]
+sources += libgnome_photos_built_sources_gdbus
enum_headers = files(
'photos-gesture-zoom.h',
'photos-item-manager.h',
+ 'photos-operation-insta-common.h',
'photos-utils.h',
)
enum = 'photos-enums'
-sources += gnome.mkenums(
+libgnome_photos_built_sources_enums = gnome.mkenums(
enum,
sources: enum_headers,
c_template: enum + '.c.template',
h_template: enum + '.h.template',
)
-marshal = 'photos-marshalers'
-
-sources += gnome.genmarshal(
- marshal,
- sources: marshal + '.list',
- prefix: '_photos_marshal',
-)
+libgnome_photos_built_headers += libgnome_photos_built_sources_enums[1]
+sources += libgnome_photos_built_sources_enums
resource_data = files(
'../data/Adwaita.css',
@@ -275,6 +180,7 @@ resource_data = files(
'../data/icons/image-edit-symbolic.svg',
'../data/icons/image-filter-symbolic.svg',
'../data/icons/image-sharpen-symbolic.svg',
+ '../data/vignette.png',
'photos-dlna-renderers-dialog.ui',
'photos-dropdown.ui',
'photos-embed.ui',
@@ -297,7 +203,7 @@ resource_data = files(
'queries/photos.sparql.template',
)
-sources += gnome.compile_resources(
+libgnome_photos_built_sources_resources = gnome.compile_resources(
'photos-resources',
'photos.gresource.xml',
source_dir: '.',
@@ -306,6 +212,63 @@ sources += gnome.compile_resources(
export: true,
)
+libgnome_photos_built_headers += libgnome_photos_built_sources_resources[1]
+sources += libgnome_photos_built_sources_resources
+
+deps = [
+ babl_dep,
+ cairo_dep,
+ gdk_pixbuf_dep,
+ gegl_dep,
+ geocode_glib_dep,
+ gexiv_dep,
+ gio_dep,
+ gio_unix_dep,
+ glib_dep,
+ goa_dep,
+ gobject_dep,
+ grilo_dep,
+ gsettings_desktop_schemas_dep,
+ gtk_dep,
+ gtk_unix_print_dep,
+ libdazzle_dep,
+ libgd_dep,
+ libgdata_dep,
+ libgfgraph_dep,
+ libjpeg_dep,
+ libpng_dep,
+ m_dep,
+ tracker_sparql_dep,
+]
+
+photos_generate_about = find_program('photos-generate-about')
+
+about_header = 'photos-about-data.h'
+
+sources += custom_target(
+ about_header,
+ output: about_header,
+ capture: true,
+ command: [photos_generate_about, '--header'],
+)
+
+about_source = 'photos-about-data.c'
+
+sources += custom_target(
+ about_source,
+ output: about_source,
+ capture: true,
+ command: [photos_generate_about, '--body', artists, authors],
+)
+
+marshal = 'photos-marshalers'
+
+sources += gnome.genmarshal(
+ marshal,
+ sources: marshal + '.list',
+ prefix: '_photos_marshal',
+)
+
dleyna_device = 'photos-dleyna-renderer-device'
sources += gnome.gdbus_codegen(
@@ -387,50 +350,50 @@ sources += gnome.gdbus_codegen(
autocleanup: 'all',
)
-deps = common_deps + [
- babl_dep,
- cairo_dep,
- geocode_glib_dep,
- gexiv_dep,
- goa_dep,
- grilo_dep,
- gsettings_desktop_schemas_dep,
- gtk_dep,
- gtk_unix_print_dep,
- libgd_dep,
- libgdata_dep,
- libgfgraph_dep,
- m_dep,
- tracker_sparql_dep,
-]
-
cflags = [
'-DPACKAGE_LIBEXEC_DIR="@0@"'.format(photos_libexecdir),
'-DPACKAGE_LOCALE_DIR="@0@"'.format(photos_localedir),
]
+libgnome_photos = shared_library(
+ meson.project_name(),
+ sources,
+ dependencies: deps,
+ c_args: cflags,
+ include_directories: top_inc,
+ install: true,
+ install_dir: photos_libdir,
+)
+
+libgnome_photos_dep = declare_dependency(link_with: libgnome_photos, sources: libgnome_photos_built_headers,
dependencies: deps)
+
+sources = files(
+ 'photos-main.c',
+)
+
executable(
meson.project_name(),
sources,
include_directories: top_inc,
- dependencies: deps,
+ dependencies: deps + [libgnome_photos_dep],
c_args: cflags,
install: true,
install_dir: photos_bindir,
install_rpath: photos_libdir,
)
-sources = common_sources + files(
+sources = files(
'photos-pixbuf.c',
'photos-thumbnailer.c',
'photos-thumbnailer-main.c',
)
+# FIXME: we need a stripped down version of the deps, or it'll happen automatically?
executable(
meson.project_name() + '-thumbnailer',
sources,
include_directories: top_inc,
- dependencies: common_deps,
+ dependencies: [libgnome_photos_dep],
c_args: cflags,
install: true,
install_dir: photos_libexecdir,
diff --git a/src/photos-enums.c.template b/src/photos-enums.c.template
index 0534d9c1..07880a83 100644
--- a/src/photos-enums.c.template
+++ b/src/photos-enums.c.template
@@ -5,6 +5,7 @@
#include "photos-enums.h"
#include "photos-gesture-zoom.h"
#include "photos-item-manager.h"
+#include "photos-operation-insta-common.h"
#include "photos-utils.h"
/*** END file-header ***/
diff --git a/src/photos-operation-insta-curve.c b/src/photos-operation-insta-curve.c
index fc62919f..a7db3e95 100644
--- a/src/photos-operation-insta-curve.c
+++ b/src/photos-operation-insta-curve.c
@@ -24,7 +24,7 @@
#include <babl/babl.h>
#include <gegl.h>
-#include "photos-enums-gegl.h"
+#include "photos-enums.h"
#include "photos-operation-insta-common.h"
#include "photos-operation-insta-curve.h"
diff --git a/src/photos-operation-insta-filter.c b/src/photos-operation-insta-filter.c
index 52a1f91f..405d5bf1 100644
--- a/src/photos-operation-insta-filter.c
+++ b/src/photos-operation-insta-filter.c
@@ -24,7 +24,7 @@
#include <babl/babl.h>
#include <gegl.h>
-#include "photos-enums-gegl.h"
+#include "photos-enums.h"
#include "photos-operation-insta-common.h"
#include "photos-operation-insta-filter.h"
diff --git a/src/photos.gresource.xml b/src/photos.gresource.xml
index 39e6d842..67d2c45d 100644
--- a/src/photos.gresource.xml
+++ b/src/photos.gresource.xml
@@ -41,6 +41,10 @@
<file alias="photos.sparql.template">queries/photos.sparql.template</file>
</gresource>
+ <gresource prefix="/org/gnome/Photos/gegl">
+ <file alias="vignette.png" preprocess="to-pixdata">../data/vignette.png</file>
+ </gresource>
+
<gresource prefix="/org/gnome/Photos/gtk">
<file alias="help-overlay.ui" preprocess="xml-stripblanks"
compressed="true">photos-help-overlay.ui</file>
</gresource>
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 625ca598..3e4e0d62 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -12,12 +12,8 @@ test_env.set('MALLOC_CHECK_', '2')
test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
tests = {
- 'photos-test-gegl': {
- 'dependencies': [babl_dep, gdk_pixbuf_dep, gegl_dep, gio_dep, gio_unix_dep, glib_dep,
libgnome_photos_dep]
- },
- 'photos-test-pipeline': {
- 'dependencies': [gdk_pixbuf_dep, gegl_dep, gio_dep, gio_unix_dep, glib_dep, libgnome_photos_dep]
- },
+ 'photos-test-gegl': {},
+ 'photos-test-pipeline': {},
}
test_data = [
@@ -41,7 +37,6 @@ test_data = [
foreach test_name, extra_args: tests
cflags = extra_args.get('c_args', [])
- deps = extra_args.get('dependencies', [])
extra_sources = extra_args.get('extra_sources', [])
install = photos_installed_tests_enabled and extra_args.get('install', true)
is_parallel = extra_args.get('is_parallel', true)
@@ -65,7 +60,7 @@ foreach test_name, extra_args: tests
test_name,
[source, extra_sources],
include_directories: [src_inc, top_inc],
- dependencies: deps,
+ dependencies: libgnome_photos_dep,
c_args: cflags,
install: install,
install_dir: photos_installed_test_execdir,
@@ -86,4 +81,4 @@ endforeach
if photos_installed_tests_enabled
install_data(test_data, install_dir: photos_installed_test_execdir)
-endif
\ No newline at end of file
+endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]