From ae413b08e8a74c605e966cb608b4142969385d17 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 13 Nov 2018 13:11:26 +0200 Subject: [PATCH] Simplified dependency installation [skip appveyor] --- .ci/after-failure.sh | 2 - .ci/install-php-psr.sh | 33 --------------- .ci/install-prereqs.sh | 78 ++++++++++++++++++++++++++++++++++++ .ci/install-zephir-parser.sh | 27 ------------- .travis.yml | 10 ++--- 5 files changed, 81 insertions(+), 69 deletions(-) delete mode 100755 .ci/install-php-psr.sh create mode 100755 .ci/install-prereqs.sh delete mode 100755 .ci/install-zephir-parser.sh diff --git a/.ci/after-failure.sh b/.ci/after-failure.sh index 322740932f..68e2073353 100755 --- a/.ci/after-failure.sh +++ b/.ci/after-failure.sh @@ -9,8 +9,6 @@ shopt -s nullglob -$(phpenv which php) -m - export LC_ALL=C for i in core core*; do diff --git a/.ci/install-php-psr.sh b/.ci/install-php-psr.sh deleted file mode 100755 index 89568c6c81..0000000000 --- a/.ci/install-php-psr.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# -# This file is part of the Zephir. -# -# (c) Zephir Team -# -# For the full copyright and license information, please view the LICENSE -# file that was distributed with this source code. - -if [ "${CI}" != "true" ]; then - echo "This script is designed to run inside a CI container only. Stop." - exit 1 -fi - -PROJECT_ROOT=$(readlink -enq "$(dirname $0)/../") - -if [ ! -f "$HOME/.cache/php-psr/php_psr.c" ]; then - rm -rf "$HOME/.cache/php-psr" - mkdir -p "$HOME/.cache/php-psr" - - git clone https://github.com/jbboehr/php-psr.git "$HOME/.cache/php-psr" -fi - -cd "$HOME/.cache/php-psr" - -phpize -./configure --with-php-config=$(phpenv which php-config) --enable-psr -make -j"$(getconf _NPROCESSORS_ONLN)" - -cp "$HOME/.cache/php-psr/modules/psr.so" `$(phpenv which php-config) --extension-dir` - -echo extension=psr.so > "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/psr.ini" -php --ri psr diff --git a/.ci/install-prereqs.sh b/.ci/install-prereqs.sh new file mode 100755 index 0000000000..e2646c3636 --- /dev/null +++ b/.ci/install-prereqs.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# +# This file is part of the Zephir. +# +# (c) Zephir Team +# +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. + +if [ "${CI}" != "true" ]; then + echo "This script is designed to run inside a CI container only. Stop." + exit 1 +fi + +printf "\n" | pecl install --force psr &> /dev/null + +install_ext_from_src () { + pkgname=$1 + source=$2 + cfgflags=$3 + downloaddir="${HOME}/.cache/${pkgname}/${pkgname}-${PHP_VERNUM}" + prefix="${HOME}/.local/opt/${pkgname}/${pkgname}-${PHP_VERNUM}" + libdir="${prefix}/lib" + + if [ ! -f "${libdir}/pkgname.so" ]; then + if [ ! -d `dirname ${downloaddir}` ]; then + mkdir -p `dirname ${downloaddir}` + fi + + cd `dirname ${downloaddir}` + + if [ ! -d "${pkgname}-${PHP_VERNUM}" ]; then + git clone --depth=1 -v "${source}" "${pkgname}-${PHP_VERNUM}" + fi + + if [ ! -f "${pkgname}-${PHP_VERNUM}/LICENSE" ]; then + echo "Unable to locate ${pkgname}-${PHP_VERNUM}/LICENSE file. Stop." + exit 1 + fi + + if [ ! -d "${downloaddir}" ]; then + echo "Unable to locate ${pkgname} source. Stop." + exit 1 + fi + + if [ ! -d "${libdir}" ]; then + mkdir -p "${libdir}" + fi + + cd "${downloaddir}" + phpize + printf "\n" | ./configure "${cfgflags}" + + make --silent -j"$(getconf _NPROCESSORS_ONLN)" + make --silent install + + if [ -f `$(phpenv which php-config) --extension-dir`/${pkgname}.so ]; then + cp `$(phpenv which php-config) --extension-dir`/${pkgname}.so "${libdir}/${pkgname}.so" + elif [ -f "${downloaddir}/modules/${pkgname}.so" ]; then + cp "${downloaddir}/modules/${pkgname}.so" "${libdir}/${pkgname}.so" + fi + fi + + if [ ! -x "${libdir}/${pkgname}.so" ]; then + echo "Unable to locate ${libdir}/${pkgname}.so. Stop." + exit 1 + fi + + echo "extension=${libdir}/${pkgname}.so" > "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/${pkgname}.ini" +} + +install_ext_from_src "zephir_parser" "https://github.com/phalcon/php-zephir-parser" "" + +if [ "${PHP_VERNUM}" -ge 70300 ]; then + install_ext_from_src "memcached" "https://github.com/php-memcached-dev/php-memcached" "--disable-memcached-sasl" +else + echo 'extension="memcached.so"' > "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/memcached.ini" +fi diff --git a/.ci/install-zephir-parser.sh b/.ci/install-zephir-parser.sh deleted file mode 100755 index d0d7f0b02a..0000000000 --- a/.ci/install-zephir-parser.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# -# This file is part of the Zephir. -# -# (c) Zephir Team -# -# For the full copyright and license information, please view the LICENSE -# file that was distributed with this source code. - -# Exit the script if any statement returns a non-true return value -set -e - -ZEPHIR_PARSER_VERSION=${ZEPHIR_PARSER_VERSION:-development} - -pushd /tmp - -git clone --depth=1 -v https://github.com/phalcon/php-zephir-parser.git -b ${ZEPHIR_PARSER_VERSION} -cd php-zephir-parser -phpize -./configure -make -make install - -popd - -echo "extension=zephir_parser.so" >> $(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/zephir-parser.ini -php --ri 'Zephir Parser' diff --git a/.travis.yml b/.travis.yml index 73dc43572b..57d532fe8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,9 +34,7 @@ cache: timeout: 604800 directories: - $HOME/.composer/cache - - $HOME/.local/opt/re2c - - $HOME/.cache/re2c - - $HOME/.cache/php-psr + - $HOME/.local/opt env: global: @@ -59,9 +57,8 @@ before_install: - phpenv config-add .ci/999-default.ini install: - - .ci/install-zephir-parser.sh + - .ci/install-prereqs.sh - .ci/install-re2c.sh $RE2C_VERSION - - .ci/install-php-psr.sh - travis_retry composer install $DEFAULT_COMPOSER_FLAGS - .ci/build-test-ext.sh @@ -108,9 +105,8 @@ jobs: env: - REPORT_COVERAGE=0 install: - - .ci/install-zephir-parser.sh + - .ci/install-prereqs.sh - .ci/install-re2c.sh $RE2C_VERSION - - .ci/install-php-psr.sh - travis_retry composer install $DEFAULT_COMPOSER_FLAGS - mkdir -p ${HOME}/bin - |