[libgweather] Consolidate define checks and forbid single includes



commit 01003769ea7f70f7029f8da8e5949348434d839a
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Apr 13 23:00:00 2015 -0700

    Consolidate define checks and forbid single includes
    
    Given that we're breaking API for apps that use single includes
    (by renaming the includes), forbid them explicitly and consolidate
    the unstable define check in gweather.h

 libgweather/Makefile.am                |    3 ++-
 libgweather/gweather-enum-types.c.tmpl |    1 -
 libgweather/gweather-enum-types.h.tmpl |    4 ++++
 libgweather/gweather-enums.h           |    4 ++++
 libgweather/gweather-location-entry.c  |    1 -
 libgweather/gweather-location-entry.h  |    4 ++++
 libgweather/gweather-location.c        |    1 -
 libgweather/gweather-location.h        |    4 ++--
 libgweather/gweather-parser.c          |    1 -
 libgweather/gweather-timezone-menu.c   |    1 -
 libgweather/gweather-timezone-menu.h   |    4 ++++
 libgweather/gweather-timezone.c        |    1 -
 libgweather/gweather-timezone.h        |    4 ++--
 libgweather/gweather-version.h.in      |    4 ++++
 libgweather/gweather-weather.c         |    1 -
 libgweather/gweather-weather.h         |    5 ++---
 libgweather/gweather.h                 |    9 ++++++++-
 libgweather/test_locations.c           |    1 -
 libgweather/test_metar.c               |    1 -
 libgweather/test_sun_moon.c            |    1 -
 libgweather/weather-iwin.c             |    1 -
 libgweather/weather-metar.c            |    1 -
 libgweather/weather-moon.c             |    1 -
 libgweather/weather-owm.c              |    1 -
 libgweather/weather-sun.c              |    1 -
 libgweather/weather-wx.c               |    1 -
 libgweather/weather-yahoo.c            |    1 -
 libgweather/weather-yrno.c             |    1 -
 28 files changed, 36 insertions(+), 27 deletions(-)
---
diff --git a/libgweather/Makefile.am b/libgweather/Makefile.am
index 931a82a..3c240e5 100644
--- a/libgweather/Makefile.am
+++ b/libgweather/Makefile.am
@@ -5,6 +5,7 @@ noinst_LTLIBRARIES = libgweather-internal-3.la
 noinst_PROGRAMS = test_metar test_locations test_sun_moon
 
 AM_CPPFLAGS =                  \
+       -DGWEATHER_COMPILATION  \
        $(DEPS_CFLAGS)          \
        -I$(top_srcdir)         \
        -I$(srcdir)
@@ -102,7 +103,7 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
 if HAVE_INTROSPECTION
 GWeather-3.0.gir: libgweather-3.la Makefile
 GWeather_3_0_gir_INCLUDES = GObject-2.0 Gtk-3.0
-GWeather_3_0_gir_CFLAGS = $(libgweather_internal_3_la_CPPFLAGS) -DGWEATHER_I_KNOW_THIS_IS_UNSTABLE
+GWeather_3_0_gir_CFLAGS = $(libgweather_internal_3_la_CPPFLAGS)
 GWeather_3_0_gir_LIBS = libgweather-3.la
 GWeather_3_0_gir_SCANNERFLAGS = --identifier-prefix=GWeather --symbol-prefix=gweather 
--pkg-export=gweather-3.0
 GWeather_3_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources)) $(addprefix 
$(builddir)/,$(built_introspection_sources))
diff --git a/libgweather/gweather-enum-types.c.tmpl b/libgweather/gweather-enum-types.c.tmpl
index bcb06e7..f5c9cb3 100644
--- a/libgweather/gweather-enum-types.c.tmpl
+++ b/libgweather/gweather-enum-types.c.tmpl
@@ -1,5 +1,4 @@
 /*** BEGIN file-header ***/
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-enum-types.h"
 #include "gweather-location.h"
 #include "gweather-enums.h"
