[gnome-contacts/nielsdg/core-should-stay-core: 10/11] Create a "core" static library




commit f44c598969203edca388516a5cb4a3c096dcb958
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Sep 7 11:22:44 2022 +0200

    Create a "core" static library
    
    The mainly useful thing about this is that we now have a way of testing
    our core logic which got added as we created the `Contacts.Chunk`
    concept.

 src/core/contacts-bin-chunk.vala |  2 +-
 src/core/contacts-type-set.vala  |  5 ++--
 src/core/meson.build             | 52 ++++++++++++++++++++++++++++++++++++++++
 src/meson.build                  | 22 ++---------------
 4 files changed, 58 insertions(+), 23 deletions(-)
---
diff --git a/src/core/contacts-bin-chunk.vala b/src/core/contacts-bin-chunk.vala
index 24b2f044..3ce05e58 100644
--- a/src/core/contacts-bin-chunk.vala
+++ b/src/core/contacts-bin-chunk.vala
@@ -204,7 +204,7 @@ public abstract class Contacts.BinChunkChild : GLib.Object {
    */
   public bool has_pref_marker () {
     var evolution_pref = this.parameters["x-evolution-ui-slot"];
-    if (evolution_pref != null && Utils.get_first (evolution_pref) == "1")
+    if (evolution_pref != null && ("1" in evolution_pref))
       return true;
 
     foreach (var param in this.parameters["type"]) {
diff --git a/src/core/contacts-type-set.vala b/src/core/contacts-type-set.vala
index 94877db3..2b6d01c3 100644
--- a/src/core/contacts-type-set.vala
+++ b/src/core/contacts-type-set.vala
@@ -135,8 +135,9 @@ public class Contacts.TypeSet : Object, GLib.ListModel  {
    */
   public TypeDescriptor lookup_by_parameters (Gee.MultiMap<string, string> parameters,
                                               out uint position = null) {
-    if (parameters.contains (TypeDescriptor.X_GOOGLE_LABEL)) {
-      var label = Utils.get_first<string> (parameters[TypeDescriptor.X_GOOGLE_LABEL]);
+    var google_label = parameters[TypeDescriptor.X_GOOGLE_LABEL];
+    if (!google_label.is_empty) {
+      var label = google_label.to_array ()[0];
       var descriptor = lookup_by_custom_label (label, out position);
       // Still didn't find it => create it
       if (descriptor == null)
diff --git a/src/core/meson.build b/src/core/meson.build
new file mode 100644
index 00000000..f3af30bf
--- /dev/null
+++ b/src/core/meson.build
@@ -0,0 +1,52 @@
+# Core library
+libcontactscore_sources = files(
+  'contacts-addresses-chunk.vala',
+  'contacts-alias-chunk.vala',
+  'contacts-avatar-chunk.vala',
+  'contacts-bin-chunk.vala',
+  'contacts-birthday-chunk.vala',
+  'contacts-chunk.vala',
+  'contacts-contact.vala',
+  'contacts-email-addresses-chunk.vala',
+  'contacts-full-name-chunk.vala',
+  'contacts-im-addresses-chunk.vala',
+  'contacts-nickname-chunk.vala',
+  'contacts-notes-chunk.vala',
+  'contacts-phones-chunk.vala',
+  'contacts-roles-chunk.vala',
+  'contacts-structured-name-chunk.vala',
+  'contacts-type-descriptor.vala',
+  'contacts-type-set.vala',
+  'contacts-urls-chunk.vala',
+  'contacts-vcard-type-mapping.vala',
+)
+
+libcontactscore_vala_args = [
+  '--target-glib=@0@'.format(min_glib_version),
+  '--pkg', 'config',
+]
+
+libcontactscore_c_args = [
+  '-include', 'config.h',
+]
+
+libcontactscore_deps = [
+  folks,
+  folks_eds,
+  gee,
+  glib,
+]
+
+libcontactscore = static_library('contactscore',
+  libcontactscore_sources,
+  include_directories: config_h_dir,
+  vala_args: libcontactscore_vala_args,
+  c_args: libcontactscore_c_args,
+  dependencies: libcontactscore_deps,
+)
+
+libcontactscore_dep = declare_dependency(
+  link_with: libcontactscore,
+  include_directories: include_directories('.'),
+  dependencies: libcontactscore_deps,
+)
diff --git a/src/meson.build b/src/meson.build
index 346aae74..e17fe6c7 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,3 +1,4 @@
+subdir('core')
 subdir('io')
 
 # GSettings
@@ -8,26 +9,6 @@ install_data('org.gnome.Contacts.gschema.xml',
 
 # Common library
 libcontacts_sources = files(
-  'core/contacts-addresses-chunk.vala',
-  'core/contacts-alias-chunk.vala',
-  'core/contacts-avatar-chunk.vala',
-  'core/contacts-bin-chunk.vala',
-  'core/contacts-birthday-chunk.vala',
-  'core/contacts-chunk.vala',
-  'core/contacts-contact.vala',
-  'core/contacts-email-addresses-chunk.vala',
-  'core/contacts-full-name-chunk.vala',
-  'core/contacts-im-addresses-chunk.vala',
-  'core/contacts-nickname-chunk.vala',
-  'core/contacts-notes-chunk.vala',
-  'core/contacts-phones-chunk.vala',
-  'core/contacts-roles-chunk.vala',
-  'core/contacts-structured-name-chunk.vala',
-  'core/contacts-type-descriptor.vala',
-  'core/contacts-type-set.vala',
-  'core/contacts-urls-chunk.vala',
-  'core/contacts-vcard-type-mapping.vala',
-
   'contacts-chunk-filter.vala',
   'contacts-chunk-empty-filter.vala',
   'contacts-chunk-property-filter.vala',
@@ -65,6 +46,7 @@ contacts_c_args = [
 ]
 
 contacts_deps = [
+  libcontactscore_dep,
   folks,
   folks_eds,
   gee,


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