[cairo-commit] 10 commits - boilerplate/cairo-boilerplate.h boilerplate/Makefile.win32 build/configure.ac.features build/Makefile.win32.common build/Makefile.win32.features-h Makefile.win32 src/cairo-compiler-private.h src/cairo-toy-font-face.c src/cairo-win32-font.c src/Makefile.win32 test/cairo-test.c test/Makefile.win32 test/pdiff

Andrea Canciani ranma42 at kemper.freedesktop.org
Mon Jun 20 01:25:08 PDT 2011


 Makefile.win32                  |   24 ++--------
 boilerplate/Makefile.win32      |    4 -
 boilerplate/cairo-boilerplate.h |    1 
 build/Makefile.win32.common     |   29 +++++++-----
 build/Makefile.win32.features-h |   96 ++++++++++++++++++++--------------------
 build/configure.ac.features     |   12 ++---
 src/Makefile.win32              |    4 -
 src/cairo-compiler-private.h    |   11 +++-
 src/cairo-toy-font-face.c       |    4 -
 src/cairo-win32-font.c          |   82 +++++++++++++++++++++-------------
 test/Makefile.win32             |   31 +++++-------
 test/cairo-test.c               |    3 -
 test/pdiff/Makefile.win32       |   13 +----
 13 files changed, 159 insertions(+), 155 deletions(-)

New commits:
commit b6d593dc71e276576ce2af9fa2267eebdddd578a
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jun 18 17:06:52 2011 +0200

    build: Clean up environment variables and flags for the win32 build
    
    Avoid ovverriding LINK, as it has a special meaning for the MSVC build
    tools.

diff --git a/boilerplate/Makefile.win32 b/boilerplate/Makefile.win32
index 46aa0b6..29df5cf 100644
--- a/boilerplate/Makefile.win32
+++ b/boilerplate/Makefile.win32
@@ -2,8 +2,6 @@ top_srcdir = ..
 include $(top_srcdir)/build/Makefile.win32.common
 include Makefile.win32.features
 
-CFLAGS += -I../src
-
 HEADERS = \
 	$(enabled_cairo_boilerplate_headers) \
 	$(enabled_cairo_boilerplate_private) \
@@ -23,4 +21,4 @@ all: $(CFG)/boiler.lib
 
 
 $(CFG)/boiler.lib: $(OBJECTS)
-	lib -NOLOGO -OUT:$@ $(OBJECTS) $(WIN_LIBS)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(OBJECTS)
diff --git a/build/Makefile.win32.common b/build/Makefile.win32.common
index 5ff0780..e422500 100644
--- a/build/Makefile.win32.common
+++ b/build/Makefile.win32.common
@@ -11,16 +11,15 @@ top_builddir = $(top_srcdir)
 endif
 
 CC := cl
-LINK := link
+LD := link
+AR := lib
 
 ifeq ($(CFG),debug)
-MS_MDFLAGS := -MDd
-MS_LDFLAGS := -LDd
-OPT := -Od -Zi
+CFG_CFLAGS := -MDd -Od -Zi
+CFG_LDFLAGS := -DEBUG
 else
-MS_MDFLAGS := -MD
-MS_LDFLAGS := -LD
-OPT := -MD -O2
+CFG_CFLAGS := -MD -O2
+CFG_LDFLAGS :=
 endif
 
 PIXMAN_CFLAGS := -I$(top_srcdir)/../pixman/pixman
@@ -37,13 +36,18 @@ ZLIB_CFLAGS += -I$(top_srcdir)/../zlib/
 CAIRO_LIBS += $(top_builddir)/../zlib/zdll.lib
 endif
 
-DEFAULT_CFLAGS = -nologo $(MS_MDFLAGS) $(OPT)
-DEFAULT_CFLAGS += -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
-DEFAULT_CFLAGS += -I. -I$(top_srcdir)
+DEFAULT_CFLAGS = -nologo $(CFG_CFLAGS)
+DEFAULT_CFLAGS += -I. -I$(top_srcdir) -I$(top_srcdir)/src
 DEFAULT_CFLAGS += $(PIXMAN_CFLAGS) $(LIBPNG_CFLAGS) $(ZLIB_CFLAGS)
 
 CAIRO_CFLAGS = $(DEFAULT_CFLAGS) $(CFLAGS)
 