diff --git a/libgweather/gweather-enum-types.h.tmpl b/libgweather/gweather-enum-types.h.tmpl
index 5fa9e38..935fd11 100644
--- a/libgweather/gweather-enum-types.h.tmpl
+++ b/libgweather/gweather-enum-types.h.tmpl
@@ -2,6 +2,10 @@
 #ifndef __GWEATHER_ENUM_TYPES_H__
 #define __GWEATHER_ENUM_TYPES_H__
 
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-enum-types.h must not be included individually, include gweather.h instead"
+#endif
+
 #include <glib-object.h>
 
 G_BEGIN_DECLS
diff --git a/libgweather/gweather-enums.h b/libgweather/gweather-enums.h
index 3ce1213..b3c2b4b 100644
--- a/libgweather/gweather-enums.h
+++ b/libgweather/gweather-enums.h
@@ -21,6 +21,10 @@
 #ifndef __GWEATHER_ENUMS_H_
 #define __GWEATHER_ENUMS_H_
 
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-enums.h must not be included individually, include gweather.h instead"
+#endif
+
 /**
  * GWeatherTemperatureUnit:
  * @GWEATHER_TEMP_UNIT_INVALID: invalid unit
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index 876b31e..5eeda3e 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -26,7 +26,6 @@
 #include <geocode-glib/geocode-glib.h>
 #include <gio/gio.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-location-entry.h"
 #include "gweather-private.h"
 
diff --git a/libgweather/gweather-location-entry.h b/libgweather/gweather-location-entry.h
index 66ba54d..3fbde06 100644
--- a/libgweather/gweather-location-entry.h
+++ b/libgweather/gweather-location-entry.h
@@ -21,6 +21,10 @@
 #ifndef GWEATHER_LOCATION_ENTRY_H
 #define GWEATHER_LOCATION_ENTRY_H 1
 
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-location-entry.h must not be included individually, include gweather.h instead"
+#endif
+
 #include <gtk/gtk.h>
 #include <libgweather/gweather-location.h>
 
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 420cda6..d6b8e4e 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -30,7 +30,6 @@
 #include <libxml/xmlreader.h>
 #include <geocode-glib/geocode-glib.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-location.h"
 #include "gweather-timezone.h"
 #include "gweather-parser.h"
diff --git a/libgweather/gweather-location.h b/libgweather/gweather-location.h
index a0f268a..9d1804a 100644
--- a/libgweather/gweather-location.h
+++ b/libgweather/gweather-location.h
@@ -21,8 +21,8 @@
 #ifndef __GWEATHER_LOCATIONS_H__
 #define __GWEATHER_LOCATIONS_H__
 
-#ifndef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
-#error "libgweather should only be used if you understand that it's subject to change, and is not supported 
as a fixed API/ABI or as part of the platform"
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-location.h must not be included individually, include gweather.h instead"
 #endif
 
 #include <glib.h>
diff --git a/libgweather/gweather-parser.c b/libgweather/gweather-parser.c
index 61b3617..e23c3e5 100644
--- a/libgweather/gweather-parser.c
+++ b/libgweather/gweather-parser.c
@@ -27,7 +27,6 @@
 #include <libxml/xmlreader.h>
 #include <glib/gi18n-lib.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 #include "gweather-parser.h"
 
diff --git a/libgweather/gweather-timezone-menu.c b/libgweather/gweather-timezone-menu.c
index 2edb6da..dfd0d1e 100644
--- a/libgweather/gweather-timezone-menu.c
+++ b/libgweather/gweather-timezone-menu.c
@@ -22,7 +22,6 @@
 #include <config.h>
 #endif
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-timezone-menu.h"
 #include "gweather-private.h"
 
diff --git a/libgweather/gweather-timezone-menu.h b/libgweather/gweather-timezone-menu.h
index 378c3c2..62e46f3 100644
--- a/libgweather/gweather-timezone-menu.h
+++ b/libgweather/gweather-timezone-menu.h
@@ -21,6 +21,10 @@
 #ifndef GWEATHER_TIMEZONE_MENU_H
 #define GWEATHER_TIMEZONE_MENU_H 1
 
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-timezone-menu.h must not be included individually, include gweather.h instead"
+#endif
+
 #include <gtk/gtk.h>
 #include <libgweather/gweather-location.h>
 
diff --git a/libgweather/gweather-timezone.c b/libgweather/gweather-timezone.c
index 34f28a2..0112937 100644
--- a/libgweather/gweather-timezone.c
+++ b/libgweather/gweather-timezone.c
@@ -24,7 +24,6 @@
 
 #include <string.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-timezone.h"
 #include "gweather-parser.h"
 #include "gweather-private.h"
diff --git a/libgweather/gweather-timezone.h b/libgweather/gweather-timezone.h
index 42f9c4b..540724e 100644
--- a/libgweather/gweather-timezone.h
+++ b/libgweather/gweather-timezone.h
@@ -21,8 +21,8 @@
 #ifndef __GWEATHER_TIMEZONE_H__
 #define __GWEATHER_TIMEZONE_H__
 
-#ifndef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
-#error "libgweather should only be used if you understand that it's subject to change, and is not supported 
as a fixed API/ABI or as part of the platform"
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-timezone.h must not be included individually, include gweather.h instead"
 #endif
 
 #include <glib-object.h>
diff --git a/libgweather/gweather-version.h.in b/libgweather/gweather-version.h.in
index bb3ae69..3554d49 100644
--- a/libgweather/gweather-version.h.in
+++ b/libgweather/gweather-version.h.in
@@ -24,6 +24,10 @@
 #ifndef __GWEATHER_VERSION_H__
 #define __GWEATHER_VERSION_H__
 
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-version.h must not be included individually, include gweather.h instead"
+#endif
+
 /**
  * SECTION:gweatherversion
  * @short_description: libgweather version checking
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c
index a93f83c..3fa6453 100644
--- a/libgweather/gweather-weather.c
+++ b/libgweather/gweather-weather.c
@@ -34,7 +34,6 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <glib.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-weather.h"
 #include "gweather-private.h"
 #include "gweather-enum-types.h"
diff --git a/libgweather/gweather-weather.h b/libgweather/gweather-weather.h
index 5496814..db67815 100644
--- a/libgweather/gweather-weather.h
+++ b/libgweather/gweather-weather.h
@@ -19,11 +19,10 @@
 #ifndef __WEATHER_H_
 #define __WEATHER_H_
 
-#ifndef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
-#error "libgweather should only be used if you understand that it's subject to change, and is not supported 
as a fixed API/ABI or as part of the platform"
+#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
+#error "gweather-weather.h must not be included individually, include gweather.h instead"
 #endif
 
-
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <libgweather/gweather-enums.h>
 #include <libgweather/gweather-location.h>
diff --git a/libgweather/gweather.h b/libgweather/gweather.h
index c3a7989..2816074 100644
--- a/libgweather/gweather.h
+++ b/libgweather/gweather.h
@@ -21,14 +21,21 @@
 #ifndef __GWEATHER_H__
 #define __GWEATHER_H__
 
-#ifndef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
+#if !(defined(GWEATHER_COMPILATION) || defined(GWEATHER_I_KNOW_THIS_IS_UNSTABLE))
 #error "libgweather should only be used if you understand that it's subject to change, and is not supported 
as a fixed API/ABI or as part of the platform"
 #endif
 
+#define IN_GWEATHER_H
+
+#include <libgweather/gweather-version.h>
+#include <libgweather/gweather-enums.h>
+#include <libgweather/gweather-enum-types.h>
 #include <libgweather/gweather-location.h>
 #include <libgweather/gweather-timezone.h>
 #include <libgweather/gweather-weather.h>
 #include <libgweather/gweather-location-entry.h>
 #include <libgweather/gweather-timezone-menu.h>
 
+#undef IN_GWEATHER_H
+
 #endif /* __GWEATHER_H__ */
