Make cairo components conditional on the relevant libaries etc existing.

This commit is contained in:
Tom Hughes 2008-03-12 19:14:51 +00:00
parent 06006d2f24
commit 2f67c036fe
5 changed files with 32 additions and 5 deletions

View file

@ -124,7 +124,9 @@ for prereq in ('BOOST', 'PNG', 'JPEG', 'TIFF', 'PGSQL', 'PROJ', 'GDAL',):
env.ParseConfig(env['FREETYPE_CONFIG'] + ' --libs --cflags')
if env.Execute('pkg-config --exists cairomm-1.0') == 0:
env.ParseConfig('pkg-config --libs --cflags cairomm-1.0')
env.Append(CXXFLAGS = '-DHAVE_CAIRO');
if env['XMLPARSER'] == 'tinyxml':
env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL')

View file

@ -25,7 +25,9 @@ import os
Import('env')
if env.Execute('pkg-config --exists pycairo') == 0:
env.ParseConfig('pkg-config --cflags pycairo')
env.Append(CXXFLAGS = '-DHAVE_PYCAIRO');
prefix = env['PYTHON_PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
install_prefix = env['DESTDIR'] + '/' + prefix

View file

@ -58,14 +58,18 @@ void export_projection();
#include <mapnik/map.hpp>
#include <mapnik/agg_renderer.hpp>
#ifdef HAVE_CAIRO
#include <mapnik/cairo_renderer.hpp>
#endif
#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/save_map.hpp>
#ifdef HAVE_PYCAIRO
#include <pycairo.h>
#endif
void render(const mapnik::Map& map,mapnik::Image32& image, unsigned offset_x = 0, unsigned offset_y = 0)
{
@ -79,6 +83,8 @@ void render2(const mapnik::Map& map,mapnik::Image32& image)
ren.apply();
}
#ifdef HAVE_PYCAIRO
void render3(const mapnik::Map& map,PycairoSurface* surface, unsigned offset_x = 0, unsigned offset_y = 0)
{
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
@ -93,6 +99,8 @@ void render4(const mapnik::Map& map,PycairoSurface* surface)
ren.apply();
}
#endif
void render_tile_to_file(const mapnik::Map& map,
unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height,
@ -176,8 +184,10 @@ BOOST_PYTHON_MODULE(_mapnik)
def("render_tile_to_file",&render_tile_to_file);
def("render",&render);
def("render",&render2);
#ifdef HAVE_PYCAIRO
def("render",&render3);
def("render",&render4);
#endif
def("scale_denominator", &scale_denominator);
def("load_map", & load_map, load_map_overloads());

View file

@ -21,6 +21,8 @@
*****************************************************************************/
//$Id$
#ifdef HAVE_PYCAIRO
#include <boost/python/type_id.hpp>
#include <boost/python/converter/registry.hpp>
@ -46,3 +48,11 @@ void register_cairo()
boost::python::converter::registry::insert(&extract_surface, boost::python::type_id<PycairoSurface>());
}
#else
void register_cairo()
{
}
#endif

View file

@ -43,7 +43,6 @@ else: # Linux and others
source = Split(
"""
agg_renderer.cpp
cairo_renderer.cpp
datasource_cache.cpp
envelope.cpp
filter_factory.cpp
@ -79,7 +78,11 @@ source = Split(
"""
)
#source.append("cairo_renderer.cpp")
if 'cairo' in env['LIBS']:
source += Split(
"""
cairo_renderer.cpp
""")
if env['XMLPARSER'] == 'tinyxml':
source += Split(