[geary/bug/776421-make-client-unit-testable: 6/8] Split the client binary build up into a static lib + final binary.



commit bf42b7e0dd93f5279705feaa09d338efe739ed92
Author: Michael James Gratton <mike vee net>
Date:   Mon Dec 26 12:17:21 2016 +1030

    Split the client binary build up into a static lib + final binary.
    
    This allows unit tests to link against client code for testing.
    
    * src/CMakeLists.txt: Add a new geary-client static lib to the build,
      that compiles all client code (except main.vala) as the executable
      previously did, and generates a VAPI for it. Make the target for the
      client then binary simply compile main.vala and link in the client
      lib.
    
    * src/client/application/geary-config.vala,
      src/client/util/util-migrate.vala: Fix errors reported vy valac when
      attempting to use the client lib VAPI.

 src/CMakeLists.txt                       |   28 +++++++++++++++++++++++-----
 src/client/application/geary-config.vala |    2 +-
 src/client/util/util-migrate.vala        |    2 +-
 3 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 020caf2..5ae8fa1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -316,7 +316,6 @@ client/application/geary-application.vala
 client/application/geary-args.vala
 client/application/geary-config.vala
 client/application/geary-controller.vala
-client/application/main.vala
 client/application/secret-mediator.vala
 
 client/accounts/account-dialog.vala
@@ -633,24 +632,43 @@ add_custom_command(
         vapigen --pkg=gio-2.0 --pkg=gtk+-3.0 --pkg=libsoup-2.4 --metadatadir=. 
--metadatadir=${WEBKITGTK_METADATA_DIR} --library=webkitgtk-3.0 --directory=${CMAKE_BINARY_DIR}/src 
${WEBKITGTK_CUSTOM_VALA} `${PKG_CONFIG_EXECUTABLE} --variable=girdir gobject-introspection-1.0`/WebKit-3.0.gir
 )
 
-# Geary client app
+# Client library (static lib used for building client and unit tests)
 #################################################
 set_property(SOURCE ${RESOURCES_C} PROPERTY GENERATED TRUE)
 set_property(SOURCE ${RESOURCES_XML} PROPERTY GENERATED TRUE)
 
-vala_precompile(GEARY_VALA_C geary
+vala_precompile(CLIENT_VALA_C geary-client
     ${CLIENT_SRC}
 PACKAGES
-    ${CLIENT_PACKAGES}
     ${ENGINE_PACKAGES}
+    ${CLIENT_PACKAGES}
+GENERATE_VAPI
+    geary-client
 OPTIONS
     ${VALAC_OPTIONS}
     --gresources=${RESOURCES_XML}
 )
 
+add_library(geary-client STATIC ${CLIENT_VALA_C})
+target_link_libraries(geary-client m ${DEPS_LIBRARIES} geary-engine)
+
+# Main client application binary
+#################################################
+
+vala_precompile(GEARY_VALA_C geary
+    "client/application/main.vala"
+PACKAGES
+    webkitgtk-3.0
+    ${ENGINE_PACKAGES}
+    ${CLIENT_PACKAGES}
+    geary-client
+OPTIONS
+    ${VALAC_OPTIONS}
+)
+
 add_executable(geary ${GEARY_VALA_C} ${RESOURCES_C})
 add_dependencies(geary webkitgtk-vapi)
-target_link_libraries(geary m ${DEPS_LIBRARIES} geary-engine)
+target_link_libraries(geary ${DEPS_LIBRARIES} geary-client)
 install(TARGETS geary RUNTIME DESTINATION bin)
 add_custom_command(
     TARGET
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index 7900a63..718c72a 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -170,7 +170,7 @@ public class Configuration {
     }
     
     public void bind(string key, Object object, string property,
-        SettingsBindFlags flags = SettingsBindFlags.DEFAULT) {
+        SettingsBindFlags flags = GLib.SettingsBindFlags.DEFAULT) {
         settings.bind(key, object, property, flags);
     }
     
diff --git a/src/client/util/util-migrate.vala b/src/client/util/util-migrate.vala
index 89a590c..201fa21 100644
--- a/src/client/util/util-migrate.vala
+++ b/src/client/util/util-migrate.vala
@@ -109,7 +109,7 @@ namespace Migrate {
         }
     }
 
-    private const string OLD_APP_ID = "org.yorba.geary";
+    public const string OLD_APP_ID = "org.yorba.geary";
     private const string MIGRATED_CONFIG_KEY = "migrated-config";
 
     public static void old_app_config(Settings newSettings, string old_app_id = OLD_APP_ID) {


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