+DEFAULT_LDFLAGS = -nologo $(CFG_LDFLAGS)
+DEFAULT_ARFLAGS = -nologo
+
+CAIRO_LDFLAGS = $(DEFAULT_LDFLAGS) $(LDFLAGS)
+CAIRO_ARFLAGS = $(DEFAULT_ARFLAGS) $(LDFLAGS)
+
 inform:
 	@echo
 ifneq ($(CFG),release)
diff --git a/src/Makefile.win32 b/src/Makefile.win32
index 6fdc395..864791f 100644
--- a/src/Makefile.win32
+++ b/src/Makefile.win32
@@ -13,10 +13,10 @@ static: inform $(CFG)/cairo-static.lib
 dynamic: inform $(CFG)/cairo.dll
 
 $(CFG)/cairo.dll: $(OBJECTS)
-	$(CC) $(OPT) $(MS_MDFLAGS) $(MS_LDFLAGS) -Fe$@ $(PIXMAN_LIBS) $(OBJECTS) -link $(CAIRO_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -DLL -OUT:$@ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(OBJECTS)
 
 $(CFG)/cairo-static.lib: $(OBJECTS_STATIC)
-	lib -NOLOGO -OUT:$@ $(PIXMAN_LIBS) $(OBJECTS_STATIC)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(PIXMAN_LIBS) $(OBJECTS_STATIC)
 
 all: inform $(CFG)/cairo.dll $(CFG)/cairo-static.lib
 	@echo "Built successfully!"
diff --git a/test/Makefile.win32 b/test/Makefile.win32
index ff5e266..cd08db8 100644
--- a/test/Makefile.win32
+++ b/test/Makefile.win32
@@ -2,7 +2,7 @@ top_srcdir = ..
 include $(top_srcdir)/build/Makefile.win32.common
 include $(top_srcdir)/test/Makefile.sources
 
-CFLAGS += -I../src -I../boilerplate -I./pdiff
+CFLAGS += -I$(top_srcdir)/boilerplate -I./pdiff
 
 TEST_LIBS = ./pdiff/$(CFG)/pdiff.lib $(top_srcdir)/src/$(CFG)/cairo-static.lib $(top_srcdir)/boilerplate/$(CFG)/boiler.lib
 
@@ -16,7 +16,7 @@ SOURCES = $(cairo_test_suite_sources) $(test_sources) cairo-test-constructors.c
 OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
 
 cairo-test-suite.exe: $(OBJECTS) $(TEST_LIBS)
-	$(CC) $(OPT) $(MS_MDFLAGS) $(OBJECTS) -Fe"$@" -link $(LDFLAGS) $(TEST_LIBS) $(CAIRO_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(OBJECTS) $(TEST_LIBS) $(CAIRO_LIBS)
 
 ./pdiff/$(CFG)/pdiff.lib:
 	$(MAKE) -C pdiff -f Makefile.win32
diff --git a/test/pdiff/Makefile.win32 b/test/pdiff/Makefile.win32
index f25383e..3d64676 100644
--- a/test/pdiff/Makefile.win32
+++ b/test/pdiff/Makefile.win32
@@ -1,8 +1,6 @@
 top_srcdir = ../..
 include $(top_srcdir)/build/Makefile.win32.common
 
-CFLAGS += -I../../src
-
 SOURCES = \
 	lpyramid.c \
 	pdiff.c \
@@ -13,4 +11,4 @@ OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
 all: $(CFG)/pdiff.lib
 
 $(CFG)/pdiff.lib: $(OBJECTS)
-	lib -NOLOGO -OUT:$@ $(OBJECTS)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(OBJECTS)
commit 5534c305241e078c9a5745e511c0700545e045bb
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jun 18 16:59:00 2011 +0200

    build: Use common rules for making pdiff
    
    Instead of providing special rules for compiling C files in pdiff, use
    the common ones and build a different pdiff for debug and release.

diff --git a/test/Makefile.win32 b/test/Makefile.win32
index 091e588..ff5e266 100644
--- a/test/Makefile.win32
+++ b/test/Makefile.win32
@@ -4,7 +4,7 @@ include $(top_srcdir)/test/Makefile.sources
 
 CFLAGS += -I../src -I../boilerplate -I./pdiff
 
-TEST_LIBS = ./pdiff/pdiff.lib $(top_srcdir)/src/$(CFG)/cairo-static.lib $(top_srcdir)/boilerplate/$(CFG)/boiler.lib
+TEST_LIBS = ./pdiff/$(CFG)/pdiff.lib $(top_srcdir)/src/$(CFG)/cairo-static.lib $(top_srcdir)/boilerplate/$(CFG)/boiler.lib
 
 all: inform cairo-test-suite.exe
 
@@ -18,8 +18,8 @@ OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
 cairo-test-suite.exe: $(OBJECTS) $(TEST_LIBS)
 	$(CC) $(OPT) $(MS_MDFLAGS) $(OBJECTS) -Fe"$@" -link $(LDFLAGS) $(TEST_LIBS) $(CAIRO_LIBS)
 
-./pdiff/pdiff.lib:
-	(cd pdiff ; $(MAKE) -f Makefile.win32)
+./pdiff/$(CFG)/pdiff.lib:
+	$(MAKE) -C pdiff -f Makefile.win32
 
 $(top_srcdir)/src/$(CFG)/cairo-static.lib:
 	$(MAKE) -C $(top_srcdir)/src -f Makefile.win32
diff --git a/test/pdiff/Makefile.win32 b/test/pdiff/Makefile.win32
index 851d3af..f25383e 100644
--- a/test/pdiff/Makefile.win32
+++ b/test/pdiff/Makefile.win32
@@ -8,12 +8,9 @@ SOURCES = \
 	pdiff.c \
 	$(NULL)
 
-OBJECTS = $(subst .c,.obj,$(SOURCES))
+OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
 
-all: pdiff.lib
+all: $(CFG)/pdiff.lib
 
-pdiff.lib: $(OBJECTS)
+$(CFG)/pdiff.lib: $(OBJECTS)
 	lib -NOLOGO -OUT:$@ $(OBJECTS)
-
-%.obj: %.c
-	@$(CC) $(CFLAGS) -DCAIRO_WIN32_STATIC_BUILD=1 -c -Fo"$@" $<
commit f9b50cec2b05a9371c90a1e6996af927e47b1d34
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jun 18 17:07:17 2011 +0200

    build: Improve dependencies in win32 Makefiles
    
    Test targets now explicitly depend on the cairo library and build it
    appropriately.
    
    Phony targets depend on inform, so that they print a warning if the
    environment is not set up appropriately.

diff --git a/Makefile.win32 b/Makefile.win32
index 7da2222..770df70 100644
--- a/Makefile.win32
+++ b/Makefile.win32
@@ -4,23 +4,10 @@
 top_srcdir = .
 include $(top_srcdir)/build/Makefile.win32.common
 
-SUBDIRS = src
-TEST_SUBDIRS = boilerplate test
+all: cairo
 
-all: inform cairo
+cairo: inform
+	@$(MAKE) -C src -f Makefile.win32
 
-cairo: src/cairo-features.h
-	@list='$(SUBDIRS)'; for f in $$list ; do \
-		echo making all in $$f... ; \
-		($(MAKE) -C $$f -f Makefile.win32) || exit 1 ; \
-	done
-
-test: cairo
-	@list='$(TEST_SUBDIRS)'; for f in $$list ; do \
-		echo making all in $$f... ; \
-		($(MAKE) -C $$f -f Makefile.win32) || exit 1 ; \
-	done
-	@(cd test ; make -f Makefile.win32 test)
-
-html:
-	@(cd test ; make -f Makefile.win32 html)
+test: inform
+	@$(MAKE) -C test -f Makefile.win32 test
diff --git a/test/Makefile.win32 b/test/Makefile.win32
index 0d9a15c..091e588 100644
--- a/test/Makefile.win32
+++ b/test/Makefile.win32
@@ -4,15 +4,9 @@ include $(top_srcdir)/test/Makefile.sources
 
 CFLAGS += -I../src -I../boilerplate -I./pdiff
 
-LDFLAGS += ./pdiff/pdiff.lib ../src/$(CFG)/cairo-static.lib $(PIXMAN_LIBS) ../boilerplate/$(CFG)/boiler.lib $(EXE_LDFLAGS)
+TEST_LIBS = ./pdiff/pdiff.lib $(top_srcdir)/src/$(CFG)/cairo-static.lib $(top_srcdir)/boilerplate/$(CFG)/boiler.lib
 
-
-TESTCORE_SOURCES = \
-	cairo-test.c \
-	buffer-diff.c \
-	$(NULL)
-
-all: cairo-test-suite.exe
+all: inform cairo-test-suite.exe
 
 cairo-test-constructors.c: Makefile.sources Makefile.win32 $(test_sources) make-cairo-test-constructors.sh
 	sh ./make-cairo-test-constructors.sh $(test_sources) > $@
@@ -21,18 +15,21 @@ SOURCES = $(cairo_test_suite_sources) $(test_sources) cairo-test-constructors.c
 
 OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
 
-cairo-test-suite.exe: $(OBJECTS) ./pdiff/pdiff.lib ../boilerplate/$(CFG)/boiler.lib
-	$(CC) $(OPT) $(MS_MDFLAGS) $(OBJECTS) -Fe"$@" -link $(LDFLAGS) $(CAIRO_LIBS) /NODEFAULTLIB:library
+cairo-test-suite.exe: $(OBJECTS) $(TEST_LIBS)
+	$(CC) $(OPT) $(MS_MDFLAGS) $(OBJECTS) -Fe"$@" -link $(LDFLAGS) $(TEST_LIBS) $(CAIRO_LIBS)
 
 ./pdiff/pdiff.lib:
 	(cd pdiff ; $(MAKE) -f Makefile.win32)
 
-../boilerplate/$(CFG)/boiler.lib:
-	(cd ../boilerplate ; $(MAKE) -f Makefile.win32)
+$(top_srcdir)/src/$(CFG)/cairo-static.lib:
+	$(MAKE) -C $(top_srcdir)/src -f Makefile.win32
+
+$(top_srcdir)/boilerplate/$(CFG)/boiler.lib:
+	$(MAKE) -C $(top_srcdir)/boilerplate -f Makefile.win32
 
 .PHONY: check test
 
-check: cairo-test-suite.exe
+check: inform cairo-test-suite.exe
 	./cairo-test-suite.exe
 
-test: check
+test: inform check
commit c7c3475cdb429a996190c2c95c20a60984a1bba9
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sat Jun 18 16:37:34 2011 +0200

    build: Improve generation of cairo-features.h on win32
    
    All of the build depends on cairo-features.h. By having a target to
    generate it that can be run from anywhere, it is possible to delegate
    the dependency handling to 'make'.

diff --git a/Makefile.win32 b/Makefile.win32
index a7e2205..7da2222 100644
--- a/Makefile.win32
+++ b/Makefile.win32
@@ -3,7 +3,6 @@
 
 top_srcdir = .
 include $(top_srcdir)/build/Makefile.win32.common
-include $(top_srcdir)/build/Makefile.win32.features-h
 
 SUBDIRS = src
 TEST_SUBDIRS = boilerplate test
diff --git a/build/Makefile.win32.common b/build/Makefile.win32.common
index c1f0cb8..5ff0780 100644
--- a/build/Makefile.win32.common
+++ b/build/Makefile.win32.common
@@ -4,6 +4,7 @@ default: all
 # Edit build/Makefile.win32.features to enable features to build
 #
 include $(top_srcdir)/build/Makefile.win32.features
+include $(top_srcdir)/build/Makefile.win32.features-h
 
 ifeq ($(top_builddir),)
 top_builddir = $(top_srcdir)
@@ -59,11 +60,11 @@ endif
 
 # Some generic rules
 
-$(CFG)/%.obj: %.c
+$(CFG)/%.obj: %.c $(top_srcdir)/src/cairo-features.h
 	@mkdir -p $(CFG)
 	@$(CC) $(CAIRO_CFLAGS) -c -Fo"$@" $<
 
-$(CFG)/%-static.obj: %.c
+$(CFG)/%-static.obj: %.c $(top_srcdir)/src/cairo-features.h
 	@mkdir -p $(CFG)
 	@$(CC) $(CAIRO_CFLAGS) -c -DCAIRO_WIN32_STATIC_BUILD=1 -Fo"$@" $<
 
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index ce39de3..c1883b9 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -1,131 +1,131 @@
 # Generated by configure.  Do not edit.
 
-src/cairo-features.h: build/Makefile.win32.features
+$(top_srcdir)/src/cairo-features.h: $(top_srcdir)/build/Makefile.win32.features
 	@echo "Generating src/cairo-features.h"
-	@echo "/* Generated by Makefile.win32.  Do not edit. */" > src/cairo-features.h
-	@echo "#ifndef CAIRO_FEATURES_H" >> src/cairo-features.h
-	@echo "#define CAIRO_FEATURES_H 1" >> src/cairo-features.h
+	@echo "/* Generated by Makefile.win32.features-h.  Do not edit. */" > $(top_srcdir)/src/cairo-features.h
+	@echo "#ifndef CAIRO_FEATURES_H" >> $(top_srcdir)/src/cairo-features.h
+	@echo "#define CAIRO_FEATURES_H 1" >> $(top_srcdir)/src/cairo-features.h
 ifeq ($(CAIRO_HAS_XLIB_SURFACE),1)
-	@echo "#define CAIRO_HAS_XLIB_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XLIB_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_XLIB_XRENDER_SURFACE),1)
-	@echo "#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_XCB_SURFACE),1)
-	@echo "#define CAIRO_HAS_XCB_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XCB_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_XLIB_XCB_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_XLIB_XCB_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XLIB_XCB_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_XCB_SHM_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XCB_SHM_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_QT_SURFACE),1)
-	@echo "#define CAIRO_HAS_QT_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_QT_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_QUARTZ_SURFACE),1)
-	@echo "#define CAIRO_HAS_QUARTZ_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_QUARTZ_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_QUARTZ_FONT),1)
-	@echo "#define CAIRO_HAS_QUARTZ_FONT 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_QUARTZ_FONT 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_QUARTZ_IMAGE_SURFACE),1)
-	@echo "#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_WIN32_SURFACE),1)
-	@echo "#define CAIRO_HAS_WIN32_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_WIN32_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_WIN32_FONT),1)
-	@echo "#define CAIRO_HAS_WIN32_FONT 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_WIN32_FONT 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_SKIA_SURFACE),1)
-	@echo "#define CAIRO_HAS_SKIA_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_SKIA_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
-	@echo "#define CAIRO_HAS_OS2_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_OS2_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_BEOS_SURFACE),1)
-	@echo "#define CAIRO_HAS_BEOS_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_BEOS_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
-	@echo "#define CAIRO_HAS_DRM_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_DRM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_DRM_XR_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_DRM_XR_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_DRM_XR_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
-	@echo "#define CAIRO_HAS_GALLIUM_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_GALLIUM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_XCB_DRM_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_XCB_DRM_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XCB_DRM_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_GL_SURFACE),1)
-	@echo "#define CAIRO_HAS_GL_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_GL_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_GLESV2_SURFACE),1)
-	@echo "#define CAIRO_HAS_GLESV2_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_GLESV2_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_DIRECTFB_SURFACE),1)
-	@echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_DIRECTFB_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_VG_SURFACE),1)
-	@echo "#define CAIRO_HAS_VG_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_VG_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_EGL_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_EGL_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_EGL_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_GLX_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_GLX_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_GLX_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_WGL_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_WGL_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_WGL_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_SCRIPT_SURFACE),1)
-	@echo "#define CAIRO_HAS_SCRIPT_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_SCRIPT_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_FT_FONT),1)
-	@echo "#define CAIRO_HAS_FT_FONT 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_FT_FONT 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_FC_FONT),1)
-	@echo "#define CAIRO_HAS_FC_FONT 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_FC_FONT 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_PS_SURFACE),1)
-	@echo "#define CAIRO_HAS_PS_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_PS_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_PDF_SURFACE),1)
-	@echo "#define CAIRO_HAS_PDF_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_PDF_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_SVG_SURFACE),1)
-	@echo "#define CAIRO_HAS_SVG_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_SVG_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_TEST_SURFACES),1)
-	@echo "#define CAIRO_HAS_TEST_SURFACES 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_TEST_SURFACES 1" >> $(top_srcdir)/src/cairo-features.h
 endif
