kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=ac1d4b0520faa627b75c3465ac5b71f71a2281f6

commit ac1d4b0520faa627b75c3465ac5b71f71a2281f6
Author: Kim Woelders <k...@woelders.dk>
Date:   Thu Mar 3 06:04:45 2022 +0100

    Deal consistently with including Imlib2.h
    
    - Always include config.h before Imlib2.h
      Needed for X_DISPLAY_MISSING.
    - Always include config.h and Imlib2.h first
      Should make it more likely to spot stuff missing but required
      in Imlib2.h, like stddef.h.
      gtest.h apparently must be included before X headers though.
    - Make sure we use the Imlib2.h here and not the one in /usr/include
    
    Also ensure that the tests build when building without X.
---
 src/bin/imlib2_bumpmap.c              |  3 +--
 src/bin/imlib2_colorspace.c           |  3 +--
 src/bin/imlib2_conv.c                 | 16 ++++++++--------
 src/bin/imlib2_grab.c                 |  3 +--
 src/bin/imlib2_load.c                 | 10 +++++-----
 src/bin/imlib2_poly.c                 |  3 +--
 src/bin/imlib2_show.c                 |  3 +--
 src/bin/imlib2_test.c                 |  3 +--
 src/bin/imlib2_view.c                 |  2 +-
 src/lib/Imlib2.h.in                   |  1 +
 src/lib/api.c                         |  2 +-
 src/lib/api_obsolete.c                |  3 +--
 src/lib/image.c                       |  5 +++--
 src/lib/script.c                      |  5 +++--
 src/modules/filters/Makefile.am       |  2 +-
 src/modules/filters/filter_bumpmap.c  |  7 +++++--
 src/modules/filters/filter_colormod.c |  7 +++++--
 src/modules/filters/filter_test.c     |  7 +++++--
 test/Makefile.am                      |  4 +++-
 test/test_context.cpp                 |  4 +++-
 test/test_grab.cpp                    |  5 +++--
 test/test_load.cpp                    |  3 ++-
 test/test_load_2.cpp                  |  3 ++-
 test/test_rotate.cpp                  |  3 ++-
 test/test_save.cpp                    |  2 +-
 test/test_scale.cpp                   |  3 ++-
 26 files changed, 63 insertions(+), 49 deletions(-)

diff --git a/src/bin/imlib2_bumpmap.c b/src/bin/imlib2_bumpmap.c
index c373a91..690ace0 100644
--- a/src/bin/imlib2_bumpmap.c
+++ b/src/bin/imlib2_bumpmap.c
@@ -1,12 +1,11 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <Imlib2.h>
-
 Display            *disp;
 Window              win;
 
diff --git a/src/bin/imlib2_colorspace.c b/src/bin/imlib2_colorspace.c
index 7a0a4ba..4f5d583 100644
--- a/src/bin/imlib2_colorspace.c
+++ b/src/bin/imlib2_colorspace.c
@@ -1,12 +1,11 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <Imlib2.h>
-
 Display            *disp;
 Window              win;
 
diff --git a/src/bin/imlib2_conv.c b/src/bin/imlib2_conv.c
index 6a88f94..d204e02 100644
--- a/src/bin/imlib2_conv.c
+++ b/src/bin/imlib2_conv.c
@@ -1,18 +1,18 @@
-#include "config.h"
-/* Convert images between formats, using Imlib2's API. Smart enough to know
- * about edb files; defaults to jpg's.
+/*
+ * Convert images between formats, using Imlib2's API.
+ * Defaults to jpg's.
  */
+#include "config.h"
+#ifndef X_DISPLAY_MISSING
+#define X_DISPLAY_MISSING
+#endif
+#include <Imlib2.h>
 
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
-#ifndef X_DISPLAY_MISSING
-#define X_DISPLAY_MISSING
-#endif
-#include <Imlib2.h>
-
 #define PROG_NAME "imlib2_conv"
 
 static void         usage(int exit_status);
diff --git a/src/bin/imlib2_grab.c b/src/bin/imlib2_grab.c
index e7db343..3004048 100644
--- a/src/bin/imlib2_grab.c
+++ b/src/bin/imlib2_grab.c
@@ -1,12 +1,11 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
-#include <Imlib2.h>
-
 Display            *disp;
 int                 image_width = 0, image_height = 0;
 
diff --git a/src/bin/imlib2_load.c b/src/bin/imlib2_load.c
index d4345d5..9e46baa 100644
--- a/src/bin/imlib2_load.c
+++ b/src/bin/imlib2_load.c
@@ -1,4 +1,9 @@
 #include "config.h"
+#ifndef X_DISPLAY_MISSING
+#define X_DISPLAY_MISSING
+#endif
+#include <Imlib2.h>
+
 #include <fcntl.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -11,11 +16,6 @@
 #include <sys/time.h>
 #endif
 
-#ifndef X_DISPLAY_MISSING
-#define X_DISPLAY_MISSING
-#endif
-#include <Imlib2.h>
-
 #define PROG_NAME "imlib2_load"
 
 static char         progress_called;
