[libgweather/ebassi/gtk4: 28/28] Use explicit symbol annotation and visibility




commit ea4eb9c1d57f453ba70a0a5621955ff00e461e9b
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Oct 11 15:18:49 2021 +0100

    Use explicit symbol annotation and visibility
    
    All symbols should be hidden by default, and public symbols should be
    explicitly annotated.
    
    Once we commit to a stable API/ABI, we will be able to use versioned
    macros to mark symbols for deprecation, and get compiler warnings that
    can be toggled on and off by consumers of our API.
    
    The current symbol visibility map includes two private symbols used by
    our tests; to avoid this leakage, we can build libgweather as a static
    library, and then use the static library for our tests and as the base
    of our public shared library.

 libgweather/gweather-enum-types.h.tmpl |  1 +
 libgweather/gweather-location-entry.h  |  6 ++++
 libgweather/gweather-location.h        | 37 +++++++++++++++++++-
 libgweather/gweather-timezone-menu.h   |  4 +++
 libgweather/gweather-timezone.h        | 11 ++++++
 libgweather/gweather-version.h.in      |  7 ++++
 libgweather/gweather-weather.h         | 64 ++++++++++++++++++++++++++++++++++
 libgweather/libgweather.map            | 10 ------
 libgweather/meson.build                | 58 ++++++++++++++++++++----------
 9 files changed, 168 insertions(+), 30 deletions(-)
---
diff --git a/libgweather/gweather-enum-types.h.tmpl b/libgweather/gweather-enum-types.h.tmpl
index 49e77752..08ffd142 100644
--- a/libgweather/gweather-enum-types.h.tmpl
+++ b/libgweather/gweather-enum-types.h.tmpl
@@ -17,6 +17,7 @@ G_BEGIN_DECLS
 /*** END file-production ***/
 
 /*** BEGIN value-header ***/
+_GWEATHER_EXTERN
 GType @enum_name@_get_type (void) G_GNUC_CONST;
 #define GWEATHER_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
 /*** END value-header ***/
diff --git a/libgweather/gweather-location-entry.h b/libgweather/gweather-location-entry.h
index 873986e8..ccd606c7 100644
--- a/libgweather/gweather-location-entry.h
+++ b/libgweather/gweather-location-entry.h
@@ -37,13 +37,19 @@ struct _GWeatherLocationEntryClass {
     GtkSearchEntryClass parent_class;
 };
 
+GWEATHER_AVAILABLE_IN_ALL
 GType                   gweather_location_entry_get_type        (void);
 
+GWEATHER_AVAILABLE_IN_ALL
 GtkWidget *             gweather_location_entry_new             (GWeatherLocation *top);