-	@echo "#define CAIRO_HAS_IMAGE_SURFACE 1" >> src/cairo-features.h
-	@echo "#define CAIRO_HAS_RECORDING_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_IMAGE_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
+	@echo "#define CAIRO_HAS_RECORDING_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 ifeq ($(CAIRO_HAS_TEE_SURFACE),1)
-	@echo "#define CAIRO_HAS_TEE_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_TEE_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_XML_SURFACE),1)
-	@echo "#define CAIRO_HAS_XML_SURFACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_XML_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
-	@echo "#define CAIRO_HAS_USER_FONT 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_USER_FONT 1" >> $(top_srcdir)/src/cairo-features.h
 ifeq ($(CAIRO_HAS_PTHREAD),1)
-	@echo "#define CAIRO_HAS_PTHREAD 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_PTHREAD 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_GOBJECT_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_GOBJECT_FUNCTIONS 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_GOBJECT_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_TRACE),1)
-	@echo "#define CAIRO_HAS_TRACE 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_TRACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_INTERPRETER),1)
-	@echo "#define CAIRO_HAS_INTERPRETER 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_INTERPRETER 1" >> $(top_srcdir)/src/cairo-features.h
 endif
 ifeq ($(CAIRO_HAS_SYMBOL_LOOKUP),1)