diff --git a/src/bin/imlib2_poly.c b/src/bin/imlib2_poly.c
index 3e7ab62..f3153e6 100644
--- a/src/bin/imlib2_poly.c
+++ b/src/bin/imlib2_poly.c
@@ -1,12 +1,11 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <Imlib2.h>
-
 Display            *disp;
 Window              win;
 
diff --git a/src/bin/imlib2_show.c b/src/bin/imlib2_show.c
index a8d75c2..7025def 100644
--- a/src/bin/imlib2_show.c
+++ b/src/bin/imlib2_show.c
@@ -1,4 +1,5 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
@@ -10,8 +11,6 @@
 #include <math.h>
 #include <locale.h>
 
-#include <Imlib2.h>
-
 Display            *disp;
 Window              win;
 
diff --git a/src/bin/imlib2_test.c b/src/bin/imlib2_test.c
index 42dab64..4762723 100644
--- a/src/bin/imlib2_test.c
+++ b/src/bin/imlib2_test.c
@@ -1,12 +1,11 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <Imlib2.h>
-
 /* some globals for our window & X display */
 Display            *disp;
 Window              win;
diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 9e22fef..fd4642c 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -1,4 +1,5 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
@@ -8,7 +9,6 @@
 #include <stdbool.h>
 #include <unistd.h>
 
-#include <Imlib2.h>
 #include "props.h"
 
 #define MIN(a, b) ((a < b) ? a : b)
diff --git a/src/lib/Imlib2.h.in b/src/lib/Imlib2.h.in
index a8c30d7..a7f9615 100644
--- a/src/lib/Imlib2.h.in
+++ b/src/lib/Imlib2.h.in
@@ -35,6 +35,7 @@
 #define IMLIB2_DEPRECATED
 #endif
 
+#include <stddef.h>
 #ifndef X_DISPLAY_MISSING
 #include <X11/Xlib.h>
 #endif
diff --git a/src/lib/api.c b/src/lib/api.c
index ff34282..acd2730 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -1,10 +1,10 @@
 #include "config.h"
+#include <Imlib2.h>
 
 #include <math.h>
 #include <string.h>
 #include <stdarg.h>
 
-#include "Imlib2.h"
 #include "blend.h"
 #include "colormod.h"
 #include "color_helpers.h"
diff --git a/src/lib/api_obsolete.c b/src/lib/api_obsolete.c
index 5215bef..70c9776 100644
--- a/src/lib/api_obsolete.c
+++ b/src/lib/api_obsolete.c
@@ -1,9 +1,8 @@
 /*
  * Obsolete, useless code
  */
-#include <stddef.h>
 #include "config.h"
-#include "Imlib2.h"
+#include <Imlib2.h>
 
 EAPI void
 imlib_image_set_irrelevant_border(char irrelevant)
diff --git a/src/lib/image.c b/src/lib/image.c
index e82d958..fbaaa11 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -1,4 +1,5 @@
-#include "common.h"
+#include "config.h"
+#include <Imlib2.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -8,7 +9,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "Imlib2.h"
+#include "common.h"
 #include "debug.h"
 #include "file.h"
 #include "image.h"
diff --git a/src/lib/script.c b/src/lib/script.c
index 0e88cde..855a749 100644
--- a/src/lib/script.c
+++ b/src/lib/script.c
@@ -1,4 +1,5 @@
-#include "common.h"
+#include "config.h"
+#include <Imlib2.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -11,7 +12,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "Imlib2.h"
+#include "common.h"
 #include "dynamic_filters.h"
 #include "image.h"
 #include "script.h"
diff --git a/src/modules/filters/Makefile.am b/src/modules/filters/Makefile.am
index f46d4b0..839b941 100644
--- a/src/modules/filters/Makefile.am
+++ b/src/modules/filters/Makefile.am
@@ -1,5 +1,5 @@
 AM_CFLAGS            = $(CFLAGS_WARNINGS) $(CFLAGS_VISIBILITY) $(CFLAGS_ASAN)
-AM_CPPFLAGS          = -I$(top_builddir) -I$(top_srcdir)/src/lib
+AM_CPPFLAGS          = -I$(top_builddir) -I$(top_builddir)/src/lib 
-I$(top_srcdir)/src/lib
 
 pkgdir                = $(libdir)/imlib2/filters
 pkg_LTLIBRARIES       = testfilter.la bumpmap.la colormod.la
diff --git a/src/modules/filters/filter_bumpmap.c 
b/src/modules/filters/filter_bumpmap.c
index b11bce0..5bb6921 100644
--- a/src/modules/filters/filter_bumpmap.c
+++ b/src/modules/filters/filter_bumpmap.c
@@ -1,7 +1,10 @@
-#include "filter_common.h"
+#include "config.h"
+#include <Imlib2.h>
+
 #include <string.h>
 #include <math.h>
-#include <Imlib2.h>
+
+#include "filter_common.h"
 #include "colormod.h"
 #include "blend.h"
 
