You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-python/pycairo/files/py2cairo-1.10.0-svg_check.p...

127 lines
2.8 KiB

--- src/cairomodule.c
+++ src/cairomodule.c
@@ -127,7 +127,7 @@
#else
0,
#endif
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
&PycairoSVGSurface_Type,
#else
0,
@@ -223,7 +223,7 @@
if (PyType_Ready(&PycairoPSSurface_Type) < 0)
return;
#endif
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
if (PyType_Ready(&PycairoSVGSurface_Type) < 0)
return;
#endif
@@ -305,7 +305,7 @@
PyModule_AddObject(m, "PSSurface", (PyObject *)&PycairoPSSurface_Type);
#endif
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
Py_INCREF(&PycairoSVGSurface_Type);
PyModule_AddObject(m, "SVGSurface", (PyObject *)&PycairoSVGSurface_Type);
#endif
@@ -379,7 +379,7 @@
#else
PyModule_AddIntConstant(m, "HAS_PS_SURFACE", 0);
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 1);
#else
PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 0);
--- src/private.h
+++ src/private.h
@@ -86,7 +86,7 @@
extern PyTypeObject PycairoPSSurface_Type;
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
extern PyTypeObject PycairoSVGSurface_Type;
#endif
--- src/pycairo.h
+++ src/pycairo.h
@@ -182,7 +182,7 @@
#define PycairoPSSurface_Type *(Pycairo_CAPI->PSSurface_Type)
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
#define PycairoSVGSurface_Type *(Pycairo_CAPI->SVGSurface_Type)
#endif
--- src/surface.c
+++ src/surface.c
@@ -83,7 +83,7 @@
type = &PycairoPSSurface_Type;
break;
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
case CAIRO_SURFACE_TYPE_SVG:
type = &PycairoSVGSurface_Type;
break;
@@ -1015,7 +1015,7 @@
/* Class SVGSurface(Surface) ----------------------------------------------- */
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
#include <cairo-svg.h>
static PyObject *
@@ -1125,7 +1125,7 @@
0, /* tp_is_gc */
0, /* tp_bases */
};
-#endif /* CAIRO_HAS_SVG_SURFACE */
+#endif /* PYCAIRO_ENABLE_SVG */
#if CAIRO_HAS_WIN32_SURFACE
--- wscript
+++ wscript
@@ -1,6 +1,7 @@
# -*- python -*-
import os
+import subprocess
top = '.'
out = 'build_directory'
@@ -11,6 +12,17 @@
cairo_version_required = '1.10.0'
+def check_svg():
+ if os.environ.get('PYCAIRO_DISABLE_SVG', None) is None:
+ return_code = subprocess.call(['pkg-config', '--exists', 'cairo-svg'])
+ if return_code == 0:
+ return True
+ else:
+ return False
+ else:
+ return False
+
+
def options(ctx):
print(' %s/options()' %d)
ctx.tool_options('gnu_dirs')
@@ -39,6 +51,8 @@
ctx.define('PYCAIRO_VERSION_MAJOR', version[0])
ctx.define('PYCAIRO_VERSION_MINOR', version[1])
ctx.define('PYCAIRO_VERSION_MICRO', version[2])
+ if check_svg():
+ ctx.define('PYCAIRO_ENABLE_SVG', 1)
ctx.write_config_header('src/config.h')