-	@echo "#define CAIRO_HAS_SYMBOL_LOOKUP 1" >> src/cairo-features.h
+	@echo "#define CAIRO_HAS_SYMBOL_LOOKUP 1" >> $(top_srcdir)/src/cairo-features.h
 endif
-	@echo "#endif" >>  src/cairo-features.h
+	@echo "#endif" >>  $(top_srcdir)/src/cairo-features.h
diff --git a/build/configure.ac.features b/build/configure.ac.features
index e1651d8..b4185a0 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -295,18 +295,18 @@ dnl Generate build/Makefile.win32.features-h that generates src/cairo-features.h
 CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32([win32_features_h],[build],[features-h])
 dnl
 CAIRO_MAKEFILE_ACCUMULATE([win32_features_h],
-[src/cairo-features.h: build/Makefile.win32.features
+[$(top_srcdir)/src/cairo-features.h: $(top_srcdir)/build/Makefile.win32.features
 	@echo "Generating src/cairo-features.h"
-	@echo "/* Generated by Makefile.win32.  Do not edit. */" > src/cairo-features.h
-	@echo "[#]ifndef CAIRO_FEATURES_H" >> src/cairo-features.h
-	@echo "[#]define CAIRO_FEATURES_H 1" >> src/cairo-features.h]dnl
+	@echo "/* Generated by Makefile.win32.features-h.  Do not edit. */" > $(top_srcdir)/src/cairo-features.h
+	@echo "[#]ifndef CAIRO_FEATURES_H" >> $(top_srcdir)/src/cairo-features.h
+	@echo "[#]define CAIRO_FEATURES_H 1" >> $(top_srcdir)/src/cairo-features.h]dnl
 )
 AC_CONFIG_COMMANDS_PRE(
 [dnl
-	CAIRO_MAKEFILE_ACCUMULATE([win32_features_h], [	@echo "[#]endif" >>  src/cairo-features.h])
+	CAIRO_MAKEFILE_ACCUMULATE([win32_features_h], [	@echo "[#]endif" >>  $(top_srcdir)/src/cairo-features.h])
 ])dnl
 CAIRO_MAKEFILE_ACCUMULATE_FEATURE([win32_features_h],yes,*,*,dnl
-[	@echo "[#]define cr_feature_tag 1" >> src/cairo-features.h]dnl
+[	@echo "[#]define cr_feature_tag 1" >> $(top_srcdir)/src/cairo-features.h]dnl
 )dnl
 
 
