Skip to content

Commit

Permalink
Merge pull request mapnik#295 from mapnik/clang
Browse files Browse the repository at this point in the history
Clang
  • Loading branch information
Dane Springmeyer committed Aug 14, 2014
2 parents 7a7042b + 5143403 commit 27548dc
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ os:
- osx

compiler:
- gcc
- clang

env:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"dependencies" : {
"nan": "~1.2.0",
"mapnik-vector-tile": "~0.5.1",
"mapnik-vector-tile": "~0.5.2",
"node-pre-gyp": "0.5.23"
},
"bundledDependencies": [
Expand Down
44 changes: 19 additions & 25 deletions scripts/build_against_sdk.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash
set -u -e

: '
On linux depends on node and:
sudo apt-get update
sudo apt-get install pkg-config build-essential zlib1g-dev
'

ARGS=""
CURRENT_DIR="$( cd "$( dirname $BASH_SOURCE )" && pwd )"
mkdir -p $CURRENT_DIR/../sdk
Expand All @@ -25,42 +25,35 @@ function upgrade_gcc {
echo "adding gcc-4.8 ppa"
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
echo "updating apt"
sudo apt-get update -y
sudo apt-get update -y -qq
echo "installing C++11 compiler"
sudo apt-get install -y gcc-4.8 g++-4.8
if [[ "${CXX#*'clang'}" == "$CXX" ]]; then
export CC="gcc-4.8"
export CXX="g++-4.8"
fi
}

COMPRESSION="tar.bz2"
SDK_URI="http://mapnik.s3.amazonaws.com/dist/dev"
platform=$(echo $UNAME | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/")

if [[ "${CXX11:-false}" != false ]]; then
# mapnik 3.x / c++11 enabled
HASH="1545-gb172129-cpp11"
if [[ $UNAME == 'Linux' ]]; then
export STDLIB="libstdcpp"
export CXX_NAME="gcc-4.8"
export CC="gcc-4.8";
export CXX="g++-4.8";
HASH="1662-gb415549"
if [[ ${platform} == 'linux' ]]; then
upgrade_gcc
else
export STDLIB="libcpp"
export CXX_NAME="clang-3.3"
fi
else
# mapnik 2.3.x / c++11 not enabled
HASH="546-gdd02192-cpp03"
export STDLIB="libstdcpp"
if [[ $UNAME == 'Linux' ]]; then
export CXX_NAME="gcc-4.6"
else
export CXX_NAME="clang-3.3"
fi
HASH="577-ga616e9d"
fi

platform=$(echo $UNAME | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/")
if [[ $platform == 'darwin' ]]; then
platform="macosx"
fi
SDK_URI="http://mapnik.s3.amazonaws.com/dist/dev"
COMPRESSION="tar.bz2"
TARBALL_NAME="mapnik-${platform}-sdk-v2.2.0-${HASH}-${STDLIB}-${CXX_NAME}"

TARBALL_NAME="mapnik-${platform}-sdk-v2.2.0-${HASH}"
REMOTE_URI="${SDK_URI}/${TARBALL_NAME}.${COMPRESSION}"
export MAPNIK_SDK=${BUILD_DIR}/${TARBALL_NAME}
export PATH=${MAPNIK_SDK}/bin:${PATH}
Expand Down Expand Up @@ -93,19 +86,20 @@ if [[ ! `which node` ]]; then
fi

if [[ $UNAME == 'Linux' ]]; then
export CXXFLAGS="-Wno-unused-local-typedefs"
readelf -d $MAPNIK_SDK/lib/libmapnik.so
#sudo apt-get install chrpath -y
#chrpath -r '$ORIGIN/' ${MAPNIK_SDK}/lib/libmapnik.so
export LDFLAGS='-Wl,-z,origin -Wl,-rpath=\$$ORIGIN'
else
otool -L $MAPNIK_SDK/lib/libmapnik.dylib
fi

cd ../
npm install node-pre-gyp
MODULE_PATH=$(node-pre-gyp reveal module_path ${ARGS})
# note: dangerous!
rm -rf ${MODULE_PATH}
npm install --build-from-source ${ARGS}
npm install --build-from-source ${ARGS} --clang=1
npm ls
# copy lib
cp ${MAPNIK_SDK}/lib/libmapnik.* ${MODULE_PATH}
Expand Down
5 changes: 4 additions & 1 deletion src/ds_emitter.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __NODE_MAPNIK_DS_EMITTER_H__
#define __NODE_MAPNIK_DS_EMITTER_H__

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

#include "utils.hpp"

// mapnik
Expand Down Expand Up @@ -146,7 +149,7 @@ static void datasource_features(Local<Array> a, mapnik::datasource_ptr ds, unsig
node_mapnik::params_to_object serializer( feat , MAPNIK_GET<0>(*f_itr));
// need to call base() since this is a mapnik::value
// not a mapnik::value_holder
boost::apply_visitor( serializer, MAPNIK_GET<1>(*f_itr).base() );
MAPNIK_APPLY_VISITOR( serializer, MAPNIK_GET<1>(*f_itr).base() );
}
// add feature id
feat->Set(NanNew("__id__"), NanNew<Number>(fp->id()));
Expand Down
5 changes: 4 additions & 1 deletion src/js_grid_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __NODE_MAPNIK_GRID_UTILS_H__
#define __NODE_MAPNIK_GRID_UTILS_H__

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

// mapnik
#include <mapnik/feature.hpp> // for feature_impl, etc
#include <mapnik/grid/grid.hpp> // for grid
Expand Down Expand Up @@ -138,7 +141,7 @@ static void write_features(T const& grid_type,
found = true;
mapnik::feature_impl::value_type const& attr_val = feature->get(attr);
feat->Set(NanNew(attr.c_str()),
boost::apply_visitor(node_mapnik::value_converter(),
MAPNIK_APPLY_VISITOR(node_mapnik::value_converter(),
attr_val.base()));
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/mapnik_datasource.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

#include "mapnik_datasource.hpp"
#include "mapnik_featureset.hpp"
#include "utils.hpp"
Expand Down Expand Up @@ -157,7 +161,7 @@ NAN_METHOD(Datasource::parameters)
for (; it != end; ++it)
{
node_mapnik::params_to_object serializer( ds , it->first);
boost::apply_visitor( serializer, it->second );
MAPNIK_APPLY_VISITOR( serializer, it->second );
}
NanReturnValue(ds);
}
Expand Down
7 changes: 5 additions & 2 deletions src/mapnik_expression.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifdef NODE_MAPNIK_EXPRESSION

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

#include "utils.hpp"
#include "mapnik_expression.hpp"
#include "mapnik_feature.hpp"
Expand Down Expand Up @@ -122,8 +125,8 @@ NAN_METHOD(Expression::evaluate)
Feature* f = node::ObjectWrap::Unwrap<Feature>(obj);

Expression* e = node::ObjectWrap::Unwrap<Expression>(args.Holder());
mapnik::value value_obj = boost::apply_visitor(mapnik::evaluate<mapnik::Feature,mapnik::value>(*(f->get())),*(e->get()));
NanReturnValue(boost::apply_visitor(node_mapnik::value_converter(),value_obj.base()));
mapnik::value value_obj = MAPNIK_APPLY_VISITOR(mapnik::evaluate<mapnik::Feature,mapnik::value>(*(f->get())),*(e->get()));
NanReturnValue(MAPNIK_APPLY_VISITOR(node_mapnik::value_converter(),value_obj.base()));
}

#endif
7 changes: 6 additions & 1 deletion src/mapnik_feature.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE


#include "utils.hpp"
#include "mapnik_feature.hpp"
#include "mapnik_geometry.hpp"
Expand Down Expand Up @@ -141,7 +146,7 @@ NAN_METHOD(Feature::attributes)
for ( ;itr!=end; ++itr)
{
node_mapnik::params_to_object serializer( feat , MAPNIK_GET<0>(*itr));
boost::apply_visitor( serializer, MAPNIK_GET<1>(*itr).base() );
MAPNIK_APPLY_VISITOR( serializer, MAPNIK_GET<1>(*itr).base() );
}
NanReturnValue(feat);
}
Expand Down
6 changes: 5 additions & 1 deletion src/mapnik_image.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

// mapnik
#include <mapnik/color.hpp> // for color
#include <mapnik/graphics.hpp> // for image_32
Expand Down Expand Up @@ -1301,7 +1305,7 @@ void Image::EIO_Composite(uv_work_t* req)
mapnik::filter::filter_visitor<mapnik::image_32> visitor(*closure->im2->this_);
BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, closure->filters)
{
boost::apply_visitor(visitor, filter_tag);
MAPNIK_APPLY_VISITOR(visitor, filter_tag);
}
}
mapnik::composite(closure->im1->this_->data(),closure->im2->this_->data(), closure->mode, closure->opacity, closure->dx, closure->dy);
Expand Down
5 changes: 4 additions & 1 deletion src/mapnik_layer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