diff --git a/src/modules/filters/filter_colormod.c 
b/src/modules/filters/filter_colormod.c
index 28d74b9..70363f0 100644
--- a/src/modules/filters/filter_colormod.c
+++ b/src/modules/filters/filter_colormod.c
@@ -1,7 +1,10 @@
-#include "filter_common.h"
+#include "config.h"
+#include <Imlib2.h>
+
 #include <string.h>
 #include <math.h>
-#include <Imlib2.h>
+
+#include "filter_common.h"
 
 #define GET_INT(x, ptr) (((ptr)->type == VAR_PTR) ?    \
                        (x) = (*(int *)(ptr)->data) :   \
diff --git a/src/modules/filters/filter_test.c 
b/src/modules/filters/filter_test.c
index f484ed8..720dace 100644
--- a/src/modules/filters/filter_test.c
+++ b/src/modules/filters/filter_test.c
@@ -1,7 +1,10 @@
-#include "filter_common.h"
-#include <string.h>
+#include "config.h"
 #include <Imlib2.h>
 
+#include <string.h>
+
+#include "filter_common.h"
+
 void
 init(ImlibFilterInfo * info)
 {
diff --git a/test/Makefile.am b/test/Makefile.am
index ec8b345..69301d7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -11,9 +11,11 @@ CLEANFILES = file.c img_save-*.*
  GTESTS += test_load
  GTESTS += test_load_2
  GTESTS += test_save
- GTESTS += test_grab
  GTESTS += test_scale
  GTESTS += test_rotate
+if BUILD_X11
+ GTESTS += test_grab
+endif
 
  AM_CFLAGS  = -Wall -Wextra -Werror -Wno-unused-parameter
  AM_CFLAGS += $(CFLAGS_ASAN)
diff --git a/test/test_context.cpp b/test/test_context.cpp
index d658350..e4bdf9a 100644
--- a/test/test_context.cpp
+++ b/test/test_context.cpp
@@ -1,8 +1,10 @@
 #include <gtest/gtest.h>
 
-#include <stddef.h>
+#include "config.h"
 #include <Imlib2.h>
 
+#include <stddef.h>
+
 #include "test.h"
 
 #define NULC ((Imlib_Context*)0)
diff --git a/test/test_grab.cpp b/test/test_grab.cpp
index bc38468..cee8550 100644
--- a/test/test_grab.cpp
+++ b/test/test_grab.cpp
@@ -1,9 +1,10 @@
 #include <gtest/gtest.h>
 
-#include <X11/Xutil.h>
+#include "config.h"
 #include <Imlib2.h>
 
-#include "config.h"
+#include <X11/Xutil.h>
+
 #include "test.h"
 
 typedef struct {
diff --git a/test/test_load.cpp b/test/test_load.cpp
index a3573ff..f2ba171 100644
--- a/test/test_load.cpp
+++ b/test/test_load.cpp
@@ -1,9 +1,10 @@
 #include <gtest/gtest.h>
 
+#include "config.h"
 #include <Imlib2.h>
+
 #include <fcntl.h>
 
-#include "config.h"
 #include "test.h"
 
 #define EXPECT_OK(x)  EXPECT_FALSE(x)
diff --git a/test/test_load_2.cpp b/test/test_load_2.cpp
index ab9dd87..ca73147 100644
--- a/test/test_load_2.cpp
+++ b/test/test_load_2.cpp
@@ -1,10 +1,11 @@
 #include <gtest/gtest.h>
 
+#include "config.h"
 #include <Imlib2.h>
+
 #include <fcntl.h>
 #include <zlib.h>
 
-#include "config.h"
 #include "test.h"
 
 #define EXPECT_OK(x)  EXPECT_FALSE(x)
diff --git a/test/test_rotate.cpp b/test/test_rotate.cpp
index 86fb6d2..6841586 100644
--- a/test/test_rotate.cpp
+++ b/test/test_rotate.cpp
@@ -1,9 +1,10 @@
 #include <gtest/gtest.h>
 
+#include "config.h"
 #include <Imlib2.h>
+
 #include <zlib.h>
 
-#include "config.h"
 #include "test.h"
 
 #define FILE_REF1      "icon-64"       // RGB
diff --git a/test/test_save.cpp b/test/test_save.cpp
index 5ce0b27..b06aa57 100644
--- a/test/test_save.cpp
+++ b/test/test_save.cpp
@@ -1,8 +1,8 @@
 #include <gtest/gtest.h>
 
+#include "config.h"
 #include <Imlib2.h>
 
-#include "config.h"
 #include "test.h"
 
 #define EXPECT_OK(x)  EXPECT_FALSE(x)
diff --git a/test/test_scale.cpp b/test/test_scale.cpp
index 8c66dd7..cecc51a 100644
--- a/test/test_scale.cpp
+++ b/test/test_scale.cpp
@@ -1,9 +1,10 @@
 #include <gtest/gtest.h>
 
+#include "config.h"
 #include <Imlib2.h>
+
 #include <zlib.h>
 
-#include "config.h"
 #include "test.h"
 
 #define FILE_REF1      "icon-64"       // RGB

-- 


Reply via email to