commit 101fab7cd8a90f7cf3d8113c792b3f8c2a9afb7d
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jun 15 11:37:36 2011 +0200

    win32-font: Improve static data reset function
    
    The hashtable is guaranteed to only contain font faces which are
    currently referenced, hence there is no need to remove any font face
    when it is reset (just like for toy-font).
    
    This makes the function simpler and fixes the assertion
    
    Assertion failed: predicate != NULL, file cairo-hash.c, line 373
    
    hit by multiple tests (the first one being "clear").
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=38049

diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 3477888..5bd5999 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -1985,32 +1985,18 @@ _cairo_win32_font_face_keys_equal (const void *key_a,
 static void
 _cairo_win32_font_face_hash_table_destroy (void)
 {
-    cairo_win32_font_face_t *font_face;
+    cairo_hash_table_t *hash_table;
 
+    /* We manually acquire the lock rather than calling
+     * _cairo_win32_font_face_hash_table_lock simply to avoid creating
+     * the table only to destroy it again. */
     CAIRO_MUTEX_LOCK (_cairo_win32_font_face_mutex);
-
-    if (cairo_win32_font_face_hash_table) {
-	/* This is rather inefficient, but destroying the hash table
-	 * is something we only do during debugging, (during
-	 * cairo_debug_reset_static_data), when efficiency is not
-	 * relevant. */
-        while (1) {
-	    font_face= _cairo_hash_table_random_entry (cairo_win32_font_face_hash_table,
-						       NULL);
-	    if (font_face == NULL)
-		break;
-	    _cairo_hash_table_remove (cairo_win32_font_face_hash_table,
-				      &font_face->base.hash_entry);
-
-	    cairo_font_face_destroy (&font_face->base);
-	}
-
-	_cairo_hash_table_destroy (cairo_win32_font_face_hash_table);
-
-	cairo_win32_font_face_hash_table = NULL;
-    }
-
+    hash_table = cairo_win32_font_face_hash_table;
+    cairo_win32_font_face_hash_table = NULL;
     CAIRO_MUTEX_UNLOCK (_cairo_win32_font_face_mutex);
+
+    if (hash_table != NULL)
+	_cairo_hash_table_destroy (hash_table);
 }
 
 static cairo_hash_table_t *
commit 94bc20da50c5984e5c04929a7fde4c2f04e66380
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Fri Jun 17 19:15:44 2011 +0200

    win32-font: Implement destroy function
    
    Win32 font faces can be removed from the hashtable upon destruction.
    Based on the toy-font destruction code.
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=38049

diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index f796f21..3477888 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -149,6 +149,10 @@ static cairo_status_t
 _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font,
 					  cairo_scaled_glyph_t      *scaled_glyph);
 
