summaryrefslogtreecommitdiff
path: root/dev-python/pycairo/files/py2cairo-1.10.0-svg_check.patch
blob: 4cd755c8d5747ac19d54a9c29dd11f6a82f09324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--- 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')