From 42d0b172555fe79e2d60e8bca6d651e34008b30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20Schr=C3=B6der?= <430662-kai.schroeder@users.noreply.gitlab.com> Date: Sat, 30 Apr 2022 15:04:04 +0200 Subject: [PATCH] fixed build of 2D graphics library Cairo on Windows (MS Visual Studio Code) - avoid continous rebuild (changed git reference from tag to commit hash) - chaining operator && not working correctly in PATCH_COMMAND -> splitted in two CMake COMMANDs - mintty started in users home so output of configure (started by autogen.sh) was not found by BUILD_COMMAND -> added --dir ${CAIRO_SOURCE_DIR} - moved duplicate autogen.sh arguments to CAIRO_AUTOGEN_ARGS variable - fixed whitespace errors brought in by packaging/cairo.patch --- packaging/cairo.patch | 18 ++++++++---------- src/3rdparty/CMakeLists.txt | 32 ++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/packaging/cairo.patch b/packaging/cairo.patch index dc92e263a3..b04b952cdc 100644 --- a/packaging/cairo.patch +++ b/packaging/cairo.patch @@ -28,14 +28,14 @@ index 293d4e30e..a22cca729 100644 bytes, sizeof(uint32_t)*width); if (unlikely (image == NULL)) { diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c -index c56845ab2..274f43df7 100644 +index c56845ab2..dd612c064 100644 --- a/src/cairo-image-source.c +++ b/src/cairo-image-source.c @@ -383,6 +383,30 @@ _pixman_image_for_gradient (const cairo_gradient_pattern_t *pattern, pixman_image_set_repeat (pixman_image, pixman_repeat); } -+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,39,0) ++#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,39,0) + { + pixman_dither_t pixman_dither; + @@ -278,12 +278,12 @@ index 567c5d4d5..24af125da 100644 * the source pattern will get fixed up for the appropriate target surface * device offsets, so we want to set our own surface offsets from /that/, diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c -index 274f43df7..93daff3c0 100644 +index dd612c064..93daff3c0 100644 --- a/src/cairo-image-source.c +++ b/src/cairo-image-source.c @@ -385,24 +385,8 @@ _pixman_image_for_gradient (const cairo_gradient_pattern_t *pattern, } - #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,39,0) + #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,39,0) { - pixman_dither_t pixman_dither; - @@ -348,7 +348,7 @@ index 2b7921133..c06b9737b 100644 #define to_image_surface(S) ((cairo_image_surface_t *)(S)) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c -index 3b11eb981..977bb48e6 100644 +index 3b11eb981..cee9e6052 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -169,6 +169,7 @@ _cairo_image_surface_init (cairo_image_surface_t *surface, @@ -424,7 +424,7 @@ index 3b11eb981..977bb48e6 100644 clone->owns_data = TRUE; return &clone->base; -@@ -1361,3 +1406,25 @@ error: +@@ -1361,3 +1406,24 @@ error: cairo_surface_destroy (image); return to_image_surface (_cairo_surface_create_in_error (status)); } @@ -449,7 +449,6 @@ index 3b11eb981..977bb48e6 100644 + +} +//slim_hidden_def (cairo_image_surface_set_dither); -+ diff --git a/src/cairo.h b/src/cairo.h index 1c911d09d..76db87d2e 100644 --- a/src/cairo.h @@ -529,7 +528,7 @@ Subject: [PATCH 3/3] make lint tests pass 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c -index 977bb48e6..d2f544a68 100644 +index 977bb48e6..977bb48e6 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -250,8 +250,9 @@ _pixman_format_from_masks (cairo_format_masks_t *masks, @@ -578,13 +577,12 @@ index 977bb48e6..d2f544a68 100644 cairo_public int cairo_image_surface_set_dither (cairo_surface_t *surface, cairo_dither_t dither) { -@@ -1426,5 +1436,5 @@ cairo_image_surface_set_dither (cairo_surface_t *surface, cairo_dither_t dither) +@@ -1426,4 +1436,4 @@ cairo_image_surface_set_dither (cairo_surface_t *surface, cairo_dither_t dither) } } -//slim_hidden_def (cairo_image_surface_set_dither); +slim_hidden_def (cairo_image_surface_set_dither); - diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 6cf907f36..7d05b06a1 100644 --- a/src/cairo-pattern.c diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index 2f94cf56eb..ebfa4948e6 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -11,23 +11,31 @@ endif() if(WITH_INTERNAL_CAIRO) include(ExternalProject) + + set(CAIRO_AUTOGEN_ARGS --prefix=${CMAKE_INSTALL_PREFIX} --disable-trace --disable-interpreter --libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + set(CAIRO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cairo) if(WIN32) - execute_process( - COMMAND cygpath "${CMAKE_CURRENT_SOURCE_DIR}/cairo/autogen.sh" - OUTPUT_VARIABLE AUTOGEN_PATH + execute_process( + COMMAND cygpath "${CAIRO_SOURCE_DIR}/autogen.sh" + OUTPUT_VARIABLE CAIRO_AUTOGEN_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE ) - set(CAIRO_CONF mintty.exe -w hide /bin/env MSYSTEM=$ENV{MSYSTEM} LDFLAGS=-lssp /bin/bash -l ${AUTOGEN_PATH} --prefix=${CMAKE_INSTALL_PREFIX} --disable-trace --disable-script-interpreter --libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} && make clean) - else() - set(CAIRO_CONF "${CMAKE_CURRENT_SOURCE_DIR}/cairo/autogen.sh" --prefix=${CMAKE_INSTALL_PREFIX} --disable-trace --disable-script-interpreter --libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} && make clean) - endif() + set(CAIRO_CONFIGURE_CMD mintty.exe -w hide --dir ${CAIRO_SOURCE_DIR} -e /bin/env MSYSTEM=$ENV{MSYSTEM} LDFLAGS=-lssp /bin/bash -l ${CAIRO_AUTOGEN_PATH} ${CAIRO_AUTOGEN_ARGS}) + else() + set(CAIRO_CONFIGURE_CMD "${CAIRO_SOURCE_DIR}/autogen.sh" ${CAIRO_AUTOGEN_ARGS}) + endif() + ExternalProject_Add(cairo_ext PREFIX cairo + SOURCE_DIR ${CAIRO_SOURCE_DIR} GIT_REPOSITORY https://gitlab.freedesktop.org/cairo/cairo.git - GIT_TAG 1.17.6 + GIT_TAG b43e7c6f3cf7855e16170a06d3a9c7234c60ca94 GIT_SHALLOW TRUE - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cairo - PATCH_COMMAND git checkout ${CMAKE_CURRENT_SOURCE_DIR}/cairo/src && git apply --unsafe-paths --directory ${CMAKE_CURRENT_SOURCE_DIR}/cairo/ ${CMAKE_SOURCE_DIR}/packaging/cairo.patch + UPDATE_COMMAND "" + PATCH_COMMAND git checkout ${CAIRO_SOURCE_DIR} + COMMAND git apply --unsafe-paths --directory ${CAIRO_SOURCE_DIR}/ ${CMAKE_SOURCE_DIR}/packaging/cairo.patch + CONFIGURE_COMMAND ${CAIRO_CONFIGURE_CMD} + BINARY_DIR ${CAIRO_SOURCE_DIR} BUILD_COMMAND make -j16 - CONFIGURE_COMMAND ${CAIRO_CONF} - ) + ) endif() -- GitLab