#include "mapnik_layer.hpp"

#include "utils.hpp" // for TOSTR, ATTR, etc
Expand Down Expand Up @@ -280,7 +283,7 @@ NAN_METHOD(Layer::describe)
for (; it != end; ++it)
{
node_mapnik::params_to_object serializer( ds , it->first);
boost::apply_visitor( serializer, it->second );
MAPNIK_APPLY_VISITOR( serializer, it->second );
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/mapnik_map.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

#include "mapnik_map.hpp"
#include "utils.hpp"
#include "mapnik_color.hpp" // for Color, Color::constructor
Expand Down Expand Up @@ -229,7 +233,7 @@ NAN_GETTER(Map::get_prop)
for (; it != end; ++it)
{
node_mapnik::params_to_object serializer( ds , it->first);
boost::apply_visitor( serializer, it->second );
MAPNIK_APPLY_VISITOR( serializer, it->second );
}
NanReturnValue(ds);
}
Expand Down
6 changes: 5 additions & 1 deletion src/mapnik_memory_datasource.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

// mapnik
#include <mapnik/version.hpp>
#include <mapnik/unicode.hpp>
Expand Down Expand Up @@ -122,7 +126,7 @@ NAN_METHOD(MemoryDatasource::parameters)
for (; it != end; ++it)
{
node_mapnik::params_to_object serializer( ds , it->first);
boost::apply_visitor( serializer, it->second );
MAPNIK_APPLY_VISITOR( serializer, it->second );
}
}
NanReturnValue(ds);
Expand Down
10 changes: 5 additions & 5 deletions src/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __NODE_MAPNIK_UTILS_H__
#define __NODE_MAPNIK_UTILS_H__

#include "mapnik3x_compatibility.hpp"
#include MAPNIK_VARIANT_INCLUDE

// nan
#include <nan.h>

Expand All @@ -13,9 +16,6 @@
#include <mapnik/value.hpp>
#include <mapnik/version.hpp>

// boost
#include <boost/variant/static_visitor.hpp>

#define TOSTR(obj) (*String::Utf8Value((obj)->ToString()))

#define FUNCTION_ARG(I, VAR) \
Expand Down Expand Up @@ -52,7 +52,7 @@ namespace node_mapnik {
#endif

// adapted to work for both mapnik features and mapnik parameters
struct params_to_object : public boost::static_visitor<>
struct params_to_object : public MAPNIK_STATIC_VISITOR<>
{
public:
params_to_object( Local<Object>& ds, std::string key):
Expand Down Expand Up @@ -97,7 +97,7 @@ struct params_to_object : public boost::static_visitor<>
std::string key_;
};

struct value_converter: public boost::static_visitor<Handle<Value> >
struct value_converter: public MAPNIK_STATIC_VISITOR<Handle<Value> >
{
Handle<Value> operator () ( value_integer val ) const
{
Expand Down

0 comments on commit 27548dc

Please sign in to comment.