diff --git a/libgweather/test_locations.c b/libgweather/test_locations.c
index 400c443..b52e67b 100644
--- a/libgweather/test_locations.c
+++ b/libgweather/test_locations.c
@@ -1,5 +1,4 @@
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-location-entry.h"
 #include "gweather-timezone-menu.h"
 
diff --git a/libgweather/test_metar.c b/libgweather/test_metar.c
index 7b00c37..1527b4a 100644
--- a/libgweather/test_metar.c
+++ b/libgweather/test_metar.c
@@ -6,7 +6,6 @@
 #include <glib.h>
 #include <string.h>
 #include <stdio.h>
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 #ifndef BUFLEN
diff --git a/libgweather/test_sun_moon.c b/libgweather/test_sun_moon.c
index 9ebfe4b..57c1b4e 100644
--- a/libgweather/test_sun_moon.c
+++ b/libgweather/test_sun_moon.c
@@ -4,7 +4,6 @@
 #include <string.h>
 #include <time.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 int
diff --git a/libgweather/weather-iwin.c b/libgweather/weather-iwin.c
index b1ebd26..3a4d9da 100644
--- a/libgweather/weather-iwin.c
+++ b/libgweather/weather-iwin.c
@@ -26,7 +26,6 @@
 
 #include <libxml/parser.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 static gboolean
diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c
index 89ed00e..b8ac2b1 100644
--- a/libgweather/weather-metar.c
+++ b/libgweather/weather-metar.c
@@ -25,7 +25,6 @@
 #include <sys/types.h>
 #include <regex.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 enum {
diff --git a/libgweather/weather-moon.c b/libgweather/weather-moon.c
index 8ad09d4..993cdff 100644
--- a/libgweather/weather-moon.c
+++ b/libgweather/weather-moon.c
@@ -35,7 +35,6 @@
 #include <string.h>
 #include <glib.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 /*
diff --git a/libgweather/weather-owm.c b/libgweather/weather-owm.c
index 5a1fc66..4ad94e9 100644
--- a/libgweather/weather-owm.c
+++ b/libgweather/weather-owm.c
@@ -35,7 +35,6 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 #define XC(t) ((const xmlChar *)(t))
diff --git a/libgweather/weather-sun.c b/libgweather/weather-sun.c
index bd0bd04..d7983b1 100644
--- a/libgweather/weather-sun.c
+++ b/libgweather/weather-sun.c
@@ -32,7 +32,6 @@
 #include <time.h>
 #include <glib.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 #define ECCENTRICITY(d)         (0.01671123 - (d)/36525.*0.00004392)
diff --git a/libgweather/weather-wx.c b/libgweather/weather-wx.c
index abc77e0..2dee559 100644
--- a/libgweather/weather-wx.c
+++ b/libgweather/weather-wx.c
@@ -20,7 +20,6 @@
 #include <config.h>
 #endif
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 static void
diff --git a/libgweather/weather-yahoo.c b/libgweather/weather-yahoo.c
index 0c7d598..77c0b2b 100644
--- a/libgweather/weather-yahoo.c
+++ b/libgweather/weather-yahoo.c
@@ -34,7 +34,6 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 #define XC(t) ((const xmlChar *)(t))
diff --git a/libgweather/weather-yrno.c b/libgweather/weather-yrno.c
index d2fe179..2e62926 100644
--- a/libgweather/weather-yrno.c
+++ b/libgweather/weather-yrno.c
@@ -34,7 +34,6 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 
-#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include "gweather-private.h"
 
 #define XC(t) ((const xmlChar *)(t))


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