summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2019-03-17 16:22:02 +0100
committerPeter Kokot <peterkokot@gmail.com>2019-03-30 02:01:02 +0100
commit3207741df0ac71dc78f8b8c54c4b3a44553208f0 (patch)
treef3db7084e52e84e350ede97d97a1663c9b89baf5 /scripts
parent072eb6dd77b079a6f90ca5b155f9b0add1b5f2d4 (diff)
downloadphp-git-3207741df0ac71dc78f8b8c54c4b3a44553208f0.tar.gz
Refactor PHP_PROG_BISON and PHP_PROG_RE2C
This patch refactors these macros to also checks for the required given versions of bison and re2c. - PHP_PROG_RE2C and PHP_PROG_BISON take optional args - minmimum version required, and bison also excluded versions. - Instead of caching values this uses manual checking and messaging outputs. - It looks like the minimum version of RE2C 0.13.4 is working ok so far. The genfiles script improvements: - Add make override in genfiles - Move checkings from makedist to genfiles - Refactored output messages - Various minor enhancements
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/genfiles96
-rwxr-xr-xscripts/dev/makedist55
-rw-r--r--scripts/phpize.m41
3 files changed, 96 insertions, 56 deletions
diff --git a/scripts/dev/genfiles b/scripts/dev/genfiles
index c633429e0f..89fdc2d6ca 100755
--- a/scripts/dev/genfiles
+++ b/scripts/dev/genfiles
@@ -29,60 +29,110 @@
#
# YACC Parser generator program, default bison
# RE2C Lexer generator program, default re2c
+# SED Path to sed program, default sed
+# MAKE Path to make program, default make
#
# For example:
# YACC=/path/to/bison ./genfiles
-# Parser generator
YACC=${YACC:-bison}
YACC="$YACC -l"
-
-# Lexer generator
RE2C=${RE2C:-re2c}
RE2C_FLAGS="-i"
+SED=${SED:-sed}
+MAKE=${MAKE:-make}
+
+# Go to project root.
+cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P)
+
+# Check required bison version from the configure.ac file.
+required_bison_version=$($SED -n 's/PHP_PROG_BISON(\[\([0-9\.]*\)\].*/\1/p' configure.ac)
+set -f; IFS='.'; set -- $required_bison_version; set +f; IFS=' '
+required_bison_num="$(expr ${1:-0} \* 10000 + ${2:-0} \* 100 + ${3:-0})"
+
+current_version=$($YACC --version 2> /dev/null | grep 'GNU Bison' | cut -d ' ' -f 4 | tr -d a-z)
+set -f; IFS='.'; set -- $current_version; set +f; IFS=' '
+current_bison_num="$(expr ${1:-0} \* 10000 + ${2:-0} \* 100 + ${3:-0})"
+
+if test -z "$current_version"; then
+ echo "genfiles: bison not found." >&2
+ echo " You need bison version $required_bison_version or newer installed" >&2
+ echo " to regenerate parser files." >&2
+ exit 1
+fi
-# Current path to return to it later. This enables running script from any path.
-original_path=`pwd`
+if test "$current_bison_num" -lt "$required_bison_num"; then
+ echo "genfiles: bison version $current_version found." >&2
+ echo " You need bison version $required_bison_version or newer installed" >&2
+ echo " to build parser files." >&2
+ exit 1
+else
+ echo "genfiles: bison version $current_version (ok)"
+fi
-# Project root directory
-project_root=`CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P`
-cd $project_root
+# Check required re2c version from the configure.ac file.
+required_re2c_version=$($SED -n 's/PHP_PROG_RE2C(\[\(.*\)\])/\1/p' configure.ac)
+set -f; IFS='.'; set -- $required_re2c_version; set +f; IFS=' '
+required_re2c_num="$(expr ${1:-0} \* 10000 + ${2:-0} \* 100 + ${3:-0})"
-echo "Generating Zend parser and lexer files"
-make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=Zend builddir=Zend top_srcdir=. \
+current_version="$($RE2C --version | cut -d ' ' -f 2 2>/dev/null)"
+set -f; IFS='.'; set -- $current_version; set +f; IFS=' '
+current_re2c_num="$(expr ${1:-0} \* 10000 + ${2:-0} \* 100 + ${3:-0})"
+
+if test -z "$current_version"; then
+ echo "genfiles: re2c not found." >&2
+ echo " You need re2c version $required_re2c_version or newer installed" >&2
+ echo " to regenerate lexer files." >&2
+ exit 1
+fi
+
+if test "$current_re2c_num" -lt "$required_re2c_num"; then
+ echo "genfiles: re2c version $current_version found." >&2
+ echo " You need re2c version $required_re2c_version or newer installed" >&2
+ echo " to build lexer files." >&2
+ exit 1
+else
+ echo "genfiles: re2c version $current_version (ok)"
+fi
+
+# Check if make exists.
+if ! test -x "$(command -v $MAKE)"; then
+ echo "genfiles: make not found. Please install make to generate files." >&2
+ exit 1
+fi
+
+echo "genfiles: Generating Zend parser and lexer files"
+$MAKE RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=Zend builddir=Zend top_srcdir=. \
-f Zend/Makefile.frag \
Zend/zend_language_parser.c \
Zend/zend_language_scanner.c \
Zend/zend_ini_parser.c \
Zend/zend_ini_scanner.c
-echo "Generating phpdbg parser and lexer files"
-make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=sapi/phpdbg builddir=sapi/phpdbg top_srcdir=. \
+echo "genfiles: Generating phpdbg parser and lexer files"
+$MAKE RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=sapi/phpdbg builddir=sapi/phpdbg top_srcdir=. \
-f sapi/phpdbg/Makefile.frag \
sapi/phpdbg/phpdbg_parser.c \
sapi/phpdbg/phpdbg_lexer.c
-echo "Generating json extension parser and lexer files"
-make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=ext/json builddir=ext/json top_srcdir=. \
+echo "genfiles: enerating json extension parser and lexer files"
+$MAKE RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" YACC="$YACC" srcdir=ext/json builddir=ext/json top_srcdir=. \
-f ext/json/Makefile.frag \
ext/json/json_parser.tab.c \
ext/json/json_scanner.c
-echo "Generating PDO lexer file"
-make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/pdo builddir=ext/pdo top_srcdir=. \
+echo "genfiles: Generating PDO lexer file"
+$MAKE RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/pdo builddir=ext/pdo top_srcdir=. \
-f ext/pdo/Makefile.frag \
ext/pdo/pdo_sql_parser.c
-echo "Generating standard extension lexer files"
-make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/standard builddir=ext/standard top_srcdir=. \
+echo "genfiles: Generating standard extension lexer files"
+$MAKE RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/standard builddir=ext/standard top_srcdir=. \
-f ext/standard/Makefile.frag \
ext/standard/var_unserializer.c \
ext/standard/url_scanner_ex.c
-echo "Generating phar extension lexer file"
-make RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/phar builddir=ext/phar top_srcdir=. \
+echo "genfiles: Generating phar extension lexer file"
+$MAKE RE2C="$RE2C" RE2C_FLAGS="$RE2C_FLAGS" srcdir=ext/phar builddir=ext/phar top_srcdir=. \
-f ext/phar/Makefile.frag \
ext/phar/phar_path_check.c
-
-# Return to the original directory.
-cd $original_path
diff --git a/scripts/dev/makedist b/scripts/dev/makedist
index e19df2a0de..588a7e344b 100755
--- a/scripts/dev/makedist
+++ b/scripts/dev/makedist
@@ -22,39 +22,25 @@
cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P)
if test "$#" != "1"; then
- echo "Usage: makedist <version>" >&2
- exit 1
+ echo "Usage: makedist <version>" >&2
+ exit 1
fi
VER=$1 ; shift
-old_IFS="$IFS"
-IFS=.
-eval set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /g'`
-if test "${1}" -lt "3" -o "${1}" = "3" -a "${2}" -eq "0" -a "${3}" -lt "2"; then
- echo "You will need bison >= 3.0.2 if you want to regenerate the Zend parser (found ${1}.${2}.${3})."
- exit 2
-fi
-eval set `re2c --version| grep 're2c' | cut -d ' ' -f 2 | sed -e 's/\./ /g'`
-if test "${2}" -lt "13" -o "${2}" -eq "13" -a "${3}" -lt "5"; then
- echo "You will need re2c >= 0.13.5 if you want to regenerate the Zend scanner (found ${1}.${2}.${3})."
- exit 2
-fi
-IFS="$old_IFS"
-
if test "x$PHPROOT" = "x"; then
- PHPROOT=git@git.php.net:php-src.git;
+ PHPROOT=git@git.php.net:php-src.git;
fi
LT_TARGETS='build/ltmain.sh build/config.guess build/config.sub'
if echo '\c' | grep -s c >/dev/null 2>&1
then
- ECHO_N="echo -n"
- ECHO_C=""
+ ECHO_N="echo -n"
+ ECHO_C=""
else
- ECHO_N="echo"
- ECHO_C='\c'
+ ECHO_N="echo"
+ ECHO_C='\c'
fi
MY_OLDPWD=`pwd`
@@ -67,9 +53,9 @@ DIR=php-$VER
DIRPATH=$MY_OLDPWD/$DIR
if test -d "$DIRPATH"; then
- echo "The directory $DIR" >&2
- echo "already exists, rename or remove it and run makedist again." >&2
- exit 1
+ echo "The directory $DIR" >&2
+ echo "already exists, rename or remove it and run makedist again." >&2
+ exit 1
fi
# Export PHP
@@ -96,7 +82,12 @@ set -x
# when a user runs buildconf in the distribution.
rm -f buildmk.stamp
+# Generate lexer and parser files
./scripts/dev/genfiles
+exit_code=$?
+if test "$exit_code" != "0"; then
+ exit $exit_code
+fi
# now restore our versions of libtool-generated files
for i in $LT_TARGETS; do
@@ -119,15 +110,15 @@ sed -i 's,^#ifndef YYTOKENTYPE,#include "zend.h"\n#ifndef YYTOKENTYPE,g' $MY_OLD
# download pear
$ECHO_N "makedist: Attempting to download PEAR's phar archive"
if test ! -x wget; then
- wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
- if [ "x$?" != "x0" ]
- then
- $ECHO_N "Pear download failed";
- exit 7
- fi
+ wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
+ if [ "x$?" != "x0" ]
+ then
+ $ECHO_N "Pear download failed";
+ exit 7
+ fi
else
- $ECHO_N "Missing wget binary needed for pear download";
- exit 7
+ $ECHO_N "Missing wget binary needed for pear download";
+ exit 7
fi
cd $MY_OLDPWD
diff --git a/scripts/phpize.m4 b/scripts/phpize.m4
index 76559d0c87..9b89d1b9cd 100644
--- a/scripts/phpize.m4
+++ b/scripts/phpize.m4
@@ -137,7 +137,6 @@ dnl Always shared
PHP_BUILD_SHARED
dnl Required programs
-PHP_PROG_RE2C
PHP_PROG_AWK
sinclude(config.m4)