+static void
+_cairo_win32_font_face_destroy (void *abstract_face);
+
+
 #define NEARLY_ZERO(d) (fabs(d) < (1. / 65536.))
 
 static HDC
@@ -1920,11 +1924,6 @@ struct _cairo_win32_font_face {
 
 /* implement the platform-specific interface */
 
-static void
-_cairo_win32_font_face_destroy (void *abstract_face)
-{
-}
-
 static cairo_bool_t
 _is_scale (const cairo_matrix_t *matrix, double scale)
 {
@@ -2041,6 +2040,37 @@ _cairo_win32_font_face_hash_table_unlock (void)
 }
 
 static void
+_cairo_win32_font_face_destroy (void *abstract_face)
+{
+    cairo_win32_font_face_t *font_face = abstract_face;
+    cairo_hash_table_t *hash_table;
+
+    if (font_face == NULL ||
+	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->base.ref_count))
+	return;
+
+    hash_table = _cairo_win32_font_face_hash_table_lock ();
+    /* All created objects must have been mapped in the hash table. */
+    assert (hash_table != NULL);
+
+    if (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&font_face->base.ref_count)) {
+	/* somebody recreated the font whilst we waited for the lock */
+	_cairo_win32_font_face_hash_table_unlock ();
+	return;
+    }
+
+    /* Font faces in SUCCESS status are guaranteed to be in the
+     * hashtable. Font faces in an error status are removed from the
+     * hashtable if they are found during a lookup, thus they should
+     * only be removed if they are in the hashtable. */
+    if (likely (font_face->base.status == CAIRO_STATUS_SUCCESS) ||
+	_cairo_hash_table_lookup (hash_table, &font_face->base.hash_entry) == font_face)
+	_cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
+
+    _cairo_win32_font_face_hash_table_unlock ();
+}
+
+static void
 _cairo_win32_font_face_init_key (cairo_win32_font_face_t *key,
 				 LOGFONTW                *logfont,
 				 HFONT                    font)
