Skip to content

Commit

Permalink
Moved setting CFLAGS out of travis script, to allow it to be more fle…
Browse files Browse the repository at this point in the history
…xible and not forced onto a single line.
  • Loading branch information
Danack committed Feb 23, 2015
1 parent 7396d2e commit f3f0d77
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Expand Up @@ -18,21 +18,19 @@ env:
before_script:
- for file in tests/*.phpt; do grep $(basename $file) package.xml >/dev/null || (echo "Missing $file from package.xml" ; exit 1); done
- ./imagemagick_dependency.sh "${IMAGEMAGICK_VERSION}"
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then COMPILE_FLAGS="-Wno-deprecated-declarations -Wdeclaration-after-statement -Werror"; else COMPILE_FLAGS=""; fi


script:
- export NO_INTERACTION=1
- export REPORT_EXIT_STATUS=1
- export TEST_PHP_EXECUTABLE=`which php`
- export PHP_IMAGICK_VERSION=$(php -r '$sxe = simplexml_load_file ("package.xml"); echo (string) $sxe->version->release;')
- pear package
- . ./configure-cflags.sh
- mkdir /tmp/php-imagick-build
- tar xfz "imagick-${PHP_IMAGICK_VERSION}.tgz" -C /tmp/php-imagick-build
- cp ./check-loaded.phpt /tmp/php-imagick-build/imagick-${PHP_IMAGICK_VERSION}/check-loaded.phpt
- cd /tmp/php-imagick-build/imagick-${PHP_IMAGICK_VERSION}
- phpize
- export CFLAGS=$COMPILE_FLAGS
- ./configure --with-imagick="${HOME}/imagemagick-${IMAGEMAGICK_VERSION}"
- make
- php run-tests.php -d extension=imagick.so -d extension_dir=modules -n ./*.phpt
Expand Down
56 changes: 56 additions & 0 deletions configure-cflags.sh
@@ -0,0 +1,56 @@
#!/bin/bash
#
# Set CFLAGS to be strict for supported versions on Travis

#containsElement () {
# local e
# for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
# return 1
#}


# Bash return statements are not useful. You have to echo the value
# and then capture it by calling the function with $( foo )
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
echo "1"
return 0
fi
}
echo "0"
return 0
}



strictPHPVersions=()
strictPHPVersions+=("5.6")
strictPHPVersions+=("7")

strictImageMagickVersions=()
strictImageMagickVersions+=("dev")
strictImageMagickVersions+=("6.8.7-0")
strictImageMagickVersions+=("6.7.5-3")
strictImageMagickVersions+=("6.6.0-9")

echo "TRAVIS_PHP_VERSION is ${TRAVIS_PHP_VERSION}"
echo "IMAGEMAGICK_VERSION is ${IMAGEMAGICK_VERSION}"

strictImageMagick=$(contains "${strictImageMagickVersions[@]}" "${IMAGEMAGICK_VERSION}" )
strictPHP=$(contains "${strictPHPVersions[@]}" "${TRAVIS_PHP_VERSION}" )

echo "strictImageMagick is ${strictImageMagick}"
echo "strictPHP is ${strictPHP}"

if [[ $strictPHP = '1' ]] && [[ $strictImageMagick = '1' ]]; then
CFLAGS="-Wno-deprecated-declarations -Wdeclaration-after-statement -Werror";
else
CFLAGS="-Wno-deprecated-declarations";
fi

echo "Setting CFLAGS to ${CFLAGS}"

export CFLAGS=$CFLAGS

0 comments on commit f3f0d77

Please sign in to comment.