[libgweather/benzea/wip-variant-backend] Properly generate binary database at build time



commit 71d44499f854d57ce14eabcc3175677ab76ae53e
Author: Benjamin Berg <bberg redhat com>
Date:   Sun Apr 26 17:23:33 2020 +0200

    Properly generate binary database at build time
    
    Still installed into source directory though.

 data/meson.build                 | 9 +++++++++
 libgweather/gweather-location.c  | 8 +++++---
 libgweather/meson.build          | 2 +-
 libgweather/test_libgweather.c   | 2 +-
 libgweather/test_locations.c     | 2 +-
 libgweather/test_locations_utc.c | 2 +-
 meson.build                      | 2 +-
 7 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 88e3d2f..3e7f386 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -16,6 +16,15 @@ if xmllint.found()
        ])
 endif
 
+gen_locations_variant = find_program('gen-locations-variant.py')
+
+locations_bin = configure_file(
+  command: [gen_locations_variant, '@INPUT@', '@OUTPUT@' ],
+  install_dir: pkgdatadir, # TODO: Either move to libdir or make arch indepenent
+  input: files('Locations.xml'),
+  output: '@BASENAME@.bin',
+)
+
 install_data('Locations.xml',
   install_dir: pkgdatadir,
 )
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 13bc77c..4f03e7d 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -325,13 +325,15 @@ gweather_location_dup_world ()
 
         locations_path = g_getenv ("LIBGWEATHER_LOCATIONS_PATH");
         if (locations_path) {
-            filename = g_strconcat (locations_path, ".bin", NULL);
-            if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+            filename = g_strdup (locations_path);
+            if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
+               g_warning ("User specified database %s does not exist", filename);
                g_clear_pointer (&filename, g_free);
+           }
         }
 
         if (!filename)
-           filename = g_build_filename (GWEATHER_XML_LOCATION_DIR, "Locations.xml.bin", NULL);
+           filename = g_build_filename (GWEATHER_XML_LOCATION_DIR, "Locations.bin", NULL);
 
        map = g_mapped_file_new (filename, FALSE, &error);
        if (!map) {
diff --git a/libgweather/meson.build b/libgweather/meson.build
index 4804ef2..fbb3a12 100644
--- a/libgweather/meson.build
+++ b/libgweather/meson.build
@@ -97,7 +97,7 @@ if enable_vala
   )
 endif
 
-test_cargs = ['-DTEST_SRCDIR="@0@/"'.format(meson.current_source_dir()),
+test_cargs = ['-DTEST_LOCATIONS="@0@"'.format(locations_bin.full_path()),
               '-DSCHEMASDIR="@0@/schemas"'.format(meson.source_root()),
               '-DSCHEMAS_BUILDDIR="@0@/schemas"'.format(meson.build_root())]
 
diff --git a/libgweather/test_libgweather.c b/libgweather/test_libgweather.c
index f176d49..0b17ad5 100644
--- a/libgweather/test_libgweather.c
+++ b/libgweather/test_libgweather.c
@@ -798,7 +798,7 @@ main (int argc, char *argv[])
        g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, log_handler, 
NULL);
 
        g_setenv ("LIBGWEATHER_LOCATIONS_PATH",
-                 TEST_SRCDIR "../data/Locations.xml",
+                 TEST_LOCATIONS,
                  FALSE);
        set_gsettings ();
 
diff --git a/libgweather/test_locations.c b/libgweather/test_locations.c
index b03375e..37b333e 100644
--- a/libgweather/test_locations.c
+++ b/libgweather/test_locations.c
@@ -38,7 +38,7 @@ main (int argc, char **argv)
     gtk_init (&argc, &argv);
 
     g_setenv ("LIBGWEATHER_LOCATIONS_PATH",
-              TEST_SRCDIR "../data/Locations.xml",
+              TEST_LOCATIONS,
               FALSE);
 
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
diff --git a/libgweather/test_locations_utc.c b/libgweather/test_locations_utc.c
index 3c599af..2804448 100644
--- a/libgweather/test_locations_utc.c
+++ b/libgweather/test_locations_utc.c
@@ -39,7 +39,7 @@ main (int argc, char **argv)
     gtk_init (&argc, &argv);
 
     g_setenv ("LIBGWEATHER_LOCATIONS_PATH",
-              TEST_SRCDIR "../data/Locations.xml",
+              TEST_LOCATIONS,
               FALSE);
 
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
diff --git a/meson.build b/meson.build
index 9bf8e75..18bf992 100644
--- a/meson.build
+++ b/meson.build
@@ -115,8 +115,8 @@ endif
 
 root_inc = include_directories('.')
 
-subdir('libgweather')
 subdir('data')
+subdir('libgweather')
 subdir('schemas')
 if get_option('gtk_doc')
   subdir('doc')


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