commit 94b14c929d75408958d4451253251fb3631a09bf
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Fri Jun 17 16:30:45 2011 +0200

    win32-font: Do not return font in error status
    
    If the hashtable cointains a font matching the font being created,
    only reuse it if it is not in an error status. Otherwise, remove it
    from teh hashtable and create a new one.

diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index d0c29bb..f796f21 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -2116,8 +2116,14 @@ cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont, HFONT font)
     font_face = _cairo_hash_table_lookup (hash_table,
 					 &key.base.hash_entry);
     if (font_face != NULL) {
-	cairo_font_face_reference (&font_face->base);
-	goto DONE;
+	if (font_face->base.status == CAIRO_STATUS_SUCCESS) {
+	    cairo_font_face_reference (&font_face->base);
+	    _cairo_win32_font_face_hash_table_unlock ();
+	    return &font_face->base;
+	}
+
+	/* remove the bad font from the hash table */
+	_cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
     }
 
     /* Otherwise create it and insert into hash table. */
commit b9d9ca281c9b686ea6df2b211b6100095640063e
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jun 15 10:31:53 2011 +0200

    Avoid deprecated functions on win32
    
    Some POSIX functions are deprecated in MSVC and should instead be used
    with an alternative name beginning with '_'.

diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h
index e25ee1f..fe1d1d4 100644
--- a/src/cairo-compiler-private.h
+++ b/src/cairo-compiler-private.h
@@ -203,10 +203,15 @@
 #endif
 
 #if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER)
