Make sure feature macros are checked using #if, not #ifdef; add a test for it

This is more robust to cases where people want to assign 0 to those variables.
(win32/alternate build systems, etc)
This commit is contained in:
Behdad Esfahbod 2008-09-20 17:20:36 -04:00
parent e00565fa3c
commit fee72c26af
10 changed files with 38 additions and 23 deletions

View file

@ -70,10 +70,10 @@ TESTS_ENVIRONMENT = \
$(NULL)
TESTS_SH = \
check-def.sh \
check-plt.sh \
check-headers.sh \
check-includes.sh \
check-doc-syntax.sh\
check-headers.sh \
check-plt.sh \
check-preprocessor-syntax.sh \
$(NULL)
TESTS += $(TESTS_SH)
if CROSS_COMPILING

View file

@ -47,7 +47,7 @@ CAIRO_BEGIN_DECLS
#if HAVE_INTEL_ATOMIC_PRIMITIVES
#define CAIRO_HAS_ATOMIC_OPS 1
#define HAS_ATOMIC_OPS 1
typedef int cairo_atomic_int_t;
@ -58,7 +58,7 @@ typedef int cairo_atomic_int_t;
#endif
#ifndef CAIRO_HAS_ATOMIC_OPS
#ifndef HAS_ATOMIC_OPS
typedef int cairo_atomic_int_t;

View file

@ -36,7 +36,7 @@
#include "cairo-atomic-private.h"
#include "cairo-mutex-private.h"
#ifndef CAIRO_HAS_ATOMIC_OPS
#ifndef HAS_ATOMIC_OPS
void
_cairo_atomic_int_inc (int *x)
{

View file

@ -49,7 +49,7 @@
#include "cairo.h"
#ifdef CAIRO_HAS_DIRECTFB_SURFACE
#if CAIRO_HAS_DIRECTFB_SURFACE
#include <directfb.h>

View file

@ -51,7 +51,7 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex)
CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex)
#endif
#if !defined (CAIRO_HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER)
#if !defined (HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER)
CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex)
#endif

View file

@ -40,7 +40,7 @@
#include "cairoint.h"
#ifdef CAIRO_HAS_QUARTZ_SURFACE
#if CAIRO_HAS_QUARTZ_SURFACE
#include "cairo-quartz.h"
typedef struct cairo_quartz_surface {
@ -95,11 +95,10 @@ _cairo_quartz_create_cgimage (cairo_format_t format,
CGFontRef
_cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont);
#else
# error Cairo was not compiled with support for the quartz backend
#endif /* CAIRO_HAS_QUARTZ_SURFACE */
#if CAIRO_HAS_CGFONT_FONT
CGFontRef
_cairo_cgfont_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont);
#endif /* CAIRO_HAS_CGFONT_FONT */
#endif /* CAIRO_QUARTZ_PRIVATE_H */

View file

@ -57,12 +57,12 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
cairo_public CGContextRef
cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);
#if CAIRO_HAS_QUARTZ_FONT
/*
* Quartz font support
*/
#ifdef CAIRO_HAS_QUARTZ_FONT
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font);

View file

@ -68,6 +68,12 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface);
cairo_public cairo_surface_t *
cairo_win32_surface_get_image (cairo_surface_t *surface);
#if CAIRO_HAS_WIN32_FONT
/*
* Win32 font support
*/
cairo_public cairo_font_face_t *
cairo_win32_font_face_create_for_logfontw (LOGFONTW *logfont);
@ -95,6 +101,8 @@ cairo_public void
cairo_win32_scaled_font_get_device_to_logical (cairo_scaled_font_t *scaled_font,
cairo_matrix_t *device_to_logical);
#endif /* CAIRO_HAS_WIN32_FONT */
CAIRO_END_DECLS
#else /* CAIRO_HAS_WIN32_SURFACE */

View file

@ -68,11 +68,20 @@
#include "cairo-compiler-private.h"
#if defined(CAIRO_HAS_PS_SURFACE) || defined(CAIRO_HAS_PDF_SURFACE) || defined(CAIRO_HAS_SVG_SURFACE)
#if CAIRO_HAS_PS_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if CAIRO_HAS_PDF_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if CAIRO_HAS_SVG_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if defined(CAIRO_HAS_PS_SURFACE) || defined(CAIRO_HAS_PDF_SURFACE)
#if CAIRO_HAS_PS_SURFACE
#define CAIRO_HAS_PDF_OPERATORS 1
#endif
#if CAIRO_HAS_PDF_SURFACE
#define CAIRO_HAS_PDF_OPERATORS 1
#endif

View file

@ -16,6 +16,7 @@ test "x$PRIVATE" = x && PRIVATE=`find . -name 'cairo*-private.h' -or -name 'cair
SOURCES=$all_cairo_sources
test "x$SOURCES" = x && SOURCES=`find . -name 'cairo*.c' -or -name 'cairo*.cpp'`
ALL="/dev/null $HEADERS $PRIVATE $SOURCES"
echo 'Checking that public header files #include "cairo.h" first (or none)'
@ -47,12 +48,10 @@ grep . && stat=1
echo 'Checking that there is no #include <cairo.*.h>'
for x in $HEADERS $PRIVATE $SOURCES; do
grep '\<include\>.*<.*cairo' "$x" /dev/null
done |
grep . && stat=1
grep '\<include\>.*<.*cairo' $ALL && stat=1
echo 'Checking that feature conditionals are used with #if only (not #ifdef)'
grep '#if.*CAIRO_HAS_' $ALL | grep def && stat=1
exit $stat