+GWEATHER_AVAILABLE_IN_ALL
 void                    gweather_location_entry_set_location    (GWeatherLocationEntry *entry,
                                                                  GWeatherLocation *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_entry_get_location    (GWeatherLocationEntry *entry);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                gweather_location_entry_has_custom_text (GWeatherLocationEntry *entry);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                gweather_location_entry_set_city        (GWeatherLocationEntry *entry,
                                                                  const char *city_name,
                                                                  const char *code);
diff --git a/libgweather/gweather-location.h b/libgweather/gweather-location.h
index ceee199e..6a29a581 100644
--- a/libgweather/gweather-location.h
+++ b/libgweather/gweather-location.h
@@ -63,78 +63,113 @@ typedef enum { /*< underscore_name=gweather_location_level >*/
 } GWeatherLocationLevel;
 
 #define GWEATHER_TYPE_LOCATION (gweather_location_get_type ())
+
+GWEATHER_AVAILABLE_IN_ALL
 GType gweather_location_get_type (void);
 
+
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_get_world             (void);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_ref                   (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 void                    gweather_location_unref                 (GWeatherLocation  *loc);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GWeatherLocation, gweather_location_unref);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_name              (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_sort_name         (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_english_name      (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_english_sort_name (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocationLevel   gweather_location_get_level             (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_get_parent            (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_next_child            (GWeatherLocation  *loc,
                                                                  GWeatherLocation  *child);
 
-G_DEPRECATED_FOR(gweather_location_next_child)
+G_DEPRECATED_FOR(gweather_location_next_child) _GWEATHER_EXTERN
 GWeatherLocation **     gweather_location_get_children          (GWeatherLocation  *loc);
 
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                gweather_location_has_coords            (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 void                    gweather_location_get_coords            (GWeatherLocation  *loc,
                                                                  double            *latitude,
                                                                  double            *longitude);
+GWEATHER_AVAILABLE_IN_ALL
 double                  gweather_location_get_distance          (GWeatherLocation  *loc,
                                                                  GWeatherLocation  *loc2);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_find_nearest_city     (GWeatherLocation  *loc,
                                                                  double             lat,
                                                                  double             lon);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_find_nearest_city_full        (GWeatherLocation   *loc,
                                                                          double              lat,
                                                                          double              lon,
                                                                          GWeatherFilterFunc  func,
                                                                          gpointer            user_data,
                                                                          GDestroyNotify      destroy);
+GWEATHER_AVAILABLE_IN_ALL
 void                    gweather_location_detect_nearest_city           (GWeatherLocation   *loc,
                                                                          double              lat,
                                                                          double              lon,
                                                                          GCancellable       *cancellable,
                                                                          GAsyncReadyCallback callback,
                                                                          gpointer            user_data);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_detect_nearest_city_finish    (GAsyncResult       *result,
                                                                          GError            **error);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_country           (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherTimezone *      gweather_location_get_timezone          (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_timezone_str      (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherTimezone **     gweather_location_get_timezones         (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 void                    gweather_location_free_timezones        (GWeatherLocation  *loc,
                                                                  GWeatherTimezone **zones);
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_get_code              (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 char *                  gweather_location_get_city_name         (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 char *                  gweather_location_get_country_name      (GWeatherLocation  *loc);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_find_by_station_code  (GWeatherLocation  *world,
                                                                  const char        *station_code);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_find_by_country_code  (GWeatherLocation  *world,
                                                                  const char        *country_code);
 
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                gweather_location_equal                 (GWeatherLocation  *one,
                                                                  GWeatherLocation  *two);
 
+GWEATHER_AVAILABLE_IN_ALL
 GVariant *              gweather_location_serialize             (GWeatherLocation  *loc);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_deserialize           (GWeatherLocation  *world,
                                                                  GVariant          *serialized);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherLocation *      gweather_location_new_detached          (const char        *name,
                                                                  const char        *icao,
                                                                  double             latitude,
                                                                  double             longitude);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_location_level_to_string       (GWeatherLocationLevel level);
 
 G_END_DECLS
diff --git a/libgweather/gweather-timezone-menu.h b/libgweather/gweather-timezone-menu.h
index ddc5d21e..884f32ae 100644
--- a/libgweather/gweather-timezone-menu.h
+++ b/libgweather/gweather-timezone-menu.h
@@ -37,10 +37,14 @@ struct _GWeatherTimezoneMenuClass {
 
 };
 
+GWEATHER_AVAILABLE_IN_ALL
 GType           gweather_timezone_menu_get_type         (void);
+GWEATHER_AVAILABLE_IN_ALL
 GtkWidget *     gweather_timezone_menu_new              (GWeatherLocation *top);
+GWEATHER_AVAILABLE_IN_ALL
 void            gweather_timezone_menu_set_tzid         (GWeatherTimezoneMenu *menu,
                                                         const char *tzid);
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_timezone_menu_get_tzid         (GWeatherTimezoneMenu *menu);
 
 G_END_DECLS
diff --git a/libgweather/gweather-timezone.h b/libgweather/gweather-timezone.h
index e5353406..9624702f 100644
--- a/libgweather/gweather-timezone.h
+++ b/libgweather/gweather-timezone.h
@@ -11,26 +11,37 @@
 #endif
 
 #include <glib-object.h>
+#include <libgweather/gweather-version.h>
 
 G_BEGIN_DECLS
 
 typedef struct _GWeatherTimezone GWeatherTimezone;
 
+GWEATHER_AVAILABLE_IN_ALL
 GType gweather_timezone_get_type (void);
 #define GWEATHER_TYPE_TIMEZONE (gweather_timezone_get_type ())
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_timezone_get_name              (GWeatherTimezone *zone);
+GWEATHER_AVAILABLE_IN_ALL
 const char *            gweather_timezone_get_tzid              (GWeatherTimezone *zone);
+GWEATHER_AVAILABLE_IN_ALL
 int                     gweather_timezone_get_offset            (GWeatherTimezone *zone);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                gweather_timezone_has_dst               (GWeatherTimezone *zone);
+GWEATHER_AVAILABLE_IN_ALL
 int                     gweather_timezone_get_dst_offset        (GWeatherTimezone *zone);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherTimezone *      gweather_timezone_ref                   (GWeatherTimezone *zone);
+GWEATHER_AVAILABLE_IN_ALL
 void                    gweather_timezone_unref                 (GWeatherTimezone *zone);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GWeatherTimezone, gweather_timezone_unref);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherTimezone *      gweather_timezone_get_utc               (void);
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherTimezone *      gweather_timezone_get_by_tzid           (const char       *tzid);
 
 G_END_DECLS
diff --git a/libgweather/gweather-version.h.in b/libgweather/gweather-version.h.in
index ffa73d5a..7e5edd77 100644
--- a/libgweather/gweather-version.h.in
+++ b/libgweather/gweather-version.h.in
@@ -14,6 +14,13 @@
 #error "gweather-version.h must not be included individually, include gweather.h instead"
 #endif
 
+#ifndef _GWEATHER_EXTERN
+#define _GWEATHER_EXTERN extern
+#endif
+
+/* Backstop for all symbols available before the introduction of versioned macros */
+#define GWEATHER_AVAILABLE_IN_ALL       _GWEATHER_EXTERN
+
 /**
  * SECTION:gweatherversion
  * @short_description: libgweather version checking
diff --git a/libgweather/gweather-weather.h b/libgweather/gweather-weather.h
index 8c5f93f6..290858e9 100644
--- a/libgweather/gweather-weather.h
+++ b/libgweather/gweather-weather.h
@@ -13,6 +13,7 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <libgweather/gweather-enums.h>
 #include <libgweather/gweather-location.h>
+#include <libgweather/gweather-version.h>
 
 G_BEGIN_DECLS
 
@@ -37,59 +38,99 @@ typedef enum { /*< flags, underscore_name=gweather_provider >*/
 } GWeatherProvider;
 
 #define GWEATHER_TYPE_INFO (gweather_info_get_type ())
+
+GWEATHER_AVAILABLE_IN_ALL
 G_DECLARE_FINAL_TYPE (GWeatherInfo, gweather_info, GWEATHER, INFO, GObject)
 
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_store_cache               (void);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherInfo *                  gweather_info_new                       (GWeatherLocation *location);
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_update                    (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_abort                     (GWeatherInfo *info);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherProvider                gweather_info_get_enabled_providers     (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_set_enabled_providers     (GWeatherInfo  *info,
                                                                          GWeatherProvider providers);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *                    gweather_info_get_application_id        (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_set_application_id        (GWeatherInfo *info,
                                                                          const char *application_id);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *                    gweather_info_get_contact_info          (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_set_contact_info          (GWeatherInfo *info,
                                                                          const char *contact_info);
 
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                        gweather_info_is_valid                  (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                        gweather_info_network_error             (GWeatherInfo *info);
 
+GWEATHER_AVAILABLE_IN_ALL
 const GWeatherLocation *        gweather_info_get_location              (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 void                            gweather_info_set_location              (GWeatherInfo *info,
                                                                          GWeatherLocation *location);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_location_name         (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_update                (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_sky                   (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_conditions            (GWeatherInfo *info);
 
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_temp                  (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_temp_min              (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_temp_max              (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_dew                   (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_humidity              (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_wind                  (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_pressure              (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_visibility            (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_apparent              (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_sunrise               (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_sunset                (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 GSList *                        gweather_info_get_forecast_list         (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 GdkPixbufAnimation *            gweather_info_get_radar                 (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 const char *                    gweather_info_get_attribution           (GWeatherInfo *info);
 
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_temp_summary          (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 char *                          gweather_info_get_weather_summary       (GWeatherInfo *info);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *                    gweather_info_get_icon_name             (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 const char *                    gweather_info_get_symbolic_icon_name    (GWeatherInfo *info);
 
+GWEATHER_AVAILABLE_IN_ALL
 int                             gweather_info_next_sun_event            (GWeatherInfo *info);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean                        gweather_info_is_daytime                (GWeatherInfo *info);
 
 /* values retrieving functions */
@@ -142,7 +183,9 @@ typedef enum { /*< underscore_name=gweather_wind_direction >*/
     GWEATHER_WIND_LAST
 } GWeatherWindDirection;
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_wind_direction_to_string       (GWeatherWindDirection wind);
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_wind_direction_to_string_full  (GWeatherWindDirection wind,
                                                          GWeatherFormatOptions options);
 
@@ -171,7 +214,9 @@ typedef enum { /*< underscore_name=gweather_sky >*/
     GWEATHER_SKY_LAST
 } GWeatherSky;
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_sky_to_string          (GWeatherSky sky);
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_sky_to_string_full     (GWeatherSky sky,
                                                  GWeatherFormatOptions options);
 
@@ -287,45 +332,60 @@ typedef double GWeatherMoonPhase;
  */
 typedef double GWeatherMoonLatitude;
 
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_update          (GWeatherInfo *info,
                                                          time_t *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_sky             (GWeatherInfo *info,
                                                          GWeatherSky *sky);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_conditions      (GWeatherInfo *info,
                                                          GWeatherConditionPhenomenon *phenomenon,
                                                          GWeatherConditionQualifier *qualifier);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_temp            (GWeatherInfo *info,
                                                          GWeatherTemperatureUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_temp_min        (GWeatherInfo *info,
                                                          GWeatherTemperatureUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_temp_max        (GWeatherInfo *info,
                                                          GWeatherTemperatureUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_dew             (GWeatherInfo *info,
                                                          GWeatherTemperatureUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_apparent        (GWeatherInfo *info,
                                                          GWeatherTemperatureUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_wind            (GWeatherInfo *info,
                                                          GWeatherSpeedUnit unit,
                                                          double *speed,
                                                          GWeatherWindDirection *direction);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_pressure        (GWeatherInfo *info,
                                                          GWeatherPressureUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_visibility      (GWeatherInfo *info,
                                                          GWeatherDistanceUnit unit,
                                                          double *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_sunrise        (GWeatherInfo *info,
                                                          time_t *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_sunset          (GWeatherInfo *info,
                                                          time_t *value);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_value_moonphase       (GWeatherInfo *info,
                                                          GWeatherMoonPhase *value,
                                                          GWeatherMoonLatitude *lat);
+GWEATHER_AVAILABLE_IN_ALL
 gboolean        gweather_info_get_upcoming_moonphases   (GWeatherInfo *info,
                                                          time_t *phases);
 
@@ -353,12 +413,16 @@ struct _GWeatherConditions {
     GWeatherConditionQualifier qualifier;
 };
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_conditions_to_string           (GWeatherConditions *conditions);
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_conditions_to_string_full      (GWeatherConditions *conditions,
                                                          GWeatherFormatOptions options);
 
+GWEATHER_AVAILABLE_IN_ALL
 GWeatherTemperatureUnit gweather_temperature_unit_to_real       (GWeatherTemperatureUnit unit);
 
+GWEATHER_AVAILABLE_IN_ALL
 const char *    gweather_speed_unit_to_string   (GWeatherSpeedUnit unit);
 
 G_END_DECLS
diff --git a/libgweather/meson.build b/libgweather/meson.build
index b631861a..0dbf41bd 100644
--- a/libgweather/meson.build
+++ b/libgweather/meson.build
@@ -23,9 +23,6 @@ add_project_arguments(c_compiler.get_supported_arguments([
 ]), language: 'c')
 
 header_subdir = 'libgweather-3.0/libgweather'
-libgweather_map = meson.current_source_dir() / 'libgweather.map'
-link_depends = []
-link_args = []
 
 # convert to soname
 current = libgweather_lt_c - libgweather_lt_a
@@ -41,11 +38,6 @@ libgweather_darwin_versions = [
   '@0@.@1@'.format(current + 1, interface_age),
 ]
 
-if c_compiler.has_link_argument('-Wl,--version-script,' + libgweather_map)
-  link_depends += libgweather_map
-  link_args += ['-Wl,--version-script,' + libgweather_map]
-endif
-
 config_h = configuration_data()
 config_h.set_quoted('GETTEXT_PACKAGE', GETTEXT_PACKAGE)
 config_h.set_quoted('LOCALEDIR', datadir / 'locale')
@@ -69,6 +61,19 @@ endif
 config_h.set_quoted('ZONEINFO_DIR', get_option('zoneinfo_dir'))
 config_h.set_quoted('OWM_APIKEY', get_option('owm_apikey'))
 
+if host_machine.system() == 'windows'
+  visibility_define = '__declspec(dllexport) extern'
+else
+  visibility_define = '__attribute__((visibility("default"))) extern'
+endif
+
+if get_option('default_library') != 'static'
+  config_h.set('_GWEATHER_EXTERN', visibility_define)
+  if host_machine.system() == 'windows'
+    config_h.set('DLL_EXPORT', true)
+  endif
+endif
+
 configure_file(
   output: 'config.h',
   configuration: config_h,
@@ -138,18 +143,31 @@ gweather_priv_sources = [
 
 introspection_sources = gweather_c_sources + gweather_headers
 
-lib_libgweather = shared_library('gweather-3',
+libgweather_static = static_library('gweather',
   sources: [
     gweather_c_sources,
     gweather_priv_sources,
   ],
   dependencies: deps_libgweather,
-  link_depends: link_depends,
-  link_args: link_args,
+  include_directories: [
+    include_directories('.'),
+    include_directories('..'),
+  ],
+)
+
+libgweather_static_dep = declare_dependency(sources: gweather_c_sources,
+  include_directories: include_directories('..'),
+  dependencies: deps_libgweather,
+  link_with: libgweather_static,
+)
+
+lib_libgweather = shared_library('gweather-3',
+  dependencies: deps_libgweather,
+  link_whole: libgweather_static,
   version: libgweather_so_version,
+  gnu_symbol_visibility: 'hidden',
   darwin_versions: libgweather_darwin_versions,
   include_directories: [
-    include_directories('.'),
     include_directories('..'),
   ],
   install: true,
@@ -178,7 +196,9 @@ libgweather_dep = declare_dependency(
   sources: [gweather_enum_types[1], gweather_gir],
   dependencies: deps_libgweather,
   link_with: lib_libgweather,
-  include_directories: include_directories('..'),
+  include_directories: [
+    include_directories('..'),
+  ],
 )
 
 if enable_vala
@@ -199,14 +219,14 @@ test_cargs = [
 executable('test_locations',
   sources: ['test_locations.c'],
   c_args: test_cargs,
-  dependencies: libgweather_dep,
+  dependencies: libgweather_static_dep,
   install: false,
 )
 
 executable('test_locations_utc',
   sources: ['test_locations_utc.c'],
   c_args: test_cargs,
-  dependencies: libgweather_dep,
+  dependencies: libgweather_static_dep,
   install: false,
 )
 
@@ -214,7 +234,7 @@ test('test_libgweather',
   executable('test_libgweather',
     sources: ['test_libgweather.c'],
     c_args: test_cargs,
-    dependencies: libgweather_dep,
+    dependencies: libgweather_static_dep,
     install: false,
   ),
   depends: [locations_bin],
@@ -223,20 +243,20 @@ test('test_libgweather',
 executable('test_metar',
   sources: ['test_metar.c', gweather_c_sources, gweather_priv_sources],
   c_args: test_cargs,
-  dependencies: libgweather_dep,
+  dependencies: libgweather_static_dep,
   install: false,
 )
 
 executable('test_sun_moon',
   sources: ['test_sun_moon.c', 'weather-sun.c', 'weather-moon.c'],
   c_args: test_cargs,
-  dependencies: libgweather_dep,
+  dependencies: libgweather_static_dep,
   install: false,
 )
 
 executable('test_weather',
   sources: ['test_weather.c'],
   c_args: test_cargs,
-  dependencies: libgweather_dep,
+  dependencies: libgweather_static_dep,
   install: false,
 )


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