-#define snprintf _snprintf
-#define popen _popen
-#define pclose _pclose
+#define access _access
+#define fdopen _fdopen
 #define hypot _hypot
+#define pclose _pclose
+#define popen _popen
+#define snprintf _snprintf
+#define strdup _strdup
+#define unlink _unlink
+#define vsnprintf _vsnprintf
 #endif
 
 #ifdef _MSC_VER
diff --git a/test/cairo-test.c b/test/cairo-test.c
index b438e07..3d834c2 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -73,9 +73,6 @@
 
 #ifdef _MSC_VER
 #include <crtdbg.h>
-#define vsnprintf _vsnprintf
-#define access _access
-#define unlink _unlink
 #define F_OK 0
 #endif
 
commit 00a5a136123cf2b66c5e8fc9fb5d20feffbd4dcd
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jun 15 10:34:03 2011 +0200

    boilerplate: Silence MSVC warnings
    
    On Win32 INT_MIN/MAX macros are defined in stdint.h, which makes MSVC
    complain about the following redefinitions:
    
    ...\stdint.h(73) : warning C4005: 'INT16_MIN' : macro redefinition
    ...\boilerplate\cairo-boilerplate.h(64) : see previous definition of 'INT16_MIN'
    ...\stdint.h(77) : warning C4005: 'INT16_MAX' : macro redefinition
    ...\cairo-boilerplate.h(67) : see previous definition of 'INT16_MAX'
    ...\stdint.h(80) : warning C4005: 'UINT16_MAX' : macro redefinition
    ...\boilerplate\cairo-boilerplate.h(70) : see previous definition of 'UINT16_MAX'

diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index d145a1e..0615221 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -45,6 +45,7 @@
 #elif HAVE_SYS_INT_TYPES_H
 # include <sys/int_types.h>
 #elif defined(_MSC_VER)
+# include <stdint.h>
   typedef __int8 int8_t;
   typedef unsigned __int8 uint8_t;
   typedef __int16 int16_t;
commit cbf11fa26109a6c725c7d7a356d4acc16a7be0e2
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Fri Jun 17 16:29:00 2011 +0200

    toy-font: Do not open-code cairo_font_face_reference ()
    
    Since 03be41151d06d48d55bc1e172535829ec45a10cf, it is safe to use
    cairo_font_face_reference () to increment the reference count of a
    font taken from the hashtable, because no mutex is being locked twice.

diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index b82d8b0..e82d535 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -302,9 +302,7 @@ cairo_toy_font_face_create (const char          *family,
 					  &key.base.hash_entry);
     if (font_face != NULL) {
 	if (font_face->base.status == CAIRO_STATUS_SUCCESS) {
-	    /* We increment the reference count here manually to avoid
-	       double-locking. */
-	    _cairo_reference_count_inc (&font_face->base.ref_count);
+	    cairo_font_face_reference (&font_face->base);
 	    _cairo_toy_font_face_hash_table_unlock ();
 	    return &font_face->base;
 	}


More information about the cairo-commit mailing list