Merge branch 'master' into develop

This commit is contained in:
artemp 2016-09-12 12:59:34 +02:00
commit 46fe1d6f4a
8 changed files with 245 additions and 69 deletions

View file

@ -8,9 +8,9 @@ For a complete change history, see the git log.
## 3.0.12
Released: xx-xx-xx
Released: September 8, 2016
(Packaged from xxxxxx)
(Packaged from 1d22d86)
#### Summary
@ -43,6 +43,8 @@ Released: xx-xx-xx
- BuildingSymbolizer - fixed closing segment of polygon in building symbolizer (ref #3505)
- Update dependencies versions
- Fixed warnings when compiling with g++5
- Fixed image swap (ref #3513)
- Stop bundling testdata in source tarball (ref #3335)
## 3.0.11

View file

@ -18,6 +18,9 @@ install:
release:
./scripts/publish_release.sh
test-release:
./scripts/test_release.sh
python:
if [ ! -d ./bindings/python ]; then git clone git@github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
make

View file

@ -76,7 +76,6 @@ public:
private:
detail::image_dimensions<65535> dimensions_;
detail::buffer buffer_;
pixel_type *pData_;
double offset_;
double scaling_;
bool premultiplied_alpha_;

View file

@ -62,7 +62,6 @@ template <typename T>
image<T>::image()
: dimensions_(0,0),
buffer_(0),
pData_(nullptr),
offset_(0.0),
scaling_(1.0),
premultiplied_alpha_(false),
@ -73,7 +72,6 @@ template <typename T>
image<T>::image(int width, int height, unsigned char* data, bool premultiplied, bool painted)
: dimensions_(width, height),
buffer_(data, width * height * sizeof(pixel_size)),
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
offset_(0.0),
scaling_(1.0),
premultiplied_alpha_(premultiplied),
@ -83,15 +81,14 @@ template <typename T>
image<T>::image(int width, int height, bool initialize, bool premultiplied, bool painted)
: dimensions_(width, height),
buffer_(dimensions_.width() * dimensions_.height() * pixel_size),
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
offset_(0.0),
scaling_(1.0),
premultiplied_alpha_(premultiplied),
painted_(painted)
{
if (pData_ && initialize)
if (initialize)
{
std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), 0);
std::fill(begin(), end(), 0);
}
}
@ -99,7 +96,6 @@ template <typename T>
image<T>::image(image<T> const& rhs)
: dimensions_(rhs.dimensions_),
buffer_(rhs.buffer_),
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
offset_(rhs.offset_),
scaling_(rhs.scaling_),
premultiplied_alpha_(rhs.premultiplied_alpha_),
@ -109,14 +105,12 @@ template <typename T>
image<T>::image(image<T> && rhs) noexcept
: dimensions_(std::move(rhs.dimensions_)),
buffer_(std::move(rhs.buffer_)),
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
offset_(rhs.offset_),
scaling_(rhs.scaling_),
premultiplied_alpha_(rhs.premultiplied_alpha_),
painted_(rhs.painted_)
{
rhs.dimensions_ = { 0, 0 };
rhs.pData_ = nullptr;
}
template <typename T>
@ -153,14 +147,14 @@ template <typename T>
inline typename image<T>::pixel_type& image<T>::operator() (std::size_t i, std::size_t j)
{
assert(i < dimensions_.width() && j < dimensions_.height());
return pData_[j * dimensions_.width() + i];
return *get_row(j, i);
}
template <typename T>
inline const typename image<T>::pixel_type& image<T>::operator() (std::size_t i, std::size_t j) const
{
assert(i < dimensions_.width() && j < dimensions_.height());
return pData_[j * dimensions_.width() + i];
return *get_row(j, i);
}
template <typename T>
@ -190,19 +184,19 @@ inline std::size_t image<T>::row_size() const
template <typename T>
inline void image<T>::set(pixel_type const& t)
{
std::fill(pData_, pData_ + dimensions_.width() * dimensions_.height(), t);
std::fill(begin(), end(), t);
}
template <typename T>
inline const typename image<T>::pixel_type* image<T>::data() const
{
return pData_;
return reinterpret_cast<const pixel_type*>(buffer_.data());
}
template <typename T>
inline typename image<T>::pixel_type* image<T>::data()
{
return pData_;
return reinterpret_cast<pixel_type*>(buffer_.data());
}
template <typename T>
@ -219,40 +213,40 @@ inline unsigned char* image<T>::bytes()
// iterator interface
template <typename T>
inline typename image<T>::iterator image<T>::begin() { return pData_; }
inline typename image<T>::iterator image<T>::begin() { return data(); }
template <typename T>
inline typename image<T>::iterator image<T>::end() { return pData_ + dimensions_.width() * dimensions_.height(); }
inline typename image<T>::iterator image<T>::end() { return data() + dimensions_.width() * dimensions_.height(); }
template <typename T>
inline typename image<T>::const_iterator image<T>::begin() const { return pData_; }
inline typename image<T>::const_iterator image<T>::begin() const { return data(); }
template <typename T>
inline typename image<T>::const_iterator image<T>::end() const{ return pData_ + dimensions_.width() * dimensions_.height(); }
inline typename image<T>::const_iterator image<T>::end() const{ return data() + dimensions_.width() * dimensions_.height(); }
template <typename T>
inline typename image<T>::pixel_type const* image<T>::get_row(std::size_t row) const
{
return pData_ + row * dimensions_.width();
return data() + row * dimensions_.width();
}
template <typename T>
inline const typename image<T>::pixel_type* image<T>::get_row(std::size_t row, std::size_t x0) const
{
return pData_ + row * dimensions_.width() + x0;
return data() + row * dimensions_.width() + x0;
}
template <typename T>
inline typename image<T>::pixel_type* image<T>::get_row(std::size_t row)
{
return pData_ + row * dimensions_.width();
return data() + row * dimensions_.width();
}
template <typename T>
inline typename image<T>::pixel_type* image<T>::get_row(std::size_t row, std::size_t x0)
{
return pData_ + row * dimensions_.width() + x0;
return data() + row * dimensions_.width() + x0;
}
template <typename T>
@ -260,7 +254,7 @@ inline void image<T>::set_row(std::size_t row, pixel_type const* buf, std::size_
{
assert(row < dimensions_.height());
assert(size <= dimensions_.width());
std::copy(buf, buf + size, pData_ + row * dimensions_.width());
std::copy(buf, buf + size, get_row(row));
}
template <typename T>
@ -268,7 +262,7 @@ inline void image<T>::set_row(std::size_t row, std::size_t x0, std::size_t x1, p
{
assert(row < dimensions_.height());
assert ((x1 - x0) <= dimensions_.width() );
std::copy(buf, buf + (x1 - x0), pData_ + row * dimensions_.width() + x0);
std::copy(buf, buf + (x1 - x0), get_row(row, x0));
}
template <typename T>

View file

@ -3,19 +3,21 @@
set -eu
set -o pipefail
VERSION=$(git describe)
if [[ -d .git ]]; then
git submodule update --init
else
if [[ -f RELEASE_VERSION.md ]]; then
VERSION=$(cat RELEASE_VERSION.md)
if [[ ! -d ./test/data ]]; then
echo "Downloading unit test data from https://github.com/mapnik/test-data/archive/${VERSION}.tar.gz"
mkdir -p test/data/
curl -L -s https://github.com/mapnik/test-data/archive/${VERSION}.tar.gz | tar zxf - --strip-components=1 -C test/data/
curl -f -L -s https://github.com/mapnik/test-data/archive/${VERSION}.tar.gz | tar zxf - --strip-components=1 -C test/data/
fi
if [[ ! -d ./test/data-visual ]]; then
echo "Downloading visual test data from https://github.com/mapnik/test-data-visual/archive/${VERSION}.tar.gz"
mkdir -p test/data-visual/
curl -L -s https://github.com/mapnik/test-data-visual/archive/${VERSION}.tar.gz | tar zxf - --strip-components=1 -C test/data-visual/
curl -f -L -s https://github.com/mapnik/test-data-visual/archive/${VERSION}.tar.gz | tar zxf - --strip-components=1 -C test/data-visual/
fi
elif [[ -d .git ]]; then
git submodule update --init test/
else
echo "Expected either git clone directory (with .git) or release tarball with `RELEASE_VERSION.md` in root"
exit 1
fi

View file

@ -1,51 +1,136 @@
#!/usr/bin/env bash
#!/bin/bash
set -eu
set -o pipefail
# for normal release leave empty
# for release candidate, add "-rcN"
export MAPNIK_VERSION=$(git describe)
if [[ $(git tag -l) =~ $MAPNIK_VERSION ]]; then echo yes;
echo "Success: found $MAPNIK_VERSION (result of git describe) in tags, continuing"
else
echo "error: $MAPNIK_VERSION (result of git describe) not in "git tag -l" output, aborting"
echo "You must create a valid annotated tag first, before running this ./scripts/publish_release.sh"
: '
Usage:
git tag v3.0.12-rc7 -a -m "Tagging v3.0.12-rc7"
./scripts/publish_release.sh
Note: before running this script you need to tag a new release or release candidate.
This script:
- confirms that the current git checkout is a valid tag
- Downloads a fresh checkout to a /tmp directory
- Updates the submodules
- Confirms that the test-data and test-data-visual is also tagged, otherwise tags them
- Removes the test-data and test-data-visual since they are large and can be downloaded dynamically for released code
- Creates a tarball and uploads to a DRAFT "github release"
After using this script:
- Go to https://github.com/mapnik/mapnik/releases and confirm that the draft release looks good, then publish it.
'
function step { >&2 echo -e "\033[1m\033[36m* $1\033[0m"; }
function step_error { >&2 echo -e "\033[1m\033[31m$1\033[0m"; }
if [[ ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO:-false} == false ]]; then
step_error "Please set GITHUB_TOKEN_MAPNIK_PUBLIC_REPO to a github token with 'public_repo' scope (create one at https://github.com/settings/tokens)"
exit 1
fi
export MAPNIK_VERSION=$(git describe)
if [[ $(git tag -l) =~ $MAPNIK_VERSION ]]; then
step "Success: found $MAPNIK_VERSION (result of git describe) in tags, continuing"
else
step_error "error: $MAPNIK_VERSION (result of git describe) not in "git tag -l" output, aborting"
step_error "You must create a valid annotated tag first, before running this ./scripts/publish_release.sh"
exit 1
fi
# alternatively set this to `git@github.com:mapnik/mapnik.git` to pull public tag
export ROOT_GIT_CLONE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )"
export TARBALL_NAME="mapnik-${MAPNIK_VERSION}"
cd /tmp/
rm -rf ${TARBALL_NAME}
echo "Cloning ${MAPNIK_VERSION}"
git clone --depth 1 --branch ${MAPNIK_VERSION} git@github.com:mapnik/mapnik.git ${TARBALL_NAME}
step "Cloning ${MAPNIK_VERSION}"
git clone --depth 1 --branch ${MAPNIK_VERSION} ${ROOT_GIT_CLONE} ${TARBALL_NAME}
cd ${TARBALL_NAME}
step "Checking out ${MAPNIK_VERSION}"
git checkout "tags/${MAPNIK_VERSION}"
echo "updating submodules"
# TODO: skip initializing submodule if data is already tagged
# Will require bundling variant as well
git submodule update --depth 100 --init
step "checking submodules"
step "vendorizing and cleaning up mapbox variant"
git submodule update --init deps/mapbox/variant
rm -rf deps/mapbox/variant/.git
cd test/data/
git remote set-url origin git@github.com:mapnik/test-data
echo "tagging test data"
git tag ${MAPNIK_VERSION} -a -m "tagging for ${MAPNIK_VERSION}"
git push --tags
cd ../../
echo "removing test data submodule"
rm -rf test/data/
cd test/data-visual/
git remote set-url origin git@github.com:mapnik/test-data-visual
echo "tagging visual data"
git tag ${MAPNIK_VERSION} -a -m "tagging for ${MAPNIK_VERSION}"
git push --tags
cd ../../
echo "removing visual test data submodule"
rm -rf test/data-visual/
rm -f deps/mapbox/variant/*yml
rm -f deps/mapbox/variant/Jamroot
function check_and_tag() {
REPO_DIR=$1
REPO_NAME=$2
cmd="curl --fail -I https://github.com/mapnik/${REPO_NAME}/releases/tag/${MAPNIK_VERSION}"
if [[ $(${cmd}) ]]; then
step "test data already tagged, no need to initialize submodule"
else
step "tagging test data"
git submodule update --depth 100 --init ${REPO_DIR}
cd ${REPO_DIR}/
git remote set-url origin git@github.com:mapnik/${REPO_NAME}
git tag ${MAPNIK_VERSION} -a -m "tagging for ${MAPNIK_VERSION}"
git push --tags
cd ../../
step "removing test data submodule"
rm -rf ${REPO_DIR}/
fi
}
# test data
check_and_tag test/data test-data
# test data visual
check_and_tag test/data-visual test-data-visual
step "removing .git and .gitignore"
rm -rf .git
rm -rf .gitignore
export TARBALL_COMPRESSED=${TARBALL_NAME}.tar.bz2
echo ${MAPNIK_VERSION} > RELEASE_VERSION.md
step "creating tarball of ${TARBALL_COMPRESSED}"
cd ../
echo "creating tarball of ${TARBALL_NAME}.tar.bz2"
tar cjf ${TARBALL_NAME}.tar.bz2 ${TARBALL_NAME}/
echo "uploading $(dirname ${TARBALL_NAME})/${TARBALL_NAME}.tar.bz2 to s3://mapnik/dist/${MAPNIK_VERSION}/"
# TODO: upload to github releases instead of s3
aws s3 cp --acl public-read ${TARBALL_NAME}.tar.bz2 s3://mapnik/dist/${MAPNIK_VERSION}/
tar cjf ${TARBALL_COMPRESSED} ${TARBALL_NAME}/
step "uploading to github"
# https://developer.github.com/v3/repos/releases/#create-a-release
IS_PRERELEASE=false
if [[ ${MAPNIK_VERSION} =~ 'rc' ]] || [[ ${MAPNIK_VERSION} =~ 'alpha' ]]; then
IS_PRERELEASE=true
fi
IS_DRAFT=true
step "creating a draft release"
export CHANGELOG_REF=$(python -c "print '${MAPNIK_VERSION}'.replace('.','').replace('v','').split('-')[0]")
export RELEASE_NOTES="Mapnik ${MAPNIK_VERSION}\r\n\r\n[Changelog](https://github.com/mapnik/mapnik/blob/${MAPNIK_VERSION}/CHANGELOG.md#${CHANGELOG_REF})"
step "release notes: $RELEASE_NOTES"
# create draft release
curl --data "{\"tag_name\": \"${MAPNIK_VERSION}\",\"target_commitish\": \"master\",\"name\": \"${MAPNIK_VERSION}\",\"body\": \"${RELEASE_NOTES}\",\"draft\": ${IS_DRAFT},\"prerelease\": ${IS_PRERELEASE}}" \
https://api.github.com/repos/mapnik/mapnik/releases?access_token=${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO} \
> create_response.json
cat create_response.json
# parse out upload url and form it up to post tarball
UPLOAD_URL=$(python -c "import json;print json.load(open('create_response.json'))['upload_url'].replace('{?name,label}','?name=${TARBALL_COMPRESSED}')")
HTML_URL=$(python -c "import json;print json.load(open('create_response.json'))['html_url']")
step "upload url: $UPLOAD_URL"
# upload source tarball
curl ${UPLOAD_URL} \
-X POST \
-H "Authorization: token ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" \
-H "Content-Type:application/octet-stream" \
--data-binary @${TARBALL_COMPRESSED}
echo
step "Success: view your new draft release at ${HTML_URL}"
open ${HTML_URL}
echo
#step "uploading $(realpath ${TARBALL_COMPRESSED}) to s3://mapnik/dist/${MAPNIK_VERSION}/"
#aws s3 cp --acl public-read ${TARBALL_COMPRESSED} s3://mapnik/dist/${MAPNIK_VERSION}/

65
scripts/test_release.sh Executable file
View file

@ -0,0 +1,65 @@
#!/bin/bash
set -eu
set -o pipefail
: '
Note: before running this script you need to tag and publish a new release (it can be a draft)
Usage:
./scripts/test_release.sh
This script:
- Downloads the latest release tarball from github
- Builds it and runs tests
'
function step { >&2 echo -e "\033[1m\033[36m* $1\033[0m"; }
function step_error { >&2 echo -e "\033[1m\033[31m$1\033[0m"; }
if [[ ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO:-false} == false ]]; then
step_error "Please set GITHUB_TOKEN_MAPNIK_PUBLIC_REPO to a github token with 'public_repo' scope (create one at https://github.com/settings/tokens)"
exit 1
fi
export MAPNIK_VERSION="$(git describe)"
if [[ $(git tag -l) =~ ${MAPNIK_VERSION} ]]; then
step "Success: found $MAPNIK_VERSION (result of git describe) in tags, continuing"
else
step_error "error: $MAPNIK_VERSION (result of git describe) not in "git tag -l" output, aborting"
step_error "You must create a valid annotated tag first, before running this ./scripts/publish_release.sh"
exit 1
fi
curl --fail https://api.github.com/repos/mapnik/mapnik/releases -H "Authorization: token ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" > /tmp/mapnik-releases.json
RELEASE_ASSET_NAME=$(python -c "import json;print json.load(open('/tmp/mapnik-releases.json'))[0]['assets'][0]['name']")
if [[ ${RELEASE_ASSET_NAME} == "mapnik-${MAPNIK_VERSION}.tar.bz2" ]]; then
step "Successfully found release asset to test: mapnik-${MAPNIK_VERSION}.tar.bz2"
else
step_error "Error: did not find correct release asset to test: mapnik-${MAPNIK_VERSION}.tar.bz2"
exit 1
fi
export RELEASE_ASSET_URL=$(python -c "import json;print json.load(open('/tmp/mapnik-releases.json'))[0]['assets'][0]['url']")
step "Downloading ${RELEASE_ASSET_URL}"
mkdir -p /tmp/build-mapnik-${MAPNIK_VERSION}/
rm -rf /tmp/build-mapnik-${MAPNIK_VERSION}/*
cd /tmp/build-mapnik-${MAPNIK_VERSION}/
# note: curl passes the "Authorization" header to redirects such that this breaks aws
# hence we need a two step approach here to downloading rather than depending on -L
# first a head request to get the download redirect
curl -I -f ${RELEASE_ASSET_URL} -H "Accept: application/octet-stream" -H "Authorization: token ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" > redirect.json
# now download from the github s3 location after stripping bogus newline
export RELEASE_ASSET_S3=$(cat redirect.json | grep location | cut -d' ' -f2 | tr '\r' ' ')
curl --retry 3 -f -S -L "${RELEASE_ASSET_S3}" -o mapnik-${MAPNIK_VERSION}.tar.bz2
tar xf mapnik-${MAPNIK_VERSION}.tar.bz2
cd mapnik-${MAPNIK_VERSION}
source bootstrap.sh
./configure CXX="$(pwd)/mason_packages/.link/bin/ccache clang++"
make
make test

View file

@ -363,4 +363,30 @@ SECTION("Image copy/move")
}
}
SECTION("image::swap")
{
auto blue = mapnik::color(50, 50, 250).rgba();
auto orange = mapnik::color(250, 150, 0).rgba();
mapnik::image_rgba8 im;
mapnik::image_rgba8 im2(16, 16);
mapnik::image_rgba8 im3(16, 16);
im2.set(blue);
im3.set(orange);
// swap two non-empty images
CHECK_NOTHROW(im2.swap(im3));
CHECK(im2(0, 0) == orange);
CHECK(im3(0, 0) == blue);
// swap empty <-> non-empty
CHECK_NOTHROW(im.swap(im3));
CHECK(im3.data() == nullptr);
CHECKED_IF(im.data() != nullptr)
{
CHECK(im(0, 0) == blue);
}
}
} // END TEST CASE