2018-11-10 09:47:26 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# +----------------------------------------------------------------------+
|
|
|
|
# | PHP Version 7 |
|
|
|
|
# +----------------------------------------------------------------------+
|
2019-01-30 17:03:12 +08:00
|
|
|
# | Copyright (c) The PHP Group |
|
2018-11-10 09:47:26 +08:00
|
|
|
# +----------------------------------------------------------------------+
|
|
|
|
# | This source file is subject to version 3.01 of the PHP license, |
|
|
|
|
# | that is bundled with this package in the file LICENSE, and is |
|
|
|
|
# | available through the world-wide-web at the following url: |
|
|
|
|
# | https://php.net/license/3_01.txt |
|
|
|
|
# | If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
# | obtain it through the world-wide-web, please send a note to |
|
|
|
|
# | license@php.net so we can mail you a copy immediately. |
|
|
|
|
# +----------------------------------------------------------------------+
|
|
|
|
# | Authors: Sascha Schumann <sascha@schumann.cx> |
|
|
|
|
# +----------------------------------------------------------------------+
|
|
|
|
#
|
|
|
|
# This script generates PHP lexer and parser files required to build PHP. The
|
|
|
|
# generated files are ignored in the Git repository and packaged during the PHP
|
|
|
|
# release process into the release installation archive download. This way the
|
|
|
|
# bison and re2c dependencies are not required to build PHP when downloading
|
|
|
|
# release archive.
|
|
|
|
#
|
|
|
|
# Usage: genfiles
|
|
|
|
#
|
|
|
|
# Environment:
|
|
|
|
# The following environment variables can override default generators paths.
|
|
|
|
#
|
|
|
|
# YACC Parser generator program, default bison
|
|
|
|
# RE2C Lexer generator program, default re2c
|
|
|
|
#
|
|
|
|
# For example:
|
|
|
|
# YACC=/path/to/bison ./genfiles
|
1999-10-05 22:12:43 +08:00
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
# Parser generator
|
|
|
|
YACC=${YACC:-bison}
|
2015-06-11 06:13:08 +08:00
|
|
|
YACC="$YACC -y -l"
|
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
# Lexer generator
|
|
|
|
RE2C=${RE2C:-re2c}
|
|
|
|
RE2C_FLAGS="-i"
|
2015-06-11 06:13:08 +08:00
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
# Current path to return to it later. This enables running script from any path.
|
|
|
|
original_path=`pwd`
|
1999-12-30 11:13:21 +08:00
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
# Project root directory
|
|
|
|
project_root=`CDPATH= cd -- "$(dirname -- "$0")" && pwd -P`
|
|
|
|
cd $project_root
|
2018-10-21 04:06:04 +08:00
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
echo "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
|
2018-10-24 23:06:21 +08:00
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
echo "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
|
2000-10-20 09:58:00 +08:00
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
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=. \
|
|
|
|
-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=. \
|
|
|
|
-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=. \
|
|
|
|
-f ext/standard/Makefile.frag \
|
2005-11-09 04:21:35 +08:00
|
|
|
ext/standard/var_unserializer.c \
|
2018-11-10 09:47:26 +08:00
|
|
|
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=. \
|
|
|
|
-f ext/phar/Makefile.frag \
|
|
|
|
ext/phar/phar_path_check.c
|
|
|
|
|
|
|
|
# Clean debug #line XY info from the bundled lexer files.
|
|
|
|
cleanup_files=" \
|
|
|
|
ext/date/lib/parse_date.c \
|
|
|
|
ext/date/lib/parse_iso_intervals.c \
|
2005-11-09 04:21:35 +08:00
|
|
|
"
|
|
|
|
|
2018-11-10 09:47:26 +08:00
|
|
|
for f in $cleanup_files; do
|
|
|
|
echo "Cleaning file $f"
|
2002-01-04 21:10:26 +08:00
|
|
|
cp $f $f.orig
|
2018-11-10 09:47:26 +08:00
|
|
|
grep -v '^#line ' $f.orig > $f
|
|
|
|
rm -f $f.orig
|
2002-02-19 23:58:31 +08:00
|
|
|
done
|
2018-11-10 09:47:26 +08:00
|
|
|
|
|
|
|
# Return to the original directory.
|
|
|
|
cd $original_path
|